Skip to content

Commit ce08e37

Browse files
authored
Merge pull request #188 from jbanusco/patch-2
FIX: Composition of deformation fields
2 parents 527dc46 + 43b1140 commit ce08e37

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

nitransforms/nonlinear.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,21 @@ 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+
new_map = np.vstack(tuple(
174174
map_coordinates(
175175
self._field[..., i],
176176
ijk.T,
177177
order=3,
178178
mode="constant",
179-
cval=0,
179+
cval=np.nan,
180180
prefilter=True,
181181
) for i in range(self.reference.ndim)
182182
)).T
183183

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

0 commit comments

Comments
 (0)