ngff_zarr.v09.zarr_metadata¶
OME-Zarr 0.9.dev1 metadata model (RFC-3).
0.9.dev1 is OME-Zarr 0.6 plus RFC-3: an image may declare any number of
axes, with any names, any type strings, and in any order. The RFC-5
coordinate-system and transformation model of 0.6 is unchanged.
The dataclasses here carry no version condition. The axis restrictions live in
- mod:
ngff_zarr.structural_validationand are applied against the target version by the writer.
This module defines :class:Axis, :class:CoordinateSystem and
- class:
Metadata; every other symbol is re-exported from- mod:
ngff_zarr.v06.zarr_metadata.
Module Contents¶
Classes¶
An RFC-3 axis. |
|
A named set of RFC-3 axes. |
|
OME-Zarr |
Functions¶
Valid field names of :class: |
|
Filter an axis dict down to the recognized :class: |
|
Re-instantiate any version’s axis object as a v0.9.dev1 :class: |
Data¶
API¶
- ngff_zarr.v09.zarr_metadata.__all__¶
[‘Affine’, ‘Axis’, ‘BaseTransform’, ‘CoordinateSystem’, ‘CoordinateSystemIdentifier’, ‘Coordinates’,…
- ngff_zarr.v09.zarr_metadata.logger¶
‘getLogger(…)’
- ngff_zarr.v09.zarr_metadata.AxisName¶
None
- ngff_zarr.v09.zarr_metadata.AxesType¶
None
- class ngff_zarr.v09.zarr_metadata.Axis¶
An RFC-3 axis.
Same fields as :class:
ngff_zarr.v06.zarr_metadata.Axis, withname,typeandunitwidened: each keeps the spec-defined vocabulary in a union with the free-form string RFC-3 allows.orientation(RFC-4) anddiscrete(RFC-5) are carried so a 0.6 document round-trips without loss.- name: ngff_zarr.v09.zarr_metadata.AxisName¶
None
- type: ngff_zarr.v09.zarr_metadata.AxesType¶
None
- orientation: ngff_zarr.rfc4.AnatomicalOrientation | None¶
None
- class ngff_zarr.v09.zarr_metadata.CoordinateSystem¶
A named set of RFC-3 axes.
- axes: list[ngff_zarr.v09.zarr_metadata.Axis]¶
None
- ngff_zarr.v09.zarr_metadata._filter_axis_dict(axis_dict: dict) dict¶
Filter an axis dict down to the recognized :class:
Axisfields.Unknown keys are logged and dropped. The 0.6 axes schema permits keys this dataclass does not declare, such as
longName.Raises
ValueError If the required
namekey is absent.
- ngff_zarr.v09.zarr_metadata._axis_from(axis: object) ngff_zarr.v09.zarr_metadata.Axis¶
Re-instantiate any version’s axis object as a v0.9.dev1 :class:
Axis.discreteis read with :func:getattr:v06.Metadata._from_v05assigns the v0.5 axis list straight into aCoordinateSystem, so a v0.6Metadatareached from a 0.4/0.5 store holds v0.4Axisinstances, which have nodiscretefield.
- class ngff_zarr.v09.zarr_metadata.Metadata¶
OME-Zarr
0.9.dev1multiscales metadata.Same fields as :class:
ngff_zarr.v06.zarr_metadata.Metadata. It carriescoordinateSystems, not the flataxeslist of v0.4/v0.5, so the v0.6 <-> 0.9.dev1 hop is a lossless structural copy; routing through v0.5 would drop every rotation, affine, coordinates and displacements transform.There is no
versionfield, as in v0.5 and v0.6. From v0.5 on the spec version lives in the group-levelomenamespace, written byto_ngff_zarr._write_root_ome_attrsfrom the writer’sversionargument. A field here would be emitted byasdictinside themultiscales[]entry, which theome-namespacerule rejects.- coordinateSystems: list[ngff_zarr.v09.zarr_metadata.CoordinateSystem]¶
None
- datasets: list[ngff_zarr.v06.zarr_metadata.Dataset]¶
None
- __post_init__()¶
On-the-fly validation not well covered by the JSON schemas.
- property intrinsic_coordinate_system: ngff_zarr.v09.zarr_metadata.CoordinateSystem¶
- property axes: list[ngff_zarr.v09.zarr_metadata.Axis]¶
The intrinsic coordinate system’s axes.
A property, not a field, so
dataclasses.asdictanddataclasses.fieldsignore it and the serialized entry is unchanged. The axis rules in :mod:ngff_zarr.structural_validationreadmetadata.axes.
- to_version(
- version: Union[str, ngff_zarr._supported_versions.NgffVersion],
- classmethod from_version(
- metadata: Union[ngff_zarr.v09.zarr_metadata.Metadata, ngff_zarr.v04.zarr_metadata.Metadata, ngff_zarr.v05.zarr_metadata.Metadata, ngff_zarr.v06.zarr_metadata.Metadata],
- _to_v06() ngff_zarr.v06.zarr_metadata.Metadata¶
Structurally map to v0.6, re-instantiating every axis.
This does not enforce the v0.6 axis restrictions; the writer applies them against the target version. This converter is also used on the way to v0.5 and v0.4.
- classmethod _from_v06(
- metadata_v06: ngff_zarr.v06.zarr_metadata.Metadata,
Structurally map from v0.6, re-instantiating every axis.
v06.Metadata._from_v05assigns the v0.5 axis list straight intoCoordinateSystem.axes, so a v0.6Metadatareached from a 0.4/0.5 store holds v0.4Axisobjects, in the same list object. Aliasing them would share mutable state with the source, drop fields underdataclasses.asdict(which walks the runtime class), and break equality, which dataclasses compare class-exact.
- classmethod _from_zarr_attrs(
- root_attrs: dict,
- store: ngff_zarr._store_types.StoreLike,
- validate: bool = False,
- subpath: str | None = None,
Read a
0.9.dev1store.Dataset transform parsing and
NgffImageconstruction are delegated to the v0.6 reader. Handled here first:validate=Trueruns the schema pass against the bundledspec/0.9tree, which holds the schemas of the0.9.dev1release. The delegate then runs withvalidate=False: it would otherwise measure the document against the schemas of its own version.A 0.5-shaped entry (flat
axes, nocoordinateSystems) is normalized to a singleintrinsiccoordinate system, so either shape is readable.Unknown axis keys are stripped; the v0.6 reader builds axes with a bare
Axis(**axis).