@@ -51,7 +51,7 @@ def _run_interface(self, runtime):
51
51
from scipy import ndimage as sim
52
52
53
53
fmap_nii = nb .load (self .inputs .in_file )
54
- data = np .squeeze (fmap_nii .get_data (). astype ( np . float32 ))
54
+ data = np .squeeze (fmap_nii .get_fdata ( dtype = ' float32' ))
55
55
56
56
# Despike / denoise (no-mask)
57
57
if self .inputs .despike :
@@ -60,7 +60,7 @@ def _run_interface(self, runtime):
60
60
mask = None
61
61
if isdefined (self .inputs .in_mask ):
62
62
masknii = nb .load (self .inputs .in_mask )
63
- mask = masknii . get_data ( ).astype (np . uint8 )
63
+ mask = np . asanyarray ( masknii . dataobj ).astype (' uint8' )
64
64
65
65
# Dilate mask
66
66
if self .inputs .mask_erode > 0 :
@@ -95,7 +95,7 @@ def _run_interface(self, runtime):
95
95
smoothed1 = bspobj .get_smoothed ()
96
96
97
97
# Manipulate the difference map
98
- diffmap = data - smoothed1 .get_data ( )
98
+ diffmap = data - smoothed1 .get_fdata ( dtype = 'float32' )
99
99
sderror = mad (diffmap [mask > 0 ])
100
100
LOGGER .info ('SD of error after B-Spline fitting is %f' , sderror )
101
101
errormask = np .zeros_like (diffmap )
@@ -118,12 +118,12 @@ def _run_interface(self, runtime):
118
118
bspobj2 = fbsp .BSplineFieldmap (diffmapnii , knots_zooms = [24. , 24. , 4. ],
119
119
njobs = self .inputs .num_threads )
120
120
bspobj2 .fit ()
121
- smoothed2 = bspobj2 .get_smoothed ().get_data ( )
121
+ smoothed2 = bspobj2 .get_smoothed ().get_fdata ( dtype = 'float32' )
122
122
123
- final = smoothed1 .get_data ( ).copy ()
123
+ final = smoothed1 .get_fdata ( dtype = 'float32' ).copy ()
124
124
final [..., errorslice [0 ]:errorslice [- 1 ]] += smoothed2
125
125
else :
126
- final = smoothed1 .get_data ( )
126
+ final = smoothed1 .get_fdata ( dtype = 'float32' )
127
127
128
128
nb .Nifti1Image (final , datanii .affine , datanii .header ).to_filename (
129
129
self ._results ['out_file' ])
@@ -329,14 +329,16 @@ def _unwrap(fmap_data, mag_file, mask=None):
329
329
330
330
nb .Nifti1Image (fmap_data , magnii .affine ).to_filename ('fmap_rad.nii.gz' )
331
331
nb .Nifti1Image (mask , magnii .affine ).to_filename ('fmap_mask.nii.gz' )
332
- nb .Nifti1Image (magnii .get_data (), magnii .affine ).to_filename ('fmap_mag.nii.gz' )
332
+ nb .Nifti1Image (magnii .get_fdata (dtype = 'float32' ),
333
+ magnii .affine ).to_filename ('fmap_mag.nii.gz' )
333
334
334
335
# Run prelude
335
336
res = PRELUDE (phase_file = 'fmap_rad.nii.gz' ,
336
337
magnitude_file = 'fmap_mag.nii.gz' ,
337
338
mask_file = 'fmap_mask.nii.gz' ).run ()
338
339
339
- unwrapped = nb .load (res .outputs .unwrapped_phase_file ).get_data () * (fmapmax / pi )
340
+ unwrapped = nb .load (
341
+ res .outputs .unwrapped_phase_file ).get_fdata (dtype = 'float32' ) * (fmapmax / pi )
340
342
return unwrapped
341
343
342
344
@@ -517,7 +519,7 @@ def _torads(in_file, fmap_range=None, newpath=None):
517
519
518
520
out_file = fname_presuffix (in_file , suffix = '_rad' , newpath = newpath )
519
521
fmapnii = nb .load (in_file )
520
- fmapdata = fmapnii .get_data ( )
522
+ fmapdata = fmapnii .get_fdata ( dtype = 'float32' )
521
523
522
524
if fmap_range is None :
523
525
fmap_range = max (abs (fmapdata .min ()), fmapdata .max ())
@@ -536,7 +538,7 @@ def _tohz(in_file, range_hz, newpath=None):
536
538
537
539
out_file = fname_presuffix (in_file , suffix = '_hz' , newpath = newpath )
538
540
fmapnii = nb .load (in_file )
539
- fmapdata = fmapnii .get_data ( )
541
+ fmapdata = fmapnii .get_fdata ( dtype = 'float32' )
540
542
fmapdata = fmapdata * (range_hz / pi )
541
543
out_img = nb .Nifti1Image (fmapdata , fmapnii .affine , fmapnii .header )
542
544
out_img .set_data_dtype ('float32' )
@@ -578,7 +580,7 @@ def phdiff2fmap(in_file, delta_te, newpath=None):
578
580
579
581
out_file = fname_presuffix (in_file , suffix = '_fmap' , newpath = newpath )
580
582
image = nb .load (in_file )
581
- data = (image .get_data (). astype ( np . float32 ) / (2. * math .pi * delta_te ))
583
+ data = (image .get_fdata ( dtype = ' float32' ) / (2. * math .pi * delta_te ))
582
584
nii = nb .Nifti1Image (data , image .affine , image .header )
583
585
nii .set_data_dtype (np .float32 )
584
586
nii .to_filename (out_file )
0 commit comments