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

added load_and_preprocess for evaluation

parent cce2d2a3
......@@ -317,9 +317,9 @@ def set_orientation(volume, label_map, orientation):
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))
return volume.transpose((1, 2, 0)), label_map.transpose((1, 2, 0))
elif orientation == "coronal":
return
return volume.transpose((2, 0, 1)), label_map.transpose((2, 0, 1))
else:
raise ValueError("Orientation value is invalid. It must be either >>coronal<<, >>axial<< or >>sagital<< ")
......@@ -338,11 +338,29 @@ def load_and_preprocess_evaluation(file_path, orientation, min_max=True):
header (class): 'nibabel.nifti1.Nifti1Header' class object, containing image metadata
Raises:
None
ValueError: "Orientation value is invalid. It must be either >>coronal<<, >>axial<< or >>sagital<< "
"""
nifty_volume = nb.load(file_path[0])
volume = nifty_volume.get_fdata()
header = nifty_volume.header
if min_max:
volume = (volume - np.min(volume)) / (np.max(volume) - np.min(volume))
else:
volume = np.round(volume)
if orientation == "sagittal":
return volume # This is assumed to be the default orientation
elif orientation == "axial":
return volume.transpose((1, 2, 0))
elif orientation == "coronal":
return volume.transpose((2, 0, 1))
else:
raise ValueError("Orientation value is invalid. It must be either >>coronal<<, >>axial<< or >>sagital<< ")
return volume, header
if __name__ == "__main__":
......
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