Skip to content

Commit 0564c12

Browse files
committed
Add mccellpose as new segmenter
mccellpose is a custom mcmicro-oriented wrapper around the Cellpose 4 Python API. It uses constant memory and low VRAM compared to the standard cellpose command line script by iterating over the image in overlapping tiles rather than processing the whole thing at once. Command line options are different from the standard script and designed for the mcmicro use case.
1 parent 468c878 commit 0564c12

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

config/defaults.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ modules:
110110
model: --pretrained_model
111111
idxbase: 0
112112
watershed: 'no'
113+
-
114+
name: mccellpose
115+
container: labsyspharm/mccellpose
116+
version: 1.0.3
117+
cmd: mccellpose --use-gpu --jobs 2 --expand-size 2 --channel 1 --output-cell cell.ome.tif --output-nucleus nucleus.ome.tif
118+
input: --input
119+
channel: --channel
120+
model: --pretrained_model
121+
idxbase: 1
122+
watershed: 'no'
113123
watershed:
114124
name: s3seg
115125
container: labsyspharm/s3segmenter

lib/mcmicro/Opts.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,23 @@ static def parseParams(gp, fns, fnw) {
219219
mcp.modules['staging'] = mcp.modules['staging'][0]
220220

221221
// Filter segmentation modules based on --segmentation
222+
if (mcp.workflow.segmentation instanceof String) {
223+
if (mcp.workflow.segmentation.contains(',')) {
224+
throw new Exception('Use an explicit list with square brackets to specify multiple segmenter modules, e.g. [mod1, mod2]')
225+
}
226+
mcp.workflow.segmentation = [mcp.workflow.segmentation]
227+
}
222228
mcp.modules['segmentation'] = mcp.modules['segmentation'].findAll{
223229
mcp.workflow.segmentation.contains(it.name)
224230
}
225231

226232
// Filter downstream modules based on --downstream
233+
if (mcp.workflow.downstream instanceof String) {
234+
if (mcp.workflow.downstream.contains(',')) {
235+
throw new Exception('Use an explicit list with square brackets to specify multiple downstream modules, e.g. [mod1, mod2]')
236+
}
237+
mcp.workflow.downstream = [mcp.workflow.downstream]
238+
}
227239
mcp.modules['downstream'] = mcp.modules['downstream'].findAll{
228240
mcp.workflow.downstream.contains(it.name)
229241
}

main.nf

100644100755
File mode changed.

modules/segmentation.nf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ workflow segmentation {
147147
// Merge against instance segmentation outputs
148148
instSeg = allpmaps.filter{ _1, _2, _3, ws -> ws == 'no' }
149149
.map{ mtd, tag, _3, _4 -> tuple("${mtd}-${tag}", _3) }.groupTuple()
150+
.map{ mt, paths -> tuple(mt, paths.flatten()) }
150151

151152
emit:
152153
s3seg.out.segmasks.mix(instSeg)

0 commit comments

Comments
 (0)