/
cellpose.cwl
574 lines (506 loc) · 15.5 KB
/
cellpose.cwl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
#!/usr/bin/env cwl-runner
class: Workflow
cwlVersion: v1.2
requirements:
- class: SubworkflowFeatureRequirement
- class: InlineJavascriptRequirement
- class: StepInputExpressionRequirement
- class: MultipleInputFeatureRequirement
inputs:
exp_loc:
type: Directory
doc: Root directory containing space_tx formatted experiment
decoded_loc:
type: Directory?
doc: Location of directory that is output from the starfishRunner step, only needed if mRNA information is to be included.
use_mrna:
type: boolean?
doc: If true and decoded_loc is provided, mrna data will be used in calculations.
parameter_json:
type: File?
doc: json containing step parameters.
selected_fovs:
type: int[]?
doc: If provided, segmentation will only be run on FOVs with these indices.
zplane_count:
type: int?
doc: The number of z-planes in each image. All that matters is whether this is equal to 1 or not, retaining the same var name as conversion for simplification.
aux_views:
type: string[]?
doc: The views to use for cellpose segmentation.
pretrained_model_str:
type: string?
doc: Cellpose-provided model to use.
pretrained_model_dir:
type: File?
doc: Manually trained cellpose model to use.
diameter:
type: float?
doc: Expected diameter of cells. Should be 0 if a custom model is used.
flow_threshold:
type: float?
doc: threshold for filtering cell segmentations (increasing this will filter out lower confidence segmentations), range is 0 to infinity
stitch_threshold:
type: float?
doc: threshold for stitching together segmentations that occur at the same xy location but in adjacent z slices, range is 0 to 1. This should only be used when the image is 3D.
cellprob_threshold:
type: float?
doc: determines the extent of the segmentations (0 is the default more negative values result in larger cells, more positive values result in smaller cells), range is -6 to 6.
border_buffer:
type: int?
doc: If not None, removes cytoplasms whose nuclei lie within the given distance from the border.
label_exp_size:
type: int?
doc: Pixel size labels are dilated by in final step. Helpful for closing small holes that are common from thresholding but can also cause cell boundaries to exceed their true boundaries if set too high. Label dilation respects label borders and does not mix labels.
min_allowed_size:
type: int?
doc: minimum size for a cell (in pixels)
max_allowed_size:
type: int?
doc: maximum size for a cell (in pixels)
outputs:
cellpose_input:
type: Directory
outputSource: execute_cellpose_prep/cellpose_input
cellpose_output:
type: Directory
outputSource: execute_cellpose/cellpose_output
cellpose_filtered:
type: Directory
outputSource: execute_filtering/cellpose_filtered
steps:
tmpname:
run: tmpdir.cwl
in: []
out: [tmp]
read_schema:
run:
class: CommandLineTool
baseCommand: cat
requirements:
DockerRequirement:
dockerPull: hubmap/starfish-custom:latest
inputs:
schema:
type: string
inputBinding:
position: 1
outputs:
data:
type: stdout
in:
schema:
valueFrom: "/opt/cellpose.json"
out: [data]
stage_cellpose:
run: inputParser.cwl
in:
datafile: parameter_json
schema: read_schema/data
out: [use_mrna, zplane_count, selected_fovs, pretrained_model_str, diameter, flow_threshold, stitch_threshold, cellprob_threshold, border_buffer, label_exp_size, min_allowed_size, max_allowed_size, aux_views]
when: $(inputs.datafile != null)
execute_cellpose_prep:
run:
class: CommandLineTool
baseCommand: /opt/cellposeStaging.py
requirements:
DockerRequirement:
dockerPull: hubmap/starfish-custom:latest
inputs:
tmp_prefix:
type: string
inputBinding:
prefix: --tmp-prefix
exp_loc:
type: Directory
doc: Root directory containing space_tx formatted experiment
inputBinding:
prefix: --input-dir
decoded_loc:
type: Directory?
doc: Location of directory that is output from the starfishRunner step.
inputBinding:
prefix: --decoded-dir
selected_fovs:
type: int[]?
doc: If provided, segmentation will only be run on FOVs with these indices.
inputBinding:
prefix: --selected-fovs
aux_views:
type: string[]?
doc: The views to use for cellpose segmentation.
inputBinding:
prefix: --aux-views
format:
type: boolean
doc: Used to specify method in python script
default: true
inputBinding:
prefix: --format
outputs:
cellpose_input:
type: Directory
outputBinding:
glob: $("tmp/" + inputs.tmp_prefix + "/5A_cellpose_input/")
in:
tmp_prefix: tmpname/tmp
exp_loc: exp_loc
decoded_loc:
source: [decoded_loc, stage_cellpose/use_mrna, use_mrna]
valueFrom: |
${
if(self[1] || self[2]){
return self[0];
} else {
return null;
}
}
selected_fovs:
source: [stage_cellpose/selected_fovs, selected_fovs]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
aux_views:
source: [stage_cellpose/aux_views, aux_views]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
out: [cellpose_input]
execute_cellpose:
run:
class: CommandLineTool
baseCommand: ["cellpose"]
requirements:
DockerRequirement:
dockerPull: hubmap/cellpose:latest
InitialWorkDirRequirement:
listing:
- entry: $(inputs.input_dir)
writable: true
inputs:
verbose:
type: boolean?
inputBinding:
prefix: --verbose
default: true
doc: Enables verbose output
input_dir:
type: Directory
inputBinding:
prefix: --dir
# valueFrom: $(self.basename)
doc: Input directory for cellpose
img_filter:
type: string
inputBinding:
prefix: --img_filter
default: _image
doc: Glob filter for input
z_axis:
type: int?
inputBinding:
prefix: --z_axis
doc: 0 if image is not flat, unset if flat.
channel_axis:
type: int?
inputBinding:
prefix: --channel_axis
doc: 1 if image is flat, 0 if flat.
all_channels:
type: boolean?
inputBinding:
prefix: --all_channels
default: true
doc: Tells cellpose to use all channels in the order they appear
save_tif:
type: boolean?
inputBinding:
prefix: --save_tif
default: true
doc: Tells cellpose to save images as a tif, instead of defaulting to png
savedir:
type: string?
inputBinding:
prefix: --savedir
default: "5B_cellpose_output"
doc: Name of directory to save to.
pretrained_model_str:
type: string?
inputBinding:
prefix: --pretrained_model
doc: Cellpose-provided model to use.
pretrained_model_dir:
type: File?
inputBinding:
prefix: --pretrained_model
doc: Manually trained cellpose model to use.
diameter:
type: float?
inputBinding:
prefix: --diameter
doc: Expected diameter of cells. Should be 0 if a custom model is used.
flow_threshold:
type: float?
inputBinding:
prefix: --flow_threshold
default: 0.4
doc: threshold for filtering cell segmentations (increasing this will filter out lower confidence segmentations), range is 0 to infinity
stitch_threshold:
type: float?
inputBinding:
prefix: --stitch_threshold
doc: threshold for stitching together segmentations that occur at the same xy location but in adjacent z slices, range is 0 to 1. This should only be used when the image is 3D.
cellprob_threshold:
type: float?
inputBinding:
prefix: --cellprob_threshold
doc: determines the extent of the segmentations (0 is the default more negative values result in larger cells, more positive values result in smaller cells), range is -6 to 6.
net_avg:
type: boolean?
inputBinding:
prefix: --net_avg
default: true
doc: tells cellpose to calculate 4 nets and take the average, improves performance.
outputs:
log:
type: stdout
cellpose_output:
type: Directory
outputBinding:
glob: "5B_cellpose_output"
in:
input_dir: execute_cellpose_prep/cellpose_input
z_axis:
source: [stage_cellpose/zplane_count, zplane_count]
valueFrom: |
${
if(self[0]){
if(self[0] > 1){
return 0;
} else {
return null;
}
} else {
if(self[1] > 1){
return 0;
} else {
return null;
}
}
}
channel_axis:
source: [stage_cellpose/zplane_count, zplane_count]
valueFrom: |
${
if(self[0]){
if(self[0] > 1){
return 1;
} else {
return 0;
}
} else {
if(self[1] > 1){
return 1;
} else {
return 0;
}
}
}
pretrained_model_str:
source: [stage_cellpose/pretrained_model_str, pretrained_model_str]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
pretrained_model_dir: pretrained_model_dir
diameter:
source: [stage_cellpose/diameter, diameter, pretrained_model_dir]
valueFrom: |
${
if(self[2]){
return 0;
} else if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
flow_threshold:
source: [stage_cellpose/flow_threshold, flow_threshold]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
stitch_threshold:
source: [stage_cellpose/stitch_threshold, stitch_threshold, stage_cellpose/zplane_count, zplane_count]
valueFrom: |
${
if(self[2] == 1 || self[3] == 1){
return null;
}
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
cellprob_threshold:
source: [stage_cellpose/cellprob_threshold, cellprob_threshold]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
out: [cellpose_output]
execute_filtering:
run:
class: CommandLineTool
baseCommand: /opt/cellposeStaging.py
requirements:
DockerRequirement:
dockerPull: hubmap/starfish-custom:latest
inputs:
tmp_prefix:
type: string
inputBinding:
prefix: --tmp-prefix
input_loc:
type: Directory
doc: Output from cellpose.
inputBinding:
prefix: --input-dir
selected_fovs:
type: int[]?
doc: If provided, segmentation will only be run on FOVs with these indices.
inputBinding:
prefix: --selected-fovs
border_buffer:
type: int?
doc: If not None, removes cytoplasms whose nuclei lie within the given distance from the border.
inputBinding:
prefix: --border-buffer
label_exp_size:
type: int?
doc: Pixel size labels are dilated by in final step. Helpful for closing small holes that are common from thresholding but can also cause cell boundaries to exceed their true boundaries if set too high. Label dilation respects label borders and does not mix labels.
inputBinding:
prefix: --label-exp-size
max_allowed_size:
type: int?
doc: maximum size for a cell (in pixels)
inputBinding:
prefix: --max-size
min_allowed_size:
type: int?
doc: minimum size for a cell (in pixels)
inputBinding:
prefix: --min-size
filter:
type: boolean
doc: Used to specify method in python script
default: true
inputBinding:
prefix: --filter
outputs:
cellpose_filtered:
type: Directory
outputBinding:
glob: $("tmp/" + inputs.tmp_prefix + "/5C_cellpose_filtered")
in:
tmp_prefix: tmpname/tmp
input_loc: execute_cellpose/cellpose_output
selected_fovs:
source: [stage_cellpose/selected_fovs, selected_fovs]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
border_buffer:
source: [stage_cellpose/border_buffer, border_buffer]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
label_exp_size:
source: [stage_cellpose/label_exp_size, label_exp_size]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
min_allowed_size:
source: [stage_cellpose/min_allowed_size, min_allowed_size]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
max_allowed_size:
source: [stage_cellpose/max_allowed_size, max_allowed_size]
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]) {
return self[1];
} else {
return null;
}
}
out: [cellpose_filtered]