Assessing average displacement resulting from a linear transform

Hi,

Is there a way in Slicer to calculate the mean DTI distortion (e.g. as mean transform needed to align DTI to T2w, like the root mean square deviation).

I found this:

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5118068/#R34 ->

From the paper:

"We also calculated the root mean square (RMS) deviation for each subject, which combines the six rigid body parameters into a single estimator of mean displacement [Jenkinson, 1999; Reuter et al., 2015]:

RMS = sqrt{r∗r ∕ 5 + tr[(M−I)T(M − I)] + tTt},

where t is the translation vector, M is (here) the 3×3 rotation matrix, I is the identity matrix, tr[] is the trace operator, and r is the approximate spherical radius of the brain (here, estimated from the data to be 65 mm). The rigid body parameters and RMS values of the navigator logs were also examined."

I have a slicer transform file (.h5) for each of my subjects and wonder if there is a way to calculate the RMS (or a similar measure) from them.

Thanks, Lorenz

This formula in Taylor2016 incorrect (since it would give non-zero value for an identity matrix), don’t use this:

The formula in Reuter2015 (the paper that Taylor2016 cites) looks correct:

image

You can get the value in Slicer by copy-pasting the following code into the Python console:

transformNode = getNode('MyLinearTransform')
r = 15

import numpy as np
import math
transformMatrix = slicer.util.arrayFromTransformMatrix(transformNode)
t = transformMatrix[0:3,3]
M = transformMatrix[0:3,0:3]
RMS = math.sqrt(r * r / 5.0 * np.trace( (M-np.eye(3)).T @ (M-np.eye(3)) ) + np.dot(t,t))
print(RMS)

Thank you very much! This is very helpful!

I tried copy-pasted the code and filled in the name of my transform. I get the following error. How can I fix this?

>>> transformNode = getNode('003_transform')
>>> r = 15
>>> import numpy as np
>>> import math
>>> transformMatrix = slicer.util.arrayFromTransformMatrix(transformNode)
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'arrayFromTransformMatrix'

Thanks again,
Lorenz

This script works in recent Slicer Preview Releases. If you need to use latest Slicer Stable Release (4.10.2) then you can copy the slicer.util.arrayFromTransformMatrix method from here.

It used it in the newest nightly release and it worked. Thank you very much again! I appreciate it a lot. - Lorenz

1 Like