patchworks 1.3.2__tar.gz → 1.3.4__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.4}/PKG-INFO +14 -1
  2. {patchworks-1.3.2 → patchworks-1.3.4}/README.md +13 -0
  3. {patchworks-1.3.2 → patchworks-1.3.4}/docs/getting_started.md +13 -0
  4. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/custom_segmentation.md +14 -0
  5. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/snakemake.md +10 -2
  6. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/config/config.yaml +2 -1
  7. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/config/config_cilia.yaml +2 -1
  8. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/scripts/_pw.py +5 -2
  9. {patchworks-1.3.2 → patchworks-1.3.4}/.github/workflows/docs.yml +0 -0
  10. {patchworks-1.3.2 → patchworks-1.3.4}/.github/workflows/lint.yml +0 -0
  11. {patchworks-1.3.2 → patchworks-1.3.4}/.github/workflows/release.yml +0 -0
  12. {patchworks-1.3.2 → patchworks-1.3.4}/.gitignore +0 -0
  13. {patchworks-1.3.2 → patchworks-1.3.4}/.markdownlint-cli2.yaml +0 -0
  14. {patchworks-1.3.2 → patchworks-1.3.4}/LICENSE +0 -0
  15. {patchworks-1.3.2 → patchworks-1.3.4}/cliff.toml +0 -0
  16. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/chunks.md +0 -0
  17. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/cluster.md +0 -0
  18. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/io.md +0 -0
  19. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/merge_tile_labels.md +0 -0
  20. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/plugins/cellpose.md +0 -0
  21. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/plugins/dog.md +0 -0
  22. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/plugins/napari.md +0 -0
  23. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/plugins/ome_zarr.md +0 -0
  24. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/postprocess.md +0 -0
  25. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/relabel.md +0 -0
  26. {patchworks-1.3.2 → patchworks-1.3.4}/docs/api/tile_process.md +0 -0
  27. {patchworks-1.3.2 → patchworks-1.3.4}/docs/assets/logo.png +0 -0
  28. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/cellpose_2d.md +0 -0
  29. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/cellpose_2d.py +0 -0
  30. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/cellpose_3d.md +0 -0
  31. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/cellpose_3d.py +0 -0
  32. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/custom.md +0 -0
  33. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/custom_method.py +0 -0
  34. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/dog.md +0 -0
  35. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/dog.py +0 -0
  36. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/standalone_merge.md +0 -0
  37. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/stardist.md +0 -0
  38. {patchworks-1.3.2 → patchworks-1.3.4}/docs/examples/stardist_2d.py +0 -0
  39. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/gpu_distributed.md +0 -0
  40. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/label_relations.md +0 -0
  41. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/measurements.md +0 -0
  42. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/merging.md +0 -0
  43. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/ome_zarr_napari.md +0 -0
  44. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/performance.md +0 -0
  45. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/pitfalls.md +0 -0
  46. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/skip_empty.md +0 -0
  47. {patchworks-1.3.2 → patchworks-1.3.4}/docs/guide/tiling.md +0 -0
  48. {patchworks-1.3.2 → patchworks-1.3.4}/docs/index.md +0 -0
  49. {patchworks-1.3.2 → patchworks-1.3.4}/mkdocs.yml +0 -0
  50. {patchworks-1.3.2 → patchworks-1.3.4}/pyproject.toml +0 -0
  51. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/__init__.py +0 -0
  52. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_chunks.py +0 -0
  53. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_cluster.py +0 -0
  54. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_core.py +0 -0
  55. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_distributed.py +0 -0
  56. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_io.py +0 -0
  57. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_merge.py +0 -0
  58. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_postprocess.py +0 -0
  59. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_relabel.py +0 -0
  60. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/_relations.py +0 -0
  61. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/plugins/__init__.py +0 -0
  62. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/plugins/cellpose.py +0 -0
  63. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/plugins/dog.py +0 -0
  64. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/plugins/napari.py +0 -0
  65. {patchworks-1.3.2 → patchworks-1.3.4}/src/patchworks/plugins/ome_zarr.py +0 -0
  66. {patchworks-1.3.2 → patchworks-1.3.4}/tests/test_core.py +0 -0
  67. {patchworks-1.3.2 → patchworks-1.3.4}/tests/test_distributed.py +0 -0
  68. {patchworks-1.3.2 → patchworks-1.3.4}/tests/test_dog.py +0 -0
  69. {patchworks-1.3.2 → patchworks-1.3.4}/tests/test_napari.py +0 -0
  70. {patchworks-1.3.2 → patchworks-1.3.4}/tests/test_ome_zarr.py +0 -0
  71. {patchworks-1.3.2 → patchworks-1.3.4}/tests/test_postprocess.py +0 -0
  72. {patchworks-1.3.2 → patchworks-1.3.4}/tests/test_relations.py +0 -0
  73. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/README.md +0 -0
  74. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/Snakefile +0 -0
  75. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/config/config_cyto.yaml +0 -0
  76. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/config/config_nuclei.yaml +0 -0
  77. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/config/multi.yaml +0 -0
  78. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/pixi.toml +0 -0
  79. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/profile/slurm/config.yaml +0 -0
  80. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/rules/common.smk +0 -0
  81. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/rules/convert.smk +0 -0
  82. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/rules/merge.smk +0 -0
  83. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/rules/segment.smk +0 -0
  84. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/scripts/convert.py +0 -0
  85. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/scripts/fetch_model.py +0 -0
  86. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/scripts/merge.py +0 -0
  87. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/scripts/prepare_tiles.py +0 -0
  88. {patchworks-1.3.2 → patchworks-1.3.4}/workflow/scripts/run_multi.py +0 -0
  89. {patchworks-1.3.2 → patchworks-1.3.4}/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.4
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
@@ -130,6 +130,7 @@ pip install "patchworks[gpu]" # GPU VRAM querying (nvidia-ml-py)
130
130
  pip install "patchworks[cellpose]" # Cellpose plugin (>=3.0, v3 or v4)
