Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
More QoL commenting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert F Cooper committed Apr 30, 2019
1 parent 5ae895d commit e585c54
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
48 changes: 48 additions & 0 deletions DFT-Based-Spacing/Montage_DFT_Analysis.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,54 @@
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
%
% Running this function will ask you to select the set of montage images that
% you wish to analyze. Montage images will have a single layer within a montage
% placed within an image the size of the montage canvas.
%
% **If you only have a PSD of a montage and do not have data in this format,
% please use my PSD Layer Exporter, at
% https://github.com/Eurybiadan/PSD_Layer_Export/releases/tag/v1.0).
% To dump them to disk in this format.
%
% **This function uses parfor loops, which requires the Parallel Toolbox
% from MATLAB.**
% If you don't have that toolbox, change the "parfor" on line 93 to a "for" loop.
%
% As above, it will then prompt the user to select what the output unit
% should be. At present, the options are:
% * Microns (using millimeters^2 for density)
% * Degrees
% * Arcminutes
%
% Once the output unit is select, it will give the user the option to pick a
% lookup table. The lookup table allows the software to analyze a folder of images
% from different subjects/timepoints/conditions. The lookup table itself **must**
% be a 3 column 'csv' file, where the **first column** is a common identifier for
% image/coordinate pairs, the **second column** is the axial length (or '24' if
% the axial length is unknown) of the image/coordinate pairs, and the **third column**
% is the pixels per degree of the image/coordinate pairs. Each row must contain a
% different identifier/axial length/pixels per degree tuple.
%
% An example common identifier could be a subject number, e.g, when working with the files
% - 1235_dateoftheyear_OD_0004.tif
% - 1235_dateoftheyear_OD_0005.tif
%
% Common identifiers could be "1235", "1235_dateoftheyear", "1235_dateoftheyear_OD".
% If all three were placed in a LUT, then the one that matches the most (as determined
% via levenshtein distance) will be used. In this example, we would use "1235_dateoftheyear_OD".
%
% If we had another date, say: 1235_differentdateoftheyear_OD_0005.tif, then
% _only_ the identifier "1235" would match between all images. However, say the
% two dates have different scales, then you would want to create two rows in the
% look up table for each date, with identifiers like: "1235_dateoftheyear" and
% "1235_differentdateoftheyear".
%
% **If you do not wish to use a lookup table, then press "cancel", and the
% software will allow you put in your own scale in UNITS/pixel.**
%
% The software will then run, showing the spacing montage, the density montage,
% the confidence montage, and the sum map. It will also save them to disk in the
% same folder you ran from alongside a mat file that contains the results.


