|
@@ -56,35 +56,6 @@ def main():
|
|
|
print(f"An error occurred: {e}")
|
|
|
|
|
|
progress_bar.update(1)
|
|
|
-
|
|
|
- registered_masks_path = os.path.join(args.input,"**","RegisteredTractMasks", "*.nii.gz")
|
|
|
- registered_masks_files = glob.glob(registered_masks_path, recursive=True)
|
|
|
-
|
|
|
- total_iterations = len(registered_masks_files)
|
|
|
- progress_bar = tqdm(total=total_iterations, desc='Flipping Masks', unit='files')
|
|
|
-
|
|
|
- for mask_file in registered_masks_files:
|
|
|
- # Load the mask file
|
|
|
- mask_nifti = nib.load(mask_file)
|
|
|
- mask_data = mask_nifti.get_fdata()
|
|
|
-
|
|
|
- # Flip the mask along the Y and Z axes
|
|
|
- #flipped_mask = np.flip(np.flip(mask_data, axis=0), axis=1)
|
|
|
- flipped_mask = np.flip(mask_data, axis=0)
|
|
|
-
|
|
|
-
|
|
|
- # Determine the directory to save the adjusted mask
|
|
|
- mask_dir = os.path.dirname(os.path.dirname(mask_file))
|
|
|
- adjusted_masks_dir = os.path.join(mask_dir, "RegisteredTractMasks")
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- # Define the new file name and save the flipped mask
|
|
|
- if "anat" in mask_file:
|
|
|
- adjusted_mask_file = os.path.join(adjusted_masks_dir, os.path.basename(mask_file).replace(".nii.gz",".nii.gz"))
|
|
|
- nib.save(nib.Nifti1Image(flipped_mask, mask_nifti.affine), adjusted_mask_file)
|
|
|
-
|
|
|
- progress_bar.update(1)
|
|
|
|
|
|
progress_bar.close()
|
|
|
print("Flipping of RegisteredTractMasks and saving to RegisteredTractMasks_adjusted: DONE\n")
|