Skip to content

Commit 084e54e

Browse files
committed
Declare semantic axes for Zarr batches
1 parent 96d754e commit 084e54e

6 files changed

Lines changed: 686 additions & 203 deletions

File tree

‎docs/source/api/backends.rst‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,58 @@ its enum values through strings or lookup tables.
6161
)
6262
)
6363
64+
Zarr batch layout
65+
-----------------
66+
67+
``ZarrStorageBackend.save_batch`` requires a ``ZarrBatchLayout`` from
68+
``polystore.zarr_batch``. The layout declares every non-pixel axis, its opaque
69+
semantic values, and the exact coordinate of each two-dimensional image plane.
70+
PolyStore validates that the coordinates form one complete dense product, so
71+
item order is never inferred from filenames or list position.
72+
73+
``ZarrBatchAxisRole.ARRAY`` places an axis inside each OME-NGFF image array.
74+
``ZarrBatchAxisRole.HCS_IMAGE`` projects one axis into the well's HCS image
75+
groups. A layout may declare at most one HCS image axis. This keeps each image
76+
array within the OME-NGFF ``t, c, z, y, x`` model while preserving fields or
77+
sites as distinct HCS images.
78+
79+
.. code-block:: python
80+
81+
from polystore.zarr_batch import (
82+
ZarrBatchAxis,
83+
ZarrBatchAxisRole,
84+
ZarrBatchLayout,
85+
)
86+
87+
layout = ZarrBatchLayout(
88+
axes=(
89+
ZarrBatchAxis("t", "time", ("1", "2")),
90+
ZarrBatchAxis(
91+
"field",
92+
"field",
93+
("3", "7"),
94+
ZarrBatchAxisRole.HCS_IMAGE,
95+
),
96+
ZarrBatchAxis("c", "channel", ("DNA", "RNA")),
97+
ZarrBatchAxis("z", "space", ("1",)),
98+
),
99+
item_coordinates=(
100+
(0, 0, 0, 0),
101+
(0, 0, 1, 0),
102+
(0, 1, 0, 0),
103+
(0, 1, 1, 0),
104+
(1, 0, 0, 0),
105+
(1, 0, 1, 0),
106+
(1, 1, 0, 0),
107+
(1, 1, 1, 0),
108+
),
109+
)
110+
111+
The backend persists both filename-to-coordinate mappings and semantic axis
112+
values. ``load_batch`` uses the stored coordinates directly, and readers can
113+
use ``ZarrStoredBatchSemantics`` to recover application-owned labels without
114+
teaching PolyStore what those labels mean.
115+
64116
Bounded native sampling
65117
-----------------------
66118

‎pyproject.toml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ target-version = ["py311", "py312"]
184184
[tool.ruff]
185185
line-length = 100
186186
target-version = "py311"
187+
188+
[tool.ruff.lint]
187189
select = [
188190
"E", # pycodestyle errors
189191
"W", # pycodestyle warnings
@@ -199,5 +201,5 @@ ignore = [
199201
"C901", # too complex
200202
]
201203

202-
[tool.ruff.per-file-ignores]
204+
[tool.ruff.lint.per-file-ignores]
203205
"__init__.py" = ["F401"] # unused imports

0 commit comments

Comments
 (0)