Determine if a transform node contains actual transformation or is identity

I wonder if there is a simple way to determine if a transform node is identity or not. The reason why it is not trivial is that such a node can contain a linear transform in which case it is simple, but can also contain various types of deformable transforms, in which case it is not trivial.

So for example if there is a method already existing for this, then I’d appreciate if someone could point it out.

An idea that I have for checking it for deformable transforms is seeing whether the transform and its inverse are the same, but it might take too long for a simple check (in my case it is for determining whether a button should be enabled or not).

Thanks!

The method to determine if a non-linear transform is identity is different for each transform type.

  • linear: compare with slicer.vtkAddonMathUtilities.MatrixAreEqual() to an identity matrix
  • thin-plate spline: source and target landmark point positions are the same
  • grid and bspline: coefficient image values are all 0 (minimum and maximum scalar range is 0)

You can get the list of transforms in a node using FlattenGeneralTransform and then use the rules above to check if each component is identity.

Thanks @lassoan ! Would it be useful to have one method in Slicer for this?

Yes, I it could be useful. You could add them as static functions to vtkTransform class.