Skip to content

Commit 667344c

Browse files
jbanuscooesteban
authored andcommitted
BF: Composition of deformation fields
1 parent e792cef commit 667344c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

nitransforms/nonlinear.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,22 @@ def map(self, x, inverse=False):
170170
indexes = tuple(tuple(i) for i in indexes.T)
171171
return self._field[indexes]
172172

173-
return np.vstack(tuple(
173+
174+
new_map = np.vstack(tuple(
174175
map_coordinates(
175176
self._field[..., i],
176177
ijk.T,
177178
order=3,
178179
mode="constant",
179-
cval=0,
180+
cval=np.nan,
180181
prefilter=True,
181182
) for i in range(self.reference.ndim)
182183
)).T
183184

185+
# Set NaN values back to the original coordinates value = no displacement
186+
new_map[np.isnan(new_map)] = x[np.isnan(new_map)]
187+
return new_map
188+
184189
def __matmul__(self, b):
185190
"""
186191
Compose with a transform on the right.

0 commit comments

Comments
 (0)