File Image Stack
ImageStack implementation for file-backed data.
FileImageStack
ImageStack implementation for file-backed data.
This implementation is aimed at representing a single file from a set of multi-file datasets, where the entire dataset cannot be loaded into memory at once.
Parameters:
-
source(Path) –Path to the file.
-
axes(str) –Axis order (e.g. STCZYX).
-
data_shape(tuple of int) –Shape in SC(Z)YX order.
-
data_dtype(DTypeLike) –Type of the data.
-
read_func(ReadFunc) –Function to read the file into an array.
-
read_kwargs(dict or Any, default:None) –Extra keyword arguments for
read_func. -
original_data_shape(tuple of int or None, default:None) –Shape in original axis order.
Notes
The data will not be loaded until the load method is called. The close
method can be used to remove the internal reference to the data.
is_loaded
property
True if the file has been loaded into memory.
Returns:
-
bool–True if the file has been loaded into memory, False otherwise.
original_axes
property
original_data_shape
property
Original shape of the data.
Returns:
-
tuple of int–Shape in original axis order.
__init__(source, axes, data_shape, data_dtype, read_func, read_kwargs=None, original_data_shape=None)
Constructor.
This implementation is aimed at representing a single file from a set of
multi-file datasets, where the entire dataset cannot be loaded into memory at
once. The data is therefore only loaded when the load method is called, and
internal reference is deleted upon calling the close method.
Parameters:
-
source(Path) –Path to the file.
-
axes(str) –Axis order (e.g. STCZYX).
-
data_shape(tuple of int) –Shape in SC(Z)YX order after transformation.
-
data_dtype(DTypeLike) –Type of the data.
-
read_func(ReadFunc) –Function to read the file into an array.
-
read_kwargs(dict or Any, default:None) –Extra keyword arguments passed to
read_func. -
original_data_shape(tuple of int or None, default:None) –Shape in original axis order before transformation.
close()
Remove the internal reference to the data to clear up memory.
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_tiff(path, axes)
classmethod
load()
Load the data stored in a file.