patchworks 1.3.2__tar.gz → 1.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. {patchworks-1.3.2 → patchworks-1.3.3}/PKG-INFO +1 -1
  2. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/custom_segmentation.md +9 -0
  3. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/snakemake.md +10 -2
  4. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/config/config.yaml +2 -1
  5. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/config/config_cilia.yaml +2 -1
  6. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/scripts/_pw.py +5 -2
  7. {patchworks-1.3.2 → patchworks-1.3.3}/.github/workflows/docs.yml +0 -0
  8. {patchworks-1.3.2 → patchworks-1.3.3}/.github/workflows/lint.yml +0 -0
  9. {patchworks-1.3.2 → patchworks-1.3.3}/.github/workflows/release.yml +0 -0
  10. {patchworks-1.3.2 → patchworks-1.3.3}/.gitignore +0 -0
  11. {patchworks-1.3.2 → patchworks-1.3.3}/.markdownlint-cli2.yaml +0 -0
  12. {patchworks-1.3.2 → patchworks-1.3.3}/LICENSE +0 -0
  13. {patchworks-1.3.2 → patchworks-1.3.3}/README.md +0 -0
  14. {patchworks-1.3.2 → patchworks-1.3.3}/cliff.toml +0 -0
  15. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/chunks.md +0 -0
  16. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/cluster.md +0 -0
  17. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/io.md +0 -0
  18. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/merge_tile_labels.md +0 -0
  19. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/plugins/cellpose.md +0 -0
  20. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/plugins/dog.md +0 -0
  21. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/plugins/napari.md +0 -0
  22. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/plugins/ome_zarr.md +0 -0
  23. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/postprocess.md +0 -0
  24. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/relabel.md +0 -0
  25. {patchworks-1.3.2 → patchworks-1.3.3}/docs/api/tile_process.md +0 -0
  26. {patchworks-1.3.2 → patchworks-1.3.3}/docs/assets/logo.png +0 -0
  27. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/cellpose_2d.md +0 -0
  28. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/cellpose_2d.py +0 -0
  29. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/cellpose_3d.md +0 -0
  30. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/cellpose_3d.py +0 -0
  31. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/custom.md +0 -0
  32. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/custom_method.py +0 -0
  33. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/dog.md +0 -0
  34. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/dog.py +0 -0
  35. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/standalone_merge.md +0 -0
  36. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/stardist.md +0 -0
  37. {patchworks-1.3.2 → patchworks-1.3.3}/docs/examples/stardist_2d.py +0 -0
  38. {patchworks-1.3.2 → patchworks-1.3.3}/docs/getting_started.md +0 -0
  39. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/gpu_distributed.md +0 -0
  40. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/label_relations.md +0 -0
  41. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/measurements.md +0 -0
  42. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/merging.md +0 -0
  43. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/ome_zarr_napari.md +0 -0
  44. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/performance.md +0 -0
  45. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/pitfalls.md +0 -0
  46. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/skip_empty.md +0 -0
  47. {patchworks-1.3.2 → patchworks-1.3.3}/docs/guide/tiling.md +0 -0
  48. {patchworks-1.3.2 → patchworks-1.3.3}/docs/index.md +0 -0
  49. {patchworks-1.3.2 → patchworks-1.3.3}/mkdocs.yml +0 -0
  50. {patchworks-1.3.2 → patchworks-1.3.3}/pyproject.toml +0 -0
  51. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/__init__.py +0 -0
  52. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_chunks.py +0 -0
  53. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_cluster.py +0 -0
  54. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_core.py +0 -0
  55. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_distributed.py +0 -0
  56. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_io.py +0 -0
  57. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_merge.py +0 -0
  58. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_postprocess.py +0 -0
  59. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_relabel.py +0 -0
  60. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/_relations.py +0 -0
  61. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/plugins/__init__.py +0 -0
  62. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/plugins/cellpose.py +0 -0
  63. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/plugins/dog.py +0 -0
  64. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/plugins/napari.py +0 -0
  65. {patchworks-1.3.2 → patchworks-1.3.3}/src/patchworks/plugins/ome_zarr.py +0 -0
  66. {patchworks-1.3.2 → patchworks-1.3.3}/tests/test_core.py +0 -0
  67. {patchworks-1.3.2 → patchworks-1.3.3}/tests/test_distributed.py +0 -0
  68. {patchworks-1.3.2 → patchworks-1.3.3}/tests/test_dog.py +0 -0
  69. {patchworks-1.3.2 → patchworks-1.3.3}/tests/test_napari.py +0 -0
  70. {patchworks-1.3.2 → patchworks-1.3.3}/tests/test_ome_zarr.py +0 -0
  71. {patchworks-1.3.2 → patchworks-1.3.3}/tests/test_postprocess.py +0 -0
  72. {patchworks-1.3.2 → patchworks-1.3.3}/tests/test_relations.py +0 -0
  73. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/README.md +0 -0
  74. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/Snakefile +0 -0
  75. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/config/config_cyto.yaml +0 -0
  76. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/config/config_nuclei.yaml +0 -0
  77. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/config/multi.yaml +0 -0
  78. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/pixi.toml +0 -0
  79. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/profile/slurm/config.yaml +0 -0
  80. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/rules/common.smk +0 -0
  81. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/rules/convert.smk +0 -0
  82. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/rules/merge.smk +0 -0
  83. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/rules/segment.smk +0 -0
  84. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/scripts/convert.py +0 -0
  85. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/scripts/fetch_model.py +0 -0
  86. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/scripts/merge.py +0 -0
  87. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/scripts/prepare_tiles.py +0 -0
  88. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/scripts/run_multi.py +0 -0
  89. {patchworks-1.3.2 → patchworks-1.3.3}/workflow/scripts/segment_tile.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchworks
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Summary: Tiled processing of arbitrarily large images with globally consistent labels
5
5
  Project-URL: Homepage, https://github.com/imcf/patchworks
