@@ -46,13 +46,13 @@ def _run_interface(self, runtime):
46
46
def extract_b0 (in_file , b0_ixs , newpath = None ):
47
47
"""Extract the *b0* volumes from a DWI dataset."""
48
48
import numpy as np
49
- import nibabel as nib
49
+ import nibabel as nb
50
50
from nipype .utils .filemanip import fname_presuffix
51
51
52
52
out_file = fname_presuffix (
53
53
in_file , suffix = '_b0' , newpath = newpath )
54
54
55
- img = nib .load (in_file )
55
+ img = nb .load (in_file )
56
56
data = img .get_fdata (dtype = 'float32' )
57
57
58
58
b0 = data [..., b0_ixs ]
@@ -61,7 +61,7 @@ def extract_b0(in_file, b0_ixs, newpath=None):
61
61
hdr .set_data_shape (b0 .shape )
62
62
hdr .set_xyzt_units ('mm' )
63
63
hdr .set_data_dtype (np .float32 )
64
- nib .Nifti1Image (b0 , img .affine , hdr ).to_filename (out_file )
64
+ nb .Nifti1Image (b0 , img .affine , hdr ).to_filename (out_file )
65
65
return out_file
66
66
67
67
@@ -106,21 +106,21 @@ def rescale_b0(in_file, mask_file, newpath=None):
106
106
and output a median image.
107
107
"""
108
108
import numpy as np
109
- import nibabel as nib
109
+ import nibabel as nb
110
110
from nipype .utils .filemanip import fname_presuffix
111
111
112
112
out_file = fname_presuffix (
113
113
in_file , suffix = '_median_b0' , newpath = newpath )
114
114
115
- img = nib .load (in_file )
115
+ img = nb .load (in_file )
116
116
if img .dataobj .ndim == 3 :
117
117
return in_file
118
118
if img .shape [- 1 ] == 1 :
119
119
nb .squeeze_image (img ).to_filename (out_file )
120
120
return out_file
121
121
122
122
data = img .get_fdata (dtype = 'float32' )
123
- mask_img = nib .load (mask_file )
123
+ mask_img = nb .load (mask_file )
124
124
mask_data = mask_img .get_fdata (dtype = 'float32' )
125
125
126
126
median_signal = data [mask_data > 0 , ...].median (axis = 0 )
@@ -133,5 +133,5 @@ def rescale_b0(in_file, mask_file, newpath=None):
133
133
hdr .set_data_shape (median_data .shape )
134
134
hdr .set_xyzt_units ('mm' )
135
135
hdr .set_data_dtype (np .float32 )
136
- nib .Nifti1Image (median_data , img .affine , hdr ).to_filename (out_file )
136
+ nb .Nifti1Image (median_data , img .affine , hdr ).to_filename (out_file )
137
137
return out_file
0 commit comments