Skip to content

Commit fe96372

Browse files
committed
fix: invert LTA matrix before storing too, update regression test of #74
1 parent 57f0f71 commit fe96372

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

nitransforms/linear.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,16 @@ def to_filename(self, filename, fmt="X5", moving=None):
166166
# xform info
167167
lt = io.LinearTransform()
168168
lt["sigma"] = 1.
169-
lt["m_L"] = self.matrix
170169
# Just for reference, nitransforms does not write VOX2VOX
171-
lt["src"] = io.VolumeGeometry.from_image(moving)
172-
lt["dst"] = io.VolumeGeometry.from_image(self.reference)
170+
# PLEASE NOTE THAT LTA USES THE "POINTS" CONVENTION, therefore
171+
# the source is the reference (coordinates for which we need
172+
# to find a projection) and destination is the moving image
173+
# (from which data is pulled-back).
174+
lt["src"] = io.VolumeGeometry.from_image(self.reference)
175+
lt["dst"] = io.VolumeGeometry.from_image(moving)
176+
# However, the affine needs to be inverted
177+
# (i.e., it is not a pure "points" convention).
178+
lt["m_L"] = np.linalg.inv(self.matrix)
173179
# to make LTA file format
174180
lta = io.LinearTransformArray()
175181
lta["type"] = 1 # RAS2RAS

nitransforms/tests/test_linear.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
""".format,
3131
'fs': """\
3232
mri_vol2vol --mov {moving} --targ {reference} --lta {transform} \
33-
--o resampled.nii.gz --nearest --inv""".format,
33+
--o resampled.nii.gz --nearest""".format,
3434
}
3535

3636

0 commit comments

Comments
 (0)