@@ -37,7 +37,7 @@ def __init__(self, field, reference=None):
37
37
Example
38
38
-------
39
39
>>> DisplacementsFieldTransform(test_dir / "someones_displacement_field.nii.gz")
40
- <(57, 67, 56) field of 3D displacements >
40
+ <DisplacementFieldTransform[3D] (57, 67, 56)>
41
41
42
42
"""
43
43
super ().__init__ ()
@@ -59,7 +59,7 @@ def __init__(self, field, reference=None):
59
59
60
60
def __repr__ (self ):
61
61
"""Beautify the python representation."""
62
- return f"<{ self ._field .shape [: 3 ] } field of { self ._field .shape [- 1 ] } D displacements >"
62
+ return f"<DisplacementFieldTransform[ { self ._field .shape [- 1 ] } D] { self ._field .shape [: 3 ] } >"
63
63
64
64
def map (self , x , inverse = False ):
65
65
r"""
@@ -132,7 +132,7 @@ def __init__(self, coefficients, reference=None, order=3):
132
132
coefficients = _ensure_image (coefficients )
133
133
134
134
self ._coeffs = np .asanyarray (coefficients .dataobj )
135
- self ._knots = ImageGrid (four_to_three ( coefficients )[ 0 ] )
135
+ self ._knots = ImageGrid (coefficients )
136
136
self ._weights = None
137
137
if reference is not None :
138
138
self .reference = reference
@@ -158,9 +158,11 @@ def to_field(self, reference=None, dtype="float32"):
158
158
field = np .zeros ((_ref .npoints , ndim ))
159
159
160
160
for d in range (ndim ):
161
+ # 1 x Nvox : (1 x K) @ (K x Nvox)
161
162
field [:, d ] = self ._coeffs [..., d ].reshape (- 1 ) @ self ._weights
162
163
163
- return field .astype (dtype )
164
+ return DisplacementsFieldTransform (
165
+ field .astype (dtype ).reshape (* _ref .shape , - 1 ), reference = _ref )
164
166
165
167
def apply (
166
168
self ,
@@ -197,10 +199,7 @@ def apply(
197
199
)
198
200
199
201
# If locations to be interpolated are on a grid, generate a displacements field
200
- return DisplacementsFieldTransform (
201
- self .to_field ().reshape ((* (_ref .shape ), - 1 )),
202
- reference = _ref ,
203
- ).apply (
202
+ return self .to_field ().apply (
204
203
spatialimage ,
205
204
reference = reference ,
206
205
order = order ,
@@ -216,7 +215,7 @@ def map(self, x, inverse=False):
216
215
217
216
.. math::
218
217
\mathbf{y} = \mathbf{x} + \Psi^3(\mathbf{k}, \mathbf{x}),
219
- \label{eq:2 }\tag{2 }
218
+ \label{eq:1 }\tag{1 }
220
219
221
220
Parameters
222
221
----------
0 commit comments