Skip to content

Abc

linc_convert.utils.io.zarr.abc

Abstract base classes for ZarrIO interfaces.

ZarrArrayConfig

Bases: TypedDict

Configuration for creating a Zarr Array.

ZarrNode

ZarrNode(store_path)

Bases: ABC

Base class for any Zarr-like object (group or array).

store_path property

store_path

Path to the Zarr store for this node.

attrs abstractmethod property

attrs

Access metadata/attributes for this node.

zarr_version abstractmethod property

zarr_version

Get the Zarr format version.

ZarrArray

ZarrArray(store_path)

Bases: ZarrNode

Abstract interface for a Zarr array (n-dimensional data).

ndim abstractmethod property

ndim

Number of dimensions of the array.

shape abstractmethod property

shape

Shape of the array.

dtype abstractmethod property

dtype

Data type of the array.

chunks abstractmethod property

chunks

Chunk shape for the array.

shards abstractmethod property

shards

Shard shape, if supported; otherwise None.

__getitem__ abstractmethod

__getitem__(key)

Read data from the array.

__setitem__ abstractmethod

__setitem__(key, value)

Write data to the array.

ZarrGroup

ZarrGroup(store_path)

Bases: ZarrNode

Abstract interface for a Zarr group (container of arrays/subgroups).

from_config abstractmethod classmethod

from_config(zarr_config)

Create a Zarr group from a configuration object.

__getitem__ abstractmethod

__getitem__(key)

Get a subgroup or array by name within this group.

__setitem__ abstractmethod

__setitem__(key, value)

Set a subgroup or array by name within this group.

__delitem__ abstractmethod

__delitem__(key)

Delete a subgroup or array by name within this group.

create_group abstractmethod

create_group(name, overwrite=False)

Create or open a subgroup within this group.

create_array abstractmethod

create_array(name, shape, dtype, *, zarr_config=None, **kwargs)

Create a new array within this group.

create_array_from_base abstractmethod

create_array_from_base(name, shape, data=None, **kwargs)

Create a new array using metadata of an existing base-level array.

generate_pyramid

generate_pyramid(levels=-1, ndim=3, mode='mean', no_pyramid_axis=None)

Generate the levels of a pyramid in an existing Zarr.

Parameters:

Name Type Description Default
levels int

Number of additional levels to generate. By default, stop when all dimensions are smaller than their corresponding chunk size.

-1
ndim int

Number of spatial dimensions.

3
mode (mean, median)

Function to be used for down-sampling, either a callable or mean or median.

"mean"
no_pyramid_axis int | None

Axis to leave unsampled.

None

Returns:

Name Type Description
shapes list[list[int]]

Shapes of each level, from finest to coarsest.

write_ome_metadata

write_ome_metadata(axes, space_scale=1.0, time_scale=1.0, space_unit='micrometer', time_unit='second', name='', pyramid_aligns=2, levels=None, no_pool=None, multiscales_type='', ome_version='0.4')

Write OME-compatible metadata into this group.

Parameters:

Name Type Description Default
axes list[str]

Name of each dimension, in Zarr order (t, c, z, y, x)

required
space_scale float | list[float]

Finest-level voxel size, in Zarr order (z, y, x)

1.0
time_scale float

Time scale

1.0
space_unit str

Unit of spatial scale (assumed identical across dimensions)

'micrometer'
time_unit str

Unit of timescale

'second'
name str

Name attribute

''
pyramid_aligns float | list[float] | {center, edge}

Whether the pyramid construction aligns the edges or the centers of the corner voxels. If a (list of) number, assume that a moving window of that size was used.

2
levels int

Number of existing levels. Default: find out automatically.

None
no_pool Optional[int]

Index of the spatial dimension that was not down-sampled when generating pyramid levels.

None
multiscales_type str

Override the type field in multiscale attribute.

''
ome_version Literal['0.4', '0.5']

Version of the OME-Zarr specification to use

'0.4'

Returns:

Type Description
None.

write_nifti_header

write_nifti_header(header)

Write a NIfTI header to the Zarr group.