In Memory Dataset
In-memory dataset module.
InMemoryDataset
Bases: Dataset
Dataset storing data in memory and allowing generating patches from it.
Parameters:
-
data_config(CAREamics DataConfig) –(see careamics.config.data_model.DataConfig) Data configuration.
-
inputs(ndarray or list[Path]) –Input data.
-
input_target(ndarray or list[Path], default:None) –Target data, by default None.
-
read_source_func(Callable, default:read_tiff) –Read source function for custom types, by default read_tiff.
-
**kwargs(Any, default:{}) –Additional keyword arguments, unused.
__getitem__(index)
Return the patch corresponding to the provided index.
Parameters:
-
index(int) –Index of the patch to return.
Returns:
-
tuple of numpy.ndarray–Patch.
Raises:
-
ValueError–If dataset mean and std are not set.
__init__(data_config, inputs, input_target=None, read_source_func=read_tiff, **kwargs)
Constructor.
Parameters:
-
data_config(GeneralDataConfig) –Data configuration.
-
inputs(ndarray or list[Path]) –Input data.
-
input_target(ndarray or list[Path], default:None) –Target data, by default None.
-
read_source_func(Callable, default:read_tiff) –Read source function for custom types, by default read_tiff.
-
**kwargs(Any, default:{}) –Additional keyword arguments, unused.
__len__()
get_data_statistics()
Return training data statistics.
This does not return the target data statistics, only those of the input.
Returns:
-
tuple of list of floats–Means and standard deviations across channels of the training data.
split_dataset(percentage=0.1, minimum_patches=1)
Split a new dataset away from the current one.
This method is used to extract random validation patches from the dataset.
Parameters:
-
percentage(float, default:0.1) –Percentage of patches to extract, by default 0.1.
-
minimum_patches(int, default:1) –Minimum number of patches to extract, by default 5.
Returns:
-
CAREamics InMemoryDataset–New dataset with the extracted patches.
Raises:
-
ValueError–If
percentageis not between 0 and 1. -
ValueError–If
minimum_numberis not between 1 and the number of patches.