SAM-SPOT 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: SAM-SPOT
3
+ Version: 0.1.1
4
+ Summary: Shape, appearance, motion Phenotype Observation Tool for streamlined live-cell phenotyping temporal analysis
5
+ Author-email: "Felix Y. Zhou" <felixzhou1@gmail.com>
6
+ License: LICR Software License
7
+ Project-URL: Homepage, https://github.com/fyz11/SPOT
8
+ Project-URL: Issues, https://github.com/fyz11/SPOT/issues
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Operating System :: MacOS :: MacOS X
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Requires-Python: <3.11,>3.9
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: numpy<2.0,>=1.23
18
+ Requires-Dist: contourpy<=1.2.0
19
+ Requires-Dist: tensorflow-gpu==2.10.*
20
+ Requires-Dist: pillow
21
+ Requires-Dist: mahotas
22
+ Requires-Dist: matplotlib
23
+ Requires-Dist: scikit-image
24
+ Requires-Dist: scikit-learn
25
+ Requires-Dist: scipy
26
+ Requires-Dist: opencv-contrib-python==4.5.*
27
+ Requires-Dist: tqdm
28
+ Requires-Dist: tifffile
29
+ Requires-Dist: seaborn
30
+ Requires-Dist: networkx
31
+ Requires-Dist: hmmviz
32
+ Requires-Dist: hmmlearn
33
+ Requires-Dist: pandas
34
+ Requires-Dist: statsmodels
35
+ Requires-Dist: umap-learn<=0.5.6
36
+ Requires-Dist: fastcluster
37
+ Requires-Dist: imagecodecs
38
+ Requires-Dist: dtaidistance
39
+ Provides-Extra: pacmap
40
+ Requires-Dist: pacmap; extra == "pacmap"
41
+
42
+ # SPOT (Shape, appearance, motion Phenotype Observation Tool)
43
+
44
+ <p align="center">
45
+ <img src="https://github.com/fyz11/SPOT/blob/main/docs/pictures/main_workflow.jpg" width=100%/>
46
+ </p>
47
+
48
+ <!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
49
+
50
+ * [Introduction to SPOT](#introduction-to-spot)
51
+ * [Introduction to the SAM phenome](#introduction-to-the-sam-phenome)
52
+ + [Code snippet to compute phenome](#code-snippet-to-compute-phenome)
53
+ * [Associated Paper](#associated-paper)
54
+ * [Getting Started](#getting-started)
55
+ * [SPOTapp](#spotapp)
56
+ * [Pretrained Neural Network Models for organoid detection and segmentation](#pretrained-neural-network-models-for-organoid-detection-and-segmentation)
57
+ * [Documentation](#documentation)
58
+ * [To install](#to-install)
59
+ * [COPYRIGHT INFORMATION:](#copyright-information)
60
+ + [FOR ACADEMIC AND NON-PROFIT USERS](#for-academic-and-non-profit-users)
61
+ + [FOR-PROFIT USERS](#for-profit-users)
62
+
63
+ <!-- TOC end -->
64
+
65
+ #### Jan 2026
66
+ - Tutorial video for installing SPOT, [link](https://www.dropbox.com/scl/fi/yyebz7clz4m46791zigj6/SPOT-tutorial.mp4?rlkey=aio3zsr33l4szh8gk4290ku1a&e=1&st=sw9ist2l&dl=0)
67
+ - added optional dependency to install `pacmap`. Requires externally installing from conda-forge the `python-annoy` package.
68
+
69
+
70
+ <!-- TOC --><a name="introduction-to-spot"></a>
71
+ ## Introduction to SPOT
72
+ SPOT is a generalized and streamlined workflow for analysing object dynamics in movies. It is designed to suit high-content imaging applications where analytical tools should be push-and-go and require no prior knowledge of the expected behaviour of the objects to be studied. In other words, users should be able to run through all the steps in one go, then retrospectively interpret the produced results. This workflow is inspired by that for single-cell sequencing and is summarized in the figure above.
73
+
74
+ Three innovations drive SPOT for temporal image analysis:
75
+ 1. a standardized Shape, Appearance and Motion phenome - a single feature set for all objects
76
+ 2. a standardized temporal analysis of compiled SAM phenomes - minimal assumption, push-and-go
77
+ 3. automated and standardized techniques to cluster related SAM features into SAM modules for interpreting discovered phenotypes
78
+
79
+ SPOT is provided here as a Python package to allow full flexibility. To get started, please check out exemplar scripts in the examples/ folder. We also include SPOTapp, a graphical user interface (GUI) to run SPOT stages 1 and 2. This app is currently in alpha development and is provided here as-is to support the paper publication.
80
+
81
+ <p align="center">
82
+ <img src="https://github.com/fyz11/SPOT/blob/main/docs/pictures/SAM_motivation2.jpg" width=100%/>
83
+ </p>
84
+
85
+ <!-- TOC --><a name="introduction-to-the-sam-phenome"></a>
86
+ ## Introduction to the SAM phenome
87
+ Dynamic objects constantly change their behaviour. Motivated by observation of natural images like birds and cars, we hypothesize that three measurable properties; Shape, Appearance and Motion (SAM) provides complementary information necessary to characterize the instantaneous phenotypic state for any object.
88
+
89
+ This led us to design a single generalized SAM feature set (depicted above) which can function similar to the single-cell transcriptome in single-cell sequencing analysis by considering in addition to shape, appearance and motion; global, (local) regional and (local) distribution features.
90
+
91
+ <!-- TOC --><a name="code-snippet-to-compute-phenome"></a>
92
+ ### Code snippet to compute phenome
93
+ The SPOT library computes the shape, appearance and motion-associated features in the SAM phenome separately to allow separate usage. To compute, you need to have the video as an array (`vid`) of (n_frames, n_rows, n_columns) and tracked and segmented object boundaries given as an array (`boundaries`) of (n_objects, n_frames, n_contour_points, 2). The last dimension of the boundaries array specifies (y,x) image coordinate convention. The boundaries array should use `numpy.nan` for any timepoints where an object was not present. You also need to specify the pixel resolution in micrometers (`pixel_res`) and the time elapsed (`time_res`) between each video frame in hours
94
+
95
+ #### Computing Shape Phenome
96
+ ```
97
+ import SPOT.Features.features as SPOT_SAM_features
98
+
99
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_morphology_features(boundaries,
100
+ imshape,
101
+ pixel_xy_res = pixel_res)
102
+ ```
103
+ #### Computing Appearance Phenome
104
+ ```
105
+ import SPOT.Features.features as SPOT_SAM_features
106
+
107
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_texture_features(vid,
108
+ boundaries)
109
+ ```
110
+ #### Computing Motion Phenome
111
+ Unlike shape and appearance, motion needs to first compute the dense optical flow. Consequently motion features are not available for object instances in the last video frame.
112
+ ```
113
+ import SPOT.Features.features as SPOT_SAM_features
114
+ import SPOT.Tracking.optical_flow as SPOT_optical_flow
115
+ import skimage.exposure as skexposure
116
+
117
+ # compute optical flow first.
118
+ optical_flow_params = dict(pyr_scale=0.5, levels=5, winsize=15, iterations=5, poly_n=3, poly_sigma=1.2, flags=0)
119
+
120
+ vid_norm = np.array([skexposure.rescale_intensity(frame) for frame in vid])
121
+ flow = SPOT_optical_flow.extract_vid_optflow(vid_norm,
122
+ flow_params=optical_flow_params,
123
+ rescale_intensity=True)
124
+
125
+ # then compute motion features. As the flow does not account for the last frame of the video, motion features also miss the last frame object instances.
126
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_motion_features(flow
127
+ boundaries)
128
+ ```
129
+
130
+ <!-- TOC --><a name="associated-paper"></a>
131
+ ## Associated Paper
132
+ SPOT is associated with the following papers (which are currently under journal revision), which you will be able to read after publication for more technical detail and get an idea of the many applications SPOT enables:
133
+
134
+ 1. (Methods paper, 2D fixed and live-cell imaging application) **Development of a universal imaging “phenome” using Shape, Appearance and Motion (SAM) features and the SAM Observation Tool (SPOT)**, (2025), written by Felix Y. Zhou, Adam Norton-Steele, Lewis Marsh, Helen M. Byrne, Heather A. Harrington and Xin Lu.
135
+
136
+ 2. (3D Organoid Timelapse Application) **Identifying phenotype-genotype-function coupling in 3D organoid imaging using
137
+ 2 Shape, Appearance and Motion Phenotype Observation Tool (SPOT)**, 2025, written by Felix Y. Zhou, Brittany-Amber Jacobs, Adam Norton-Steele, Xiaoyue Han, Thomas M. Carroll, Carlos Ruiz Puig, Joseph Chadwick, Xiao Qin, Richard Lisle, Lewis Marsh, Helen M. Byrne, Heather A. Harrington, Linna Zhou and Xin Lu.
138
+
139
+ <!-- TOC --><a name="getting-started"></a>
140
+ ## Getting Started
141
+ Detailed guide to setting up and installing SPOT, and running the exemplar scripts provided on example data is detailed in the [Getting Started word document]( https://github.com/fyz11/SPOT/blob/main/Getting%20Started%20with%20SPOT.docx)
142
+
143
+ Exemplar scripts to run every step of the workflow are provided in the Examples folder to work with the provided example data located in the data/ folder. This includes:
144
+
145
+ **for SPOT Stage 1: video acquisition and object segmentation:**
146
+ 1. SPOT_Stage1_Step0_translation-register-RGB-confocal_video.py
147
+ 2. SPOT_Stage1_Step0_unmix-RGB-confocal_video.py
148
+ 3. SPOT_Stage1_Step1_detect_bbox-RGB-confocal_video.py
149
+ 4. SPOT_Stage1_Step2_track_detect_bbox-RGB-confocal_video.py
150
+ 5. SPOT_Stage1_Step3_segment_tracked_bbox-RGB-confocal_video.py
151
+ 6. SPOT_Stage1_Step4_postprocess_segment_tracked_bbox-RGB-confocal_video.py
152
+
153
+ **for SPOT Stage 2: computation of SAM (Shape, Appearance and Motion) phenome:**
154
+
155
+ <u>based on the example fluorescent video:</u>
156
+ 1. SPOT_Stage2_Step1_compute_SAM_phenomes.py
157
+ 2. SPOT_Stage2_Step2_generate_metadata_table.py
158
+ 3. SPOT_Stage2_Step3_compile_and_export_SAM_phenomes.py
159
+ 4. SPOT_Stage2_Step4_compile_and_export_object_patch_imgs.py
160
+
161
+ <u>based on the single cell tracking challenge:</u>
162
+ 1. SPOT_demo_single-cell-tracking-challenge_Step0_Prepare_Single_Cell_Tracking_Challenge_Dataset_All.py
163
+ 2. SPOT_demo_single-cell-tracking-challenge_Step1_Compute_SAM_phenome_Single_Cell_Tracking_Challenge_Dataset_All.py
164
+
165
+ **for SPOT Stage 3: analysis of SAM (Shape, Appearance and Motion) phenome:**
166
+ 1. SPOT_demo_single-cell-tracking-challenge_Step2_Compile_All_SAM_phenomes_cell-tracking-challenge.py
167
+ 2. SPOT_demo_single-cell-tracking-challenge_Step3_SPOT_analyze_all_SAM_phenomes_cell_tracking_challenge.py
168
+
169
+ Each example should take around a few mins to run. The longest time is computing the SAM phenome which might take 10s of mins.
170
+
171
+ <!-- TOC --><a name="spotapp"></a>
172
+ ## SPOTapp
173
+ In parallel to the scripts, we provide an alpha version of a GUI to run SPOT called SPOTapp. You can find download instructions in the file SPOTapp.md. Instructions to use the software can also be found at the download link.
174
+
175
+ <!-- TOC --><a name="pretrained-neural-network-models-for-organoid-detection-and-segmentation"></a>
176
+ ## Pretrained Neural Network Models for organoid detection and segmentation
177
+ We make available pretrained neural network organoid detection and segmentation models with this repo. The segmentation model is already provided in the repo. The detection model should be downloaded and copied to the models/detect_CNN_model/ folder of this repo if you are running the example scripts.
178
+
179
+ 1. Organoid bounding box detector for brightfield/phase contrast and fluorescence microscopy. [Organoid YOLOv3 bounding box detection model weights](https://www.dropbox.com/scl/fi/qzowc9s9n30zh6qdyzeqw/keras_YOLOv3_organoid_detector2.h5?rlkey=6deiqemsmcz3yin9b5dnz0e6y&dl=0)
180
+ 2. Organoid attention UNet segmentation model given a bounding box cropped image. (this repo, [models/segment_CNN_model/organoid-bbox_attn_seg-unet-master-v2_64x64-8feats_v2.h5](https://github.com/fyz11/SPOT/blob/main/models/segment_CNN_model/organoid-bbox_attn_seg-unet-master-v2_64x64-8feats_v2.h5))
181
+
182
+ <!-- TOC --><a name="documentation"></a>
183
+ ## Documentation
184
+ Documented API of the functions provided in this library is available as a html in the docs/build/hmtl folder. You can build up-to-date docs by going into docs/ and executing:
185
+ ```shell
186
+ make html
187
+ ```
188
+
189
+ <!-- TOC --><a name="to-install"></a>
190
+ ## To install
191
+ The package can be installed automatically using pip after cloning the repository. It has been tested and working for Python 3.9 and 3.10. Installation time in mins. We recommend installing into a new conda environment, and preinstalling the annoy package from conda-forge if you want to use pacmap instead of umap for dimensionality reduction:
192
+ ```shell
193
+ conda create -n SAM-SPOT_env python=3.9
194
+ conda install -n SAM-SPOT_env -c conda-forge python-annoy
195
+ pip install .
196
+ ```
197
+ You can also install directly from the github without cloning, but will still need to manually download the pretrained model weights:
198
+ ```shell
199
+ pip install SPOT@git+https://github.com/fyz11/SPOT.git
200
+ ```
201
+
202
+ <!-- TOC --><a name="copyright-information"></a>
203
+ ### COPYRIGHT INFORMATION:
204
+
205
+ <!-- TOC --><a name="for-academic-and-non-profit-users"></a>
206
+ #### FOR ACADEMIC AND NON-PROFIT USERS
207
+ ---
208
+ The software and scripts is made available as is under a Ludwig Software License for academic non-commercial research purposes. Please read the included software license agreement.
209
+
210
+ <!-- TOC --><a name="for-profit-users"></a>
211
+ #### FOR-PROFIT USERS
212
+ ---
213
+ If you plan to use SPOT in any for-profit application, you are required to obtain a separate license. To do so, please contact Shayda Hemmati (shemmati@licr.org) or Par Olsson (polsson@licr.org) at the Ludwig Institute for Cancer Research Ltd.
@@ -0,0 +1,172 @@
1
+ # SPOT (Shape, appearance, motion Phenotype Observation Tool)
2
+
3
+ <p align="center">
4
+ <img src="https://github.com/fyz11/SPOT/blob/main/docs/pictures/main_workflow.jpg" width=100%/>
5
+ </p>
6
+
7
+ <!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
8
+
9
+ * [Introduction to SPOT](#introduction-to-spot)
10
+ * [Introduction to the SAM phenome](#introduction-to-the-sam-phenome)
11
+ + [Code snippet to compute phenome](#code-snippet-to-compute-phenome)
12
+ * [Associated Paper](#associated-paper)
13
+ * [Getting Started](#getting-started)
14
+ * [SPOTapp](#spotapp)
15
+ * [Pretrained Neural Network Models for organoid detection and segmentation](#pretrained-neural-network-models-for-organoid-detection-and-segmentation)
16
+ * [Documentation](#documentation)
17
+ * [To install](#to-install)
18
+ * [COPYRIGHT INFORMATION:](#copyright-information)
19
+ + [FOR ACADEMIC AND NON-PROFIT USERS](#for-academic-and-non-profit-users)
20
+ + [FOR-PROFIT USERS](#for-profit-users)
21
+
22
+ <!-- TOC end -->
23
+
24
+ #### Jan 2026
25
+ - Tutorial video for installing SPOT, [link](https://www.dropbox.com/scl/fi/yyebz7clz4m46791zigj6/SPOT-tutorial.mp4?rlkey=aio3zsr33l4szh8gk4290ku1a&e=1&st=sw9ist2l&dl=0)
26
+ - added optional dependency to install `pacmap`. Requires externally installing from conda-forge the `python-annoy` package.
27
+
28
+
29
+ <!-- TOC --><a name="introduction-to-spot"></a>
30
+ ## Introduction to SPOT
31
+ SPOT is a generalized and streamlined workflow for analysing object dynamics in movies. It is designed to suit high-content imaging applications where analytical tools should be push-and-go and require no prior knowledge of the expected behaviour of the objects to be studied. In other words, users should be able to run through all the steps in one go, then retrospectively interpret the produced results. This workflow is inspired by that for single-cell sequencing and is summarized in the figure above.
32
+
33
+ Three innovations drive SPOT for temporal image analysis:
34
+ 1. a standardized Shape, Appearance and Motion phenome - a single feature set for all objects
35
+ 2. a standardized temporal analysis of compiled SAM phenomes - minimal assumption, push-and-go
36
+ 3. automated and standardized techniques to cluster related SAM features into SAM modules for interpreting discovered phenotypes
37
+
38
+ SPOT is provided here as a Python package to allow full flexibility. To get started, please check out exemplar scripts in the examples/ folder. We also include SPOTapp, a graphical user interface (GUI) to run SPOT stages 1 and 2. This app is currently in alpha development and is provided here as-is to support the paper publication.
39
+
40
+ <p align="center">
41
+ <img src="https://github.com/fyz11/SPOT/blob/main/docs/pictures/SAM_motivation2.jpg" width=100%/>
42
+ </p>
43
+
44
+ <!-- TOC --><a name="introduction-to-the-sam-phenome"></a>
45
+ ## Introduction to the SAM phenome
46
+ Dynamic objects constantly change their behaviour. Motivated by observation of natural images like birds and cars, we hypothesize that three measurable properties; Shape, Appearance and Motion (SAM) provides complementary information necessary to characterize the instantaneous phenotypic state for any object.
47
+
48
+ This led us to design a single generalized SAM feature set (depicted above) which can function similar to the single-cell transcriptome in single-cell sequencing analysis by considering in addition to shape, appearance and motion; global, (local) regional and (local) distribution features.
49
+
50
+ <!-- TOC --><a name="code-snippet-to-compute-phenome"></a>
51
+ ### Code snippet to compute phenome
52
+ The SPOT library computes the shape, appearance and motion-associated features in the SAM phenome separately to allow separate usage. To compute, you need to have the video as an array (`vid`) of (n_frames, n_rows, n_columns) and tracked and segmented object boundaries given as an array (`boundaries`) of (n_objects, n_frames, n_contour_points, 2). The last dimension of the boundaries array specifies (y,x) image coordinate convention. The boundaries array should use `numpy.nan` for any timepoints where an object was not present. You also need to specify the pixel resolution in micrometers (`pixel_res`) and the time elapsed (`time_res`) between each video frame in hours
53
+
54
+ #### Computing Shape Phenome
55
+ ```
56
+ import SPOT.Features.features as SPOT_SAM_features
57
+
58
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_morphology_features(boundaries,
59
+ imshape,
60
+ pixel_xy_res = pixel_res)
61
+ ```
62
+ #### Computing Appearance Phenome
63
+ ```
64
+ import SPOT.Features.features as SPOT_SAM_features
65
+
66
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_texture_features(vid,
67
+ boundaries)
68
+ ```
69
+ #### Computing Motion Phenome
70
+ Unlike shape and appearance, motion needs to first compute the dense optical flow. Consequently motion features are not available for object instances in the last video frame.
71
+ ```
72
+ import SPOT.Features.features as SPOT_SAM_features
73
+ import SPOT.Tracking.optical_flow as SPOT_optical_flow
74
+ import skimage.exposure as skexposure
75
+
76
+ # compute optical flow first.
77
+ optical_flow_params = dict(pyr_scale=0.5, levels=5, winsize=15, iterations=5, poly_n=3, poly_sigma=1.2, flags=0)
78
+
79
+ vid_norm = np.array([skexposure.rescale_intensity(frame) for frame in vid])
80
+ flow = SPOT_optical_flow.extract_vid_optflow(vid_norm,
81
+ flow_params=optical_flow_params,
82
+ rescale_intensity=True)
83
+
84
+ # then compute motion features. As the flow does not account for the last frame of the video, motion features also miss the last frame object instances.
85
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_motion_features(flow
86
+ boundaries)
87
+ ```
88
+
89
+ <!-- TOC --><a name="associated-paper"></a>
90
+ ## Associated Paper
91
+ SPOT is associated with the following papers (which are currently under journal revision), which you will be able to read after publication for more technical detail and get an idea of the many applications SPOT enables:
92
+
93
+ 1. (Methods paper, 2D fixed and live-cell imaging application) **Development of a universal imaging “phenome” using Shape, Appearance and Motion (SAM) features and the SAM Observation Tool (SPOT)**, (2025), written by Felix Y. Zhou, Adam Norton-Steele, Lewis Marsh, Helen M. Byrne, Heather A. Harrington and Xin Lu.
94
+
95
+ 2. (3D Organoid Timelapse Application) **Identifying phenotype-genotype-function coupling in 3D organoid imaging using
96
+ 2 Shape, Appearance and Motion Phenotype Observation Tool (SPOT)**, 2025, written by Felix Y. Zhou, Brittany-Amber Jacobs, Adam Norton-Steele, Xiaoyue Han, Thomas M. Carroll, Carlos Ruiz Puig, Joseph Chadwick, Xiao Qin, Richard Lisle, Lewis Marsh, Helen M. Byrne, Heather A. Harrington, Linna Zhou and Xin Lu.
97
+
98
+ <!-- TOC --><a name="getting-started"></a>
99
+ ## Getting Started
100
+ Detailed guide to setting up and installing SPOT, and running the exemplar scripts provided on example data is detailed in the [Getting Started word document]( https://github.com/fyz11/SPOT/blob/main/Getting%20Started%20with%20SPOT.docx)
101
+
102
+ Exemplar scripts to run every step of the workflow are provided in the Examples folder to work with the provided example data located in the data/ folder. This includes:
103
+
104
+ **for SPOT Stage 1: video acquisition and object segmentation:**
105
+ 1. SPOT_Stage1_Step0_translation-register-RGB-confocal_video.py
106
+ 2. SPOT_Stage1_Step0_unmix-RGB-confocal_video.py
107
+ 3. SPOT_Stage1_Step1_detect_bbox-RGB-confocal_video.py
108
+ 4. SPOT_Stage1_Step2_track_detect_bbox-RGB-confocal_video.py
109
+ 5. SPOT_Stage1_Step3_segment_tracked_bbox-RGB-confocal_video.py
110
+ 6. SPOT_Stage1_Step4_postprocess_segment_tracked_bbox-RGB-confocal_video.py
111
+
112
+ **for SPOT Stage 2: computation of SAM (Shape, Appearance and Motion) phenome:**
113
+
114
+ <u>based on the example fluorescent video:</u>
115
+ 1. SPOT_Stage2_Step1_compute_SAM_phenomes.py
116
+ 2. SPOT_Stage2_Step2_generate_metadata_table.py
117
+ 3. SPOT_Stage2_Step3_compile_and_export_SAM_phenomes.py
118
+ 4. SPOT_Stage2_Step4_compile_and_export_object_patch_imgs.py
119
+
120
+ <u>based on the single cell tracking challenge:</u>
121
+ 1. SPOT_demo_single-cell-tracking-challenge_Step0_Prepare_Single_Cell_Tracking_Challenge_Dataset_All.py
122
+ 2. SPOT_demo_single-cell-tracking-challenge_Step1_Compute_SAM_phenome_Single_Cell_Tracking_Challenge_Dataset_All.py
123
+
124
+ **for SPOT Stage 3: analysis of SAM (Shape, Appearance and Motion) phenome:**
125
+ 1. SPOT_demo_single-cell-tracking-challenge_Step2_Compile_All_SAM_phenomes_cell-tracking-challenge.py
126
+ 2. SPOT_demo_single-cell-tracking-challenge_Step3_SPOT_analyze_all_SAM_phenomes_cell_tracking_challenge.py
127
+
128
+ Each example should take around a few mins to run. The longest time is computing the SAM phenome which might take 10s of mins.
129
+
130
+ <!-- TOC --><a name="spotapp"></a>
131
+ ## SPOTapp
132
+ In parallel to the scripts, we provide an alpha version of a GUI to run SPOT called SPOTapp. You can find download instructions in the file SPOTapp.md. Instructions to use the software can also be found at the download link.
133
+
134
+ <!-- TOC --><a name="pretrained-neural-network-models-for-organoid-detection-and-segmentation"></a>
135
+ ## Pretrained Neural Network Models for organoid detection and segmentation
136
+ We make available pretrained neural network organoid detection and segmentation models with this repo. The segmentation model is already provided in the repo. The detection model should be downloaded and copied to the models/detect_CNN_model/ folder of this repo if you are running the example scripts.
137
+
138
+ 1. Organoid bounding box detector for brightfield/phase contrast and fluorescence microscopy. [Organoid YOLOv3 bounding box detection model weights](https://www.dropbox.com/scl/fi/qzowc9s9n30zh6qdyzeqw/keras_YOLOv3_organoid_detector2.h5?rlkey=6deiqemsmcz3yin9b5dnz0e6y&dl=0)
139
+ 2. Organoid attention UNet segmentation model given a bounding box cropped image. (this repo, [models/segment_CNN_model/organoid-bbox_attn_seg-unet-master-v2_64x64-8feats_v2.h5](https://github.com/fyz11/SPOT/blob/main/models/segment_CNN_model/organoid-bbox_attn_seg-unet-master-v2_64x64-8feats_v2.h5))
140
+
141
+ <!-- TOC --><a name="documentation"></a>
142
+ ## Documentation
143
+ Documented API of the functions provided in this library is available as a html in the docs/build/hmtl folder. You can build up-to-date docs by going into docs/ and executing:
144
+ ```shell
145
+ make html
146
+ ```
147
+
148
+ <!-- TOC --><a name="to-install"></a>
149
+ ## To install
150
+ The package can be installed automatically using pip after cloning the repository. It has been tested and working for Python 3.9 and 3.10. Installation time in mins. We recommend installing into a new conda environment, and preinstalling the annoy package from conda-forge if you want to use pacmap instead of umap for dimensionality reduction:
151
+ ```shell
152
+ conda create -n SAM-SPOT_env python=3.9
153
+ conda install -n SAM-SPOT_env -c conda-forge python-annoy
154
+ pip install .
155
+ ```
156
+ You can also install directly from the github without cloning, but will still need to manually download the pretrained model weights:
157
+ ```shell
158
+ pip install SPOT@git+https://github.com/fyz11/SPOT.git
159
+ ```
160
+
161
+ <!-- TOC --><a name="copyright-information"></a>
162
+ ### COPYRIGHT INFORMATION:
163
+
164
+ <!-- TOC --><a name="for-academic-and-non-profit-users"></a>
165
+ #### FOR ACADEMIC AND NON-PROFIT USERS
166
+ ---
167
+ The software and scripts is made available as is under a Ludwig Software License for academic non-commercial research purposes. Please read the included software license agreement.
168
+
169
+ <!-- TOC --><a name="for-profit-users"></a>
170
+ #### FOR-PROFIT USERS
171
+ ---
172
+ If you plan to use SPOT in any for-profit application, you are required to obtain a separate license. To do so, please contact Shayda Hemmati (shemmati@licr.org) or Par Olsson (polsson@licr.org) at the Ludwig Institute for Cancer Research Ltd.
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: SAM-SPOT
3
+ Version: 0.1.1
4
+ Summary: Shape, appearance, motion Phenotype Observation Tool for streamlined live-cell phenotyping temporal analysis
5
+ Author-email: "Felix Y. Zhou" <felixzhou1@gmail.com>
6
+ License: LICR Software License
7
+ Project-URL: Homepage, https://github.com/fyz11/SPOT
8
+ Project-URL: Issues, https://github.com/fyz11/SPOT/issues
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Operating System :: MacOS :: MacOS X
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Requires-Python: <3.11,>3.9
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: numpy<2.0,>=1.23
18
+ Requires-Dist: contourpy<=1.2.0
19
+ Requires-Dist: tensorflow-gpu==2.10.*
20
+ Requires-Dist: pillow
21
+ Requires-Dist: mahotas
22
+ Requires-Dist: matplotlib
23
+ Requires-Dist: scikit-image
24
+ Requires-Dist: scikit-learn
25
+ Requires-Dist: scipy
26
+ Requires-Dist: opencv-contrib-python==4.5.*
27
+ Requires-Dist: tqdm
28
+ Requires-Dist: tifffile
29
+ Requires-Dist: seaborn
30
+ Requires-Dist: networkx
31
+ Requires-Dist: hmmviz
32
+ Requires-Dist: hmmlearn
33
+ Requires-Dist: pandas
34
+ Requires-Dist: statsmodels
35
+ Requires-Dist: umap-learn<=0.5.6
36
+ Requires-Dist: fastcluster
37
+ Requires-Dist: imagecodecs
38
+ Requires-Dist: dtaidistance
39
+ Provides-Extra: pacmap
40
+ Requires-Dist: pacmap; extra == "pacmap"
41
+
42
+ # SPOT (Shape, appearance, motion Phenotype Observation Tool)
43
+
44
+ <p align="center">
45
+ <img src="https://github.com/fyz11/SPOT/blob/main/docs/pictures/main_workflow.jpg" width=100%/>
46
+ </p>
47
+
48
+ <!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
49
+
50
+ * [Introduction to SPOT](#introduction-to-spot)
51
+ * [Introduction to the SAM phenome](#introduction-to-the-sam-phenome)
52
+ + [Code snippet to compute phenome](#code-snippet-to-compute-phenome)
53
+ * [Associated Paper](#associated-paper)
54
+ * [Getting Started](#getting-started)
55
+ * [SPOTapp](#spotapp)
56
+ * [Pretrained Neural Network Models for organoid detection and segmentation](#pretrained-neural-network-models-for-organoid-detection-and-segmentation)
57
+ * [Documentation](#documentation)
58
+ * [To install](#to-install)
59
+ * [COPYRIGHT INFORMATION:](#copyright-information)
60
+ + [FOR ACADEMIC AND NON-PROFIT USERS](#for-academic-and-non-profit-users)
61
+ + [FOR-PROFIT USERS](#for-profit-users)
62
+
63
+ <!-- TOC end -->
64
+
65
+ #### Jan 2026
66
+ - Tutorial video for installing SPOT, [link](https://www.dropbox.com/scl/fi/yyebz7clz4m46791zigj6/SPOT-tutorial.mp4?rlkey=aio3zsr33l4szh8gk4290ku1a&e=1&st=sw9ist2l&dl=0)
67
+ - added optional dependency to install `pacmap`. Requires externally installing from conda-forge the `python-annoy` package.
68
+
69
+
70
+ <!-- TOC --><a name="introduction-to-spot"></a>
71
+ ## Introduction to SPOT
72
+ SPOT is a generalized and streamlined workflow for analysing object dynamics in movies. It is designed to suit high-content imaging applications where analytical tools should be push-and-go and require no prior knowledge of the expected behaviour of the objects to be studied. In other words, users should be able to run through all the steps in one go, then retrospectively interpret the produced results. This workflow is inspired by that for single-cell sequencing and is summarized in the figure above.
73
+
74
+ Three innovations drive SPOT for temporal image analysis:
75
+ 1. a standardized Shape, Appearance and Motion phenome - a single feature set for all objects
76
+ 2. a standardized temporal analysis of compiled SAM phenomes - minimal assumption, push-and-go
77
+ 3. automated and standardized techniques to cluster related SAM features into SAM modules for interpreting discovered phenotypes
78
+
79
+ SPOT is provided here as a Python package to allow full flexibility. To get started, please check out exemplar scripts in the examples/ folder. We also include SPOTapp, a graphical user interface (GUI) to run SPOT stages 1 and 2. This app is currently in alpha development and is provided here as-is to support the paper publication.
80
+
81
+ <p align="center">
82
+ <img src="https://github.com/fyz11/SPOT/blob/main/docs/pictures/SAM_motivation2.jpg" width=100%/>
83
+ </p>
84
+
85
+ <!-- TOC --><a name="introduction-to-the-sam-phenome"></a>
86
+ ## Introduction to the SAM phenome
87
+ Dynamic objects constantly change their behaviour. Motivated by observation of natural images like birds and cars, we hypothesize that three measurable properties; Shape, Appearance and Motion (SAM) provides complementary information necessary to characterize the instantaneous phenotypic state for any object.
88
+
89
+ This led us to design a single generalized SAM feature set (depicted above) which can function similar to the single-cell transcriptome in single-cell sequencing analysis by considering in addition to shape, appearance and motion; global, (local) regional and (local) distribution features.
90
+
91
+ <!-- TOC --><a name="code-snippet-to-compute-phenome"></a>
92
+ ### Code snippet to compute phenome
93
+ The SPOT library computes the shape, appearance and motion-associated features in the SAM phenome separately to allow separate usage. To compute, you need to have the video as an array (`vid`) of (n_frames, n_rows, n_columns) and tracked and segmented object boundaries given as an array (`boundaries`) of (n_objects, n_frames, n_contour_points, 2). The last dimension of the boundaries array specifies (y,x) image coordinate convention. The boundaries array should use `numpy.nan` for any timepoints where an object was not present. You also need to specify the pixel resolution in micrometers (`pixel_res`) and the time elapsed (`time_res`) between each video frame in hours
94
+
95
+ #### Computing Shape Phenome
96
+ ```
97
+ import SPOT.Features.features as SPOT_SAM_features
98
+
99
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_morphology_features(boundaries,
100
+ imshape,
101
+ pixel_xy_res = pixel_res)
102
+ ```
103
+ #### Computing Appearance Phenome
104
+ ```
105
+ import SPOT.Features.features as SPOT_SAM_features
106
+
107
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_texture_features(vid,
108
+ boundaries)
109
+ ```
110
+ #### Computing Motion Phenome
111
+ Unlike shape and appearance, motion needs to first compute the dense optical flow. Consequently motion features are not available for object instances in the last video frame.
112
+ ```
113
+ import SPOT.Features.features as SPOT_SAM_features
114
+ import SPOT.Tracking.optical_flow as SPOT_optical_flow
115
+ import skimage.exposure as skexposure
116
+
117
+ # compute optical flow first.
118
+ optical_flow_params = dict(pyr_scale=0.5, levels=5, winsize=15, iterations=5, poly_n=3, poly_sigma=1.2, flags=0)
119
+
120
+ vid_norm = np.array([skexposure.rescale_intensity(frame) for frame in vid])
121
+ flow = SPOT_optical_flow.extract_vid_optflow(vid_norm,
122
+ flow_params=optical_flow_params,
123
+ rescale_intensity=True)
124
+
125
+ # then compute motion features. As the flow does not account for the last frame of the video, motion features also miss the last frame object instances.
126
+ metrics, metrics_labels, metrics_norm_bool = SPOT_SAM_features.compute_boundary_motion_features(flow
127
+ boundaries)
128
+ ```
129
+
130
+ <!-- TOC --><a name="associated-paper"></a>
131
+ ## Associated Paper
132
+ SPOT is associated with the following papers (which are currently under journal revision), which you will be able to read after publication for more technical detail and get an idea of the many applications SPOT enables:
133
+
134
+ 1. (Methods paper, 2D fixed and live-cell imaging application) **Development of a universal imaging “phenome” using Shape, Appearance and Motion (SAM) features and the SAM Observation Tool (SPOT)**, (2025), written by Felix Y. Zhou, Adam Norton-Steele, Lewis Marsh, Helen M. Byrne, Heather A. Harrington and Xin Lu.
135
+
136
+ 2. (3D Organoid Timelapse Application) **Identifying phenotype-genotype-function coupling in 3D organoid imaging using
137
+ 2 Shape, Appearance and Motion Phenotype Observation Tool (SPOT)**, 2025, written by Felix Y. Zhou, Brittany-Amber Jacobs, Adam Norton-Steele, Xiaoyue Han, Thomas M. Carroll, Carlos Ruiz Puig, Joseph Chadwick, Xiao Qin, Richard Lisle, Lewis Marsh, Helen M. Byrne, Heather A. Harrington, Linna Zhou and Xin Lu.
138
+
139
+ <!-- TOC --><a name="getting-started"></a>
140
+ ## Getting Started
141
+ Detailed guide to setting up and installing SPOT, and running the exemplar scripts provided on example data is detailed in the [Getting Started word document]( https://github.com/fyz11/SPOT/blob/main/Getting%20Started%20with%20SPOT.docx)
142
+
143
+ Exemplar scripts to run every step of the workflow are provided in the Examples folder to work with the provided example data located in the data/ folder. This includes:
144
+
145
+ **for SPOT Stage 1: video acquisition and object segmentation:**
146
+ 1. SPOT_Stage1_Step0_translation-register-RGB-confocal_video.py
147
+ 2. SPOT_Stage1_Step0_unmix-RGB-confocal_video.py
148
+ 3. SPOT_Stage1_Step1_detect_bbox-RGB-confocal_video.py
149
+ 4. SPOT_Stage1_Step2_track_detect_bbox-RGB-confocal_video.py
150
+ 5. SPOT_Stage1_Step3_segment_tracked_bbox-RGB-confocal_video.py
151
+ 6. SPOT_Stage1_Step4_postprocess_segment_tracked_bbox-RGB-confocal_video.py
152
+
153
+ **for SPOT Stage 2: computation of SAM (Shape, Appearance and Motion) phenome:**
154
+
155
+ <u>based on the example fluorescent video:</u>
156
+ 1. SPOT_Stage2_Step1_compute_SAM_phenomes.py
157
+ 2. SPOT_Stage2_Step2_generate_metadata_table.py
158
+ 3. SPOT_Stage2_Step3_compile_and_export_SAM_phenomes.py
159
+ 4. SPOT_Stage2_Step4_compile_and_export_object_patch_imgs.py
160
+
161
+ <u>based on the single cell tracking challenge:</u>
162
+ 1. SPOT_demo_single-cell-tracking-challenge_Step0_Prepare_Single_Cell_Tracking_Challenge_Dataset_All.py
163
+ 2. SPOT_demo_single-cell-tracking-challenge_Step1_Compute_SAM_phenome_Single_Cell_Tracking_Challenge_Dataset_All.py
164
+
165
+ **for SPOT Stage 3: analysis of SAM (Shape, Appearance and Motion) phenome:**
166
+ 1. SPOT_demo_single-cell-tracking-challenge_Step2_Compile_All_SAM_phenomes_cell-tracking-challenge.py
167
+ 2. SPOT_demo_single-cell-tracking-challenge_Step3_SPOT_analyze_all_SAM_phenomes_cell_tracking_challenge.py
168
+
169
+ Each example should take around a few mins to run. The longest time is computing the SAM phenome which might take 10s of mins.
170
+
171
+ <!-- TOC --><a name="spotapp"></a>
172
+ ## SPOTapp
173
+ In parallel to the scripts, we provide an alpha version of a GUI to run SPOT called SPOTapp. You can find download instructions in the file SPOTapp.md. Instructions to use the software can also be found at the download link.
174
+
175
+ <!-- TOC --><a name="pretrained-neural-network-models-for-organoid-detection-and-segmentation"></a>
176
+ ## Pretrained Neural Network Models for organoid detection and segmentation
177
+ We make available pretrained neural network organoid detection and segmentation models with this repo. The segmentation model is already provided in the repo. The detection model should be downloaded and copied to the models/detect_CNN_model/ folder of this repo if you are running the example scripts.
178
+
179
+ 1. Organoid bounding box detector for brightfield/phase contrast and fluorescence microscopy. [Organoid YOLOv3 bounding box detection model weights](https://www.dropbox.com/scl/fi/qzowc9s9n30zh6qdyzeqw/keras_YOLOv3_organoid_detector2.h5?rlkey=6deiqemsmcz3yin9b5dnz0e6y&dl=0)
180
+ 2. Organoid attention UNet segmentation model given a bounding box cropped image. (this repo, [models/segment_CNN_model/organoid-bbox_attn_seg-unet-master-v2_64x64-8feats_v2.h5](https://github.com/fyz11/SPOT/blob/main/models/segment_CNN_model/organoid-bbox_attn_seg-unet-master-v2_64x64-8feats_v2.h5))
181
+
182
+ <!-- TOC --><a name="documentation"></a>
183
+ ## Documentation
184
+ Documented API of the functions provided in this library is available as a html in the docs/build/hmtl folder. You can build up-to-date docs by going into docs/ and executing:
185
+ ```shell
186
+ make html
187
+ ```
188
+
189
+ <!-- TOC --><a name="to-install"></a>
190
+ ## To install
191
+ The package can be installed automatically using pip after cloning the repository. It has been tested and working for Python 3.9 and 3.10. Installation time in mins. We recommend installing into a new conda environment, and preinstalling the annoy package from conda-forge if you want to use pacmap instead of umap for dimensionality reduction:
192
+ ```shell
193
+ conda create -n SAM-SPOT_env python=3.9
194
+ conda install -n SAM-SPOT_env -c conda-forge python-annoy
195
+ pip install .
196
+ ```
197
+ You can also install directly from the github without cloning, but will still need to manually download the pretrained model weights:
198
+ ```shell
199
+ pip install SPOT@git+https://github.com/fyz11/SPOT.git
200
+ ```
201
+
202
+ <!-- TOC --><a name="copyright-information"></a>
203
+ ### COPYRIGHT INFORMATION:
204
+
205
+ <!-- TOC --><a name="for-academic-and-non-profit-users"></a>
206
+ #### FOR ACADEMIC AND NON-PROFIT USERS
207
+ ---
208
+ The software and scripts is made available as is under a Ludwig Software License for academic non-commercial research purposes. Please read the included software license agreement.
209
+
210
+ <!-- TOC --><a name="for-profit-users"></a>
211
+ #### FOR-PROFIT USERS
212
+ ---
213
+ If you plan to use SPOT in any for-profit application, you are required to obtain a separate license. To do so, please contact Shayda Hemmati (shemmati@licr.org) or Par Olsson (polsson@licr.org) at the Ludwig Institute for Cancer Research Ltd.
@@ -0,0 +1,25 @@
1
+ README.md
2
+ pyproject.toml
3
+ SAM_SPOT.egg-info/PKG-INFO
4
+ SAM_SPOT.egg-info/SOURCES.txt
5
+ SAM_SPOT.egg-info/dependency_links.txt
6
+ SAM_SPOT.egg-info/requires.txt
7
+ SAM_SPOT.egg-info/top_level.txt
8
+ SPOT/__init__.py
9
+ SPOT/Analysis/__init__.py
10
+ SPOT/Analysis/preprocessing.py
11
+ SPOT/Analysis/sam_analysis.py
12
+ SPOT/Detection/__init__.py
13
+ SPOT/Detection/detection.py
14
+ SPOT/Detection/unets.py
15
+ SPOT/Features/__init__.py
16
+ SPOT/Features/features.py
17
+ SPOT/Image/image.py
18
+ SPOT/Registration/__init__.py
19
+ SPOT/Registration/registration_2D.py
20
+ SPOT/Tracking/__init__.py
21
+ SPOT/Tracking/optical_flow.py
22
+ SPOT/Tracking/track.py
23
+ SPOT/Utility_Functions/__init__.py
24
+ SPOT/Utility_Functions/file_io.py
25
+ SPOT/Utility_Functions/plotting.py