gunz_cm.resolution_enhancements.datasets package
Submodules
gunz_cm.resolution_enhancements.datasets.csr module
gunz_cm.resolution_enhancements.datasets.memmap_v1 module
Module.
Examples
- class gunz_cm.resolution_enhancements.datasets.memmap_v1.MemmapDatasetV1(memmap_fpath: str, win_size: int, stride_size: int = None, transformations: Callable | None = None)[source]
Bases:
DatasetA PyTorch Dataset class for loading patches from a memory-mapped file.
- Args:
memmap_fpath (str): The path to the memory-mapped file. win_size (int): The size of the window/patch to extract from the memory-mapped file. stride_size (int, optional): The stride size to use when extracting patches. Defaults to win_size. transformations (callable, optional): A function/transform to apply to the data. Defaults to None.
- Attributes:
_f (numpy.memmap): The memory-mapped file. win_size (int): The size of the window/patch to extract from the memory-mapped file. stride_size (int): The stride size to use when extracting patches. transformations (callable): A function/transform to apply to the data. npatches_in_row (int): The number of patches that can be extracted from a single row. npatches_in_col (int): The number of patches that can be extracted from a single column.
Examples
- any_transformation()[source]
Check if any transformations are defined.
- bool
True if transformations are defined, False otherwise.
Examples
- load_data(idx: int)[source]
Load a patch from the memory-mapped file based on the given index.
- idxint
Index of the patch.
- dict
A dictionary containing the loaded patch data under the key ‘X’.
Examples
- property shape
Returns the shape of the dataset as a tuple.
- tuple
The shape of the dataset as a tuple (npatches_in_row, npatches_in_col).
Examples
gunz_cm.resolution_enhancements.datasets.memmap_v2 module
Module.
Examples
- class gunz_cm.resolution_enhancements.datasets.memmap_v2.MemmapDatasetV2(memmap_fpath: str, win_size: int, stride_size: int = None, transformations: Callable | None = None, max_dist: int = None)[source]
Bases:
MemmapDatasetV1- PyTorch Dataset for loading specific patches from a memory-mapped file
based on a provided max_distance attribute constraining the diagonal of the patches.
Inherits from MemmapDatasetV1 and extends its functionality as follows: - Adds a max_dist attribute to calculate the maximum diagonal length max_diag - Modifies __len__ method to return the total number of patches within the max_diag - Modifies load_data method to load a patch of size win_size with stride size stride_size
using the provided index idx only if the index corresponds to a valid pair within the max_diag
See MemmapDatasetV1 docstring for shared attributes and methods.
Examples
- load_data(idx) ndarray[source]
Loads a patch of size win_size with stride size stride_size using the provided index idx only if the index corresponds to a valid pair within the max_diag.
- idxint
The index of the patch to be loaded.
- np.ndarray
A numpy array containing the patch of size win_size at the indicated valid location.
Examples
gunz_cm.resolution_enhancements.datasets.ren_memmap_v1 module
Module.
Examples
- class gunz_cm.resolution_enhancements.datasets.ren_memmap_v1.RENMemmapDatasetV1(hr_memmap_fpath: str, win_size: int, stride_size: int = None, transformations: List = None, max_dist: int = None, lr_memmap_fpath: str = None, lr_ds_ratio: int = None, ret_float: bool = True)[source]
Bases:
DatasetDataset class for loading and manipulating memmap data.
- hr_memmap_fpathstr
Path to the high-resolution memmap file.
- win_sizeint
Window size for patch extraction.
- stride_sizeint, optional
Stride size for patch extraction. Defaults to win_size.
- transformationslist, optional
List of transformations to apply to the data. Defaults to None.
- max_distint, optional
Maximum distance between patches. Defaults to shape[0].
- lr_memmap_fpathstr, optional
Path to the low-resolution memmap file. Defaults to None.
- lr_ds_ratioint, optional
Downscale ratio for the low-resolution data. Defaults to None.
- ret_floatbool, optional
Whether to return floating-point data. Defaults to True.
- _hr_fmemmap
High-resolution memmap file.
- _lr_fmemmap
Low-resolution memmap file.
- win_sizeint
Window size for patch extraction.
- transformationslist
List of transformations to apply to the data.
- stride_sizeint
Stride size for patch extraction.
- npatches_in_rowint
Number of patches in each row.
- npatches_in_colint
Number of patches in each column.
- max_diagint
Maximum diagonal distance between patches.
- i_j_pairsndarray
Array of patch indices.
- ret_floatbool
Whether to return floating-point data.
Examples
- any_transformation() bool[source]
Checks if there are any transformations present.
- bool
True if there are transformations, False otherwise.
Examples
- load_data(idx) ndarray[source]
Loads a patch of size win_size with stride size stride_size using the provided index idx.
- idxint
The index of the patch to be loaded.
- numpy.ndarray
A numpy array containing the patch of size win_size.
Examples
- set_transformations(transformations)[source]
Sets the transformations.
- transformations
The transformations to be set.
Examples
- property shape
Function shape.
Examples
Notes