Exporting Rigid Registration result as Transform results in strange errors


I rigidly registered two images using the Landmark-Based registration. I chose “Affine Registration” as the Registration Type and “Rigid” as Registration Mode. The resulting registration looks good, so I tried to export the transform for usage in other programs by choosing “save”.
However, the resulting files (I tested both .txt and .mat) have a slightly different transformation matrix than what I get when I look at the transform in slicer (Right click on the transformation->Edit properties).

Slicer’s GUI shows:

In the text file, I have:

#Insight Transform File V1.0
#Transform 0
Transform: AffineTransform_double_3_3
Parameters: 0.9989776251379424 0.04090843080016693 -0.01924070589205142 -0.04089969593416781 0.9991628979972874 0.0008474303244814285 0.01925926650340259 -0.00005962491247667927 0.9998145213481452 -4.374452815811267 -95.00156325189849 424.48027296194584
FixedParameters: 0 0 0

I expect the first 9 parameters to be the rotation and the last three to be the translation. Some values are not the same (see for example the x-value of the translation which changes from -7 mm to -4 mm)

When applying the exported transform in blender or paraview (to the segmented meshes which I get from the original images) I thus get a small offset in position and rotation.

Tested with Slicer Version 4.8.0 r26489. Is this a bug, or am I interpreting the transform wrong in the other programs?

What you describe is the correct behavior. The difference that you see compared to the transform in Slicer GUI is due to ITK storing resampling transform (“from parent” direction) between data sets are defined in LPS coordinate system. See explanation and conversions between different coordinate systems and directions here: https://www.slicer.org/wiki/Documentation/Nightly/Modules/Transforms#Transform_files

1 Like

Thank you, that was the issue! I was able to get the correct transformation into another program by loading the saved transform and using the python script under the link you posted to convert it.

Thanks a lot for the quick reply as well!

1 Like