# Determine if a transform node contains actual transformation or is identity

**URL:** https://discourse.slicer.org/t/determine-if-a-transform-node-contains-actual-transformation-or-is-identity/15387
**Category:** Support
**Tags:** registration
**Created:** [January 7, 2021, 11:58am UTC](https://discourse.slicer.org/t/determine-if-a-transform-node-contains-actual-transformation-or-is-identity/15387 "2021-01-07T11:58:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [January 7, 2021, 11:58am UTC](https://discourse.slicer.org/t/determine-if-a-transform-node-contains-actual-transformation-or-is-identity/15387/1 "2021-01-07T11:58:12Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [January 7, 2021, 4:41pm UTC](https://discourse.slicer.org/t/determine-if-a-transform-node-contains-actual-transformation-or-is-identity/15387/2 "2021-01-07T16:41:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [January 7, 2021, 4:45pm UTC](https://discourse.slicer.org/t/determine-if-a-transform-node-contains-actual-transformation-or-is-identity/15387/3 "2021-01-07T16:45:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [January 7, 2021, 4:53pm UTC](https://discourse.slicer.org/t/determine-if-a-transform-node-contains-actual-transformation-or-is-identity/15387/4 "2021-01-07T16:53:22Z")

</div>

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