-
Notifications
You must be signed in to change notification settings - Fork 2
/
e01_3b_collectInformation.m
236 lines (213 loc) · 7.21 KB
/
e01_3b_collectInformation.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
% Information collector. This script:
% - reads in raw results from e01_2a_simProcessLLSQ.m & e01_2b_simProcessNLSQ.m
% - collects the following features:
% - the runtimes of each method
% - the kepRR estimates from the Linear and Non-Linear approach
% Estimated run time: < 1s
clearvars
fclose('all')
addpath('./mfiles');
refName = 'refY'; % Match this with e01_2*
% Choices are:
% 'refY'
% 'refWS'
% 'refP'
%% Simulation Properties
simProp = SimProperties(refName);
listCNR = simProp.CNR; % Range of Contrast-Noise Ratio to simulate
nVox = simProp.nVox; % Number of replications for each CNR
listTRes = simProp.TRes; % Temporal resolutions (in seconds)
tDuration = simProp.tDuration; % Duration of DCE Acquisition (in minutes)
% Pharmacokinetics of tumour tissue
Kt = simProp.Kt;
ve = simProp.ve;
kep = simProp.kep;
% Pharmacokinetics of reference tissue
KtRR = simProp.KtRR;
veRR = simProp.veRR;
kepRR = simProp.kepRR;
relKt = Kt/KtRR;
relVe = ve/veRR;
%%
dirLocation = DefaultFolders();
dataDir = fullfile(dirLocation.sim,simProp.name);
%%
tic
for i = 1:length(listCNR)
for j = 1:length(listTRes)
curFile = ['Sim-CNR-' num2str(listCNR(i)) ...
'-TRes-' num2str(listTRes(j)) '.mat'];
clrrmFile = fullfile(dataDir, 'CLRRM', curFile);
lrrmFile = fullfile(dataDir, 'LRRM', curFile);
nrrmFile = fullfile(dataDir, 'NRRM', curFile);
load(clrrmFile);
load(lrrmFile);
load(nrrmFile);
% Note down the run times
rN(i,j) = runtimeN;
rCN(i,j) = runtimeC;
rL(i,j) = runtimeLL;
rCL(i,j) = runtimeCL;
% Note down the estimated kepRR from LRRM and NRRM
estKepRRL(i,j) = estKepRRCL;
estKepRRN(i,j) = medianKepRR;
% Also, note down the mean kepRR (instead of the mean)
% estKepRRLm(i,j) = mean(pkParamsLLRaw(:,2)./pkParamsLLRaw(:,1));
% estKepRRNm(i,j) = mean(pkParamsN(4,:));
end
end
toc
return
% Code ends here, the next sections look into different features
%% Runtime as a function of DCE time points
noiseInd = 1; % Choose the CNR (index in variable 'listCNR')
% Plot the run time and do a polynomial fit
numTime = 600./listTRes; % Number of time points
x = 1:max(numTime);
fitRL = polyfit(numTime,rL(noiseInd,:),1); % Linear fit for Linear RRM
fitRN = polyfit(numTime,rN(noiseInd,:),2); % Quadratic fir for Non-Linear RRM
yRL = polyval(fitRL,x);
yRN = polyval(fitRN,x);
figure
scatter(numTime,rN(noiseInd,:))
hold on
plot(x,yRN);
hold off
xlabel('Number of DCE Frames')
ylabel('Run time [s]')
title(['Run time vs number of DCE timepoints - NRRM'])
legend('Measured','Quadratic Fit','Location','southeast')
figure
scatter(numTime,rL(noiseInd,:))
hold on
plot(x,yRL);
hold off
xlabel('Number of DCE Frames')
ylabel('Run time [s]')
title(['Run time vs number of DCE timepoints - LRRM'])
legend('Measured','Linear Fit','Location','southeast')
%% Runtime as function of DCE time points - for CLRRM & CNRRM at ALL noise
% Plot the run time and do a polynomial fit
numTime = 600./listTRes; % Number of time points
x = 1:max(numTime);
tempX=repmat(numTime,[10 1]);
fitRL = polyfit(tempX(:),rL(:),1); % Linear fit for Linear RRM
fitRCL = polyfit(tempX(:),rCL(:),1);
fitRN = polyfit(tempX(:),rN(:),2); % Quadratic fir for Non-Linear RRM
fitRCN = polyfit(tempX(:),rCN(:)+rN(:),2);
yRL = polyval(fitRL,x);
yRCL = polyval(fitRCL,x);
yRN = polyval(fitRN,x);
yRCN = polyval(fitRCN,x);
figure
scatter(tempX(:),rCN(:)+rN(:),'o')
hold on
plot(x,yRCN);
hold off
xlabel('Number of DCE Frames')
ylabel('Run time [s]')
title(['Run time vs number of DCE timepoints - NRRM'])
legend('Measured','Quadratic Fit','Location','southeast')
figure
scatter(tempX(:),rCL(:))
hold on
plot(x,yRCL);
hold off
xlabel('Number of DCE Frames')
ylabel('Run time [s]')
title(['Run time vs number of DCE timepoints - LRRM'])
legend('Measured','Linear Fit','Location','southeast')
%% Runtime as a function of Noise
% This is actually the runtime ratio where the reference value is the
% runtime at the lowest noise level.
% The question being asked here is whether noise affects the run time
% The answer seems to be... not really?
figure
plot(listCNR,rCN./repmat(rCN(end,:),[10 1]))
xlabel('CNR')
ylabel('Runtime Ratio')
title(['Runtime Ratio vs Noise at different temporal resolutions - CNRRM'])
legend('1s','5s','10s','15s','30s','60s')
figure
plot(listCNR,rCL./repmat(rCL(end,:),[10 1]))
xlabel('CNR')
ylabel('Runtime Ratio')
title(['Runtime Ratio vs Noise at different temporal resolutions - CLRRM'])
legend('1s','5s','10s','15s','30s','60s')
%% EstKepRR as a function of Noise - NRRM vs LRRM
TResInd = 6; % Choose the TemporalResolution (index in variable: listTRes)
figure
scatter(listCNR,PercentError(estKepRRL(:,TResInd),1),'^')
hold on
scatter(listCNR,PercentError(estKepRRN(:,TResInd),1),'o');
hold off
xlabel('CNR')
ylabel('Percent Error in Estimated k_{ep,RR}')
title(['Percent Error in Estimated k_{ep,RR} for TRes = ' num2str(listTRes(TResInd)) 's'])
legend('LRRM','NRRM')
% Use absolute percent error
figure
scatter(listCNR,abs(PercentError(estKepRRL(:,TResInd),1)),'^')
hold on
scatter(listCNR,abs(PercentError(estKepRRN(:,TResInd),1)),'o');
hold off
xlabel('CNR')
ylabel('Percent Error in Estimated k_{ep,RR}')
title(['Absolute Percent Error in Estimated k_{ep,RR} for TRes = ' num2str(listTRes(TResInd)) 's'])
legend('LRRM','NRRM')
%% EstKepRR as a function of TRes - NRRM vs LRRM
noiseInd = 1; % Choose the CNR (index in variable: 'listCNR')
figure
scatter(listTRes,PercentError(estKepRRL(noiseInd,:),1),'^')
hold on
scatter(listTRes,PercentError(estKepRRN(noiseInd,:),1),'o');
hold off
xlabel('Temporal Resolution [s]')
ylabel('Percent Error in Estimated k_{ep,RR}')
title(['Percent Error in Estimated k_{ep,RR} for CNR = ' num2str(listCNR(noiseInd))])
legend('LRRM','NRRM')
% Use absolute percent error
figure
scatter(listTRes,abs(PercentError(estKepRRL(noiseInd,:),1)),'^')
hold on
scatter(listTRes,abs(PercentError(estKepRRN(noiseInd,:),1)),'o');
hold off
xlabel('Temporal Resolution [s]')
ylabel('Percent Error in Estimated k_{ep,RR}')
title(['Absolute Percent Error in Estimated k_{ep,RR} for CNR = ' num2str(listCNR(noiseInd))])
legend('LRRM','NRRM')
%% Estimated kep,RR from LRRM
figure
scatter(listCNR,estKepRRL(:,1),'^')
hold on
scatter(listCNR,estKepRRL(:,4),'o')
hold on
scatter(listCNR,estKepRRL(:,6),'v')
hold off
xlabel('CNR')
ylabel('Estimated k_{ep,RR}')
title('Estimated k_{ep,RR} for different noise levels and temporal resolutions - LRRM')
legend('1s','15s','60s','Location','southeast')
%% Estimated kep,RR from NRRM
figure
scatter(listCNR,estKepRRN(:,1),'^')
hold on
scatter(listCNR,estKepRRN(:,4),'o')
hold on
scatter(listCNR,estKepRRN(:,5),'v')
hold off
xlabel('CNR')
ylabel('Estimated k_{ep,RR}')
title('Estimated k_{ep,RR} for different noise levels and temporal resolutions - NRRM')
legend('1s','15s','30s')
%% Difference of absolute percent error in kepRR
figure
scatter(listCNR,abs(PercentError(estKepRRL(:,1),1))-abs(PercentError(estKepRRN(:,1),1)),'^')
hold on
scatter(listCNR,abs(PercentError(estKepRRL(:,3),1))-abs(PercentError(estKepRRN(:,3),1)),'o')
scatter(listCNR,abs(PercentError(estKepRRL(:,5),1))-abs(PercentError(estKepRRN(:,5),1)),'v')
hold off
xlabel('CNR')
ylabel('Percent Error Difference')
title(['Difference in absolute percent error for kepRR (LRRM-NRRM)'])
legend('1s','15s','30s')