dcnum.read.cache ================ .. py:module:: dcnum.read.cache Exceptions ---------- .. autoapisummary:: dcnum.read.cache.EmptyDatasetWarning Classes ------- .. autoapisummary:: dcnum.read.cache.BaseImageChunkCache dcnum.read.cache.HDF5ImageCache dcnum.read.cache.ImageCorrCache Functions --------- .. autoapisummary:: dcnum.read.cache.md5sum Module Contents --------------- .. py:exception:: EmptyDatasetWarning Bases: :py:obj:`UserWarning` Initialize self. See help(type(self)) for accurate signature. .. py:class:: BaseImageChunkCache(shape: tuple[int], chunk_size: int = 1000, cache_size: int = 2) Bases: :py:obj:`abc.ABC` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: shape .. py:attribute:: _dtype :value: None .. py:attribute:: _len .. py:attribute:: cache This is a FILO cache for the chunks .. py:attribute:: image_shape .. py:attribute:: chunk_shape .. py:attribute:: chunk_size .. py:attribute:: cache_size :value: 2 .. py:attribute:: num_chunks .. py:method:: __getitem__(index) .. py:method:: __len__() .. py:property:: dtype data type of the image data .. py:method:: _get_chunk_data(chunk_slice) :abstractmethod: Implemented in subclass to obtain actual data .. py:method:: _get_chunk_index_for_index(index) .. py:method:: get_chunk(chunk_index) Return one chunk of images .. py:method:: get_chunk_size(chunk_index) Return the number of images in this chunk .. py:method:: get_chunk_slice(chunk_index) Return the slice corresponding to the chunk index .. py:method:: iter_chunks() .. py:class:: HDF5ImageCache(h5ds: dcnum.common.h5py.Dataset | dcnum.read.mapped.MappedHDF5Dataset, chunk_size: int = 1000, cache_size: int = 2, boolean: bool = False) Bases: :py:obj:`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. .. py:attribute:: h5ds .. py:attribute:: boolean :value: False .. py:method:: _get_chunk_data(chunk_slice) Implemented in subclass to obtain actual data .. py:class:: ImageCorrCache(image: HDF5ImageCache, image_bg: HDF5ImageCache) Bases: :py:obj:`BaseImageChunkCache` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: image .. py:attribute:: image_bg .. py:method:: _get_chunk_data(chunk_slice) Implemented in subclass to obtain actual data .. py:function:: md5sum(path, blocksize=65536, count=0) Compute (partial) MD5 sum of a file :param path: path to the file :type path: str or pathlib.Path :param blocksize: block size in bytes read from the file (set to `0` to hash the entire file) :type blocksize: int :param count: number of blocks read from the file :type count: int