@@ -105,12 +105,12 @@ def _eucl_min(self, nii1, nii2):
105105 set2_coordinates .T [point2 , :])
106106
107107 def _eucl_cog (self , nii1 , nii2 ):
108- origdata1 = nii1 .get_data (). astype (np .bool )
109- cog_t = np .array (center_of_mass (origdata1 )).reshape (- 1 , 1 )
108+ origdata1 = np . logical_and ( nii1 .get_data () != 0 , np . logical_not (np .isnan ( nii1 . get_data ())) )
109+ cog_t = np .array (center_of_mass (origdata1 . copy () )).reshape (- 1 , 1 )
110110 cog_t = np .vstack ((cog_t , np .array ([1 ])))
111111 cog_t_coor = np .dot (nii1 .affine , cog_t )[:3 , :]
112112
113- origdata2 = nii2 .get_data (). astype (np .bool )
113+ origdata2 = np . logical_and ( nii2 .get_data () != 0 , np . logical_not (np .isnan ( nii2 . get_data ())) )
114114 (labeled_data , n_labels ) = label (origdata2 )
115115
116116 cogs = np .ones ((4 , n_labels ))
@@ -181,8 +181,9 @@ def _eucl_max(self, nii1, nii2):
181181 return np .max (mins )
182182
183183 def _run_interface (self , runtime ):
184- nii1 = nb .load (self .inputs .volume1 )
185- nii2 = nb .load (self .inputs .volume2 )
184+ # there is a bug in some scipy ndimage methods that gets tripped by memory mapped objects
185+ nii1 = nb .load (self .inputs .volume1 , mmap = False )
186+ nii2 = nb .load (self .inputs .volume2 , mmap = False )
186187
187188 if self .inputs .method == "eucl_min" :
188189 self ._distance , self ._point1 , self ._point2 = self ._eucl_min (
0 commit comments