Commit 78b7768d authored by Andrei-Claudiu Roibu's avatar Andrei-Claudiu Roibu 🖥
Browse files

wrote the load & preprocess master function

parent ad14e775
......@@ -19,8 +19,9 @@ import numpy as np
import nibabel as nib
import torch
import torch.utils.data as data
import nibabel as nb
def dirReader(folder_location):
def directory_reader(folder_location):
"""Produces a list of of data-tags which are accessible
This function looks in a large data directory, and returns a list of sub-directories which are accessible.
......@@ -49,7 +50,7 @@ def dirReader(folder_location):
return subDirectoryList
def tractSum(folder_path):
def tract_sum_generator(folder_path):
"""Sums the tracts of different dMRI files
When performing subject-specific probabilistic diffusion tractography using standard-space protocols, 27 tracts are created.
......@@ -224,6 +225,62 @@ def load_file_paths(data_directory, targets_directory, data_list):
return file_paths
def load_and_preprocess(file_paths, orientation):
"""Load & Preprocess
This function is composed of two other function calls: one that calls a function loading the data, and another which preprocesses the data to the required format.
# TODO: Need to check if any more proprocessing would be required besides summing the tracts!
Args:
file_paths (list): List containing the input data and target labelled output data
orientation (str): String detailing the current view (COR, SAG, AXL)
Returns:
volume (np.array): Array of training image data of data type dtype.
label_map (np.array): Array of labelled image data of data type dtype.
header (class): 'nibabel.nifti1.Nifti1Header' class object, containing image metadata
Raises:
None
"""
volume, label_map, header = load(file_paths, orientation)
return volume, label_map, header
def load():
"""Load Data Function
This function loads the required data files and extracts relevant information from it.
Args:
file_paths (list): List containing the input data and target labelled output data
orientation (str): String detailing the current view (COR, SAG, AXL)
Returns:
volume (np.array): Array of training image data of data type dtype.
label_map (np.array): Array of labelled image data of data type dtype.
header (class): 'nibabel.nifti1.Nifti1Header' class object, containing image metadata
Raises:
None
"""
return pass
def preprocess():
# IDEEA - Might be worth adding the summed tracts function either to here, or the preprocessor file!
"""Data ProProcessing Function
This function carries out several specific pre-processing operations on the loaded data.
As things are - no specific pre-processing currently required!
"""
return pass
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