SPACE - Spatial Pattern Analysis using Closest Events
- SPACE.m - the main function for performing SPACE analysis of mask pairs.
- SPACE_batch.m - function for performing batch analysis of SPACE results.
- ttest2w.m - accessory function to compute the weighted version of a 2-sided Student's T-test. Recommended test for comparing spatial association indices across groups of images to account for differences in signal volume.
- plot_error.m - accessory function to plot lines with shaded error region.
- gen_overlay.m - function to combine two masks into an RGB image.
- example_single.m - script with an example use of SPACE to analyze a single image.
- example_batch.m - script with an example use of SPACE to analyze a batch of images.
- example_compare_groups.m - script with an example use of SPACE to analyze and compare 3 different groups of images.
- generate_example_data.m - script called by example scripts to generate data for demonstration of SPACE.
- CDF – cumulative distribution function
- PDF – probability density function
- NN – nearest neighbor
- SPACE – Spatial Pattern Analysis using Closest Events
- KS – Kolmogorov-Smirnov
- CSR – complete spatial randomness
- ROI – region of interest
- Observed_Event_Count – number of events (white pixels) used to generate the observed CDF.
- Random_Event_Count – number of points (pixels) used to generate the random CDF.
- Observed_x – x-coordinates (distance) for all observed functions.
- Observed_PDF_y – y-coordinates (event count) for PDF of observed event NN distances. Corresponding x-coordinates are stored in Observed_x.
- Random_x – x-coordinates (distance) for all random functions.
- Random_PDF_y – y-coordinates (event count) for PDF of random event distances. Corresponding x-coordinates are stored in Random_x.
- Observed_CDF_y – y-coordinates (probability) for CDF of observed event NN distances. Corresponding x-coordinates are stored in Observed_x.
- Random_CDF_y – y-coordinates (probability) for CDF of random event NN distances. Corresponding x-coordinates are stored in Random_x.
- Delta_CDF_x – x-coordinates (distance) of delta function. Delta functions represent subtraction of the random CDF from the observed CDF.
- Delta_CDF_y – y-coordinates (delta probability) of delta function. Corresponding x-coordinates are stored in Delta_CDF_x.
- Spatial_Association_Index – spatial association index for describing that type and magnitude of spatial association exhibited between both signals. Computed as the absolute maximum of XY_Delta_CDF_y. This can take on a value between -1 and 1, where negative values indicate dispersion of signals between both masks, positive values indicate aggregation, and values at or near zero indicate random (Poisson) association.
- Spatial_Association_pValue – p-value from a 2-sided KS test comparing the observed and random distributions. The null hypothesis states that these distributions are identical and therefor signals from the first mask are CSR relative to signals from the second mask.
- Spatial_Association_Verdict - logical scalar indicating whether the null hypothesis from the KS test was rejected. A value of 'true' indicates there is sufficient evidence to reject the null hypothesis and a value of 'false' indicates there is not sufficient evidence to reject the null hypothesis.
- Sample_Size – number of images used to generate the SPACE results.
- Global_x – x-coordinates shared by all functions and used to create their global y-coordinates.
- Observed_CDF_x – subset of global x-coordinates (Global_x) corresponding to observed CDF y-coordinates (Observed_CDF_y_Matrix). This is a single column vector used for all observed CDFs.
- Observed_CDF_y_Matrix – y-coordinates for all individual observed CDFs that are all defined over the same global x-coordinate scheme (Observed_CDF_x). Functions for individual images are stored in every column and y-coordinates are stored along rows. Thus, the number of columns corresponds to the number of individual analyses and the number of rows corresponds to the number of y-coordinates for each function.
- Random_CDF_x – subset of global x-coordinates (Global_x) corresponding to random CDF y-coordinates (Random_CDF_y_Matrix). This is a single column vector used for all random CDFs.
- Random_CDF_y_Matrix – y-coordinates for all individual random CDFs that are all defined over the same global x-coordinate scheme (Random_CDF_x). Functions for individual analyses are stored in every column and y-coordinates are stored along rows. Thus, the number of columns corresponds to the number of individual analyses and the number of rows corresponds to the number of y-coordinates for each function.
- Delta_CDF_x – subset of global x-coordinates (Global_x) corresponding to delta function y-coordinates (Delta_CDF_y_Matrix). This is a single column vector used for all delta functions. Delta functions represent subtraction of the random CDF from the observed CDF.
- Delta_CDF_y_Matrix – y-coordinates for all individual delta functions that are all defined over the same global x-coordinate scheme (Delta_CDF_x). Functions for individual analyses are stored in every column and y-coordinates are stored along rows. Thus, the number of columns corresponds to the number of individual analyses and the number of rows corresponds to the number of y-coordinates for each function.
- Observed_CDF_y_Median – y-coordinates for the median observed CDF. Computed as the weighted median for every row of Observed_CDF_y_Matrix. Corresponding x-coordinates are stored in Observed_CDF_x.
- Observed_CDF_y_Lower – y-coordinates for the lower quantile of the median observed CDF. Computed as the weighted lower quantile for every row of Observed_CDF_y_Matrix. Corresponding x-coordinates are stored in Observed_CDF_x.
- Observed_CDF_y_Upper – y-coordinates for the upper quantile of the median observed CDF. Computed as the weighted upper quantile for every row of Observed_CDF_y_Matrix. Corresponding x-coordinates are stored in Observed_CDF_x.
- Random_CDF_y_Median – y-coordinates for the median random CDF. Computed as the weighted median for every row of Random_CDF_y_Matrix. Corresponding x-coordinates are stored in Random_CDF_x.
- Random_CDF_y_Lower – y-coordinates for the lower quantile of the median random CDF. Computed as the weighted lower quantile for every row of Random_CDF_y_Matrix. Corresponding x-coordinates are stored in Random_CDF_x.
- Random_CDF_y_Upper – y-coordinates for the upper quantile of the median random CDF. Computed as the weighted upper quantile for every row of Random_CDF_y_Matrix. Corresponding x-coordinates are stored in Random_CDF_x.
- Delta_CDF_y_Median – y-coordinates for the median delta function. Computed as the weighted median for every row of Delta_CDF_y_Matrix. Corresponding x-coordinates are stored in Delta_CDF_x.
- Delta_CDF_y_Lower – y-coordinates for the lower quantile of the median delta function. Computed as the weighted lower quantile for every row of Delta_CDF_y_Matrix. Corresponding x-coordinates are stored in Delta_CDF_x.
- Delta_CDF_y_Upper – y-coordinates for the upper quantile of the median delta function. Computed as the weighted upper quantile for every row of Delta_CDF_y_Matrix. Corresponding x-coordinates are stored in Delta_CDF_x.
- Sample_Event_Count – List of event counts (white pixels) for each individual image, used to generate all functions. This is a column vector and each element corresponds to the columns in all function matrices.
- Sample_Spatial_Association_Index – List of spatial association indices from individual analyses. Computed as the absolute maximum of each column in Delta_CDF_y_Matrix.
- Global_Spatial_Association_Index – Global spatial association index given all analyses in the batch. Computed as the absolute maximum of Delta_CDF_y_Median.
- Global_CSR_Verdict – verdict of the test for CSR between the first and second mask. The null hypothesis states that the white pixels in one mask are CSR relative to the white pixels in the other mask. This variable returns true if the null hypothesis is rejected and false if it is not rejected.
Cite As
Andrew M Soltisz, Peter F Craigmile, Rengasayee Veeraraghavan. Spatial Pattern Analysis using Closest Events (SPACE)—A Nearest Neighbor Point Pattern Analysis Framework for Assessing Spatial Relationships from Digital Images. Microscopy and Microanalysis, 2024, ozae022. https://doi.org/10.1093/mam/ozae022.
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
2.0.2 | Significantly simplified code and consistency of comments in the main function file. |
||
2.0.1 | Fixed punctuation in readme |
||
2.0.0 | Fixed issue with errors thrown from empty/blank masks. Split single analysis and batch analysis into separate function files. Removed multi-image analysis. Split XY and YX analysis results into different table outputs. Added batch analysis of tables. |
||
1.0.53 | Improved main function comments. |
||
1.0.52 | Updated comments describing SPACE function |
||
1.0.51 | Updated license year, citation link, and comments in SPACE.m. |
||
1.0.50 | fixed typos in the comments of SPACE.m |
||
1.0.49 | Updated comments and added a readme.txt file and the license file. |
||
1.0.48 | Added M&M citation to SPACE.m |
||
1.0.47 | Updated citation |
||
1.0.46 | Fixed comment typos in example scripts |
||
1.0.45 | Updated link to theory literature |
||
1.0.44 | Fixed link to theory literature |
||
1.0.43 | Added BSD-3 copyright licensing. |
||
1.0.42 | Fixed textual errors in description |
||
1.0.41 | actually fixed weighted variance calculation in ttest2w, for real this time |
||
1.0.40 | Fixed error in ttest2.m of weighted variance calculation |
||
1.0.39 | Added phase diagrams to example scripts |
||
1.0.38 | Added Google Scholar links |
||
1.0.37 | Relabeled images in description |
||
1.0.36 | Added spatial association index graphs to description |
||
1.0.35 | Clarified some output definitions. |
||
1.0.34 | fixed pre-print link |
||
1.0.33 | Updated description with link to pre-print paper. |
||
1.0.32 | Updated summary. |
||
1.0.31 | Updated summary. |
||
1.0.30 | Added reference the theory in description. |
||
1.0.29 | Fixed typos in description |
||
1.0.28 | Fixed typo in SPACE.m single-image analysis. Changed "assocation" to "association". |
||
1.0.27 | Improved SPACE.m use-case comments |
||
1.0.26 | Improved comments |
||
1.0.25 | Added ability to specify real-world pixel sizes |
||
1.0.24 | fixed typos in description |
||
1.0.23 | Added GitHub link to description |
||
1.0.22 | added publication to description |
||
1.0.21 | Updated examples |
||
1.0.20 | Added function to create overlay images. |
||
1.0.19 | Added images. |
||
1.0.18 | Added references to source code inspiration for ttest2w and CSRtest_single |
||
1.0.17 | Fixed commented description in plot_error.m |
||
1.0.16 | Updated ttest2s |
||
1.0.15 | Correct equation for weighted variance in ttest2w |
||
1.0.14 | Improved commented description in SPACE.m function. |
||
1.0.13 | Improved commented description in SPACE.m function |
||
1.0.12 | - Added Sample_Size field to SPACE batch results table
|
||
1.0.11 | Improved summary. |
||
1.0.10 | Added a my LinkedIn profile info. |
||
1.0.9 | Fixed error in calculated of weighted variance in ttest2w function. |
||
1.0.8 | Fixed description formatting. |
||
1.0.7 | Fixed formatting issues with description. |
||
1.0.6 | Edited description to include list of included files. |
||
1.0.5 | Added acknowledgments to the description. |
||
1.0.4 | Fixed typos in the description. |
||
1.0.3 | Add code to example scripts to automatically generate example images if they don't already exist. |
||
1.0.2 | Duplicate citation deleted. |
||
1.0.1 | Added my full name to the citation. |
||
1.0.0 |