Skip to content

Commit 314dc4f

Browse files
committed
merge dev into main
2 parents 8b7f761 + da8de4f commit 314dc4f

1 file changed

Lines changed: 47 additions & 6 deletions

File tree

docs/guide/ome_zarr_napari.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ existed.
3939
## Convert any image to OME-ZARR
4040

4141
`to_ome_zarr` accepts a dask/NumPy array, an existing `.zarr` store, an
42-
**Imaris `.ims`** file, or **any format** readable by
43-
[bioio](https://github.com/bioio-devs/bioio) (CZI, LIF, ND2, OME-TIFF, …). File
44-
inputs are read **lazily**.
42+
**Imaris `.ims`** file, **any format** readable by
43+
[bioio](https://github.com/bioio-devs/bioio) (CZI, LIF, ND2, OME-TIFF, …), or
44+
a **folder of single-plane TIFFs** (see below). File inputs are read
45+
**lazily**.
4546

4647
```python
4748
from patchworks.plugins.ome_zarr import to_ome_zarr
@@ -50,6 +51,44 @@ to_ome_zarr("scan.czi", "scan.zarr", n_levels=5) # via bioio
5051
to_ome_zarr("scan.ims", "scan.zarr") # Imaris, native HDF5
5152
```
5253

54+
### A folder of single-plane TIFFs
55+
56+
Some acquisitions/stitching tools save **one TIFF per Z/C plane** instead of a
57+
single multi-page file, e.g.:
58+
59+
```text
60+
sample_T0_Z000_C0_V0.tif
61+
sample_T0_Z000_C1_V0.tif
62+
sample_T0_Z001_C0_V0.tif
63+
sample_T0_Z001_C1_V0.tif
64+
...
65+
```
66+
67+
Pass `sequence_pattern=` and let `source` be a glob over the folder instead of
68+
one file path. The pattern is a regex whose **named groups** map to axis
69+
labels — axis order follows the order the groups appear in the pattern:
70+
71+
```python
72+
to_ome_zarr(
73+
"sample/*.tif",
74+
"sample.zarr",
75+
sequence_pattern=r"_T(?P<T>\d+)_Z(?P<Z>\d+)_C(?P<C>\d+)_V\d+",
76+
shard=True, # recommended for large sequences, see Sharding below
77+
)
78+
```
79+
80+
Each file becomes exactly **one dask chunk**, decoded lazily on access — no
81+
data is duplicated or eagerly loaded, so this scales to huge (multi-TB)
82+
sequences (built on `tifffile.TiffSequence`, the same mechanism Cellpose's
83+
own distributed pipeline uses). Pixel calibration is read automatically from
84+
the first file's own metadata — see [Pixel calibration](#pixel-calibration)
85+
below.
86+
87+
Available on the cluster too: the Snakemake `convert` rule reads a
88+
`sequence_pattern:` key from the config (`input:` then being the glob), so a
89+
folder-of-TIFFs conversion runs through the same SLURM profile as any other
90+
input — see [Cluster usage](snakemake.md).
91+
5392
!!! note "Imaris pyramids: rebuild (default) or reuse"
5493
`.ims` files carry their own resolution pyramid. By default `to_ome_zarr`
5594
reads only the **full-resolution** level and **builds a fresh NGFF pyramid**
@@ -64,9 +103,11 @@ to_ome_zarr("scan.ims", "scan.zarr") # Imaris, native HDF5
64103
### Pixel calibration
65104

66105
The physical voxel size is read from the input — bioio's `physical_pixel_sizes`,
67-
the Imaris resolution metadata, or an existing OME-ZARR's scale — and written
68-
into the NGFF `coordinateTransformations` (in micrometers), so calibration is
69-
preserved regardless of input. Override or supply it for bare arrays with
106+
the Imaris resolution metadata, an existing OME-ZARR's scale, or (for a TIFF
107+
sequence) the first file's own ImageJ metadata (`spacing`/`unit`) or
108+
`XResolution`/`YResolution` tags — and written into the NGFF
109+
`coordinateTransformations` (in micrometers), so calibration is preserved
110+
regardless of input. Override or supply it for bare arrays with
70111
`pixel_size={"z": 2.0, "y": 0.32, "x": 0.32}`.
71112

72113
### Won't OOM

0 commit comments

Comments
 (0)