@@ -46,11 +46,11 @@ patchworks can be installed from PyPI on all operating systems, for Python ≥ 3
4646
4747## The one function you need
4848
49- ``` python
50- from patchworks import tile_process
49+ ```python
50+ from patchworks import tile_process
5151
52- result = tile_process(image, fn)
53- ```
52+ result = tile_process(image, fn)
53+ ```
5454
5555` tile_process(image, fn) ` splits ` image ` into tiles, runs ` fn ` on each tile,
5656and returns a globally consistent label array.
@@ -65,17 +65,17 @@ and returns a globally consistent label array.
6565patchworks is method-agnostic. Your function receives a NumPy array (one tile)
6666and must return an integer label array of the same shape:
6767
68- ``` python
69- import numpy as np
68+ ```python
69+ import numpy as np
7070
7171
72- def my_fn (tile : np.ndarray) -> np.ndarray:
73- from skimage.filters import threshold_otsu
74- from skimage.measure import label
72+ def my_fn(tile: np.ndarray) -> np.ndarray:
73+ from skimage.filters import threshold_otsu
74+ from skimage.measure import label
7575
76- binary = tile > threshold_otsu(tile)
77- return label(binary).astype(" int32" )
78- ```
76+ binary = tile > threshold_otsu(tile)
77+ return label(binary).astype("int32")
78+ ```
7979
8080The function is called independently on every tile. patchworks ensures that
8181objects spanning tile boundaries are merged into a single label.
@@ -155,14 +155,14 @@ objects spanning tile boundaries are merged into a single label.
155155Methods like Cellpose and StarDist need spatial context at tile boundaries.
156156Use ` overlap ` (in voxels) so boundary objects are fully visible:
157157
158- ``` python
159- result = tile_process(
160- " image.zarr" ,
161- my_fn,
162- tile_shape = (1 , 2048 , 2048 ),
163- overlap = 20 , # 20-voxel halo on every side
164- )
165- ```
158+ ```python
159+ result = tile_process(
160+ "image.zarr",
161+ my_fn,
162+ tile_shape=(1, 2048, 2048),
163+ overlap=20, # 20-voxel halo on every side
164+ )
165+ ```
166166
167167!!! info "How overlap works"
168168 Each tile is expanded by ` overlap ` voxels on every side before calling ` fn ` .
@@ -173,22 +173,22 @@ result = tile_process(
173173
174174## Use Cellpose
175175
176- ``` python
177- from patchworks import tile_process
178- from patchworks.plugins.cellpose import cellpose_fn
179-
180- fn = cellpose_fn(" cyto3" , gpu = True , diameter = 30 )
181-
182- tile_process(
183- " image.zarr" ,
184- fn,
185- channel = 0 ,
186- tile_shape = (1 , 2048 , 2048 ),
187- overlap = 20 ,
188- write_to = " labels.zarr" ,
189- progress = True ,
190- )
191- ```
176+ ```python
177+ from patchworks import tile_process
178+ from patchworks.plugins.cellpose import cellpose_fn
179+
180+ fn = cellpose_fn("cyto3", gpu=True, diameter=30)
181+
182+ tile_process(
183+ "image.zarr",
184+ fn,
185+ channel=0,
186+ tile_shape=(1, 2048, 2048),
187+ overlap=20,
188+ write_to="labels.zarr",
189+ progress=True,
190+ )
191+ ```
192192
193193See the [ Cellpose 2-D example] ( examples/cellpose_2d.md ) for the full workflow.
194194
0 commit comments