Skip to content

Commit

Permalink
enh: one less iterated operation (transpose)
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban committed Nov 16, 2023
1 parent 3ec84d2 commit 616ee06
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nitransforms/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -472,7 +472,7 @@ def apply(
# Order F ensures individual volumes are contiguous in memory
# Also matches NIfTI, making final save more efficient
resampled = np.zeros(
(xcoords.T.shape[0], len(self)), dtype=output_dtype, order="F"
(xcoords.shape[0], len(self)), dtype=output_dtype, order="F"
)

dataobj = (
Expand All @@ -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]
Expand Down

0 comments on commit 616ee06

Please sign in to comment.