Skip to content

Commit 40e3c13

Browse files
committed
enh: one less iterated operation (transpose)
1 parent 9772710 commit 40e3c13

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

nitransforms/linear.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def apply(
458458
output_dtype = output_dtype or input_dtype
459459

460460
# Prepare physical coordinates of input (grid, points)
461-
xcoords = _ref.ndcoords.astype("f4")
461+
xcoords = _ref.ndcoords.astype("f4").T
462462

463463
# Invert target's (moving) affine once
464464
ras2vox = ~Affine(spatialimage.affine)
@@ -472,7 +472,7 @@ def apply(
472472
# Order F ensures individual volumes are contiguous in memory
473473
# Also matches NIfTI, making final save more efficient
474474
resampled = np.zeros(
475-
(xcoords.T.shape[0], len(self)), dtype=output_dtype, order="F"
475+
(xcoords.shape[0], len(self)), dtype=output_dtype, order="F"
476476
)
477477

478478
dataobj = (
@@ -483,7 +483,7 @@ def apply(
483483

484484
for t, xfm_t in enumerate(self):
485485
# Map the input coordinates on to timepoint t of the target (moving)
486-
ycoords = xfm_t.map(xcoords.T)[..., : _ref.ndim]
486+
ycoords = xfm_t.map(xcoords)[..., : _ref.ndim]
487487

488488
# Calculate corresponding voxel coordinates
489489
yvoxels = ras2vox.map(ycoords)[..., : _ref.ndim]

0 commit comments

Comments
 (0)