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

**URL:** https://discourse.itk.org/t/problem-in-the-calculation-of-the-inverse-of-the-bspline-using-simple-itk/2624
**Category:** Algorithms
**Tags:** simpleitk
**Created:** [January 15, 2020, 4:49am UTC](https://discourse.itk.org/t/problem-in-the-calculation-of-the-inverse-of-the-bspline-using-simple-itk/2624 "2020-01-15T04:49:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Everaldo](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b9bd4f/32.png) [@Everaldo](https://discourse.itk.org/u/Everaldo)
#### Post date: [January 15, 2020, 4:49am UTC](https://discourse.itk.org/t/problem-in-the-calculation-of-the-inverse-of-the-bspline-using-simple-itk/2624/1 "2020-01-15T04:49:48Z")

</div>

I’m trying to calculate the inverse transformation of a BSpline Transformation and I’m following the instructions of this [link](https://discourse.itk.org/t/inverse-of-bspline-transform/496/2) 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?

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [January 15, 2020, 4:17pm UTC](https://discourse.itk.org/t/problem-in-the-calculation-of-the-inverse-of-the-bspline-using-simple-itk/2624/2 "2020-01-15T16:17:39Z")

</div>

Hello @Everaldo,

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

To convert any transformation to a displacement field use the [TransformToDisplacementFieldFilter](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1TransformToDisplacementFieldFilter.html) which will output a displacement field **image** that can be used as input to the [InverseDisplacementFieldImageFilter](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1InverseDisplacementFieldImageFilter.html#details) that returns the inverse displacement **image**. You can then use this image as input for the [DisplacementFieldTransform](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1DisplacementFieldTransform.html) constructor.
