-
Notifications
You must be signed in to change notification settings - Fork 1
/
HDR_3D_PostProcess.m
150 lines (134 loc) · 3.77 KB
/
HDR_3D_PostProcess.m
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
clear all;
close all;
f_patha = 'T:\Radonc_Shared\shared\Physics\Users\Bredfeldt\QA_RT\BlackCap\';
[file_list, f_path] = uigetfile('*.csv','',f_patha,'MultiSelect','on');
if iscell(file_list)
mult = 1;
num_files = length(file_list);
else
if file_list == 0
disp('No file was selected.');
return;
else
num_files = 1;
end
end
%search for matching files
%loop through all the files that were selected
nlist = cell(num_files,3);
for m = 1:num_files
if num_files > 1
f_file = file_list{m}; %convert from cell to string
else
f_file = file_list;
end
[~,fn,ext] = fileparts(f_file); %remove extension from filename
nlist(m,:) = strsplit(fn,'_');
end
for m = 1:num_files
for n = 1:num_files
c(m,n) = strcmp(nlist(m,2),nlist(n,2));
end
end
%for each match, process all files
for m = 1:num_files
for n = 1:num_files
if c(m,n) && m>n
[~,~,xa] = xlsread([f_path file_list{m}]);
[~,~,xb] = xlsread([f_path file_list{n}]);
%find first nan
for i = 1:length(xa)
if isnan(xa{i,1})
break;
end
end
%tandem
%compare 1D positions
a = cell2mat(xa(3:i-1,2:4));
b = cell2mat(xb(3:i-1,2:4));
d1 = a - b;
md1t(m,n,:) = mean(d1);
%compare 3D positions
d3 = sqrt(d1(:,1).^2 + d1(:,2).^2 + d1(:,3).^2);
md3t(m,n) = mean(d3);
%ring
%compare 1D positions
a = cell2mat(xa(i+3:end,2:4));
b = cell2mat(xb(i+3:end,2:4));
d1 = a - b;
md1r(m,n,:) = mean(d1);
%compare 3D positions
d3 = sqrt(d1(:,1).^2 + d1(:,2).^2 + d1(:,3).^2);
md3r(m,n) = mean(d3);
end
end
end
%%
%plot the results
i1 = 1; i2 = 1; i3 = 1;
for m = 1:num_files
for n = 1:num_files
if mod(m,3) == 2 && mod(n,3) == 1 && m>n && m<n+3
T(1,i1) = md3t(m,n);
R(1,i1) = md3r(m,n);
T1(1,i1,:) = md1t(m,n,:);
R1(1,i1,:) = md1r(m,n,:);
i1 = i1 + 1;
end
if mod(m,3) == 0 && mod(n,3) == 1 && m>n && m<n+3
T(2,i2) = md3t(m,n);
R(2,i2) = md3r(m,n);
T1(2,i2,:) = md1t(m,n,:);
R1(2,i2,:) = md1r(m,n,:);
i2 = i2 + 1;
end
end
end
%%
figure(1); clf;
boxplot(T');
ylabel('Average 3D Position Error (mm)');
set(gca,'XTickLabel',{'CT to MR1','CT to MR2'});
title('Tandem');
ylim([0 5]);
figure(2); clf;
boxplot(R');
ylabel('Average 3D Position Error (mm)');
set(gca,'XTickLabel',{'CT to MR1','CT to MR2'});
title('Ring');
ylim([0 5]);
figure(3); clf;
plot(T','*');
%ax = gca;
%ax.ColorOrderIndex = 1;
ylabel('Average 3D Position Error (mm)');
title('Tandem: Errors for each model');
legend('CT to MR1','CT to MR2');
set(gca,'XTickLabel',{'30R2T','30R4T','30R6T','45R2T','45R4T','45R6T','60R2T','60R4T','60R6T'});
figure(33);
plot(R','o');
ylabel('Average 3D Position Error (mm)');
title('Ring: Errors for each model');
legend('CT to MR1','CT to MR2');
set(gca,'XTickLabel',{'30R2T','30R4T','30R6T','45R2T','45R4T','45R6T','60R2T','60R4T','60R6T'});
%%
figure(4);
xt = T1(:,:,1); xt = xt(:);
yt = T1(:,:,2); yt = yt(:);
zt = T1(:,:,3); zt = zt(:);
td = [xt,yt,zt];
boxplot(td);
ylim([-3 3]);
ylabel('3D Position Error (mm)');
set(gca,'XTickLabel',{'X','Y','Z'});
title('Tandem: single dimension error distribution');
figure(5);
xr = R1(:,:,1); xr = xr(:);
yr = R1(:,:,2); yr = yr(:);
zr = R1(:,:,3); zr = zr(:);
rd = [xr,yr,zr];
boxplot(rd);
ylim([-3 3]);
ylabel('3D Position Error (mm)');
set(gca,'XTickLabel',{'X','Y','Z'});
title('Ring: single dimension error distribution');