Commit 79b25c20 authored by Andrei-Claudiu Roibu's avatar Andrei-Claudiu Roibu 🖥
Browse files

added orientation setting function

parent 78b7768d
......@@ -248,7 +248,7 @@ def load_and_preprocess(file_paths, orientation):
return volume, label_map, header
def load():
def load(file_paths, orientation):
"""Load Data Function
This function loads the required data files and extracts relevant information from it.
......@@ -266,7 +266,15 @@ def load():
None
"""
return pass
nifty_volume, label_map = nb.load(file_paths[0]), nb.load(file_paths[1])
volume, label_map = nifty_volume.get_fdata(), nift_labeled_volume.ged_fdata()
# Do we need min-max normalization here? Will need to check when debuggint and testing
volume = (volume - np.min(volume)) / (np.max(volume) - np.min(volume))
volume, label_map =
return volume, label_map, nifty_volume.header
def preprocess():
......@@ -281,6 +289,36 @@ def preprocess():
return pass
def set_orientation(volume, label_map, orientation):
"""Load Data Orientation
This function modifies the orientation of the input and output data depending on the required orientation.
Args:
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.
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.
Raises:
ValueError: Orientation value is invalid. It must be either >>coronal<<, >>axial<< or >>sagital<<
"""
# TODO: will need to check if these alignments correpond with our data.
# These alignments work for ADNI
if orientation == "sagittal":
return volume, label_map # This is assumed to be the default orientation
elif orientation == "axial":
return volume.transpose((1, 2, 0)), label_map.transpose((2, 0, 1))
elif orientation == "coronal":
return
else:
raise ValueError("Orientation value is invalid. It must be either >>coronal<<, >>axial<< or >>sagital<< ")
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