I’m working on a project where I use a
Versor3DRigidTransform for registering 3D MRI images, and I’m having some issues interpreting the output from the registration results. My end goal is to get a transformation which is equivalent to a centered rotation (as in the middle of the image) and a translation, this is because I’m applying image corrections in the frequency domain (i.e. MRI k-space data).
I’ve generated test data with a 3D Shepp Logan phantom with a 45 deg rotation between the fixed and moving image. The images are generated outside of ITK and I use
itk.image_from_array to create an image object, where I specify the centre of the image as the origin.
spacing = [1,1,1] img = itk.image_from_array(np.abs(np.ascontiguousarray(img_array))) img.SetSpacing([float(x) for x in spacing]) img.SetOrigin([-img_array.shape[i]/2*spacing[i] for i in range(3)])
I set up an initialiser with
.GeometryOn() to ensure the image origin is used for the transformation.
After running the registration I resample the moving image to the fixed space and I get a perfect overlap, but when I look at the estimated registration parameters there is a discrepancy in the rotation estimate between the versor rotation and the rotation matrix which I dont understand.
The final parameters from the registration are:
Rotation: (-0.04, 0.01, -21.93) deg Translation: (-0.39, 0.94, 0.00) mm
But when I pull out the rotation matrix and the offset using
.GetOffset() I get
[-8.49832563e-04 -9.54532133e-04 -1.09447133e-05] [[ 7.07122107e-01 7.07090904e-01 8.82676813e-04] [-7.07091446e-01 7.07121348e-01 1.04216899e-03] [ 1.12748595e-04 -1.36107396e-03 9.99999067e-01]]
The offset is basically 0, which I was hoping since I set the origin to be at iso-centre. But the rotation matrix equates to the following rotations (if my math is correct):
Rotation (x,y,z): -0.078, -0.00646, -45.0 degrees
And this is what I would expect.
Can someone explain why there is this difference in the outputs?
Please let me know if you need more information, I could go on and on about the details but tried to make it as brief as possible.