Skip to content

Commit

Permalink
Merge pull request #81 from kbestak/stardist
Browse files Browse the repository at this point in the history
Stardist
  • Loading branch information
kbestak authored Feb 13, 2025
2 parents 12d9c3f + 10d9f59 commit 16ca914
Show file tree
Hide file tree
Showing 20 changed files with 332 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CITATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

> Ewels P, Magnusson M, Lundin S, Käller M. MultiQC: summarize analysis results for multiple tools and samples in a single report. Bioinformatics. 2016 Oct 1;32(19):3047-8. doi: 10.1093/bioinformatics/btw354. Epub 2016 Jun 16. PubMed PMID: 27312411; PubMed Central PMCID: PMC5039924.
- [Stardist](https://github.com/stardist/stardist)

> Schmidt, U., Weigert, M., Broaddus, C., Myers, G. (2018). Cell Detection with Star-Convex Polygons. In: Frangi, A., Schnabel, J., Davatzikos, C., Alberola-López, C., Fichtinger, G. (eds) Medical Image Computing and Computer Assisted Intervention – MICCAI 2018. MICCAI 2018. Lecture Notes in Computer Science(), vol 11071. Springer, Cham. https://doi.org/10.1007/978-3-030-00934-2_30
## Software packaging/containerisation tools

- [Anaconda](https://anaconda.com)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Image preprocessing

Cell segmentation

- Apply cell segmentation based on provided images, available options are: - [`Cellpose`](https://www.cellpose.org/) - [`Mesmer`](https://deepcell.readthedocs.io/en/master/API/deepcell.applications.html#mesmer) - [`ilastik`](https://www.ilastik.org/)
- Apply cell segmentation based on provided images, available options are: - [`Cellpose`](https://www.cellpose.org/) - [`Mesmer`](https://deepcell.readthedocs.io/en/master/API/deepcell.applications.html#mesmer) - [`ilastik`](https://www.ilastik.org/) - [`Stardist`](https://github.com/stardist/stardist)
- Filter cells based on cell size to remove artifacts

Spot processing
Expand Down
15 changes: 15 additions & 0 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ process {
].join(" ").trim()
}


withName: STARDIST {
ext.when = { params.segmentation_method.split(',').contains('stardist') }
ext.args = [ "",
params.stardist_model ? "--model ${params.stardist_model}" : "",
(params.stardist_n_tiles_x && params.stardist_n_tiles_y) ? "--n_tiles ${params.stardist_n_tiles_x} ${params.stardist_n_tiles_y}" : "",
].join(" ").trim()
ext.prefix = { "${meta.id}_stardist_mask" }
publishDir = [
path: "${params.outdir}/segmentation/stardist",
pattern: "*.tif",
saveAs: { filename -> "${meta.id}_stardist_mask.tif" }
]
}

withName: "DEEPCELL_MESMER" {
ext.when = { params.segmentation_method.split(',').contains('mesmer') }
ext.args = [ "",
Expand Down
2 changes: 1 addition & 1 deletion conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ params {
mindagap_boxsize = 7
mindagap_loopnum = 100
clahe_pyramid_tile = 368
segmentation_method = "mesmer,cellpose"
segmentation_method = "mesmer,cellpose,stardist"

// Only used if additionally params.create_training_subset is used
crop_size_x = 30
Expand Down
4 changes: 3 additions & 1 deletion conf/test_full.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ params {

input = params.pipelines_testdata_base_path + 'molkart/test_data/samplesheets/samplesheet_full_test.csv'

segmentation_method = "mesmer,cellpose"
segmentation_method = "mesmer,cellpose,stardist"
mindagap_boxsize = 3
mindagap_loopnum = 40
cellpose_pretrained_model = "nuclei"
stardist_n_tiles_x = 20
stardist_n_tiles_y = 20
}
4 changes: 4 additions & 0 deletions docs/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Create stack is a local module used to merge images into a stack as preparation
- `*_ilastik_mask.tif`: Segmentation masks created by ilastik's Boundary prediction with Multicut workflow.
- `mesmer/`:
- `*_mesmer_mask.tif`: Segmentation masks created by Mesmer.
- `stardist/`:
- `*_stardist_mask.tif`: Nuclear segmentation masks created by Stardist.
- `filtered_masks/` - `*_method_filtered.tif`: Segmentation masks filtered based on provided area limits.
</details>

Expand All @@ -82,6 +84,8 @@ Create stack is a local module used to merge images into a stack as preparation

[Mesmer](https://deepcell.readthedocs.io/en/master/API/deepcell.applications.html#mesmer) is a segmentation tool that provides pretrained models for whole-cell and nuclear segmentation.

[Stardist](https://github.com/stardist/stardist) is an object detection tool using star-convex shapes.

### Spot2cell

<details markdown="1">
Expand Down
7 changes: 7 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ cellpose_pretrained_model: "cyto"
cellpose_custom_model: null
cellpose_flow_threshold: 0.4
cellpose_edge_exclude: true
stardist_model: "2D_versatile_fluo"
stardist_n_tiles_x: 3
stardist_n_tiles_y: 3
mesmer_image_mpp: 0.138
mesmer_compartment: "whole-cell"
ilastik_pixel_project: null
Expand Down Expand Up @@ -121,6 +124,10 @@ To run the pipeline so that the training subset is created with default values,
nextflow run nf-core/molkart --input ./samplesheet.csv --outdir ./results -profile docker --create_training_subset
```

:::note
Stardist segmentation currently only support nuclear segmentation and the additional marker will not be used.
:::

After training a Cellpose 2.0 model, or creating ilastik Pixel Classification and Multicut projects, make sure you match the parameters (e.g cell diameter, flow threshold) in the run to your training and continue the default pipeline run with:

```bash
Expand Down
5 changes: 5 additions & 0 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"branch": "master",
"git_sha": "81880787133db07d9b4c1febd152c090eb8325dc",
"installed_by": ["modules"]
},
"stardist": {
"branch": "master",
"git_sha": "666652151335353eef2fcd58880bcef5bc2928e1",
"installed_by": ["modules"]
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions modules/nf-core/stardist/environment.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions modules/nf-core/stardist/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions modules/nf-core/stardist/meta.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions modules/nf-core/stardist/tests/main.nf.test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions modules/nf-core/stardist/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions modules/nf-core/stardist/tests/nextflow.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ params {
segmentation_method = 'mesmer'
segmentation_min_area = null
segmentation_max_area = null
// cellpose
cellpose_save_flows = false
cellpose_diameter = 30
cellpose_chan = 0
Expand All @@ -24,10 +25,16 @@ params {
cellpose_custom_model = null
cellpose_flow_threshold = 0.4
cellpose_edge_exclude = true
// mesmer
mesmer_image_mpp = 0.138
mesmer_compartment = 'whole-cell'
// ilastik
ilastik_pixel_project = null
ilastik_multicut_project = null
// stardist
stardist_model = '2D_versatile_fluo'
stardist_n_tiles_x = 3
stardist_n_tiles_y = 3

// Preprocessing command line flags
skip_mindagap = false
Expand Down
Loading

0 comments on commit 16ca914

Please sign in to comment.