Skip to content

Commit

Permalink
Merge pull request #207 from nipy/fix/transpose-not-necessary
Browse files Browse the repository at this point in the history
FIX: Do not transpose (see scipy.ndimage.map_coordinates docs)
  • Loading branch information
oesteban authored May 18, 2024
2 parents 3d0ecc2 + e68c81b commit 8dae35f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nitransforms/nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def map(self, x, inverse=False):
if inverse is True:
raise NotImplementedError

x = np.array(x)
ijk = self.reference.index(x)
indexes = np.round(ijk).astype("int")

Expand All @@ -172,7 +171,7 @@ def map(self, x, inverse=False):
tuple(
map_coordinates(
self._field[..., i],
ijk.T,
ijk,
order=3,
mode="constant",
cval=np.nan,
Expand All @@ -183,7 +182,7 @@ def map(self, x, inverse=False):
).T

# Set NaN values back to the original coordinates value = no displacement
new_map[np.isnan(new_map)] = x[np.isnan(new_map)]
new_map[np.isnan(new_map)] = np.array(x)[np.isnan(new_map)]
return new_map

def __matmul__(self, b):
Expand Down

0 comments on commit 8dae35f

Please sign in to comment.