File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -270,7 +270,10 @@ def apply(
270
270
if isinstance (spatialimage , (str , Path )):
271
271
spatialimage = _nbload (str (spatialimage ))
272
272
273
- data = np .asanyarray (spatialimage .dataobj )
273
+ data = np .asanyarray (
274
+ spatialimage .dataobj ,
275
+ dtype = spatialimage .get_data_dtype ()
276
+ )
274
277
output_dtype = output_dtype or data .dtype
275
278
targets = ImageGrid (spatialimage ).index ( # data should be an image
276
279
_as_homogeneous (self .map (_ref .ndcoords .T ), dim = _ref .ndim )
@@ -288,9 +291,11 @@ def apply(
288
291
289
292
if isinstance (_ref , ImageGrid ): # If reference is grid, reshape
290
293
moved = spatialimage .__class__ (
291
- resampled .reshape (_ref .shape ), _ref .affine , spatialimage .header
294
+ resampled .reshape (_ref .shape ).astype (output_dtype ),
295
+ _ref .affine ,
296
+ spatialimage .header
292
297
)
293
- moved .header . set_data_dtype (output_dtype )
298
+ moved .set_data_dtype (output_dtype )
294
299
return moved
295
300
296
301
return resampled
You can’t perform that action at this time.
0 commit comments