Skip to content

Commit

Permalink
Merge pull request #188 from jbanusco/patch-2
Browse files Browse the repository at this point in the history
FIX: Composition of deformation fields
  • Loading branch information
oesteban authored May 16, 2024
2 parents 527dc46 + 43b1140 commit ce08e37
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nitransforms/nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,21 @@ def map(self, x, inverse=False):
indexes = tuple(tuple(i) for i in indexes.T)
return self._field[indexes]

return np.vstack(tuple(
new_map = np.vstack(tuple(
map_coordinates(
self._field[..., i],
ijk.T,
order=3,
mode="constant",
cval=0,
cval=np.nan,
prefilter=True,
) for i in range(self.reference.ndim)
)).T

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

def __matmul__(self, b):
"""
Compose with a transform on the right.
Expand Down

0 comments on commit ce08e37

Please sign in to comment.