# How to compute Target Registration Error (TRE) of Rigid Body Registration in SITK?

**URL:** https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292
**Category:** Beginner Questions
**Tags:** registration, python, simpleitk
**Created:** [August 25, 2022, 7:39am UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292 "2022-08-25T07:39:22Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![debapriya](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/bc79bd/32.png) [@debapriya](https://discourse.itk.org/u/debapriya)
#### Post date: [August 25, 2022, 7:39am UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292/1 "2022-08-25T07:39:22Z")

</div>

Hello,

I am trying to find out TRE of 3D Multimodal Rigid Medical Image Registration using metric `JointHistogramMutualInformation`. The TRE function of SimpleITK takes a list of landmark points from the fixed and moving images, as input parameters.

```auto
initial_TRE = utilities.target_registration_errors(sitk.Transform(), fixed_points, moving_points)
final_TRE = utilities.target_registration_errors(final_transformation, fixed_points, moving_points)

```

How can I generate `fixed_points` and `moving_points` in case of rigid registration using Mutual Information?

---

<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: [August 25, 2022, 5:00pm UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292/2 "2022-08-25T17:00:24Z")

</div>

Hello @debapriya,

The TRE concept is independent from the metric used for registration. To compute TRE you need to obtain pairs of corresponding points in the fixed and moving coordinate systems. Note that these points are not used in the registration process itself. You then use the transformation estimated by the registration process to transform the points from the fixed coordinate system to the moving coordinate system and compute the distance between the transformed point and the actual point in the moving coordinate system (the TRE).

The easiest way to obtain corresponding points is to manually identify them (e.g. the `RegistrationPointDataAquisition` GUI used in [this Jupyter notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/63_Registration_Initialization.ipynb)).

---

<div class="post-metadata">

### Author: ![debapriya](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/bc79bd/32.png) [@debapriya](https://discourse.itk.org/u/debapriya)
#### Post date: [August 26, 2022, 2:46pm UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292/3 "2022-08-26T14:46:54Z")

</div>

Thank you @zivy .

`gui.RegistrationPointDataAquisition` is showing me the corresponding points in the two images.

 ![image](https://discourse.itk.org/uploads/default/original/2X/3/350ee3387943938b1f87d5c21b5b87d48747cc6e.png)

However, I need the coordinates of the points. How can I get the coordinates?

---

<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: [August 28, 2022, 1:41pm UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292/4 "2022-08-28T13:41:31Z")

</div>

Hello @debapriya,

Please take a look at the Jupyter notebook that I pointed to in the previous post (hint: the method you are looking for starts with `get_p...`.

---

<div class="post-metadata">

### Author: ![debapriya](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/bc79bd/32.png) [@debapriya](https://discourse.itk.org/u/debapriya)
#### Post date: [August 31, 2022, 4:00pm UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292/5 "2022-08-31T16:00:37Z")

</div>

Thank you @zivy .  
I could get the coordinates from `point_acquisition_interface.get_points()`. Hope this is the method you hinted.

I have another query.  
With `point_acquisition_interface.get_points()`, we are manually selecting the corresponding points in the two images. However, in 3D images, two consecutive slices can have very similar images. Is there a way to decide which slice gives the correct correspondence with the fixed image?

For example, in the below two figures, both slice 4 and 5 in the moving image have similarity with slice 4 of the fixed image.

Slice 4 of Fixed image and Slice 4 of Moving image

 ![Slice4_Moving](https://discourse.itk.org/uploads/default/original/2X/4/48c5aa552d848c3e194e313a6c4ec03b4497766a.jpeg)

Slice 4 of Fixed image and Slice 5 of Moving image

 ![Slice5_Moving](https://discourse.itk.org/uploads/default/original/2X/3/368f31e333935f3fe8a5ca3d0355546646795aa0.jpeg)

How can I visually decide which correspondence is correct?

---

<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: [August 31, 2022, 5:39pm UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292/6 "2022-08-31T17:39:39Z")

</div>

Hello @debapriya,

Generally speaking, accurately and precisely localizing corresponding points in a manual fashion is not easy because anatomical structures are usually smooth, no unique well defined corner points (vessel bifurcations are an exception and are reasonably well defined). This is why fiducials, external markers, are often used.

Having said that, you can use another registration to help with the task of localizing corresponding points changing it from a fully manual process to a semi-automatic one. Local rigid registration is used to refine a coarse manual localization which is then visually verified. [This notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/67_Registration_Semiautomatic_Homework.ipynb) formulates the task - you will need to implement the solution.

[This paper](https://yanivresearch.info/writtenMaterial/nagy2014.pdf) discusses the approach and may also be helpful.

---

<div class="post-metadata">

### Author: ![debapriya](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/bc79bd/32.png) [@debapriya](https://discourse.itk.org/u/debapriya)
#### Post date: [October 7, 2022, 9:52am UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292/7 "2022-10-07T09:52:25Z")

</div>

I have gone through the notebook and the paper that you referred.

My task is to compare TRE of three intensity based rigid registration algorithms (`JointHistogramMutualInformation`, `MattesMutualInformation` and `My_Metric`). Is it logical to use the semi-automatic method here? If yes, which intensity based registration, among the three, should I use for refining the manual localization?

---

<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: [October 7, 2022, 1:12pm UTC](https://discourse.itk.org/t/how-to-compute-target-registration-error-tre-of-rigid-body-registration-in-sitk/5292/8 "2022-10-07T13:12:02Z")

</div>

Hello @debapriya,

Yes, it is logical to use the semi-automated method. It’s assumption is that the object remains _locally_ rigid which is a closer approximation to reality than the assumption that the _whole_ object is rigid.

The reason for using a semi-automated approach is that the human operator can identify cases where the automated localization fails and ignore those.

With respect to which metric to use for the local registration, assuming all metrics are equal in terms of accuracy, the most straightforward approach is to use all three and combine the results. An ensemble regression, the final result is the mean point - don’t average the transformations that is a non-linear space and is more complicated to do than what you need.
