Skip to content

Commit b951db7

Browse files
committed
fix: seems like LTA affines are defined inversed
In other words, the ``src volume`` is the moving image and the ``dest volume`` is the reference image. However, the matrix written in the file seems to map coordinates from ``src`` to ``dest`` (i.e., it is the right one to move the data from ``dest`` to ``src``.
1 parent b49e9f2 commit b951db7

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

nitransforms/io/lta.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,38 @@ def set_type(self, new_type):
160160
)
161161

162162
def to_ras(self, moving=None, reference=None):
163-
"""Return a nitransforms internal RAS+ matrix."""
163+
"""
164+
Return a nitransforms' internal RAS+ array.
165+
166+
Seemingly, the matrix of an LTA is defined such that it
167+
maps coordinates from the ``dest volume`` to the ``src volume``.
168+
Therefore, without inversion, the LTA matrix is appropiate
169+
to move the information from ``src volume`` into the
170+
``dest volume``'s grid.
171+
172+
.. important ::
173+
174+
The ``moving`` and ``reference`` parameters are dismissed
175+
because ``VOX2VOX`` LTAs are converted to ``RAS2RAS`` type
176+
before returning the RAS+ matrix, using the ``dest`` and
177+
``src`` contained in the LTA. Both arguments are kept for
178+
API compatibility.
179+
180+
Parameters
181+
----------
182+
moving : dismissed
183+
The spatial reference of moving images.
184+
reference : dismissed
185+
The spatial reference of moving images.
186+
187+
Returns
188+
-------
189+
matrix : :obj:`numpy.ndarray`
190+
The RAS+ affine matrix corresponding to the LTA.
191+
192+
"""
164193
self.set_type(1)
165-
return self.structarr['m_L']
194+
return np.linalg.inv(self.structarr['m_L'])
166195

167196
def to_string(self):
168197
"""Convert this transform to text."""

0 commit comments

Comments
 (0)