Skip to content

Image Stack Loader

Source

Image stack protocol, implementations and loading utilities.

ImageStackLoader

Bases: Protocol[P, GenericImageStack]

Protocol to define how ImageStacks are loaded from a source.

An ImageStackLoader is a callable that must take the source of the data as the first argument, and the data axes as the second argument.

Additional *args and **kwargs are allowed, but they should only be used to determine how the data is loaded, not what data is loaded. The source argument has to wholly determine what data is loaded, this is because, downstream, both an input-source and a target-source have to be specified but they will share *args and **kwargs.

An ImageStackLoader must return a sequence of the ImageStack class. This could be a sequence of one of the existing concrete implementations, such as ZarrImageStack, or a custom user defined ImageStack.

__call__(source, axes, *args, **kwargs)

Load ImageStacks from a source.

Parameters:

  • source (Any) –

    Data source (paths, store, etc.).

  • axes (str) –

    Axis order (e.g. "SYX", "SCZYX").

  • *args (args, default: () ) –

    Additional positional arguments for loading.

  • **kwargs (kwargs, default: {} ) –

    Additional keyword arguments for loading.

Returns:

  • Sequence[GenericImageStack]

    The loaded ImageStacks.

load_arrays(source, axes)

Load ImageStacks from a sequence of numpy arrays.

Parameters:

  • source (sequence of numpy.ndarray) –

    Source arrays of the data.

  • axes (str) –

    Original axes of the data, must be a subset of "STCZYX".

Returns:

load_custom_file(source, axes, *, read_func, read_kwargs)

Load ImageStacks from a sequence of files of a custom type.

Parameters:

  • source (sequence of Path) –

    Source files for the data.

  • axes (str) –

    Original axes of the data, must be a subset of "STCZYX".

  • read_func (ReadFunc) –

    A function to read the custom file type, see the ReadFunc protocol.

  • read_kwargs (dict of {str: Any}) –

    Additional arguments passed to the custom read_func.

Returns:

load_czis(source, axes)

Load CZI image stacks from a sequence of CZI files paths.

If the CZI files contain multiple scenes, one image stack will be created for each scene.

Axes should be in the format "SC(Z/T)YX", where Z or T are optional, and S and C can be singleton dimensions, but must be provided.

Parameters:

  • source (sequence of Path) –

    Source files for the data.

  • axes (str) –

    Axes of the data, must be either "SCYX", "SCZYX" or "SCTYX". Depth axis is inferred from the axes string. If this string ends with "ZYX" or "TYX", the data will consist of 3-D.

Returns:

Raises:

  • ValueError

    If the provided axes are not valid.

load_iter_tiff(source, axes)

Load image stacks from a sequence of TIFF files.

Parameters:

  • source (sequence of Path) –

    Source files for the data.

  • axes (str) –

    Original axes of the data, must be a subset of "STCZYX".

Returns:

load_tiffs(source, axes)

Load ImageStacks from a sequence of TIFF files.

Parameters:

  • source (sequence of Path) –

    Source files for the data.

  • axes (str) –

    Original axes of the data, must be a subset of "STCZYX".

Returns:

load_zarrs(source, axes)

Create a list of ZarrImageStack from a sequence of zarr file paths or URIs.

File paths must point to a zarr store (ending with .zarr) and URIs must be in the format "file://path/to/zarr_store.zarr/group/path/array_name".

If the zarr file is an OME-Zarr, the specified multiscale level will be used. Note that OME-Zarrs are only supported when providing a path to the zarr store, not when using a file URI. One can, however, provide a file URI to the specific resolution array within the OME-Zarr.

Parameters:

  • source (sequence of str or Path) –

    Source zarr file paths or URIs.

  • axes (str) –

    Original axes of the data, must be a subset of "STCZYX".

Returns:

  • list of ZarrImageStack

    A list of ZarrImageStack created from the sources.