@@ -743,13 +743,15 @@ def _dilate_mask(in_file, iterations=4):
743743 import os
744744 from nipype .utils import NUMPY_MMAP
745745 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 )
747749
748750 name , fext = os .path .splitext (os .path .basename (in_file ))
749751 if fext == '.gz' :
750752 name , _ = os .path .splitext (name )
751753 out_file = os .path .abspath ('./%s_dil.nii.gz' % name )
752- nb .save (img , out_file )
754+ nb .save (dilated_img , out_file )
753755 return out_file
754756
755757
@@ -781,12 +783,13 @@ def _vsm_remove_mean(in_file, mask_file, in_unwarped):
781783 img_data [msk == 0 ] = 0
782784 vsmmag_masked = ma .masked_values (img_data .reshape (- 1 ), 0.0 )
783785 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 )
785788 name , fext = os .path .splitext (os .path .basename (in_file ))
786789 if fext == '.gz' :
787790 name , _ = os .path .splitext (name )
788791 out_file = os .path .abspath ('./%s_demeaned.nii.gz' % name )
789- nb .save (img , out_file )
792+ nb .save (masked_img , out_file )
790793 return out_file
791794
792795
0 commit comments