My code with VersorTransform & CompositeTransform doesn’t work anymore after I updated SimpleITK from 1.2.4 to anything above 2.0.0. Diving into the issue, I found that for some reason by adding VersorTransform into a CompositeTransform, the offset for VersorTransform gets reset to zero. [Credits to Josh M. who identified the bug]
I am using a temporary fix of replacing VersorTransform with VersorRigid3DTransform, which works perfectly fine with CompositeTransform. Nevertheless, it would be really helpful if this issue can be corrected in the newer version.
import SimpleITK as sitk
rotTrans = sitk.VersorTransform((0, 1, 0), -np.pi/2)
rotTrans.SetCenter((10, 10, 10))
compositeTrans = sitk.CompositeTransform([rotTrans])
print(rotTrans)
print(compositeTrans)
And the corresponding output:
itk::simple::VersorTransform
VersorTransform (000002048ADD4060)
RTTI typeinfo: class itk::VersorTransform<double>
Reference Count: 1
Modified Time: 670
Debug: Off
Object Name:
Observers:
none
Matrix:
-2.22045e-16 0 -1
0 1 0
1 0 -2.22045e-16
Offset: [20, 0, 4.44089e-16]
Center: [10, 10, 10]
Translation: [0, 0, 0]
Inverse:
-2.22045e-16 0 1
0 1 0
-1 0 -2.22045e-16
Singular: 0
Versor: [ -0, -0.707107, -0, 0.707107 ]
itk::simple::CompositeTransform
CompositeTransform (00000204FFC1F140)
RTTI typeinfo: class itk::CompositeTransform<double,3>
Reference Count: 1
Modified Time: 680
Debug: Off
Object Name:
Observers:
none
Transforms in queue, from begin to end:
>>>>>>>>>
VersorTransform (000002048ADD50E0)
RTTI typeinfo: class itk::VersorTransform<double>
Reference Count: 1
Modified Time: 676
Debug: Off
Object Name:
Observers:
none
Matrix:
-2.22045e-16 0 -1
0 1 0
1 0 -2.22045e-16
Offset: [0, 0, 0]
Center: [10, 10, 10]
Translation: [0, 0, 0]
Inverse:
-2.22045e-16 0 1
0 1 0
-1 0 -2.22045e-16
Singular: 0
Versor: [ -0, -0.707107, -0, 0.707107 ]
End of MultiTransform.
<<<<<<<<<<
TransformsToOptimizeFlags, begin() to end():
1
TransformsToOptimize in queue, from begin to end:
End of TransformsToOptimizeQueue.
<<<<<<<<<<
End of CompositeTransform.
<<<<<<<<<<