Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Do not transpose (see scipy.ndimage.map_coordinates docs) #207

Merged
merged 1 commit into from
May 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading