@@ -105,12 +105,12 @@ def _eucl_min(self, nii1, nii2):
105
105
set2_coordinates .T [point2 , :])
106
106
107
107
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 )
110
110
cog_t = np .vstack ((cog_t , np .array ([1 ])))
111
111
cog_t_coor = np .dot (nii1 .affine , cog_t )[:3 , :]
112
112
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 ())) )
114
114
(labeled_data , n_labels ) = label (origdata2 )
115
115
116
116
cogs = np .ones ((4 , n_labels ))
@@ -181,8 +181,9 @@ def _eucl_max(self, nii1, nii2):
181
181
return np .max (mins )
182
182
183
183
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 )
186
187
187
188
if self .inputs .method == "eucl_min" :
188
189
self ._distance , self ._point1 , self ._point2 = self ._eucl_min (
0 commit comments