/MacModScanSync

Macula Modeller and Scan Synchronizer

Primary LanguageMATLABGNU General Public License v3.0GPL-3.0

_____________________________________________________
Package name   Macula Modeller and Scan Synchronizer
Language       MATLAB
Author         József Vass <jozsef.vass@outlook.com>
Project for    Andrew Symons <andrewsymons@gmail.com>
               Joos Meyer <joos.meyer@gmail.com>
Version date   Jul. 2, 2021
MATLAB         R2021a
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Purpose
‾‾‾‾‾‾‾
This software package was created to handle the following tasks:
▪ Importing the macula scan output files, given in a particular format, and converting them to layer matrices that can be analyzed in MATLAB, corresponding to the 11 standard layers of the retina.
▪ Visualizing the retinal layers in 3D.
▪ Modelling the 2D central cross-section of a macula scan with the Difference of Gaussians (DoG) model in the literature.
▪ Modelling the macula in 3D with the above model to find its most reasonable center and foveal radius.
▪ Transforming a batch of scans, often several visits for a particular patient, to a common mesh, i.e. shifting the foveal centers to the mesh center, and making the mesh dimensions a standard factor of the foveal radius.

Instructions for use
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
1. Create a folder to work in. Unzip / move this package there.
2. Download and unzip the open source packages listed below.
3. Download, install, and launch MATLAB (trial version available).
4. Navigate to this package in your created folder with the "Browse for folder" icon towards the top-left of the MATLAB interface, so that you can see main.m in the left-sidebar of MATLAB.
5. Type "main" at the >> prompt, and hit enter. This will launch the software menu.
6. Always start with either option 1. for loading raw data (for further analysis via the other options), or 8. for processing raw data to a standard mesh (which automatically includes / runs several other menu options, like modelling).

Open source packages:
Download and unzip these packages under the Open_Source folder, so that the .m files are directly under the subfolder names below.
▪ cprintf:
https://www.mathworks.com/matlabcentral/fileexchange/24093-cprintf-display-formatted-colored-text-in-the-command-wind/
▪ export_fig:
https://www.mathworks.com/matlabcentral/fileexchange/23629-export_fig/
▪ fit_ellipse:
https://www.mathworks.com/matlabcentral/fileexchange/3215-fit_ellipse/
▪ hline_vline:
https://www.mathworks.com/matlabcentral/fileexchange/1039-hline-and-vline/

Input:
▪ The raw scan data files are to be placed under Data/xls. The Data/scans.xlsx file can be generated by this software, but the mesh parameters (increments A/Binc and size A/Bnum columns) should be filled in manually based on the scanner settings.
▪ The processed data parameters file Data/scans_p.xlsx is generated automatically for runtime use, so it should never be edited!
▪ For modelling 2D cross-sections only (not from standard scan files), place your image file under Imgs. It should contain solely the contours of the nerve fiber layer, and two flat layers including / near the basement membrane.
▪ The Initialization section of main.m can be edited to change some global constants for the data location etc. (rare use).

Output: To be found under Plots, or Data/xls_p or csv_p.

Subroutine dependency tree
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
main                    Main program launching the menu, and calling the subroutines.

MyHexaColor             Converts hexagesimal color code to MATLAB convention.
OptSel                  Prompts a selection from a text menu of options.
OptSel2                 Prompts a selection from a numerical menu of options.
DataImport              Imports raw / processed data files.
   OptSel               See above.
   OptSel2              See above.
   MyStr2Num            The built-in str2num generalized to "n/a" values.
DataMissingValues       Fills in missing values in the raw data via interpolation.
SurfSym                 Symmetrizes the NFL layer in the x-direction (A scans).
   ModelAxis2D          Estimates the axis of a cross-section giving the best symmetry.
      MyFindPeaks       The findpeaks function generalized to account for global extrema.
PlotLayer               Plots a layer in 3D relative to another.
DataStats               Calculates some statistics for the loaded data.
ImgImport               Imports a cross-section image file from Imgs.
   OptSel               See above.
ModelAxis2D             See above.
Model_DoG2D             2D modelling (optimization) of a cross-section with DoG.
   Function_DoG2D       2D DoG function.
   MyR2                 Finds the coefficient of determination.
ModelAxis3D             Estimates the axis of a layer.
   ModelAxis2D          See above.
FitCircle               Fits a circle to a set of points in the 2D plane.
ModInt                  Computes the residue of a real number w.r.t. an interval.
Model_DoG3D_Ell         3D modelling of a layer with elliptical DoG.
   Function_DoG3D_Ell   Elliptical 3D DoG function.
   MyR2                 See above.
Model_DoG3D_Cir         3D modelling of a layer with circular DoG.
   Function_DoG3D_Cir   Circular 3D DoG function.
   MyR2                 See above.
DataModel               Finds the center and radius of the raw data.
   MyStr2Num            See above.
   DataMissingValues    See above.
   ModelAxis3D          See above.
   FitCircle            See above.
   Model_DoG3D_Cir      See above.
   MyFindPeaks          See above.
DataTransform           Transforms all the layers to a common grid.
DataExport              Exports the transformed layers in the original and matrix format.
   TabSep               Unions cell elements with a tab separator.