Commit 2eb696b5 authored by Andrei-Claudiu Roibu's avatar Andrei-Claudiu Roibu 🖥
Browse files

created DataMapper helper subclass of data.Dataset

parent c4d7d0ad
......@@ -110,6 +110,41 @@ def tractSum(folder_path):
return None
class DataMapper(data.Dataset):
"""Data Mapper Class.
This class represents a generic parent class for mapping between keys and data samples.
The class represents a subclass/child class of data.Dataset, inheriting its functionality.
This class is composed of a __init__ constructor, a __getitem__(), supporting fetching a data sample for a given key, and __len__(), which returns the size of the dataset.
X (HDF5 datafile): hierarchically organized input data
y (HDF5 datafile): hierarchically organized output data
input_data (torch.tensor): Tensor representation of the input data
label_data (torch.tensor): Tensor representation of the output data
int: lenght of the output
def __init__(self, X, y):
self.X = X
self.y = y
def __getitem__(self, index):
input_data = torch.from_numpy(self.X[index])
label_data = torch.from_numpy(self.y[index])
return input_data, label_data
def __len__(self):
return len(self.y)
def get_datasets(data_parameters):
if __name__ == "__main__":
folder_location = '/well/win-biobank/projects/imaging/data/data3/subjectsAll/'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment