A composite transform node, such as those created by an ANTs QuickSyN registration, is not cloned correctly by the subject hierarchy node. I am using Slicer 5.8.1 on Windows 11. I have been working on taking apart and reassembling composite transforms and initially thought that my code must have errors somewhere, but I have now reproduced the problems without using any of my code.
Clone the transform (e.g. by right-clicking on it in the subject hierarchy and clicking “Clone”)
Alternately soft-apply the original and the cloned transformation to MRHead. Note the visible shifts in the image distortion in the slice views
This particular transform was created using the QuickSyN preset in the “General Registration (ANTs)” module, but it shouldn’t matter how it was created: a cloned MRML node should behave just like the original. I wonder if the problem might arise from the fact that the component transforms of this composite transform are both defined in the inverse (“FromParent”) direction, and maybe something in the cloning isn’t respecting or appreciating that? It looks like the actual copying in CloneSubjectHierarchyItem is done with a call to CopyContent(), which in turn involves a call to DeepCopyTransform in vtkMRMLTransformNode.cxx. I would speculate that the problem is here, but I don’t follow the C++ well enough to pinpoint the issue.
I do regard this as a relatively serious bug. I have never had cause previously to doubt the reliability of cloning a node in Slicer.
It sounds like your guess is correct about where the bug is. It would help if you could write a small self contained script to reproduce this and file an issue on github. There’s probably just a small change needed in the mrml code.
That’s probably the case. Looks like the order of linear and grid transforms are swapped in cloned and original one. Transforms are exactly the same, but the order is not preserved during the cloning for some reason.
Thanks, that’s what it looked like, but I was hoping that someone would be able to look at the C++ code and fix it so it worked appropriately in all cases. In this case, it was reversed, but I wasn’t sure if there were other cases where reversing the order would not be the right thing to do. It seems like Andras took a look and was able to fix it, hopefully in a general way.