# Calculating RMSE in Landmarks Registration

**URL:** <https://discourse.slicer.org/t/calculating-rmse-in-landmarks-registration/26049>\
**Category:** Support\
**Created:** [November 3, 2022, 10:45am UTC](https://discourse.slicer.org/t/calculating-rmse-in-landmarks-registration/26049 "2022-11-03T10:45:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![domP](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/domp/32/17086_2.png) [@domP](https://discourse.slicer.org/u/domP)\
**Post date:** [November 3, 2022, 10:45am UTC](https://discourse.slicer.org/t/calculating-rmse-in-landmarks-registration/26049/1 "2022-11-03T10:45:36Z")

</div>

Hi,  
Could I ask if anyone has a code to calculate RMSE obtained from “Fiducial Registration Wizard” module?  
I have read the repository’s code linked below:

> <https://github.com/SlicerIGT/SlicerIGT/blob/master/FiducialRegistrationWizard/Logic/vtkSlicerFiducialRegistrationWizardLogic.cxx#L480>

but when I have tried to replicate it on Matlab I have got the wrong result.

Below my data and results:  
Fixed points: [61.8616132503630; 48.4552443635927; 42.4899670291801]  
[29.4899390311330; 48.4552443635927; 23.5335812251265]  
[77.9016320076391; 48.4552443635927; 35.1990494122364]

Moving points transformed: [61.9137516947608; 48.4552459716797; 43.5304726392767]  
[27.5809622469604; 48.4552459716797; 22.7209879790148]  
[79.7584735999537; 48.4552459716797; 34.9711363721714]

RMSE from Slicer: 1.7214  
RMSE from Matlab: 0.8654

Fixed and moving points are expressed in RAS coordinates.

Below my Matlab code:

euclideanDistance= zeros(3,1);  
for i= 1:3  
euclideanDistance(i)= ((norm(points\_moving{i} - points\_fixed{i})));  
end  
RMSE= sqrt(mean(euclideanDistance));

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 3, 2022, 3:56pm UTC](https://discourse.slicer.org/t/calculating-rmse-in-landmarks-registration/26049/2 "2022-11-03T15:56:20Z")

</div>

You need compute the mean of the `error^2` (`vtkMath::Distance2BetweenPoints` provides distance^2). In your matlab code you computed the mean of `error` instead.
