@@ -743,13 +743,15 @@ def _dilate_mask(in_file, iterations=4):
743
743
import os
744
744
from nipype .utils import NUMPY_MMAP
745
745
img = nb .load (in_file , mmap = NUMPY_MMAP )
746
- img ._data = ndimage .binary_dilation (img .get_data (), iterations = iterations )
746
+ dilated_img = img .__class__ (ndimage .binary_dilation (img .get_data (),
747
+ iterations = iterations ),
748
+ img .affine , img .header )
747
749
748
750
name , fext = os .path .splitext (os .path .basename (in_file ))
749
751
if fext == '.gz' :
750
752
name , _ = os .path .splitext (name )
751
753
out_file = os .path .abspath ('./%s_dil.nii.gz' % name )
752
- nb .save (img , out_file )
754
+ nb .save (dilated_img , out_file )
753
755
return out_file
754
756
755
757
@@ -781,12 +783,13 @@ def _vsm_remove_mean(in_file, mask_file, in_unwarped):
781
783
img_data [msk == 0 ] = 0
782
784
vsmmag_masked = ma .masked_values (img_data .reshape (- 1 ), 0.0 )
783
785
vsmmag_masked = vsmmag_masked - vsmmag_masked .mean ()
784
- img ._data = vsmmag_masked .reshape (img .shape )
786
+ masked_img = img .__class__ (vsmmag_masked .reshape (img .shape ),
787
+ img .affine , img .header )
785
788
name , fext = os .path .splitext (os .path .basename (in_file ))
786
789
if fext == '.gz' :
787
790
name , _ = os .path .splitext (name )
788
791
out_file = os .path .abspath ('./%s_demeaned.nii.gz' % name )
789
- nb .save (img , out_file )
792
+ nb .save (masked_img , out_file )
790
793
return out_file
791
794
792
795
0 commit comments