Skip to content

Commit faef239

Browse files
authored
fix: respect singleton 4d
1 parent f663530 commit faef239

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

nitransforms/resampling.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def apply(
234234
if isinstance(spatialimage, (str, Path)):
235235
spatialimage = _nbload(str(spatialimage))
236236

237+
singleton_4d = spatialimage.ndim == 4 and spatialimage.shape[-1] == 1
237238
spatialimage = squeeze_image(spatialimage)
238239

239240
# Avoid opening the data array just yet
@@ -370,7 +371,8 @@ def apply(
370371
with suppress(ValueError):
371372
resampled = np.squeeze(resampled, axis=3)
372373

373-
moved = spatialimage.__class__(resampled, _ref.affine, hdr)
374+
moved = spatialimage.__class__(
375+
resampled[..., None] if singleton_4d else resampled, _ref.affine, hdr)
374376
return moved
375377

376378
output_dtype = output_dtype or input_dtype

0 commit comments

Comments
 (0)