Is there a way to get the coregistration metrics (that are normally output after using "Refine registration") after manually adjusting the coregistration? Sometime the regine registration doesn't do well, so I need to manually fix it, but would still like to know some metrics about the fit.
Hi @maggierempe, stats for the distance between head points and head surface are not stored, but they can be easily recomputed from the Scalp surface and the HeadPoints.
If manual registration was performed, set the tolerance to 0, i.e., no points were removed removed.
%% Parameters
% Subject
subjectName = 'Subject21';
% Folder with channel file
conditionName = '@rawS01_AEF_20131218_01_600Hz';
% Longest XX% of distances discarded from statistics
tolerance = 0.02;
%% Computation
% Get scalp surface
sSubject = bst_get('Subject', subjectName);
SurfaceMat = in_tess_bst(sSubject.Surface(sSubject.iScalp).FileName);
% Get head points
[~, iStudy] = bst_get('Study', bst_fullfile(bst_fileparts(sSubject.FileName), conditionName, 'brainstormstudy.mat'));
ChannelFile = bst_get('ChannelFileForStudy', iStudy);
ChannelMat = in_bst_channel(ChannelFile);
HeadPoints = channel_get_headpoints(ChannelMat, 1, 1);
HP = HeadPoints.Loc';
% Compute distance as in `bst_meshfit.m`
VertNorm = tess_normals(SurfaceMat.Vertices, SurfaceMat.Faces);
iNearest = bst_nearest(SurfaceMat.Vertices, HP, 1, 0);
dist = abs(sum(VertNorm(iNearest,:) .* (HP - SurfaceMat.Vertices(iNearest,:)),2));
% Remove distances to be ignored
nRemove = ceil(tolerance * size(HP,1));
dist = sort(dist);
dist = dist(1:end-nRemove);
%% Report
% Distance between fitted points and reference surface
strReport = ['Distance between ' num2str(length(dist)) ' head points and head surface:' 10 ...
' | Mean : ' sprintf('%4.1f', mean(dist) * 1000) ' mm | Distance > 3mm: ' sprintf('%3d points (%2d%%)\n', nnz(dist > 0.003), round(100*nnz(dist > 0.003)/length(dist))), ...
' | Max : ' sprintf('%4.1f', max(dist) * 1000) ' mm | Distance > 5mm: ' sprintf('%3d points (%2d%%)\n', nnz(dist > 0.005), round(100*nnz(dist > 0.005)/length(dist))), ...
' | Std : ' sprintf('%4.1f', std(dist) * 1000) ' mm | Distance > 10mm: ' sprintf('%3d points (%2d%%)\n', nnz(dist > 0.010), round(100*nnz(dist > 0.010)/length(dist))), ...
' | Number of outlier points removed: ' sprintf('%d (%d%%)', nRemove, round(tolerance*100)), 10 ...
' | Initial number of head points: ' num2str(size(HeadPoints.Loc,2))];
disp(strReport)