def preprocess_and_convert_to_numpy(nifti_scan: nib.Nifti1Image, nifti_mask: nib.Nifti1Image) -> list: """ Convert scan and label to numpy arrays and perform preprocessing Return: Tuple(np.array, np.array) """ np_scan = nifti_scan.get_fdata() np_label = nifti_mask.get_fdata() nifti_mask.uncache() nifti_scan.uncache() np_scan = preprocess_scan(np_scan) np_label = rotate_label(np_label) assert np_scan.shape == np_label.shape return np_scan, np_label