File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -270,7 +270,10 @@ def apply(
270270 if isinstance (spatialimage , (str , Path )):
271271 spatialimage = _nbload (str (spatialimage ))
272272
273- data = np .asanyarray (spatialimage .dataobj )
273+ data = np .asanyarray (
274+ spatialimage .dataobj ,
275+ dtype = spatialimage .get_data_dtype ()
276+ )
274277 output_dtype = output_dtype or data .dtype
275278 targets = ImageGrid (spatialimage ).index ( # data should be an image
276279 _as_homogeneous (self .map (_ref .ndcoords .T ), dim = _ref .ndim )
@@ -288,9 +291,11 @@ def apply(
288291
289292 if isinstance (_ref , ImageGrid ): # If reference is grid, reshape
290293 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
292297 )
293- moved .header . set_data_dtype (output_dtype )
298+ moved .set_data_dtype (output_dtype )
294299 return moved
295300
296301 return resampled
You can’t perform that action at this time.
0 commit comments