@@ -484,8 +484,12 @@ def _gen_output_file_name(self, suffix=None):
484
484
485
485
def _run_interface (self , runtime ):
486
486
img = nb .load (self .inputs .in_file [0 ])
487
+ header = img .get_header ().copy ()
487
488
vollist = [nb .load (filename ) for filename in self .inputs .in_file ]
488
489
data = np .concatenate ([vol .get_data ().reshape (vol .get_shape ()[:3 ] + (- 1 ,)) for vol in vollist ], axis = 3 )
490
+ if data .dtype .kind == 'i' :
491
+ header .set_data_dtype (np .float32 )
492
+ data = data .astype (np .float32 )
489
493
if isdefined (self .inputs .regress_poly ):
490
494
timepoints = img .get_shape ()[- 1 ]
491
495
X = np .ones ((timepoints , 1 ))
@@ -496,16 +500,16 @@ def _run_interface(self, runtime):
496
500
np .rollaxis (betas [1 :, :, :, :], 0 , 3 )),
497
501
0 , 4 )
498
502
data = data - datahat
499
- img = nb .Nifti1Image (data , img .get_affine (), img . get_header () )
503
+ img = nb .Nifti1Image (data , img .get_affine (), header )
500
504
nb .save (img , self ._gen_output_file_name ('detrended' ))
501
505
meanimg = np .mean (data , axis = 3 )
502
506
stddevimg = np .std (data , axis = 3 )
503
507
tsnr = meanimg / stddevimg
504
- img = nb .Nifti1Image (tsnr , img .get_affine (), img . get_header () )
508
+ img = nb .Nifti1Image (tsnr , img .get_affine (), header )
505
509
nb .save (img , self ._gen_output_file_name ())
506
- img = nb .Nifti1Image (meanimg , img .get_affine (), img . get_header () )
510
+ img = nb .Nifti1Image (meanimg , img .get_affine (), header )
507
511
nb .save (img , self ._gen_output_file_name ('mean' ))
508
- img = nb .Nifti1Image (stddevimg , img .get_affine (), img . get_header () )
512
+ img = nb .Nifti1Image (stddevimg , img .get_affine (), header )
509
513
nb .save (img , self ._gen_output_file_name ('stddev' ))
510
514
return runtime
511
515
0 commit comments