Skip to content

Commit 9a63544

Browse files
committed
fix(workflow): πŸ› wire dilate_labels' use_gpu through cfg["dilate_gpu"]
build_fn called dilate_labels(fn, iterations=dilate) with no way to reach its use_gpu flag from YAML, so GPU dilation on the cluster was silently unreachable despite the API supporting it. Adds cfg["dilate_gpu"] (bool, default False) and documents it in both example configs.
1 parent 3aa969d commit 9a63544

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

β€Žworkflow/config/config.yamlβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ empty_threshold: null # null β†’ Otsu; or a number
3030

3131
# ---- segmentation -----------------------------------------------------------
3232
method: "cellpose" # "cellpose" (GPU), "threshold" (no GPU; testing), "custom"
33-
# dilate: 2 # optional: pixels to grow labels by after segmentation, any method
33+
# dilate: 2 # optional: pixels to grow labels by after segmentation, any method
34+
# dilate_gpu: true # optional: dilate via cupy instead of scipy, needs a GPU
3435
# Also namespaces this run's intermediate files under work_dir/<label_name>/,
3536
# so a second segmentation (different label_name, e.g. nuclei vs cytoplasm)
3637
# can safely target the same work_dir β€” see docs/guide/snakemake.md

β€Žworkflow/config/config_cilia.yamlβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ skip_empty: true
2525
empty_threshold: null
2626

2727
method: "custom"
28-
# dilate: 2 # optional: pixels to grow labels by after segmentation
28+
# dilate: 2 # optional: pixels to grow labels by after segmentation
29+
# dilate_gpu: true # optional: dilate via cupy instead of scipy, needs a GPU
2930
label_name: "cilia_labels"
3031
custom:
3132
module: "patchworks.plugins.dog"

β€Žworkflow/scripts/_pw.pyβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def build_fn(cfg):
136136
function (``cfg["custom"] = {module, function, kwargs}``). Optional
137137
``cfg["dilate"]``: int, pixels to grow labels by after segmentation
138138
(via ``patchworks.dilate_labels``), applied regardless of ``method``.
139-
Omitted/0 disables dilation.
139+
Omitted/0 disables dilation. ``cfg["dilate_gpu"]``: bool, dilate via
140+
cupyx instead of scipy (default ``False``); only takes effect when
141+
``dilate`` is set, and needs a GPU allocated for the segment job
142+
(independent of whether ``method`` itself uses one).
140143
141144
Returns
142145
-------
@@ -149,7 +152,7 @@ def build_fn(cfg):
149152
if dilate:
150153
from patchworks import dilate_labels
151154

152-
fn = dilate_labels(fn, iterations=dilate)
155+
fn = dilate_labels(fn, iterations=dilate, use_gpu=cfg.get("dilate_gpu", False))
153156

154157
return fn
155158

0 commit comments

Comments
Β (0)