6
6
  Project-URL: Issues, https://github.com/imcf/patchworks/issues
@@ -74,6 +74,15 @@ tiles are merged, so `overlap` must still cover the dilation amount. On the
74
74
  cluster, set `dilate: N` in the config instead — see [Configure the
75
75
  run](snakemake.md#3-configure-the-run).
76
76
 
77
+ By default the dilation itself runs on CPU (scipy), independent of whatever
78
+ backend `fn` used — pass `use_gpu=True` to dilate via cupy instead:
79
+
80
+ ```python
81
+ fn = dilate_labels(fn, iterations=2, use_gpu=True) # needs cupy installed
82
+ ```
83
+
84
+ On the cluster, this is the `dilate_gpu: true` config key.
85
+
77
86
  ## Real example: StarDist 3-D, with model caching
78
87
 
79
88
  Heavy models must be loaded **once**, not per tile. On SLURM each tile is its
@@ -65,6 +65,7 @@ empty_threshold: null # null → Otsu
65
65
  method: "cellpose" # "cellpose" (GPU), "threshold" (no GPU), "custom"
66
66
  label_name: "cellpose" # name under image.zarr/labels/
67
67
  dilate: 0 # optional: pixels to grow labels by, any method
68
+ dilate_gpu: false # dilate via cupy instead of scipy (needs a GPU)
68
69
  cellpose:
69
70
  model: "cyto3"
70
71
  diameter: 30
@@ -80,8 +81,15 @@ sequential_labels: true # renumber labels to a contiguous 1..N
80
81
 
81
82
  !!! tip "Growing labels after segmentation"
82
83
  `dilate: N` grows every label by `N` pixels once segmentation finishes,
83
- regardless of `method`. `0` (default) disables it. See [Growing labels
84
- afterwards](custom_segmentation.md#growing-labels-afterwards-dilation)
84
+ regardless of `method`. `0` (default) disables it. Runs on CPU (scipy)
85
+ by default; set `dilate_gpu: true` to dilate via cupy instead — that
86
+ needs `cupy` installed in the segment job's environment (matching your
87
+ CUDA version, e.g. `pip install cupy-cuda12x`) and a GPU allocated for
88
+ that job (`set-resources: segment:` in `profile/slurm/config.yaml`,
89
+ same as for a GPU `method`). It's independent of whatever `method`
90
+ itself runs on — you can dilate on GPU even with `method: "threshold"`
91
+ (CPU), or on CPU even with `method: "cellpose"` (GPU). See [Growing
92
+ labels afterwards](custom_segmentation.md#growing-labels-afterwards-dilation)
85
93
  for how it works and the equivalent direct-API call.
86
94
 
87
95
  !!! tip "Tile size vs runtime"
@@ -30,7 +30,8 @@ empty_threshold: null # null → Otsu; or a number
30
30
 
31
31
  # ---- segmentation -----------------------------------------------------------
32
32
  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
34
35
  # Also namespaces this run's intermediate files under work_dir/<label_name>/,
35
36
  # so a second segmentation (different label_name, e.g. nuclei vs cytoplasm)
36
37
  # can safely target the same work_dir — see docs/guide/snakemake.md
@@ -25,7 +25,8 @@ skip_empty: true
25
25
  empty_threshold: null
26
26
 
27
27
  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
29
30
  label_name: "cilia_labels"
30
31
  custom:
31
32
  module: "patchworks.plugins.dog"
@@ -136,7 +136,10 @@ def build_fn(cfg):
136
136
  function (``cfg["custom"] = {module, function, kwargs}``). Optional
137
137
  ``cfg["dilate"]``: int, pixels to grow labels by after segmentation
138
138
  (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).
140
143
 
141
144
  Returns
142
145
  -------
@@ -149,7 +152,7 @@ def build_fn(cfg):
149
152
  if dilate:
150
153
  from patchworks import dilate_labels
151
154
 
152
- fn = dilate_labels(fn, iterations=dilate)
155
+ fn = dilate_labels(fn, iterations=dilate, use_gpu=cfg.get("dilate_gpu", False))
153
156
 
154
157
  return fn
155
158
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes