# Get the transformation or displacement vector field with SITK

**URL:** https://discourse.itk.org/t/get-the-transformation-or-displacement-vector-field-with-sitk/5610
**Category:** Algorithms
**Tags:** registration, python, simpleitk
**Created:** [January 4, 2023, 5:13pm UTC](https://discourse.itk.org/t/get-the-transformation-or-displacement-vector-field-with-sitk/5610 "2023-01-04T17:13:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![VHK](https://discourse.itk.org/user_avatar/discourse.itk.org/vhk/32/3136_2.png) [@VHK](https://discourse.itk.org/u/VHK)
#### Post date: [January 4, 2023, 5:13pm UTC](https://discourse.itk.org/t/get-the-transformation-or-displacement-vector-field-with-sitk/5610/1 "2023-01-04T17:13:57Z")

</div>

Hello everyone,

I did the registration and want to calculate TRE (target registration error) with SITK. I have the fixed image and the deformed moving image, and the landmarks.

To compute TRE, I need to get the transformation or the displacement vector field. How can I get them in SITK?

Thanks for your help,  
Vahdaneh

---

<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 4, 2023, 6:11pm UTC](https://discourse.itk.org/t/get-the-transformation-or-displacement-vector-field-with-sitk/5610/2 "2023-01-04T18:11:47Z")

</div>

Hello @VHK,

Please take a look at the SimpleITK tutorial [advanced registration notebook](https://github.com/SimpleITK/TUTORIAL/blob/main/06_advanced_registration.ipynb), section titled _Quantitative evaluation_. The [65\_Registration\_FFD](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/65_Registration_FFD.ipynb) and [66\_Registration\_Demons](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/66_Registration_Demons.ipynb) notebooks from the general [notebook repository](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks) may also be of interest.

---

<div class="post-metadata">

### Author: ![VHK](https://discourse.itk.org/user_avatar/discourse.itk.org/vhk/32/3136_2.png) [@VHK](https://discourse.itk.org/u/VHK)
#### Post date: [January 4, 2023, 7:47pm UTC](https://discourse.itk.org/t/get-the-transformation-or-displacement-vector-field-with-sitk/5610/3 "2023-01-04T19:47:06Z")

</div>

Dear @zivy,

Many thanks for your answer. In _ **Quantitative evaluation** _ we can see how TRE is calculated. I actually know about this. As can be seen, we have to have a **‘final transformation’** to calculate TRE and I do not have this.

The point is that I use my own image registration framework, not the ones that are in SITK. So, I only have the deformed image. My question is how I can get the **final transformation** from the **deformed image** in **SITK**.

---

<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 4, 2023, 8:29pm UTC](https://discourse.itk.org/t/get-the-transformation-or-displacement-vector-field-with-sitk/5610/4 "2023-01-04T20:29:45Z")

</div>

Hello @VHK ,

Generally speaking, the answer is you cannot do this easily (not specific to SimpleITK, just an ill posed problem given your input).

If I understand correctly the input is:

1. `fixed_image`
2. `moving_image`
3. `deformed_image` - `moving_image` resampled onto the fixed image grid using an unknown `final_transformation` which you want to estimate.
4. corresponding point pairs localized in `fixed_image` and `moving_image` coordinate systems.

I would recommend that you localize the target points one more time, this time on the `deformed_image`. Then you have point pairs that are both in the `fixed_image` coordinate system, those localized in the `fixed_image` and those localized in the `deformed_image`. The distance between them is the TRE, no need to know the `final_transformation`.

The only way to explicitly obtain the `final_transformation` is to redo the registration. You can either register the `fixed_image` to the `moving_image` or the `deformed_image` to the `moving_image` and then you have the `final_transform`. This is more problematic because it introduces errors that are associated with this second registration.

---

<div class="post-metadata">

### Author: ![VHK](https://discourse.itk.org/user_avatar/discourse.itk.org/vhk/32/3136_2.png) [@VHK](https://discourse.itk.org/u/VHK)
#### Post date: [January 5, 2023, 3:21pm UTC](https://discourse.itk.org/t/get-the-transformation-or-displacement-vector-field-with-sitk/5610/5 "2023-01-05T15:21:33Z")

</div>

Thanks a lot! 🙂
