You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 36d75ce
Browse filesBrowse the repository at this point in the historyBrowse files
* Add CellSAM segmentation support
* Add KRONOS embedding generation with optional merged GeoJSON output
* Add optional mask smoothing for complex geometries, with morphological or shapely-based simplification
* Replace Groovy cellmeasurement with Python-only bin/cellmeasurement.py
* Add structure to support running pytest with CI
* Update erosion measurement output to use 5 equal-area bins with new ErosionBin_* column names
* Change --erosion-steps to a boolean flag; numeric pixel-depth values are no longer supported
* Add dist_threshold parameter for nucleus-to-cell ROI matching
* Add downsample_factor parameter to speed up cellmeasurement on large images
---------
Co-authored-by: Marek Cmero <7799828+mcmero@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: .github/CONTRIBUTING.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,13 @@ nf-test test --profile debug,test_mesmer,docker --verbose
30
30
nf-test test --profile debug,test_cellpose,docker --verbose
31
31
```
32
32
33
+
KRONOS module tests run in stub mode by default to avoid downloading large model checkpoints. To run the KRONOS integration module test, set a pre-downloaded model directory (must contain a `.pt` checkpoint) and run:
34
+
35
+
```bash
36
+
export KRONOS_MODEL_DIR=/path/to/kronos_model_dir
37
+
nf-test test modules/local/kronosembeddings/tests/main.nf.test --profile debug,test,apptainer --verbose
38
+
```
39
+
33
40
When you create a pull request with changes, [GitHub Actions](https://github.com/features/actions) will run automatic tests.
34
41
Typically, pull-requests are only fully reviewed when these tests are passing, though of course we can help out before then.
**WEHI-SODA-Hub/sp_segment** is a pipeline for running cell segmentation
22
-
on COMETand MIBI data. For COMET, background subtraction can be performed
23
-
followed by patched cellpose segmentation, or non-patched mesmer segmentation.
24
-
For MIBI, mesmer segmentation can be run. Whole-cell and nuclear segmentations
25
-
are run separately, and then consolidated into whole cells with nuclei with full
26
-
shape and intensity measurements per compartment. The output GeoJSON files can
27
-
be viewed in QuPath.
22
+
on COMET, MIBI, and OPAL data. For COMET, background subtraction can be performed
23
+
followed by patched cellpose segmentation, non-patched mesmer segmentation, or
24
+
CellSAM foundation model segmentation. For MIBI, mesmer or CellSAM segmentation
25
+
can be run. Whole-cell and nuclear segmentations are run separately, and then
26
+
consolidated into whole cells with nuclei with full shape and intensity
27
+
measurements per compartment. The output GeoJSON files can be viewed in QuPath.
28
28
29
29
<details>
30
30
<summary>Click to view Mermaid diagram</summary>
@@ -69,9 +69,13 @@ The pipeline uses the following tools:
69
69
-- background subtraction tool for COMET.
70
70
-[MesmerSegmentation](https://github.com/WEHI-SODA-Hub/mesmersegmentation) -- a
71
71
CLI for running Mesmer segmentation of MIBI and OME-XML TIFFs.
72
+
-[CellSAM](https://github.com/vanvalenlab/cellSAM) -- a foundation model for
73
+
cell segmentation across diverse imaging modalities.
72
74
-[cellmeasurement](https://github.com/WEHI-SODA-Hub/cellmeasurement) -- a
73
-
Groovy app that matches whole-cell segmentations with nuclei, and uses the
74
-
QuPath API to calculate compartment measurements and intensities.
75
+
Python app that matches whole-cell segmentations with nuclei and calculates
76
+
compartment measurements and intensities.
77
+
-[KRONOS](https://github.com/mahmoodlab/KRONOS) -- a foundation model for
78
+
multiplex spatial proteomics that extracts rich embeddings for each cell.
75
79
-[sopa](https://github.com/gustaveroussy/sopa) -- we use the sopa CLI tool to
76
80
patchify images and perform cellpose segmentation.
77
81
-[spatialVis](https://github.com/WEHI-SODA-Hub/spatialVis) -- R package for spatial
@@ -86,9 +90,6 @@ Please see the [docs for more detailed information on pipeline usage and output]
86
90
87
91
If you are running this pipeline from WEHI, it has been set up to run on [Seqera Platform](https://seqera.services.biocommons.org.au/).
88
92
89
-
> [!NOTE]
90
-
> If you don't have a .gradle directory in your home, make sure you create it with `mkdir $HOME/.gradle` before runnning the pipeline. You con't need to do this if you are running via WEHI's Seqera Platform mentioned above.
91
-
92
93
Usage will depend on your desired steps. See [usage docs](docs/usage.md) for more detailed information.
93
94
94
95
### Background subtraction
@@ -101,9 +102,9 @@ Prepare a sample sheet as follows:
You may also prefer to use YAML for your samplesheet, either is supported:
@@ -115,19 +116,20 @@ You may also prefer to use YAML for your samplesheet, either is supported:
115
116
run_backsub: true
116
117
run_mesmer: true
117
118
run_cellpose: false
119
+
run_cellsam: false
118
120
tiff: /path/to/sample1.tiff
119
121
- sample: sample2
120
122
run_backsub: true
121
123
run_mesmer: true
122
124
run_cellpose: false
125
+
run_cellsam: false
123
126
tiff: /path/to/sample2.tiff
124
127
```
125
128
126
129
> [!WARNING]
127
-
> Please ensure that your image name and all directories in your file path do not contain spaces.
130
+
> Please ensure that your image name and all directories in your path do not contain spaces.
128
131
129
-
If you don't specify any segmentation algorithm to run (mesmer or cellpose), the
130
-
pipeline will run a background subtraction only.
132
+
If you don't specify any segmentation algorithm to run (mesmer, cellpose, or cellsam), the pipeline will run a background subtraction only.
131
133
132
134
Now, you can run the pipeline using:
133
135
@@ -167,10 +169,8 @@ You can also set the segmentation parameters for mesmer either via CLI
167
169
(e.g., `--combine_method prod` or in a config file pass to the workflow
168
170
via `-c`. See [usage](docs/usage.md) for a full list.
169
171
170
-
> [!WARNING]
171
-
> You cannot run both Mesmer and Cellpose segmentation on the same sample (with
172
-
> the same name). If you want to run both on a sample, put it on a different
173
-
> line and give it a different sample name.
172
+
> [!NOTE]
173
+
> You cannot run multiple segmentation methods (Mesmer, Cellpose, or CellSAM) on the same sample (with the same name). If you want to run multiple methods on a sample, put it on a different line and give it a different sample name.
174
174
175
175
### Cellpose segmentation
176
176
@@ -195,6 +195,110 @@ parameters.
195
195
If you want to skip measurements (this may take some time for large images), you
196
196
can use set the parameter `skip_measurements` to `true`.
197
197
198
+
### KRONOS embeddings
199
+
200
+
KRONOS is a foundation model for multiplex spatial proteomics that extracts rich embeddings for each cell. These embeddings capture cellular phenotype and microenvironment context, enabling downstream analysis like clustering, classification, and spatial analysis.
-`--kronos_distance_threshold` (default: 5.0): Maximum centroid distance (pixels) used for GeoJSON merge fallback matching
227
+
228
+
#### Embeddings for filtered data with KRONOS
229
+
230
+
When `--kronos_merge_geojson` is enabled, the pipeline automatically creates a new segmentation mask directly from the GeoJSON polygons.
231
+
232
+
#### Output files
233
+
234
+
KRONOS produces the following outputs:
235
+
236
+
-`*_kronos_embeddings.csv`: CSV file with cell IDs, centroids, and 384 embedding dimensions
237
+
-`*_marker_report.txt`: Report showing which image channels were matched to KRONOS markers
238
+
-`*_kronos_merged.geojson` (if `--kronos_merge_geojson=true`): GeoJSON file with embeddings added as cell properties
239
+
240
+
The merged GeoJSON file contains all original cell measurements plus additional features (`kronos_emb_0` through `kronos_emb_#`), enabling integrated analysis of morphology, intensity, and KRONOS embeddings.
241
+
242
+
#### Marker matching
243
+
244
+
KRONOS expects specific marker names based on its training data. The pipeline automatically performs case-insensitive matching between your image channel names and the KRONOS marker metadata. For markers that don't auto-match, use `--kronos_marker_mapping`:
0 commit comments