EMCqMRI.core.base.base_dataset module
- class EMCqMRI.core.base.base_dataset.Dataset(config_object)[source]
Bases:
abc.ABCBase class for implementation of datasets :param config_object: Configuration object where following attributes
must be specified:
args.engine.fileExtension ([string])
- abstract get_label(idx)[source]
Abstract function for fetching labels and masks from the data directory.
Need subclass to implement different logics, like Relaxometry, Reconstruction, QSM, etc.
- Parameters
idx ([int]) – Index automatically provided by the DataLoader. It ranges from 0 to len(self.filename_list)-1.
- Raises
NotImplementedError – When the subclass does not override this method.
- Returns
The subclass implementation should return the label, and, if available, a mask. For seemless integration with the framework, label should have shape [N, X, Y, …] and the mask should have shape [1,X,Y, …], where N is the number of channels (e.g. weighted images) and X,Y,… are the image dimensions.
- Return type
(Label [torch.Tensor]), (Mask [torch.Tensor] - optional)
- get_length()[source]
It returns the length of the dataset (i.e. number of files in the dataset folder).
- Raises
TypeError – When self.filename_list is not initialized.
- Returns
The number of files within the data directory.
- Return type
(Data set length[list])
- abstract get_signal(idx)[source]
Abstract function for fetching the signal from the data directory.
Need subclass to implement different logics, like Relaxometry, Reconstruction, QSM, etc.
- Parameters
idx ([int]) – Index automatically provided by the DataLoader. It ranges from 0 to len(self.filename_list)-1.
- Raises
NotImplementedError – When the subclass does not override this method.
- Returns
The subclass implementation should return the signal. For seemless integration with the framework, signal should have shape [N, X, Y, …], where N is the number of channels (e.g. weighted images) and X,Y,… are the image dimensions.
- Return type
(Signal [torch.Tensor])
- index_files()[source]
Index all files within the folder path contained in self.path.
If fileExtension is provided (as an option in engine_configuration.txt), only files that match this file extension will be indexed.
- Raises
Exception – When fileExtension is not provided.
- Sets:
self.filename_list ([list])
- load_file(idx)[source]
It loads the file indexed by idx.
It is called when the option preLoadData==False.
- Parameters
idx ([int]) – the index of the file to load from disk.
- Raises
Exception – When fileExtension is not provided.
- load_folder()[source]
It pre-loads all the data in self.path.
It is called when the option preLoadData==True. Use with care, if the size of the data is too large, might cause memory issues.
- Raises
Exception – When fileExtension is not provided.
- Sets:
self.data ([list])
- set_data_path(path)[source]
Set the path for the folder containing training, validation or testing files.
- Parameters
path ([string]) – path for training or testing data. It is provided as an option in engine_configuration.txt.
- Raises
Exception – When path does not point to a directory.
Exception – When path points to an empty directory.
- Sets:
self.path ([string])