Problem in the calculation of the inverse of the BSpline using Simple ITK

I’m trying to calculate the inverse transformation of a BSpline Transformation and I’m following the instructions of this link here in the Discourse. Here is the code I’m using:

#Calculating the inverse of the Bspline
disp_field_bs = sitk.DisplacementFieldTransform(BS_result)
BS_inverse = disp_field_bs.GetInverseDisplacementField()

The problem is that I’m getting some error:

sitk::ERROR: Transform is not of type DisplacementFieldTransform!

I’ve checked the documentation and the DisplacementFieldTransform class has a constructor which accepts a Transformation. So what is the problem here?

1 Like

Hello @Everaldo,

This is indeed a feature/issue of the simpleitk transformation hierarchy.

To convert any transformation to a displacement field use the TransformToDisplacementFieldFilter which will output a displacement field image that can be used as input to the InverseDisplacementFieldImageFilter that returns the inverse displacement image. You can then use this image as input for the DisplacementFieldTransform constructor.