itksnap txt file saved after manual registration

This is the txt file that I saved after manually registering itksnap:
#Insight Transform File V1.0
#Transform 0
Transform: MatrixOffsetTransformBase_double_3_3
Parameters: 0.9999932831934126 -0.00005697241326605847 -0.003664740400452174 0.0000153526386869449 0.999935520256914 -0.011355839591630987 0.0036651510685188405 0.011355707053217666 0.9999288047581026 50.82752907152394 -19.93882591957195 -20.086759849693525
FixedParameters: 0 0 0

I just rotated and translated the image. What is the information in the Txt file and how can I use it to convert the image to get a new image?

Hello @ljjiayou,

This is a 3D affine transformation (even if you just did a rigid alignment).

Code for resampling the moving image onto the fixed image grid using SimpleITK below (ITK code would look very similar):

import SimpleITK as sitk

fixed_image_file_name = 
moving_image_file_name =
resampled_moving_image_file_name = 
transform_file_name = 

fixed_image = sitk.ReadImage(fixed_image_file_name)
moving_image = sitk.ReadImage(moving_image_file_name)
tx = sitk.ReadTransform(transform_file_name)

resampled_moving_image = sitk.Resample(moving_image, fixed_image, tx)
sitk.WriteImage(resampled_moving_image, resampled_moving_image_file_name)


Thank you very much. I have one more question for you. After I have calculated the rigid transformation parameters (rotation and shift) between the two images using the marked key pairs, I want to use sitk.Euler3DTransform() to transform the image. But I’m not sure about the ‘center’ parameter in Euler3DTransform(). Does the ‘center’ parameter usually use the center of the image or is there some other rule? I hope you can help me.

Hello @ljjiayou,

I don’t think you need to modify anything, likely you can ignore the usage of the center point as it is taken care of by the algorithm you used.

Having said that, based on your description and without seeing code, you are using paired point registration (LandmarkBasedTransformInitializer)? Something along the lines of the “manual initialization” section in this notebook.

If yes, the center of rotation may vary based on what is used in the algorithm. If the point coordinates are with respect to the coordinate system origin (0,0,0) then that is the rotation center. If not, then often it is the center of the image and the coordinates are modified relative to it before the computation.

For more details about ITK/SimpleITK transforms and the usage of a center point see this notebook, likely the relevant section is Modify transform center without changing the transformation effect.