abczarr.ome.config
Describes an OME-Zarr multiscale image to write.
An ImageConfig is to OME-Zarr metadata what an ArrayConfig is to a Zarr array: a high-level, human-facing description that lowers to the exact typed metadata a group carries. It holds the axes, the voxel geometry, and how the pyramid was built, and produces OME-NGFF multiscales metadata for any requested version.
Three coordinate spaces sit behind the config::
voxel (array index) --scale+translation--> intrinsic --transforms--> model
scale and translation place each resolution level's array indices
into a single intrinsic space shared by every level. transforms
(or the voxel_to_world shortcut) map that intrinsic space onto a
model space, a world or anatomical frame. One config lowers to both
the stable 0.5 shape and the 0.6 preview.
Classes
ImageConfig
ImageConfig(axes: Sequence[str | Mapping[str, Any] | Sequence[Any] | Axis] | Mapping[str, Any], scale: float | int | Sequence[float] | Mapping[str, float] | None = None, translation: float | int | Sequence[float] | Mapping[str, float] | None = None, intrinsic_name: str = 'intrinsic', model_name: str = 'model', transforms: Sequence[Any] | Mapping[str | tuple[str, str], Any] = (), voxel_to_world: Any = None, name: str | None = None, ome_version: str = 'stable', factor: float | int | Sequence[float] | Mapping[str, float] = 2, strategy: str | int = 'edge')
A high-level description of an OME-Zarr multiscale image.
The axes and the voxel geometry are set once. The config then lowers to typed OME metadata for any version through to_ome, producing both the stable 0.5 shape and the 0.6 preview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axes
|
sequence or mapping
|
The array's axes, one per dimension. A sequence lists each axis as a
name ( |
required |
scale
|
number, sequence, or mapping
|
The voxel-to-intrinsic diagonal scale (physical size of one voxel). One value for all axes, a value per axis, or a mapping keyed by axis name or type (name wins). Defaults to 1. |
None
|
translation
|
number, sequence, or mapping
|
The voxel-to-intrinsic translation, same shapes as |
None
|
intrinsic_name
|
str
|
The name of the intrinsic coordinate system every level maps into. |
'intrinsic'
|
model_name
|
str
|
The default name of the model system the |
'model'
|
transforms
|
sequence or mapping
|
The transforms from the intrinsic system to a model system. A
sequence lists each transform as a numpy affine matrix, which maps
the intrinsic system to |
()
|
voxel_to_world
|
array - like or CoordinateTransformation
|
A shortcut for images with a single voxel-to-world affine, in
place of separate |
None
|
name
|
str
|
The multiscale's name. |
None
|
ome_version
|
str
|
The version to lower to: |
'stable'
|
factor
|
number, sequence, or mapping
|
The per-axis downsampling factor between levels, same shapes as
|
2
|
strategy
|
(edge, center, window)
|
How a level's placement is worked out from the downsampling.
The |
"edge"
|
Attributes
Methods:
resolved_version
The concrete OME version this config lowers to.
The method resolves version, or ome_version when
version is None. "stable" is the latest released
version, "latest" is the newest version including
previews, and any other value is taken as an explicit
version string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
An override for |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The resolved version string. |
to_ome
to_ome(*, version: str | None = None, policy: ConversionPolicy = 'warn', level_shapes: Sequence[Sequence[int]] | None = None, level_paths: Sequence[str] | None = None) -> OME
Lowers this config to typed OME-Zarr metadata.
The result carries the intrinsic and model coordinate systems, one dataset per resolution level mapping the array onto the intrinsic system, and the intrinsic-to-model transforms, all for the resolved version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
An override for |
None
|
policy
|
(lossy, warn, strict)
|
How to treat information an older target version cannot hold.
|
"lossy"
|
level_shapes
|
sequence of shape
|
The array shape of each resolution level, finest first. Required
by the |
None
|
level_paths
|
sequence of str
|
The array path of each level. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
OME
|
The typed metadata for the resolved version, ready to assign to a group's ome. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a per-axis quantity does not match the axes, or a strategy is asked for more levels than it can build without shapes. |
apply
Sets a group's OME metadata from this config.
The metadata is produced by lowering the config with
to_ome, and the
result is assigned to group's
ome. Keyword arguments are
passed through to to_ome.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
ZarrNode
|
The group to write the metadata to. |
required |
**kwargs
|
Any
|
Passed through to to_ome. |
{}
|
Returns:
| Type | Description |
|---|---|
OME
|
The metadata that was written. |
Functions:
axis
Builds a 0.6 Axis from a name.
The axis type is inferred from name when not given: x, y,
and z are space, t is time, c is channel, and anything
else is space. A known type gives back the matching axis subclass, a
SpaceAxis and so on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The axis name, such as |
required |
type
|
str
|
The axis type. Inferred from |
None
|
unit
|
str
|
The axis's physical unit, such as |
None
|
Returns:
| Type | Description |
|---|---|
Axis
|
The typed axis. |
!!! example
|