[8406bc]: / MATLAB / analysis / findDuplicateSubjects.m

Download this file

61 lines (52 with data), 1.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
%FINDDUPLICATESUBJECTS finds duplicate subjects in the database.
%
% AUTHOR: Maximilian C. M. Fischer
% COPYRIGHT (C) 2023 Maximilian C. M. Fischer
% LICENSE: EUPL v1.2
%
clearvars; close all
addpath(genpath('..\src'))
VSD_addPathes('..\..\..\..\..\')
% Load subjects & meta data
subjectXLSX = '..\res\VSD_Subjects.xlsx';
Subjects = readtable(subjectXLSX);
%% Import
NoS = size(Subjects, 1);
patchProps.FaceAlpha = 0.5;
TFM2 = repmat(struct('APP',[]),NoS,1);
Sacrum = repmat(struct('vertices',[],'faces',[]),NoS,1);
for s=1:NoS
% Import the bones
load(['..\..\Bones\' Subjects.ID{s} '.mat'], 'B')
% Import the transformation to the APP coordinate system
load(['D:\Biomechanics\Hip\Code\AcetabularMorphologyAnalysis\data\' Subjects.ID{s} '.mat'], 'TFM2APP')
TFM2(s).APP = TFM2APP;
% Transform the sacrum to the APP coordinate system
Sacrum(s) = transformPoint3d(splitMesh(...
B(ismember({B.name},'Sacrum')).mesh,'maxBoundingBox'), TFM2(s).APP);
end
clearvars B TFM2APP
% Compare the sacrum of each subject using an ICP registration
patchProps.FaceAlpha = 0.5;
SS = 1:NoS;
rigidRegRMSE = nan(NoS);
for s=1:NoS
SS(SS==s)=[];
for ss=SS
rigidReg = icp(Sacrum(s),Sacrum(ss),'Plot',false,'ChangeRate',1e-2,'Delay',0);
rigidRegRMSE(s,ss) = rigidReg.rmse;
end
end
save('rigidRegRMSE','rigidRegRMSE')
%% Evaluate results
load('rigidRegRMSE','rigidRegRMSE')
medianRMSE = median(rigidRegRMSE(:), 'omitnan');
outlierCutOff = prctile(rigidRegRMSE(:),25)-1.5*iqr(rigidRegRMSE(:));
[row,col] = ind2sub(size(rigidRegRMSE),find(rigidRegRMSE<outlierCutOff));
for d=1:length(row)
disp([...
'Subject ' Subjects.ID{row(d)} ' and ' Subjects.ID{col(d)} ...
' are dupes based on a comparison of the sacrum!'])
end
% [List.f, List.p] = matlab.codetools.requiredFilesAndProducts([mfilename '.m']);
% List.f = List.f'; List.p = List.p';