Skip to content

Zarr Utils

Source

Zarr path and URI utilities for image stack loaders.

collect_arrays(zarr_group)

Collect all arrays in a Zarr group into a list.

Only run on the first level of the group.

Parameters:

  • zarr_group (Group) –

    The Zarr group to collect arrays from.

Returns:

  • listof str

    A list of Zarr arrays contained in the group as relative path to the group.

decipher_zarr_uri(source)

Extract the zarr store path, group path and array path from a zarr source.

The input string is expected to be in the format: file://path/to/zarr_store.zarr/group/path/array_name.

Note that the root folder of the zarr store must end with ".zarr".

Parameters:

  • source (str) –

    The zarr source string.

Returns:

  • str

    The path to the zarr store.

  • str

    The parent group within the zarr store, if it is not the root, else "".

  • str

    The group or array name the source is pointing to.

Raises:

  • ValueError

    If the source string does not start with "file://".

  • ValueError

    If the source string does not contain a ".zarr" file extension.

is_ome_zarr(zarr_group)

Check if a Zarr group is an OME-Zarr.

Parameters:

  • zarr_group (Group) –

    The Zarr group to check.

Returns:

  • bool

    True if the Zarr group is an OME-Zarr, False otherwise.

is_valid_uri(path)

Check if a path is a valid URI.

Parameters:

  • path (str | Path) –

    The path to check.

Returns:

  • bool

    True if the path is valid URI, False otherwise.