Skip to content

In Memory Image Stack

Source

ImageStack implementation for in-memory data.

InMemoryImageStack

ImageStack with data already loaded in memory.

Parameters:

  • source (Path or array) –

    Origin of the data, either a path to a file or the string "array" for numpy arrays.

  • data (ndarray) –

    Array with axes SC(Z)YX.

  • original_axes (str or None, default: None ) –

    Axis in original order.

  • original_data_shape (tuple of int or None, default: None ) –

    Shape in original axis order.

original_axes property

Original axes of the data.

Returns:

  • str

    Axis order string.

original_data_shape property

Original shape of the data.

Returns:

  • tuple of int

    Shape in original axis order.

__init__(source, data, original_axes=None, original_data_shape=None)

Constructor.

Parameters:

  • source (Path or array) –

    Origin of the data, either a path to a file or the string "array" for numpy arrays.

  • data (ndarray) –

    Array with axes SC(Z)YX.

  • original_axes (str or None, default: None ) –

    Axis in original order.

  • original_data_shape (tuple of int or None, default: None ) –

    Shape in original axis order.

extract_patch(sample_idx, channels, coords, patch_size)

Extract a patch for a given sample and channels within the image stack.

Parameters:

  • sample_idx (int) –

    Sample index.

  • channels (sequence of int or None) –

    Channel indices to extract. If None, all channels will be extracted.

  • coords (sequence of int) –

    Spatial coordinates of the top-left corner of the patch.

  • patch_size (sequence of int) –

    Size of the patch in each spatial dimension.

Returns:

  • ndarray

    A patch of the image data from a particular sample with dimensions C(Z)YX.

from_array(data, axes) classmethod

Construct an in-memory stack from an array.

Parameters:

  • data (ndarray) –

    Array (any axis order).

  • axes (str) –

    Axis order of the data.

Returns:

  • Self

    In-memory stack.

from_custom_file_type(path, axes, read_func, **read_kwargs) classmethod

Build an in-memory stack from a custom file type.

Parameters:

  • path (Path) –

    Path to file.

  • axes (str) –

    Axis order of the data.

  • read_func (ReadFunc) –

    Function to read the file.

  • **read_kwargs (Any, default: {} ) –

    Additional keyword arguments passed to read_func.

Returns:

  • Self

    In-memory stack.

from_tiff(path, axes) classmethod

Build an in-memory stack from a TIFF file.

Parameters:

  • path (Path) –

    Path to TIFF file.

  • axes (str) –

    Axis order of the data.

Returns:

  • Self

    In-memory stack.