# Calculating RMSE in Landmarks Registration

Hi,
Could I ask if anyone has a code to calculate RMSE obtained from “Fiducial Registration Wizard” module?

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));

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.