clear;
Expand Down
18 changes: 18 additions & 0 deletions DFT-Based-Spacing/fit_fourier_spacing.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
function [avg_pixel_spac, interped_spac_map, interped_conf_map, sum_map, imbox ] = fit_fourier_spacing(test_image, roi_size, supersampling, row_or_cell)
% FUNCTION [avg_pixel_spac, interped_spac_map, interped_conf_map, sum_map, imbox ] = fit_fourier_spacing(test_image, roi_size, supersampling, row_or_cell)`
%
% #### Inputs:
%
% - **test_image**: The image that will be analyzed. The only requirement is that it is a 2d, grayscale (1 channel) image.
% - **supersampling**: If "true", then each roi will be super-sampled in accordance with: [Bernstein et al.](https://arxiv.org/pdf/1401.2636.pdf) before calculating the DFT-derived spacing.
% - **roi_size**: The side length (in pixels) of a sliding roi window- The roi will march along the image you've provided at a rate of 1/4 the size of the ROI, creating a "map" of spacing of the image.
% - **row_or_cell**: The range of angles from the polar DFT that will be used to calculate the DFT-derived spacing. If "row", then it will be the upper and lower 90 degrees of the DFT. If "cell", it will be the left and right 90 degrees.
%
% #### Outputs:
%
% - **avg_pixel_spac**: The average spacing of the image.
% - **interped_spac_map**: The spacing map of the input image (in pixel spacing).
% - **interped_conf_map**: The confidence map of the input image.
% - **sum_map**: The map corresponding to the amount of ROI overlap across the output map.
% - **imbox**: The bounding region of valid (nonzero, NaN, or Inf) pixels.
%
%
% Copyright (C) 2019 Robert F Cooper
%
% This program is free software: you can redistribute it and/or modify
Expand Down
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ If you wish to specify the sliding window size, input the size (in the units you

### Run fit_fourier_spacing.m:

Running this function will ask the user to select the image that will be used for analysis. It will then calculate the DFT-derived spacing across the entire image, and return the average pixel spacing of the input image.
Running this function will ask the you to select the image that will be used for analysis. It will then calculate the DFT-derived spacing across the entire image, and return the average pixel spacing of the input image.

This script can also be run with arguments, and has the form:

Expand All @@ -107,10 +107,35 @@ This script can also be run with arguments, and has the form:

### Run Montage_DFT_Analysis.m:

Running this function will ask you to select the set of montage images that you wish to analyze. Montage images will have a single layer within a montage placed within an image the size of the montage canvas.

**If you only have a PSD of a montage and do not have data in this format, please use [my PSD Layer Exporter](https://github.com/Eurybiadan/PSD_Layer_Export/releases/tag/v1.0). To dump them to disk in this format.

**This function uses parfor loops, which requires the Parallel Toolbox from MATLAB.** If you don't have that toolbox, change the "parfor" on line 93 to a "for" loop.

As above, it will then prompt the user to select what the output unit should be. At present, the options are:
* Microns (using millimeters^2 for density)
* Degrees
* Arcminutes

Once the output unit is select, it will give the user the option to pick a lookup table. The lookup table allows the software to analyze a folder of images from different subjects/timepoints/conditions. The lookup table itself **must** be a 3 column 'csv' file, where the **first column** is a common identifier for image/coordinate pairs, the **second column** is the axial length (or '24' if the axial length is unknown) of the image/coordinate pairs, and the **third column** is the pixels per degree of the image/coordinate pairs. Each row must contain a different identifier/axial length/pixels per degree tuple.

An example common identifier could be a subject number, e.g, when working with the files
- 1235_dateoftheyear_OD_0004.tif
- 1235_dateoftheyear_OD_0005.tif

Common identifiers could be "1235", "1235_dateoftheyear", "1235_dateoftheyear_OD". If all three were placed in a LUT, then the one that matches the most (as determined via levenshtein distance) will be used. In this example, we would use "1235_dateoftheyear_OD".

If we had another date, say: 1235_differentdateoftheyear_OD_0005.tif, then _only_ the identifier "1235" would match between all images. However, say the two dates have different scales, then you would want to create two rows in the look up table for each date, with identifiers like: "1235_dateoftheyear" and "1235_differentdateoftheyear".

**If you do not wish to use a lookup table, then press "cancel", and the software will allow you put in your own scale in UNITS/pixel.**

The software will then run, showing the spacing montage, the density montage, the confidence montage, and the sum map. It will also save them to disk in the same folder you ran from alongside a mat file that contains the results.

## How to calculate the orientation of cells in an image: <a name="Orientation"></a>

Ask me via email or via issue- this code is older and less user-friendly.

# Don't thank me; cite me:
Every metric that is run via the main "Coordinate_Mosaic_Metrics.m" script has been validated and used in the following manuscript: **Cooper RF, Wilk MA, Tarima S, Dubra A, Carroll J. “Evaluating descriptive metrics of the human cone mosaic.” Invest Ophthalmol Vis Sci. 2016 57(7):2993.** You can also find formal definitions of each metric calculated here in that paper.

Expand Down

0 comments on commit e585c54

Please sign in to comment.