ngff_zarr.declare_field_transform¶
Declare a field image as an RFC-5 displacements or coordinates transform.
A field store that only types its component axis is labelled, not applicable:
a reader sees what the channels are, but no transformation says between which
coordinate systems the field maps, so nothing can apply it. The declaration is
the displacements (or coordinates) entry on the multiscales’
coordinateTransformations; building it by hand means reaching into the
version metadata model and validating axis order, component count and system
references oneself. This function is that composition, validated, in one call.
Two layouts use it. A standalone field store – the artifact a registration
emits – declares the transform on its own multiscales, mapping a spatial
coordinate system onto itself through its own level-0 array; the default
arguments produce exactly that. A field written beside the image it displaces
declares the transform on the image’s multiscales instead, with path
naming the field’s array and input_system/output_system referencing
the image’s own coordinate systems.
Declared and written at 0.6, the store is applicable by this package’s own
reader: :func:~ngff_zarr.ngff_displacement_field_to_itk_transform rebuilds an
ITK transform from it with no other information.
Module Contents¶
Classes¶
Which RFC-5 field transformation a field image declares. |
Functions¶
Return |
|
The standalone checks – the multiscales is the field, so its shape is here to check: one component axis of the right type first, then the spatial axes, one component per spatial axis. Returns the spatial dims. |
|
The systems with a spatial one named |
Data¶
API¶
- class ngff_zarr.declare_field_transform.FieldTransformType¶
Bases:
enum.StrEnumWhich RFC-5 field transformation a field image declares.
Displacementsholds offsets from each point,Coordinatesthe output positions themselves. The members are the values, soFieldTransformType.Displacements == "displacements"and a plain string still passes.Initialization
Initialize self. See help(type(self)) for accurate signature.
- Displacements¶
‘displacements’
- Coordinates¶
‘coordinates’
- ngff_zarr.declare_field_transform._COMPONENT_TYPES¶
None
- ngff_zarr.declare_field_transform.declare_field_transform(
- multiscales: ngff_zarr.multiscales.NgffMultiscales,
- *,
- transform_type: ngff_zarr.declare_field_transform.FieldTransformType | str = FieldTransformType.Displacements,
- path: str | None = None,
- input_system: str | None = None,
- output_system: str | None = None,
- coordinate_system: str = 'physical',
- interpolation: str = 'linear',
Return
multiscaleswith the field transform declared on it.Functional and additive: the argument is not mutated, and the entry is appended to any
coordinateTransformationsalready declared. The result must be written at OME-Zarr 0.6 or later; earlier versions cannot carry multiscale-level transformations and :func:~ngff_zarr.to_ome_zarrrefuses them.- Parameters:
multiscales (NgffMultiscales) – The multiscales to declare the transform on: the field itself (standalone, the default), or the image the field displaces (with
pathnaming the field’s array).transform_type (FieldTransformType | str, optional) – Which field transformation the declaration is, as a :class:
FieldTransformTypemember or its string value:Displacements(the field holds offsets from each point) orCoordinates(it holds the output positions themselves). The choice fixes the component axis type the field must carry.path (str, optional) – The zarr path of the field’s array. Default: the multiscales’ own finest dataset – the standalone store. When given, the field is elsewhere and its shape cannot be checked here; the references still are.
input_system (str, optional) – Name of the declared coordinate system the transform maps from. Pass both
input_systemandoutput_system, or neither: with neither, a spatial system namedcoordinate_systemis declared from the field’s own axes and the transform maps it onto itself, which is the standalone total field.output_system (str, optional) – Name of the declared coordinate system the transform maps onto. See
input_system.coordinate_system (str, optional) – Name of the spatial coordinate system to declare when
input_system/output_systemare not given.interpolation (str, optional) – How a reader interpolates the field between grid points.
- Returns:
A new multiscales carrying the declaration.
- Return type:
- Raises:
ValueError – If the field’s axes are not one component axis of the type the transform calls for followed by the spatial axes, if it holds a number of components other than the number of spatial axes, if a named system is not declared, or if the entry does not validate against the systems it references.
- ngff_zarr.declare_field_transform._check_field_image(
- multiscales: ngff_zarr.multiscales.NgffMultiscales,
- component_type: str,
The standalone checks – the multiscales is the field, so its shape is here to check: one component axis of the right type first, then the spatial axes, one component per spatial axis. Returns the spatial dims.
- ngff_zarr.declare_field_transform._with_spatial_system(systems: list, name: str, spatial: list, units) list¶
The systems with a spatial one named
name, declared from the field’s own axes if absent; an existing one must already carry those axes in order, or the declaration would reference a system the field does not match.