131
131
  pip install "patchworks[cellpose3]" # Cellpose plugin, pinned to v3.x
132
132
  pip install "patchworks[cellpose4]" # Cellpose plugin, pinned to v4+
133
+ pip install "patchworks[dog]" # deconvolution + DoG plugin (pycudadecon)
133
134
  pip install "patchworks[bioio]" # convert any image format to OME-ZARR
134
135
  pip install "patchworks[imaris]" # convert Imaris .ims files to OME-ZARR
135
136
  pip install "patchworks[napari]" # interactive napari viewer plugin
@@ -142,6 +143,14 @@ pip install "patchworks[all]" # Everything, incl. the napari viewer
142
143
  > `[imaris]` adds native `.ims` support (HDF5, no JVM). Physical pixel
143
144
  > calibration is read from the input and written into the OME-ZARR.
144
145
 
146
+ > **`cupy` is never installed automatically**, unlike Cellpose's GPU support
147
+ > (which comes for free via PyTorch's self-contained CUDA wheels). Any
148
+ > `use_gpu=True`/`dilate_gpu: true` option (the `dog` plugin, `dilate_labels`)
149
+ > needs `cupy` installed separately, matching your CUDA version — e.g.
150
+ > `pip install cupy-cuda12x`. Not bundled because cupy ships one wheel per
151
+ > CUDA major version; a generic pin would resolve to the wrong build (or fail
152
+ > to resolve) depending on the machine.
153
+
145
154
  ---
146
155
 
147
156
  ## Quick start — 5 lines
@@ -397,10 +406,14 @@ Optional:
397
406
  - `tqdm` — progress bars
398
407
  - `cellpose` — Cellpose plugin, v3 or v4 (`patchworks[cellpose]`);
399
408
  pin with `[cellpose3]` or `[cellpose4]`
409
+ - `pycudadecon` — deconvolution step of the `dog` plugin (`patchworks[dog]`)
400
410
  - `bioio` + readers — convert CZI/LIF/ND2/OME-TIFF/… to OME-ZARR
401
411
  (`patchworks[bioio]`)
402
412
  - `imaris-ims-file-reader` — convert Imaris `.ims` (`patchworks[imaris]`)
403
413
  - `napari` — interactive viewer plugin (`patchworks[napari]`)
414
+ - `cupy` — **install manually**, matching your CUDA version (e.g.
415
+ `pip install cupy-cuda12x`); not offered as an extra since it isn't one
416
+ generic pin. Needed for `use_gpu=True`/`dilate_gpu: true`.
404
417
 
405
418
  ---
406
419
 
@@ -40,6 +40,7 @@ pip install "patchworks[gpu]" # GPU VRAM querying (nvidia-ml-py)
40
40
  pip install "patchworks[cellpose]" # Cellpose plugin (>=3.0, v3 or v4)
41
41
  pip install "patchworks[cellpose3]" # Cellpose plugin, pinned to v3.x
42
42
  pip install "patchworks[cellpose4]" # Cellpose plugin, pinned to v4+
43
+ pip install "patchworks[dog]" # deconvolution + DoG plugin (pycudadecon)
43
44
  pip install "patchworks[bioio]" # convert any image format to OME-ZARR
44
45
  pip install "patchworks[imaris]" # convert Imaris .ims files to OME-ZARR
45
46
  pip install "patchworks[napari]" # interactive napari viewer plugin
@@ -52,6 +53,14 @@ pip install "patchworks[all]" # Everything, incl. the napari viewer
52
53
  > `[imaris]` adds native `.ims` support (HDF5, no JVM). Physical pixel
53
54
  > calibration is read from the input and written into the OME-ZARR.
54
55
 
56
+ > **`cupy` is never installed automatically**, unlike Cellpose's GPU support
57
+ > (which comes for free via PyTorch's self-contained CUDA wheels). Any
58
+ > `use_gpu=True`/`dilate_gpu: true` option (the `dog` plugin, `dilate_labels`)
59
+ > needs `cupy` installed separately, matching your CUDA version — e.g.
60
+ > `pip install cupy-cuda12x`. Not bundled because cupy ships one wheel per
61
+ > CUDA major version; a generic pin would resolve to the wrong build (or fail
62
+ > to resolve) depending on the machine.
63
+
55
64
  ---
56
65
 
57
66
  ## Quick start — 5 lines
@@ -307,10 +316,14 @@ Optional:
307
316
  - `tqdm` — progress bars
308
317
  - `cellpose` — Cellpose plugin, v3 or v4 (`patchworks[cellpose]`);
309
318
  pin with `[cellpose3]` or `[cellpose4]`
319
+ - `pycudadecon` — deconvolution step of the `dog` plugin (`patchworks[dog]`)
310
320
  - `bioio` + readers — convert CZI/LIF/ND2/OME-TIFF/… to OME-ZARR
311
321
  (`patchworks[bioio]`)
312
322
  - `imaris-ims-file-reader` — convert Imaris `.ims` (`patchworks[imaris]`)
313
323
  - `napari` — interactive viewer plugin (`patchworks[napari]`)
324
+ - `cupy` — **install manually**, matching your CUDA version (e.g.
325
+ `pip install cupy-cuda12x`); not offered as an extra since it isn't one
326
+ generic pin. Needed for `use_gpu=True`/`dilate_gpu: true`.
314
327
 
315
328
  ---
316
329
 
@@ -36,12 +36,25 @@ patchworks can be installed from PyPI on all operating systems, for Python ≥ 3
36
36
  pip install "patchworks[cellpose]"
37
37
  ```
38
38
 
39
+ === "With deconvolution + DoG plugin"
40
+
41
+ ```bash
42
+ pip install "patchworks[dog]"
43
+ ```
44
+
39
45
  === "Everything"
40
46
 
41
47
  ```bash
42
48
  pip install "patchworks[all]"
43
49
  ```
44
50
 
51
+ !!! note "cupy is always a manual install"
52
+ `use_gpu=True` (the `dog` plugin, `dilate_labels`) needs `cupy`, but it's
53
+ never pulled in automatically — unlike Cellpose, which gets GPU support
54
+ for free via PyTorch's self-contained CUDA wheels, `cupy` ships one wheel
55
+ per CUDA major version. Install the one matching your CUDA version
56
+ yourself, e.g. `pip install cupy-cuda12x`.
57
+
45
58
  ---
46
59
 
47
60
  ## The one function you need
@@ -74,6 +74,20 @@ 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)
82
+ ```
83
+
84
+ Needs `cupy` installed **manually**, matching your CUDA version (e.g.
85
+ `pip install cupy-cuda12x`) — it's never installed automatically by
86
+ patchworks, unlike Cellpose's GPU support (which comes for free via
87
+ PyTorch's self-contained CUDA wheels); cupy ships one wheel per CUDA major
88
+ version, so there's no single generic pin that works everywhere. On the
89
+ cluster, this is the `dilate_gpu: true` config key.
90
+
77
91
  ## Real example: StarDist 3-D, with model caching
78
92
 
79
93
  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