Multiscale
multiscale_metadata #
multiscale_metadata(arrays, name=None, type=None, metadata=None, normalize_units=True, infer_axis_type=True, transform_precision=None)
Create version 0.4 OME-NGFF multiscales
metadata from a dict of xarray.DataArrays.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arrays |
dict[str, DataArray]
|
The values of this |
required |
name |
str | None
|
The name of the multiscale collection. Used to populate the 'name' field of Multiscale metadata. |
None
|
type |
str | None
|
The type of the multiscale collection. Used to populate the 'type' field of Multiscale metadata. |
None
|
metadata |
Dict[str, Any] | None
|
Additional metadata associated with this multiscale collection. Used to populate the 'metadata' field of Multiscale metadata. |
None
|
normalize_units |
bool
|
Whether to normalize units to standard names, e.g. 'nm' -> 'nanometer' |
True
|
infer_axis_type |
bool
|
Whether to infer the |
True
|
transform_precision |
int | None
|
Whether, and how much, to round the transformations estimated from the coordinates.
The default ( |
None
|
Returns:
Type | Description |
---|---|
`MultiscaleMetadata`
|
|
Source code in src/xarray_ome_ngff/v04/multiscale.py
transforms_from_coords #
transforms_from_coords(coords, normalize_units=True, infer_axis_type=True, transform_precision=None)
Generate Axes and CoordinateTransformations from the coordinates of an xarray.DataArray.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords |
dict[str, DataArray]
|
A dict of DataArray coordinates. Scale and translation transform parameters are inferred from the coordinate data, per dimension. Note that no effort is made to ensure that the coordinates represent a regular grid. Axis types are inferred by querying the attributes of each coordinate for the 'type' key. Axis units are inferred by querying the attributes of each coordinate for the 'unit' key, and if that key is not present then the 'units' key is queried. Axis names are inferred from the dimension of each coordinate array. |
required |
normalize_units |
bool
|
If True, unit strings will be normalized to a canonical representation using the
|
True
|
infer_axis_type |
bool
|
Whether to infer the axis type from the units. This will have no effect if the array has 'type' in its attrs. |
True
|
transform_precision |
int | None
|
Whether, and how much, to round the transformations estimated from the coordinates.
The default ( |
None
|
Returns:
Type | Description |
---|---|
tuple[tuple[Axis, ...], tuple[VectorScale, VectorTranslation]]
|
A tuple containing a tuple of |
Source code in src/xarray_ome_ngff/v04/multiscale.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
coords_from_transforms #
Given an output shape, convert a sequence of Axis objects and a corresponding sequence of coordinateTransform objects into xarray-compatible coordinates.
Source code in src/xarray_ome_ngff/v04/multiscale.py
model_multiscale_group #
model_multiscale_group(*, arrays, transform_precision=None, chunks='auto', compressor=DEFAULT_COMPRESSOR, fill_value=0)
Create a model of an OME-NGFF multiscale group from a dict of xarray.DataArray
.
The dimensions / coordinates of the arrays will be used to infer OME-NGFF axis metadata, as well
as the OME-NGFF coordinate transformation metadata (i.e., scaling and translation).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arrays |
dict[str, DataArray]
|
A mapping from strings to |
required |
transform_precision |
int | None
|
Whether, and how much, to round the transformations estimated from the coordinates.
The default ( |
None
|
chunks |
tuple[int, ...] | tuple[tuple[int, ...]] | Literal['auto']
|
The chunks for the arrays in the multiscale group. If the string "auto" is provided, each array will have chunks set to the zarr-python default value, which depends on the shape and dtype of the array. If a single sequence of ints is provided, then this defines the chunks for all arrays. If a sequence of sequences of ints is provided, then this defines the chunks for each array. |
'auto'
|
compressor |
Codec | None
|
The compressor to use for the arrays. Default is |
DEFAULT_COMPRESSOR
|
fill_value |
Any
|
The fill value for the Zarr arrays. |
0
|
Source code in src/xarray_ome_ngff/v04/multiscale.py
create_multiscale_group #
create_multiscale_group(*, store, path, arrays, transform_precision=None, chunks='auto', compressor=DEFAULT_COMPRESSOR, fill_value=0, overwrite=False)
Create Zarr group that complies with 0.4 of the OME-NGFF multiscale specification from a dict
of xarray.DataArray
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
store |
BaseStore
|
The storage backend for the Zarr hierarchy. |
required |
path |
str
|
The path in the storage backend for the multiscale group. |
required |
transform_precision |
int | None
|
Whether, and how much, to round the transformations estimated from the coordinates.
The default ( |
None
|
compressor |
Codec | None
|
The compressor to use for the arrays. Default is |
DEFAULT_COMPRESSOR
|
fill_value |
Any
|
The fill value for the Zarr arrays. |
0
|
overwrite |
bool
|
Whether to overwrite an existing Zarr array or group at |
False
|
Source code in src/xarray_ome_ngff/v04/multiscale.py
read_multiscale_group #
Create a dictionary of xarray.DataArray
from a Zarr group that implements version 0.4 of the
OME-NGFF multiscale image specification.
The keys of the dictionary are the paths to the Zarr arrays. The values of the dictionary are
xarray.DataArray
objects, one per Zarr array described in the OME-NGFF multiscale metadata,
with dimensions and coordinates that are consistent with the OME-NGFF Axes
and
coordinateTransformations
metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
Group
|
A handle for the Zarr group that contains the |
required |
array_wrapper |
ZarrArrayWrapper | DaskArrayWrapper | ArrayWrapperSpec
|
Either an object that implements |
ZarrArrayWrapper()
|
multiscales_index |
int
|
Version 0.4 of the OME-NGFF multiscales spec states that multiscale metadata is stored in a JSON array within Zarr group attributes. This parameter determines which element from that array to use when defining DataArrays. |
0
|
Returns:
Type | Description |
---|---|
dict[str, DataArray]
|
|
Source code in src/xarray_ome_ngff/v04/multiscale.py
read_multiscale_array #
Read a single Zarr array as an xarray.DataArray
, using version 0.4 OME-NGFF multiscale
metadata.
The information necessary for creating the coordinates of the DataArray
are not stored
in the attributes of the Zarr array given to this function. Instead, the coordinates must
be inferred by walking up the Zarr hierarchy, group by group, until a Zarr group with attributes
containing OME-NGFF multiscales metadata is found; then that metadata is parsed to determine
whether that metadata references the provided array. Once the correct multiscales metadata is
found, the coordinates can be constructed correctly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array |
Array
|
A Zarr array that is part of a version 0.4 OME-NGFF multiscale image. |
required |
array_wrapper |
ZarrArrayWrapper | DaskArrayWrapper | ArrayWrapperSpec
|
The array wrapper class to use when converting the Zarr array to an |
ZarrArrayWrapper()
|
Returns:
Type | Description |
---|---|
DataArray
|
|