Calculation of numerical data for transformation

I would like to know the rotation and translation of two segmented models, in numerical values. Could you please suggest the best way to do that.

Thanks

You can align segments using Segment Registration extension then see the transformation matrix values in Transforms module.

1 Like

Thank you Professor @lassoan.
It only gives translation along the xyz axes. Is it because the displacement here is based on the centre of mass/ centroid? If I want the rotation of a the rigid body/ bone- what should I do. In the transforms matrix rotation is indicated as 0 in all 3 axes. Do i have to define an axis of rotation please? Thanks

Tom

The sliders are only for changing the transforms, they don’t necessarily represent the current state.

The transformation is specified by a 4x4 homogeneous transformation matrix (top-left 3x3 matrix defines orientation and scaling, top-right 3x1 vector defines translation).

1 Like

Apologies Prof Lasso @lassoan.
I did not understand I am afraid- I am trying to see the change of position in terms of translation and rotation of two segments. Could you please let me know the numerical values given in the transform correspond to the translation of segment 2, compared to segment 1. If not, what should I do to calculate that, please? Also, how can I calculate rotation, please? Apologies for taking your time- I am a medical person with no software background. Thanks a lot.

Hi All

Sorry about all this amateur questions and new post. But could someone explain me how to get the displacement of one segment to another in terms of rotations please. I did segment registration and got a the linear transform, but I don’t know how to calculate Euler s angles of rotation of my segment out of this numbers. Thanks a lot

You can get Euler angles orientation matrix using this code snippet:

transformNode = getNode('LinearTransform_3')
transformMatrix = vtk.vtkMatrix4x4()
transformNode.GetMatrixTransformToParent(transformMatrix)
transform = vtk.vtkTransform()
transform.SetMatrix(transformMatrix)
orientation = transform.GetOrientation()
print(orientation)

Note that the same orientation can be encoded using many different combinations of rotations, even Euler angles have many variants.

If you need to use a particular convention then you can implement the angle computations from the corresponding mathematical formulae directly you can access orientation matrix element in the transformMatrix object in the example above.

1 Like

I can’t thank you enough Professor @lassoan
I will try this- I don’t get all the mathematical side of it, but my project is to segment bones and calculate the translation and rotation with time points. so I m planning to take the translation values , off the transform module top right and rotation in Euler angles with this. hope my steps are correct. Thanks again.

Hi Prof @lassoan

I have tried to use this code for my calculations of Euler angles.
When I apply to my linear transformation of known roll yaw and pitch, the values I get is only 2 values correct. What could be the possible.

Thanks

The same orientation can be encoded using many different combinations of rotations, even Euler angles have many variants. The code snippet above uses ZXY rotation order - see complete conversion between matrix and Euler angles representation in this post:

1 Like

Thank you Professor @lassoan

Hello Andras,

I’m wondering what the Z, X, and Y axes are in terms of LR, PA, and IS axes?
Thank you,

Michele

Slicer’s coordinate system axis directions are right, anterior, superior.

Yes, but you mentioned in your earlier post that the code snippet is uses the ZXY rotation order, and I was wondering which axes these correspond to, in the slicer axes?

Thank you,

Michele

I meant first, second, third coordinate system axis by X, Y, Z . Therefore, X=R, Y=A, Z=S.

Oh my apologies. Thank you very much!!

Michele