dcnum.read.cache

Exceptions

EmptyDatasetWarning

Initialize self. See help(type(self)) for accurate signature.

Classes

BaseImageChunkCache

Helper class that provides a standard way to create an ABC using

HDF5ImageCache

An HDF5 image cache

ImageCorrCache

Helper class that provides a standard way to create an ABC using

Functions

md5sum(path[, blocksize, count])

Compute (partial) MD5 sum of a file

Module Contents

exception dcnum.read.cache.EmptyDatasetWarning[source]

Bases: UserWarning

Initialize self. See help(type(self)) for accurate signature.

class dcnum.read.cache.BaseImageChunkCache(shape: tuple[int], chunk_size: int = 1000, cache_size: int = 2)[source]

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

shape
_dtype = None
_len
cache

This is a FILO cache for the chunks

image_shape
chunk_shape
chunk_size
cache_size = 2
num_chunks
__getitem__(index)[source]
__len__()[source]
property dtype

data type of the image data

abstractmethod _get_chunk_data(chunk_slice)[source]

Implemented in subclass to obtain actual data

_get_chunk_index_for_index(index)[source]
get_chunk(chunk_index)[source]

Return one chunk of images

get_chunk_size(chunk_index)[source]

Return the number of images in this chunk

get_chunk_slice(chunk_index)[source]

Return the slice corresponding to the chunk index

iter_chunks()[source]
class dcnum.read.cache.HDF5ImageCache(h5ds: dcnum.common.h5py.Dataset | dcnum.read.mapped.MappedHDF5Dataset, chunk_size: int = 1000, cache_size: int = 2, boolean: bool = False)[source]

Bases: BaseImageChunkCache

An HDF5 image cache

Deformability cytometry data files commonly contain image stacks that are chunked in various ways. Loading just a single image can be time-consuming, because an entire HDF5 chunk has to be loaded, decompressed and from that one image extracted. The HDF5ImageCache class caches the chunks from the HDF5 files into memory, making single-image-access very fast.

h5ds
boolean = False
_get_chunk_data(chunk_slice)[source]

Implemented in subclass to obtain actual data

class dcnum.read.cache.ImageCorrCache(image: HDF5ImageCache, image_bg: HDF5ImageCache)[source]

Bases: BaseImageChunkCache

Helper class that provides a standard way to create an ABC using inheritance.

image
image_bg
_get_chunk_data(chunk_slice)[source]

Implemented in subclass to obtain actual data

dcnum.read.cache.md5sum(path, blocksize=65536, count=0)[source]

Compute (partial) MD5 sum of a file

Parameters:
  • path (str or pathlib.Path) – path to the file

  • blocksize (int) – block size in bytes read from the file (set to 0 to hash the entire file)

  • count (int) – number of blocks read from the file