From 8b21efa87898f977a3d9ee601e2c4789294c1f82 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Thu, 16 Nov 2023 23:18:31 +0100 Subject: [PATCH] enh: one less iterated operation (transpose) --- nitransforms/linear.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nitransforms/linear.py b/nitransforms/linear.py index a2b6b148..58976466 100644 --- a/nitransforms/linear.py +++ b/nitransforms/linear.py @@ -458,7 +458,7 @@ def apply( output_dtype = output_dtype or input_dtype # Prepare physical coordinates of input (grid, points) - xcoords = _ref.ndcoords.astype("f4") + xcoords = _ref.ndcoords.astype("f4").T # Invert target's (moving) affine once ras2vox = ~Affine(spatialimage.affine) @@ -483,7 +483,7 @@ def apply( for t, xfm_t in enumerate(self): # Map the input coordinates on to timepoint t of the target (moving) - ycoords = xfm_t.map(xcoords.T)[..., : _ref.ndim] + ycoords = xfm_t.map(xcoords)[..., : _ref.ndim] # Calculate corresponding voxel coordinates yvoxels = ras2vox.map(ycoords)[..., : _ref.ndim]