Yaozarrs Guide to OME-Zarr#
What you'll learn
This guide attempts to demystify the OME-Zarr specification and shows you how to work with it using yaozarrs. It is designed to answer common questions and confusions encountered in the community.
Quicklinks#
-
I have images
Any data with 5 or less dimensions, typically
[T][C][Z]YX. -
I have plate data
Multi-well plates and high-content screening (HCS) experiments
-
I have image annotations
Segmentation masks, annotation labels, and regions of interest (ROIs)
-
I have multiple images
Collections of related images (multi-FOV, stage positions, split files)
-
My images are related in space
Tiles of a mosaic, multiple views of a sample, or images to register onto each other (v0.6 and later)
Which version is this guide about?
This guide covers OME-Zarr v0.4, v0.5 and v0.6, with tabs to show the differences. The coordinate systems and transformations of v0.6 get their own page: Coordinate Systems & Transformations.
Which version should I write?
It depends on who needs to read your data. Newer versions can express more, but your files are only useful if the tools you (and your collaborators) rely on can read them, so check those first.
What is OME-Zarr?#
The official OME-Zarr specification can be found at https://ngff.openmicroscopy.org/. In case of any discrepancies between this guide and the official spec, the official spec takes precedence!
OME-Zarr is a file format specification used by the bioimaging community for storing multi-dimensional data. It is a "meta-specification", based on the pre-existing Zarr format, which is designed for the storage of chunked, compressed, N-dimensional arrays. OME-Zarr extends Zarr by adding metadata conventions specific to bioimaging, making it easier to store and share complex imaging datasets.
But what is it?
To resolve a somewhat common confusion...
OME-Zarr is "just" Zarr (A file format used in many domains). The "OME" part is a specification on top of the zarr format that additionally defines:
-
How domain specific metadata should be stored.
The details are version-specific, but this generally defines the exact form of the data inside of the.zattrsorzarr.jsonfiles that accompany the zarr groups. -
How datasets are organized.
Beyond metadata, the OME-Zarr specification also defines how datasets should be organized. For example: it defines how the images collected across a multi-well plate experiment should be organized in a single Zarr directory, or how the different resolutions of a multi-scale (pyramidal) image should be stored.
Working with Images#
An Image is the fundamental building block of OME-Zarr.
Since v0.4, a single image may have no less than 2 and no more than 5 dimensions, and may store multiple resolution levels.
- Spatial dimensions: X, Y, optionally Z
- Time: T (temporal axis)
- Channels: C (fluorescence channels, RGB, etc.)
What if I have more than 5 dimensions?
While it is common to have datasets with more than 5 dimensions (e.g.,
different stage positions in a shared coordinate space, angles in light
sheet microscopy, etc.), there is currently no formal specification for more
than 5 dimensions in OME-Zarr. You may use the transitional
bioformats2raw.layout to store multiple images in a single zarr group.
See Working with Collections
See also: an RFC ("request for comments") proposing a relaxation of this restriction: RFC-3
What if I have both RGB and optical channels?
As of v0.6, there is no formal specification for mixing the concepts of RGB image components and conventional "channels" (like optical configurations). You will need to either create a custom group layout or flatten them all into a single channel dimension.
Directory Structure#
image.zarr/
├── zarr.json # {"zarr_format": 3} group, with attributes.ome.multiscales
├── 0/ # Full resolution array
│ ├── zarr.json # Array metadata (standard zarr schema)
│ └── c/0/1/2/3 # Chunk files
├── 1/ # downsampled level 1
│ └── ...
└── 2/ # downsampled level 2
└── ...
image.zarr/
├── zarr.json # {"zarr_format": 3} group, with attributes.ome.multiscales
├── 0/ # Full resolution array
│ ├── zarr.json # Array metadata (standard zarr schema)
│ └── c/0/1/2/3 # Chunk files
├── 1/ # downsampled level 1
│ └── ...
└── 2/ # downsampled level 2
└── ...
image.zarr/
├── .zgroup # {"zarr_format": 2} group
├── .zattrs # Contains "multiscales"
├── 0/ # Full resolution array
│ ├── .zarray # Array metadata (standard zarr schema)
│ └── t/c/z/y/x # Chunk files with "/" separator
├── 1/ # downsampled level 1
│ └── ...
└── 2/ # downsampled level 2
└── ...
Key difference
Most of the structural changes between v0.4 and v0.5 relate to the transition from Zarr v2 to Zarr v3.
- <=v0.4: "multiscales" metadata directly in root of
.zattrsfiles - >=v0.5: "multiscales" metadata in
zarr.jsonunderattributes.omenamespace
Axes#
Axes define the dimensions of your image data. Starting with v0.4, axes are
objects with a name, and optional type and/or unit:
Axis Constraints
Constraints for image axes in OME-Zarr are the same in v0.4, v0.5 and v0.6 (in v0.6, they apply to every coordinate system inside a multiscale):
- MUST have 2-5 dimensions total
- MUST have 2-3 spatial axes
- MAY have 0-1 time axis
- MAY have 0-1 channel axis
- Ordering enforced: time → channel/custom → space
In practice, this limits valid axis combinations to: [T][C][Z] Y X
(though no explicit restriction is placed on naming conventions)
In v0.6, the axes are no longer listed directly in the multiscale. Instead,
they belong to a named coordinate system, and each multiscale lists one
or more of these under coordinateSystems. (See Coordinate Systems &
Transformations.)
Spec JSON:
{
// found in a "multiscales" object
"coordinateSystems": [
{
"name": "physical",
"axes": [
{"name": "c", "type": "channel", "discrete": true},
{"name": "z", "type": "space", "unit": "micrometer"},
{"name": "y", "type": "space", "unit": "micrometer"},
{"name": "x", "type": "space", "unit": "micrometer"}
]
}
]
}
yaozarrs Code:
from yaozarrs import v06
physical = v06.CoordinateSystem(
name="physical",
axes=[
v06.Axis(name="c", type="channel", discrete=True),
v06.Axis(name="z", type="space", unit="micrometer"),
v06.Axis(name="y", type="space", unit="micrometer"),
v06.Axis(name="x", type="space", unit="micrometer"),
],
)
Axis fields in v0.6
discrete(optional):trueif the axis may only be indexed by whole numbers (channels usually are),falseif values in between samples are meaningful, so interpolating along it makes sense (space and time usually are).longName(optional): a longer name or description of the axis.typeSHOULD be one ofspace,time,channel,array,coordinateordisplacement(the last two are for the vector-field arrays ofdisplacementsandcoordinatestransformations), but other strings are allowed for custom types.- Axis names MUST be non-empty, and unique within their coordinate system.
Spec JSON:
{
// found in a "multiscales" object
"axes": [
{"name": "c", "type": "channel"},
{"name": "z", "type": "space", "unit": "micrometer"},
{"name": "y", "type": "space", "unit": "micrometer"},
{"name": "x", "type": "space", "unit": "micrometer"}
]
}
yaozarrs Code:
from yaozarrs import v05
axes = [
v05.Axis(name="c", type="channel"),
v05.Axis(name="z", type="space", unit="micrometer"),
v05.Axis(name="y", type="space", unit="micrometer"),
v05.Axis(name="x", type="space", unit="micrometer"),
]
Spec JSON:
{
// found in a "multiscales" object
"axes": [
{"name": "c", "type": "channel"},
{"name": "z", "type": "space", "unit": "micrometer"},
{"name": "y", "type": "space", "unit": "micrometer"},
{"name": "x", "type": "space", "unit": "micrometer"}
]
}
yaozarrs Code:
from yaozarrs import v04
axes = [
v04.Axis(name="c", type="channel"),
v04.Axis(name="z", type="space", unit="micrometer"),
v04.Axis(name="y", type="space", unit="micrometer"),
v04.Axis(name="x", type="space", unit="micrometer"),
]
Building axes#
Every axis is an Axis (v0.4 ·
v0.5 · v0.6), whose fields mirror
the JSON, as above. As a shortcut, SpaceAxis, TimeAxis
and ChannelAxis fill in the type for you, and for SpaceAxis and TimeAxis, IDEs
complete the units the spec recommends for space and time axes. These are the same axes as the v0.6 example above:
from yaozarrs import v06
axes = [
v06.ChannelAxis(name="c", discrete=True),
v06.SpaceAxis(name="z", unit="micrometer"),
v06.SpaceAxis(name="y", unit="micrometer"),
v06.SpaceAxis(name="x", unit="micrometer"),
]
A few more things to know:
- Units: the spec recommends specific units for
spaceandtimeaxes (e.g."micrometer","second"). Other units are accepted, with ayaozarrs.ValidationWarning. - Shortcuts return an
Axis: they are functions, not classes, so check an axis's type withaxis.type == "space"(notisinstance). (CustomAxisis deprecated: it's the same asAxis.) - Dicts: anywhere yaozarrs takes an axis, a dict like
{"name": "z", "type": "space"}is validated into anAxistoo. - New images: to build a multiscale's axes and its per-level transformations
in one go, use
Multiscale.from_dimswith a list ofDimSpec.
Coordinate Transformations#
Starting in v0.4, every dataset MUST include coordinate transformations that map data coordinates to physical coordinates. This is where you specify the pixel size (in the units of the axes), the scale of each resolution level, and spatial offsets.
Each dataset still has a transformation from its array (pixel) coordinates
to physical coordinates, but now it explicitly says where it maps from and
to: its input is the dataset's array (by path), and its output is a
coordinate system of the multiscale (by name). Every dataset maps into
the same coordinate system, which the spec calls the image's
"intrinsic" coordinate
system.
Scale Transformation:
Spec JSON:
{
"coordinateSystems": [
{"name": "physical", "axes": [...]} // the 4 axes from above
],
"datasets": [{
"path": "0",
"coordinateTransformations": [{
"type": "scale",
"scale": [1.0, 0.5, 0.1, 0.1],
"input": {"path": "0"},
"output": {"name": "physical"}
}]
}]
}
yaozarrs Code:
from yaozarrs import v06
dataset = v06.Dataset(
path="0",
coordinateTransformations=[
v06.ScaleTransformation(
scale=[1.0, 0.5, 0.1, 0.1],
input={"path": "0"},
output={"name": "physical"},
)
],
)
Scale + Translation:
A scale and a translation are no longer listed side by side. To add a
translation, wrap both in a single sequence transformation (scale first):
Spec JSON:
{
"path": "0",
"coordinateTransformations": [{
"type": "sequence",
"input": {"path": "0"},
"output": {"name": "physical"},
"transformations": [
{"type": "scale", "scale": [1.0, 0.5, 0.1, 0.1]},
{"type": "translation", "translation": [0.0, 0.0, 100.0, 200.0]}
]
}]
}
yaozarrs Code:
dataset = v06.Dataset(
path="0",
coordinateTransformations=[
v06.SequenceTransformation(
input={"path": "0"},
output={"name": "physical"},
transformations=[
v06.ScaleTransformation(scale=[1.0, 0.5, 0.1, 0.1]),
v06.TranslationTransformation(translation=[0.0, 0.0, 100.0, 200.0]),
],
)
],
)
Transformation Rules (v0.6)
- MUST have exactly one transformation per dataset: a
scale, anidentity, or asequenceof a scale followed by a translation - Its
inputMUST have apathmatching the dataset'spath, and SHOULD omitname - Its
outputMUST have thenameof a coordinate system incoordinateSystems, the same one for every dataset, and SHOULD omitpath - Parameter lengths MUST match the number of axes
- The scale gives the pixel size in physical units (or the time step).
If that isn't known (or doesn't apply) for an axis, the value MUST
be the downsampling factor relative to the first level instead (
1.0if that axis isn't downsampled)
Use Multiscale.from_dims
v06.Multiscale.from_dims builds
the coordinate system and every level's transformation for you (see
DimSpec).
v0.6 doesn't require dimension_names (yaozarrs still writes them).
For other transformation types, label links and scenes, see Coordinate Systems & Transformations.
Identical to v0.4, just stored under attributes.ome namespace.
yaozarrs Code (same as v0.4):
from yaozarrs import v05
dataset = v05.Dataset(
path="0",
coordinateTransformations=[
v05.ScaleTransformation(scale=[1.0, 0.5, 0.1, 0.1]),
v05.TranslationTransformation(translation=[0.0, 0.0, 100.0, 200.0]),
],
)
v0.5 Additional Requirement
In v0.5, each array's zarr.json MUST include dimension_names matching the axes:
{
"dimension_names": ["c", "z", "y", "x"]
}
Scale Transformation (REQUIRED):
Maps array indices to physical coordinates. Scale values represent the physical size per pixel for each dimension.
Spec JSON:
{
"datasets": [{
"path": "0",
"coordinateTransformations": [
{"type": "scale", "scale": [1.0, 0.5, 0.1, 0.1]}
]
}]
}
yaozarrs Code:
from yaozarrs import v04
dataset = v04.Dataset(
path="0",
coordinateTransformations=[v04.ScaleTransformation(scale=[1.0, 0.5, 0.1, 0.1])],
)
Translation Transformation (OPTIONAL):
Adds a spatial offset. Must come after scale.
Spec JSON:
{
"coordinateTransformations": [
{"type": "scale", "scale": [1.0, 0.5, 0.1, 0.1]},
{"type": "translation", "translation": [0.0, 0.0, 100.0, 200.0]}
]
}
yaozarrs Code:
dataset = v04.Dataset(
path="0",
coordinateTransformations=[
v04.ScaleTransformation(scale=[1.0, 0.5, 0.1, 0.1]),
v04.TranslationTransformation(translation=[0.0, 0.0, 100.0, 200.0]),
],
)
Transformation Rules
- MUST have exactly one scale transformation per dataset
- MAY have at most one translation transformation
- If translation exists, it MUST come after scale
- Transformation length MUST match number of axes
Interactive Example#
Modify the parameters below to see how different image configurations are represented in OME-Zarr:
Labels (Segmentation Masks)#
Labels are specialized images with integer dtype representing segmentation masks (nuclei, cells, regions of interest, etc.).
They are represented as a special group named "labels/" within an image group.
Careful
This is one of the only places in the specification where the name of the
group itself is normative: it MUST be named labels/.
Conforming readers must search for the labels/ group within an image
group to discover it: its presence is not indicated in the parent image
metadata.
Label Structure and Code
Directory Structure:
Same as v0.5:
image.zarr/
├── zarr.json # Image metadata ("attributes.ome.multiscales")
├── 0/ # Full resolution image
├── 1/ # Downsampled level 1
└── labels/
├── zarr.json # Labels group metadata ("attributes.ome.labels")
├── nuclei/ # Label image (integer dtype)
│ ├── zarr.json # Label metadata ("attributes.ome.multiscales", "attributes.ome.image-label")
│ ├── 0/ # Full resolution labels
│ └── 1/ # Downsampled labels
└── cells/
└── ...
Labels Group Metadata (labels/zarr.json):
{
"zarr_format": 3,
"node_type": "group",
"attributes": {
"ome": {
"version": "0.6",
"labels": ["nuclei", "cells"]
}
}
}
Label Image Metadata (labels/nuclei/zarr.json):
{
"zarr_format": 3,
"node_type": "group",
"attributes": {
"ome": {
"version": "0.6",
"multiscales": [...],
"image-label": {
"colors": [
{"label-value": 1, "rgba": [255, 0, 0, 255]},
{"label-value": 2, "rgba": [0, 255, 0, 255]}
],
"source": {
"image": "../../"
}
}
}
}
}
yaozarrs Code:
from yaozarrs import DimSpec, v06
# Label metadata stored at labels/nuclei/zarr.json
label_image = v06.LabelImage(
# same structure as a regular image
multiscales=[v06.Multiscale.from_dims([DimSpec(name="y"), DimSpec(name="x")])],
image_label=v06.ImageLabel(
colors=[
v06.LabelColor(label_value=1, rgba=[255, 0, 0, 255]),
v06.LabelColor(label_value=2, rgba=[0, 255, 0, 255]),
],
source=v06.LabelSource(image="../../"),
),
)
Directory Structure:
image.zarr/
├── zarr.json # Image metadata ("attributes.ome.multiscales")
├── 0/ # Full resolution image
├── 1/ # Downsampled level 1
├── ... # Downsampled level 2
└── labels/
├── zarr.json # Labels group metadata ("attributes.ome.labels")
├── nuclei/ # Label image (integer dtype)
│ ├── zarr.json # Label metadata ("attributes.ome.multiscales", "attributes.ome.image-label")
│ ├── 0/ # Full resolution labels
│ └── 1/ # Downsampled labels
└── cells/
└── ...
Labels Group Metadata (labels/zarr.json):
{
"zarr_format": 3,
"node_type": "group",
"attributes": {
"ome": {
"version": "0.5",
"labels": ["nuclei", "cells"]
}
}
}
Label Image Metadata (labels/nuclei/zarr.json):
{
"zarr_format": 3,
"node_type": "group",
"attributes": {
"ome": {
"version": "0.5",
"multiscales": [...],
"image-label": {
"colors": [
{"label-value": 1, "rgba": [255, 0, 0, 255]},
{"label-value": 2, "rgba": [0, 255, 0, 255]}
],
"source": {
"image": "../../"
}
}
}
}
}
yaozarrs Code:
from yaozarrs import DimSpec, v05
# Label metadata stored at labels/nuclei/zarr.json
label_image = v05.LabelImage(
# same structure as a regular image
multiscales=[v05.Multiscale.from_dims([DimSpec(name="y"), DimSpec(name="x")])],
image_label=v05.ImageLabel(
colors=[
v05.LabelColor(label_value=1, rgba=[255, 0, 0, 255]),
v05.LabelColor(label_value=2, rgba=[0, 255, 0, 255]),
],
source=v05.LabelSource(image="../../"),
),
)
Directory Structure:
image.zarr/
├── .zgroup
├── .zattrs # Image metadata ("multiscales")
├── 0/ # Full resolution image
├── 1/ # Downsampled level 1
├── ... # Downsampled level 2
└── labels/
├── .zgroup
├── .zattrs # Labels group metadata ("labels")
├── nuclei/ # Label image (integer dtype)
│ ├── .zgroup
│ ├── .zattrs # Label metadata ("multiscales", "image-label")
│ ├── 0/ # Full resolution labels
│ └── 1/ # Downsampled labels
└── cells/
└── ...
Labels Group Metadata (labels/.zattrs):
{
"labels": ["nuclei", "cells"]
}
Label Image Metadata (labels/nuclei/.zattrs):
{
"multiscales": [...],
"image-label": {
"version": "0.4",
"colors": [
{"label-value": 1, "rgba": [255, 0, 0, 255]},
{"label-value": 2, "rgba": [0, 255, 0, 255]}
],
"source": {
"image": "../../"
}
}
}
yaozarrs Code:
from yaozarrs import DimSpec, v04
# Label metadata stored at labels/nuclei/.zattrs
label_image = v04.LabelImage(
# same structure as a regular image
multiscales=[v04.Multiscale.from_dims([DimSpec(name="y"), DimSpec(name="x")])],
image_label=v04.ImageLabel(
colors=[
v04.LabelColor(label_value=1, rgba=[255, 0, 0, 255]),
v04.LabelColor(label_value=2, rgba=[0, 255, 0, 255]),
],
source=v04.LabelSource(image="../../"),
),
)
Labels must use integer dtype
Validation will fail if label arrays use float dtypes. Use an integer
dtype (uint8 through int64).
Lining labels up with the image (v0.6)#
By default, a label image's intrinsic coordinate
system is "usually
understood to be the same" as its image's. In v0.6, you can also link the two
when they aren't the same. Say a
segmentation tool wrote labels for a crop of the image, with the corner of the
crop as its origin. Rather than rewriting the label image's metadata, you can add
a transformation to the parent image's multiscale coordinateTransformations,
linking its intrinsic coordinate system to the label image's (referenced by name
and path, relative to the image group). For a z, y, x image:
{
// found in the multiscales object of the *image* (not the label image)
"coordinateTransformations": [
{
"type": "translation",
"translation": [0.0, 100.0, 50.0],
"input": {"name": "physical", "path": "labels/cells"},
"output": {"name": "physical"}
}
]
}
Here, a point in the cells label image's physical coordinate system, shifted
by (0, 100, 50), gives the matching point in the image's own physical
coordinate system.
Only simple transformations
A transformation to a label image MUST be an identity, scale,
translation, or a sequence of a scale and a translation.
Working with Plates#
A Plate represents multi-well plate data from high-content screening (HCS) experiments. The hierarchy is:
Plate → Rows/Columns → Wells → Fields of View (Images)
Each well can contain multiple fields of view (FOVs) across multiple acquisitions (timepoints).
Directory Structure#
Same as v0.5:
plate.zarr/
├── zarr.json # contains Plate metadata ("attributes.ome.plate")
├── A/ # Row A
│ ├── 1/ # Well A1
│ │ ├── zarr.json # contains Well metadata ("attributes.ome.well")
│ │ ├── 0/ # Field 0 (Standard multiscales image)
│ │ │ ├── zarr.json # contains Image metadata ("attributes.ome.multiscales")
│ │ │ ├── 0/ # Full resolution
│ │ │ ├── 1/ # Downsampled
│ │ │ └── labels/ # Optional labels group (see above)
│ │ └── 1/ # Field 1
│ └── 2/ # Well A2
└── B/ # Row B
└── 1/
plate.zarr/
├── zarr.json # contains Plate metadata ("attributes.ome.plate")
├── A/ # Row A
│ ├── 1/ # Well A1
│ │ ├── zarr.json # contains Well metadata ("attributes.ome.well")
│ │ ├── 0/ # Field 0 (Standard multiscales image)
│ │ │ ├── zarr.json # contains Image metadata ("attributes.ome.multiscales")
│ │ │ ├── 0/ # Full resolution
│ │ │ ├── 1/ # Downsampled
│ │ │ └── labels/ # Optional labels group (see above)
│ │ └── 1/ # Field 1
│ └── 2/ # Well A2
└── B/ # Row B
└── 1/
plate.zarr/
├── .zgroup
├── .zattrs # contains Plate metadata ("plate")
├── A/ # Row A
│ ├── 1/ # Well A1
│ │ ├── .zgroup
│ │ ├── .zattrs # contains Well metadata ("well")
│ │ ├── 0/ # Field 0 (Standard multiscales image)
│ │ │ ├── .zgroup
│ │ │ ├── .zattrs # contains Image metadata ("multiscales")
│ │ │ ├── 0/ # Full resolution
│ │ │ ├── 1/ # Downsampled
│ │ │ └── labels/ # Optional labels group (see above)
│ │ └── 1/ # Field 1
│ └── 2/ # Well A2
└── B/ # Row B
└── 1/
Three-level hierarchy
Three groups MUST exist above images: plate → row → well
Plate Metadata#
The same structure as v0.5, with "version": "0.6" at ome.version.
In yaozarrs, just swap v05 for v06:
from yaozarrs import v06
plate_def = v06.PlateDef(
name="HCS Experiment",
columns=[v06.Column(name="1"), v06.Column(name="2"), v06.Column(name="3")],
rows=[v06.Row(name="A"), v06.Row(name="B")],
wells=[
v06.PlateWell(path="A/1", rowIndex=0, columnIndex=0),
v06.PlateWell(path="A/2", rowIndex=0, columnIndex=1),
v06.PlateWell(path="B/1", rowIndex=1, columnIndex=0),
],
acquisitions=[
v06.Acquisition(id=0, name="Initial", maximumfieldcount=4),
v06.Acquisition(id=1, name="24h", maximumfieldcount=4),
],
field_count=4,
)
plate = v06.Plate(plate=plate_def)
Same structure as v0.4, stored under attributes.ome in zarr.json:
Spec JSON (zarr.json at plate root):
{
"zarr_format": 3,
"node_type": "group",
"attributes": {
"ome": {
"version": "0.5",
"plate": {
"columns": [
{ "name": "1" },
{ "name": "2" },
{ "name": "3" }
],
"rows": [
{ "name": "A" },
{ "name": "B" }
],
"wells": [
{ "path": "A/1", "rowIndex": 0, "columnIndex": 0 },
{ "path": "A/2", "rowIndex": 0, "columnIndex": 1 },
{ "path": "B/1", "rowIndex": 1, "columnIndex": 0 }
],
"acquisitions": [
{ "id": 0, "maximumfieldcount": 4, "name": "Initial" },
{ "id": 1, "maximumfieldcount": 4, "name": "24h" }
],
"field_count": 4,
"name": "HCS Experiment"
}
}
}
}
from yaozarrs import v05
plate_def = v05.PlateDef(
name="HCS Experiment",
columns=[ # must have at least 1 column
v05.Column(name="1"),
v05.Column(name="2"),
v05.Column(name="3"),
],
rows=[ # must have at least 1 row
v05.Row(name="A"),
v05.Row(name="B"),
],
wells=[ # must have at least 1 well, paths match tree structure
v05.PlateWell(path="A/1", rowIndex=0, columnIndex=0),
v05.PlateWell(path="A/2", rowIndex=0, columnIndex=1),
v05.PlateWell(path="B/1", rowIndex=1, columnIndex=0),
],
acquisitions=[ # optional
v05.Acquisition(id=0, name="Initial", maximumfieldcount=4),
v05.Acquisition(id=1, name="24h", maximumfieldcount=4),
],
field_count=4, # max FOV per well
)
plate = v05.Plate(plate=plate_def)
# Create full zarr.json
zarr_json = v05.OMEZarrGroupJSON(attributes={"ome": plate})
json_str = zarr_json.model_dump_json(indent=2)
Spec JSON (.zattrs at plate root):
{
"plate": {
"version": "0.4",
"name": "HCS Experiment",
"columns": [
{"name": "1"},
{"name": "2"},
{"name": "3"}
],
"rows": [
{"name": "A"},
{"name": "B"}
],
"wells": [
{"path": "A/1", "rowIndex": 0, "columnIndex": 0},
{"path": "A/2", "rowIndex": 0, "columnIndex": 1},
{"path": "B/1", "rowIndex": 1, "columnIndex": 0}
],
"acquisitions": [
{"id": 0, "name": "Initial", "maximumfieldcount": 4},
{"id": 1, "name": "24h", "maximumfieldcount": 4}
]
}
}
yaozarrs Code:
from yaozarrs import v04
plate_def = v04.PlateDef(
name="HCS Experiment",
columns=[v04.Column(name="1"), v04.Column(name="2"), v04.Column(name="3")],
rows=[v04.Row(name="A"), v04.Row(name="B")],
wells=[
v04.PlateWell(path="A/1", rowIndex=0, columnIndex=0),
v04.PlateWell(path="A/2", rowIndex=0, columnIndex=1),
v04.PlateWell(path="B/1", rowIndex=1, columnIndex=0),
],
acquisitions=[
v04.Acquisition(id=0, name="Initial", maximumfieldcount=4),
v04.Acquisition(id=1, name="24h", maximumfieldcount=4),
],
)
plate = v04.Plate(plate=plate_def)
Well Metadata#
Wells list the fields of view (images) they contain:
Spec JSON (zarr.json in well directory):
{
"zarr_format": 3,
"node_type": "group",
"attributes": {
"ome": {
"version": "0.6",
"well": {
"images": [
{"path": "0", "acquisition": 0},
{"path": "1", "acquisition": 0},
{"path": "2", "acquisition": 1}
]
}
}
}
}
yaozarrs Code:
from yaozarrs import v06
well_def = v06.WellDef(
images=[
v06.FieldOfView(path="0", acquisition=0),
v06.FieldOfView(path="1", acquisition=0),
v06.FieldOfView(path="2", acquisition=1),
]
)
well = v06.Well(well=well_def)
Field of view paths
A field of view's path MUST use only letters, digits, -, _
and ., and MUST NOT be empty, contain /, consist only of periods
(like . or ..), start with __, or repeat another path in the
well.
Spec JSON (zarr.json in well directory):
{
"zarr_format": 3,
"node_type": "group",
"attributes": {
"ome": {
"version": "0.5",
"well": {
"images": [
{"path": "0", "acquisition": 0},
{"path": "1", "acquisition": 0},
{"path": "2", "acquisition": 1}
]
}
}
}
}
yaozarrs Code:
from yaozarrs import v05
well_def = v05.WellDef(
images=[
v05.FieldOfView(path="0", acquisition=0),
v05.FieldOfView(path="1", acquisition=0),
v05.FieldOfView(path="2", acquisition=1),
]
)
well = v05.Well(well=well_def)
A field of view's path MUST be alphanumeric and unique within the well.
Spec JSON (.zattrs in well directory):
{
"well": {
"version": "0.4",
"images": [
{"path": "0", "acquisition": 0},
{"path": "1", "acquisition": 0},
{"path": "2", "acquisition": 1}
]
}
}
yaozarrs Code:
from yaozarrs import v04
well_def = v04.WellDef(
images=[
v04.FieldOfView(path="0", acquisition=0),
v04.FieldOfView(path="1", acquisition=0),
v04.FieldOfView(path="2", acquisition=1),
]
)
well = v04.Well(well=well_def)
A field of view's path MUST be alphanumeric and unique within the well.
| Field | Requirement | Description |
|---|---|---|
images |
MUST | List of field of view objects |
images[].path |
MUST | Path to image group |
images[].acquisition |
MUST (if multiple acquisitions exist) | Links to plate acquisition ID |
Interactive Example#
Modify the parameters below to see how different image configurations are represented in OME-Zarr:
Working with Collections#
OME-Zarr does not currently have an official specification for collections of images.
By Collections of images, we mean groups of related images, usually sharing a coordinate space, that do not fit into the plate model. Examples include:
- Multiple stage positions on single coverslip
- Multiple angles in light sheet microscopy
- Tomographic tilt series
- Jagged or otherwise irregular sets of related images that don't fit the multiscales model
Status
There is a long-standing github issue that discusses potential future standards for collections, and RFC-8, which covers this topic (still under review). But as of v0.6, there is no official spec for collections.
v0.6 does add scenes, which cover one common case: images that share a spatial relationship.
The "bioformats2raw"
layout is a
transitional solution, internally employed by the
bioformats2raw tool when
dumping multiple series (commonly found in image formats supported by
bioformats) into a single zarr hierarchy.
This bioformats2raw layout described in the NGFF spec, is described below:
Directory Structure#
series.ome.zarr # One converted fileset from bioformats2raw
├── zarr.json # Contains "bioformats2raw.layout" metadata
├── OME # Special group for containing OME metadata
│ ├── zarr.json # Contains "series" metadata
│ └── METADATA.ome.xml # OME-XML file stored within the Zarr fileset
├── 0 # First image in the collection
├── 1 # Second image in the collection
└── ...
series.ome.zarr # One converted fileset from bioformats2raw
├── zarr.json # Contains "bioformats2raw.layout" metadata
├── OME # Special group for containing OME metadata
│ ├── zarr.json # Contains "series" metadata
│ └── METADATA.ome.xml # OME-XML file stored within the Zarr fileset
├── 0 # First image in the collection
├── 1 # Second image in the collection
└── ...
series.ome.zarr # One converted fileset from bioformats2raw
├── .zgroup
├── .zattrs # Contains "bioformats2raw.layout" metadata
├── OME # Special group for containing OME metadata
│ ├── .zgroup
│ ├── .zattrs # Contains "series" metadata
│ └── METADATA.ome.xml # OME-XML file stored within the Zarr fileset
├── 0 # First image in the collection
├── 1 # Second image in the collection
└── ...
Metadata#
Unchanged from v0.5 (it's still transitional).
yaozarrs Code:
from yaozarrs import v06
# Root zarr.json
root_zarr_json = v06.OMEZarrGroupJSON(attributes={"ome": v06.Bf2Raw()})
# OME/zarr.json
ome_zarr_json = v06.OMEZarrGroupJSON(
attributes={"ome": v06.Series(series=["0", "1", "2", "3"])}
)
yaozarrs Code:
from yaozarrs import v05
# Root zarr.json
root_zarr_json = v05.OMEZarrGroupJSON(attributes={"ome": v05.Bf2Raw()})
# OME/zarr.json
ome_zarr_json = v05.OMEZarrGroupJSON(
attributes={"ome": v05.Series(series=["0", "1", "2", "3"])}
)
Spec JSON (.zattrs at root):
{
"bioformats2raw.layout": 3
}
yaozarrs Code:
from yaozarrs import v04
# Root .zattrs
bf2raw = v04.Bf2Raw() # layout defaults to 3
# OME/.zattrs
series = v04.Series(series=["0", "1", "2", "3"])
Image Location Rules
- If
platemetadata exists → use plate structure - If
seriesattribute exists in theOMEgroup → paths must match OME-XML Image element order - Otherwise → consecutively numbered groups:
0/,1/,2/...
yaozarrs.bioformats2raw_series applies these rules for you, and returns the
image paths in series order:
from yaozarrs import bioformats2raw_series, open_group
root = open_group("path/to/collection.ome.zarr")
paths = bioformats2raw_series(root)
root.prefetch_children(paths) # (1)!
images = {path: root[path].ome_metadata() for path in paths}
ZarrGroup.prefetch_childrenfetches the metadata of all the images at once (in one batch, on remote stores).
Working with Scenes#
A Scene (v0.6 and later) is a group of images that share a spatial relationship with each other. For example:
- Tiles of a mosaic, placed side by side in a common "stage" coordinate system
- The same sample imaged from several angles (e.g. multiview light sheet)
- Images from different instruments (or modalities), registered onto each other
A scene group's zarr.json holds scene metadata, describing transformations
between the coordinate systems of its images, and each image is a normal
multiscale image group inside it.
Directory Structure#
mosaic.zarr/
├── zarr.json # contains Scene metadata ("attributes.ome.scene")
├── tile_0/ # a normal multiscale image
│ ├── zarr.json # contains Image metadata ("attributes.ome.multiscales")
│ ├── 0/ # Full resolution
│ └── labels/ # Optional labels group
├── tile_1/ # another multiscale image
│ └── ...
└── coordinateTransformations/ # (optional) transformation parameters stored in Zarr
Scene Metadata#
The scene object MUST contain coordinateTransformations, and MAY
contain coordinateSystems of its own. Here, two tiles are placed in a shared
stage coordinate system, defined by the scene:
Spec JSON (zarr.json at the scene root):
{
"zarr_format": 3,
"node_type": "group",
"attributes": {
"ome": {
"version": "0.6",
"scene": {
"coordinateSystems": [
{
"name": "stage",
"axes": [
{"name": "y", "type": "space", "unit": "micrometer"},
{"name": "x", "type": "space", "unit": "micrometer"}
]
}
],
"coordinateTransformations": [
{
"type": "translation",
"translation": [0.0, 0.0],
"input": {"path": "tile_0", "name": "physical"},
"output": {"name": "stage"}
},
{
"type": "translation",
"translation": [0.0, 270.0],
"input": {"path": "tile_1", "name": "physical"},
"output": {"name": "stage"}
}
]
}
}
}
}
Each input and output MUST refer to a coordinate system by name:
- With a
path(required for an image's coordinate system), it's a coordinate system of the image at thatpath(relative to the scene group). Here,physicalis the intrinsic coordinate system of each tile. - Without a
path, it's one of the scene's owncoordinateSystems(here,stage).
The second transformation says "a point in tile_1's physical coordinates,
shifted by 270 µm along x, is that point's position on the stage". (The tiles
below are 300 µm wide, so they overlap by 30 µm.)
yaozarrs Code:
from yaozarrs import v06
stage = v06.CoordinateSystem(
name="stage",
axes=[
v06.Axis(name="y", type="space", unit="micrometer"),
v06.Axis(name="x", type="space", unit="micrometer"),
],
)
scene = v06.Scene(
scene=v06.SceneDef(
coordinateSystems=[stage],
coordinateTransformations=[
v06.TranslationTransformation(
translation=[0.0, 270.0 * i],
input={"path": f"tile_{i}", "name": "physical"},
output={"name": "stage"},
)
for i in range(2)
],
)
)
Writing it (with data)
write_scene writes the scene group and
all of its images at once, after checking that the scene and the images fit
together:
import numpy as np
from yaozarrs import DimSpec, v06
from yaozarrs.write.v06 import write_scene
# each tile is 600x600 pixels, at 0.5 µm per pixel (300 µm wide)
tile = v06.Image(
multiscales=[
v06.Multiscale.from_dims(
[
DimSpec(name="y", scale=0.5, unit="micrometer"),
DimSpec(name="x", scale=0.5, unit="micrometer"),
],
coordinate_system="physical",
)
]
)
data = np.zeros((600, 600), dtype=np.uint16)
write_scene("mosaic.zarr", scene, {"tile_0": (tile, data), "tile_1": (tile, data)})
For bigger scenes (or to write data piece by piece), see
SceneBuilder.
Scene rules
All of the coordinate systems (the scene's and its images') MUST be connected by transformations.
Default coordinate system
If a viewer picks a default coordinate system to display a scene in, the
spec RECOMMENDS the first of the scene's own coordinateSystems. Likewise, when
writing a scene, if one coordinate system acts as the common reference for
the others (like stage above), put it first.
Linking images directly
A transformation may also link one image directly to another (both with a
path), with no scene coordinate system in between, e.g. for registration,
mapping a "moving" image onto a "fixed" one:
{
"type": "affine",
"affine": [[...], [...], [...]], // a 3x4 matrix, for 3D images
"input": {"path": "moving_image", "name": "physical"},
"output": {"path": "fixed_image", "name": "physical"}
}
Where do large transformation parameters go?
Some transformations store their parameters in Zarr: an affine or
rotation matrix can (instead of inline JSON), and the vector field of a
displacements or coordinates transformation (e.g. for non-rigid
registration) must, as a multiscale image group. In a scene, those
SHOULD be stored in a group called coordinateTransformations, next to
the images.
Reference#
Version Comparison Matrix#
| Feature | v0.4 | v0.5 | v0.6 |
|---|---|---|---|
| Zarr version | v2 | v3 | v3 |
| Axes format | Objects | Objects | Objects, in named coordinate systems |
| Transformation types | identity, scale, translation | identity, scale, translation | 12 types |
| Metadata location | .zattrs |
zarr.json |
zarr.json |
| OME namespace | N/A | attributes.ome |
attributes.ome |
dimension_names |
N/A | MUST | Not required |
| Scenes | N/A | N/A | Yes |
What changed in each version#
| Version | Main changes |
|---|---|
| v0.5 | Zarr v3: metadata moves to zarr.json, under attributes.ome |
| v0.6 | Axes move into named coordinate systems, transformations get an explicit input/output, many more transformation types, and scenes (RFC-5) |
To convert metadata models between v0.4, v0.5 and v0.6, see
yaozarrs.convert_version.
Additional Resources#
- OME-Zarr Specification - Official specification
- yaozarrs API Documentation - Complete API reference
- Zarr Format Specification - Zarr v2 and v3 specs
- OME Data Model - Full OME-XML specification
- GitHub Repository - Source code and issues
You're ready!
You now understand the OME-Zarr specification and how to work with it using yaozarrs. Happy imaging!