From b63d9f908da35b4c84bfac7555e97c4ab8449e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sun, 22 Oct 2023 12:38:02 -0400 Subject: [PATCH] STYLE: Prefer importing `nibabel` as `nib` Prefer importing `nibabel` as `nib` to be consistent with current common practice and for the sake of compactness. --- bin/wm_cluster_volumetric_measurements.py | 8 ++++---- bin/wm_tract_to_volume.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/wm_cluster_volumetric_measurements.py b/bin/wm_cluster_volumetric_measurements.py index 22ca3f53..e8ee4a1d 100644 --- a/bin/wm_cluster_volumetric_measurements.py +++ b/bin/wm_cluster_volumetric_measurements.py @@ -4,7 +4,7 @@ import argparse import os -import nibabel +import nibabel as nib import numpy import vtk from nibabel.affines import apply_affine @@ -68,7 +68,7 @@ def main(): print("Output directory", args.outputDirectory, "does not exist, creating it.") os.makedirs(outdir) - input_volume = nibabel.load(inputvol) + input_volume = nib.load(inputvol) print(f'<{os.path.basename(__file__)}> Input volume shape:', input_volume.get_data().shape) input_vtk_list = wma.io.list_vtk_files(inputdir) @@ -182,9 +182,9 @@ def compute_stat(inpd, volume, sampling_size=None): str_out = str_out + '\n' + str_line if args.outputLabelmap: - volume_new = nibabel.Nifti1Image(new_voxel_data, input_volume.affine, input_volume.header) + volume_new = nib.Nifti1Image(new_voxel_data, input_volume.affine, input_volume.header) output_labelmap = os.path.join(outdir, vtk_file_name+'.nii.gz') - nibabel.save(volume_new, output_labelmap) + nib.save(volume_new, output_labelmap) output_file = open(output_stats_file, 'w') output_file.write(str_out) diff --git a/bin/wm_tract_to_volume.py b/bin/wm_tract_to_volume.py index 7e58b450..350dfa54 100644 --- a/bin/wm_tract_to_volume.py +++ b/bin/wm_tract_to_volume.py @@ -4,7 +4,7 @@ import argparse import os -import nibabel +import nibabel as nib import numpy import vtk from nibabel.affines import apply_affine @@ -149,16 +149,16 @@ def convert_cluster_to_volume(inpd, volume, measure=None): return new_voxel_data - volume = nibabel.load(args.refvolume) + volume = nib.load(args.refvolume) print(f'<{os.path.basename(__file__)}>', args.refvolume, ', input volume shape: ', volume.get_fdata().shape) inpd = wma.io.read_polydata(args.inputVTK) new_voxel_data = convert_cluster_to_volume(inpd, volume, measure=args.measure) - volume_new = nibabel.Nifti1Image(new_voxel_data, volume.affine, volume.header) + volume_new = nib.Nifti1Image(new_voxel_data, volume.affine, volume.header) - nibabel.save(volume_new, args.outputVol) + nib.save(volume_new, args.outputVol) print('Done: save tract map to', args.outputVol)