-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloodVolumeRate.m
472 lines (346 loc) · 20.2 KB
/
bloodVolumeRate.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
function [] = bloodVolumeRate(maskArtery, maskVein, v_RMS, M0_disp_video, ToolBox, k, path, flagBloodVelocityProfile)
PW_params = Parameters_json(path);
veins_analysis = PW_params.veins_analysis;
exportVideos = PW_params.exportVideos;
force_width = [];
if ~isempty(PW_params.forcewidth)
force_width = PW_params.forcewidth;
end
tic
mkdir(ToolBox.PW_path_png, 'volumeRate')
mkdir(ToolBox.PW_path_eps, 'volumeRate')
[numX, numY, numFrames] = size(v_RMS);
[X, Y] = meshgrid(1:numY, 1:numX);
Color_std = [0.7 0.7 0.7];
v_RMS_AVG = mean(v_RMS, 3);
fullTime = linspace(0, numFrames * ToolBox.stride / ToolBox.fs / 1000, numFrames);
%% 0) Change mask section
radius1 = (PW_params.radius_ratio - PW_params.radius_gap) * (numY + numX) / 2;
radius2 = (PW_params.radius_ratio + PW_params.radius_gap) * (numY + numX) / 2;
cercle_mask1 = sqrt((X - ToolBox.x_barycentre) .^ 2 + (Y - ToolBox.y_barycentre) .^ 2) <= radius1;
cercle_mask2 = sqrt((X - ToolBox.x_barycentre) .^ 2 + (Y - ToolBox.y_barycentre) .^ 2) <= radius2;
maskSection = xor(cercle_mask1, cercle_mask2);
figure(1)
imagesc(maskSection), axis image
%% 1) Find the locations of the sections
%% 1) 1) Arteries
maskSectionArtery = maskSection .* maskArtery;
figure(110)
imagesc(maskSectionArtery .* v_RMS_AVG), axis image
maskSectionArtery = bwlabel(maskSectionArtery);
figure(111)
imagesc(maskSectionArtery), axis image
numSectionsArtery = max(maskSectionArtery, [], 'all');
masksSectionsArtery = zeros(numX, numY, numSectionsArtery);
parfor sectionIdx = 1:numSectionsArtery
masksSectionsArtery(:, :, sectionIdx) = (maskSectionArtery == sectionIdx);
end
SubImg_locs_artery = zeros(numSectionsArtery, 2);
SubImg_width_artery = zeros(numSectionsArtery, 1);
for sectionIdx = 1:numSectionsArtery
[row, col] = find(masksSectionsArtery(:, :, sectionIdx));
SubImg_locs_artery(sectionIdx, 1) = round(mean(row));
SubImg_locs_artery(sectionIdx, 2) = round(mean(col));
SubImg_width_artery(sectionIdx) = 0.01 * numX;
end
%% 1) 2) Veins
if veins_analysis
maskSectionVein = maskSection .* maskVein;
figure(120)
imagesc(maskSectionVein .* v_RMS_AVG), axis image
maskSectionVein = bwlabel(maskSectionVein);
figure(121), axis image
imagesc(maskSectionVein)
numSectionsVein = max(maskSectionVein, [], 'all');
masksSectionsVein = zeros(numX, numY, numSectionsVein);
parfor sectionIdx = 1:numSectionsVein
masksSectionsVein(:, :, sectionIdx) = (maskSectionVein == sectionIdx);
end
SubImg_locs_vein = zeros(numSectionsVein, 2);
SubImg_width_vein = zeros(numSectionsVein, 1);
for sectionIdx = 1:numSectionsVein
[row, col] = find(masksSectionsVein(:, :, sectionIdx));
SubImg_locs_vein(sectionIdx, 1) = round(mean(row));
SubImg_locs_vein(sectionIdx, 2) = round(mean(col));
SubImg_width_vein(sectionIdx) = 0.01 * numX;
end
end
%% 2) Compute blood volume rate: Cross_section_analysis
strXlabel = 'Time(s)';
strYlabel = 'Velocity (mm.s-1)';
%% Arteries
[avgVolumeRateArtery, stdVolumeRateArtery, crossSectionAreaArtery, avgVelocityArtery, stdVelocityArtery, crossSectionMaskArtery,~,~,~,crossSectionWidthArtery] = crossSectionAnalysis2(SubImg_locs_artery, SubImg_width_artery, maskArtery, v_RMS, PW_params.flowRate_sliceHalfThickness, k, ToolBox, path, 'artery', flagBloodVelocityProfile, [], force_width,1);
labelsArteries = cell(numSectionsArtery, 1);
avgVolumeRateArtery_total = sum(avgVolumeRateArtery, 1);
stdVolumeRateArtery_total = sqrt(sum(stdVolumeRateArtery.^2, 1));
avgVelocityArtery_total = sum(avgVelocityArtery, 1);
stdVelocityArtery_total = sqrt(sum(stdVelocityArtery.^2, 1));
velocityArtery_mean = mean(avgVelocityArtery_total);
for sectionIdx = 1:numSectionsArtery
labelsArteries{sectionIdx} = sprintf("A%d", sectionIdx);
end
% Velocity Over Sections
figure(220)
plot(fullTime, avgVelocityArtery, 'LineWidth', 2)
title('Blood velocity in artery sections');
legend(labelsArteries);
fontsize(gca, 14, "points");
xlabel(strXlabel, 'FontSize', 14);
ylabel(strYlabel, 'FontSize', 14);
pbaspect([1.618 1 1]);
set(gca, 'LineWidth', 2);
axis tight;
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'velocityArteryEverySection.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'velocityArteryEverySection.eps')))
% Mean Velocity
velocityArtery_plot = figure(221);
velocityArtery_plot.Position = [200 475 600 300];
graphSignalStd(velocityArtery_plot, avgVelocityArtery_total, stdVelocityArtery_total,ToolBox,numFrames,strYlabel,strXlabel,"Total velocity in arteries",'mm/s')
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'velocityArterySection.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'velocityArterySection.eps')))
plot2txt(fullTime, avgVelocityArtery_total, 'AVGVelocityArteriesTotal', ToolBox)
plot2txt(fullTime, stdVelocityArtery_total, 'STDVelocityArteriesTotal', ToolBox)
plot2txt(fullTime, avgVolumeRateArtery_total, 'AVGVolumeRateArteriesTotal', ToolBox)
plot2txt(fullTime, stdVolumeRateArtery_total, 'STDVolumeRateArteriesTotal', ToolBox)
for sectionIdx = 1:numSectionsArtery
plot2txt(fullTime, avgVolumeRateArtery(sectionIdx, :), strcat('volumeRate_artery_A', num2str(sectionIdx)), ToolBox)
plot2txt(fullTime, stdVolumeRateArtery(sectionIdx, :), strcat('volumeRate_artery_std_A', num2str(sectionIdx)), ToolBox)
plot2txt(fullTime, avgVelocityArtery(sectionIdx, :), strcat('avg_velocity_artery_A', num2str(sectionIdx)), ToolBox)
plot2txt(fullTime, stdVelocityArtery(sectionIdx, :), strcat('std_velocity_artery_A', num2str(sectionIdx)), ToolBox)
end
%% 2) 2) Veins
if veins_analysis
[avgVolumeRateVein, stdVolumeRateVein, crossSectionAreaVein, avgVelocityVein, stdVelocityVein, crossSectionMaskVein,~,~,~,crossSectionWidthVein] = crossSectionAnalysis2(SubImg_locs_vein, SubImg_width_vein, maskVein, v_RMS, PW_params.flowRate_sliceHalfThickness, k, ToolBox, path, 'vein', flagBloodVelocityProfile, [], force_width,1);
labelsVeins = cell(numSectionsVein, 1);
avgVolumeRateVein_total = sum(avgVolumeRateVein, 1);
stdVolumeRateVein_total = sqrt(sum(stdVolumeRateVein.^2, 1));
avgVelocityVein_total = sum(avgVelocityVein, 1);
stdVelocityVein_total = sqrt(sum(stdVelocityVein.^2, 1));
velocityVein_mean = mean(avgVelocityVein_total);
for sectionIdx = 1:numSectionsVein
labelsVeins{sectionIdx} = sprintf("V%d", sectionIdx);
end
% Velocity Over Sections
figure(220)
plot(fullTime, avgVelocityVein, 'LineWidth', 2)
title('Blood velocity in vein sections');
legend(labelsVeins);
fontsize(gca, 14, "points");
xlabel(strXlabel, 'FontSize', 14);
ylabel(strYlabel, 'FontSize', 14);
pbaspect([1.618 1 1]);
set(gca, 'LineWidth', 2);
axis tight;
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'velocityVeinEverySection.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'velocityVeinEverySection.eps')))
% Mean Velocity
velocityVein_plot = figure(221);
velocityVein_plot.Position = [200 475 600 300];
graphSignalStd(velocityVein_plot, avgVelocityVein_total, stdVelocityVein_total,ToolBox,numFrames,strYlabel,strXlabel,"Total velocity in arteries",'mm/s')
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'velocityVeinSection.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'velocityVeinSection.eps')))
plot2txt(fullTime, avgVelocityVein_total, 'AVGVelocityVeinsTotal', ToolBox)
plot2txt(fullTime, stdVelocityVein_total, 'STDVelocityVeinsTotal', ToolBox)
plot2txt(fullTime, avgVolumeRateVein_total, 'AVGVolumeRateVeinsTotal', ToolBox)
plot2txt(fullTime, stdVolumeRateVein_total, 'STDVolumeRateVeinsTotal', ToolBox)
for sectionIdx = 1:numSectionsVein
plot2txt(fullTime, avgVolumeRateVein(sectionIdx, :), strcat('volumeRate_vein_V', num2str(sectionIdx)), ToolBox)
plot2txt(fullTime, stdVolumeRateVein(sectionIdx, :), strcat('volumeRate_vein_std_V', num2str(sectionIdx)), ToolBox)
plot2txt(fullTime, avgVelocityVein(sectionIdx, :), strcat('avg_velocity_vein_V', num2str(sectionIdx)), ToolBox)
plot2txt(fullTime, stdVelocityVein(sectionIdx, :), strcat('std_velocity_vein_V', num2str(sectionIdx)), ToolBox)
end
end
%% 3) Vein and artery numerotation
M0_disp_image = rescale(mean(M0_disp_video,3));
numerotation_plot = figure(300);
numerotation_plot.Position = [100 100 600 600];
x_center = ToolBox.x_barycentre;
y_center = ToolBox.y_barycentre;
graphMaskTags(300, M0_disp_image, crossSectionMaskArtery, SubImg_locs_artery, labelsArteries,x_center,y_center)
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'arteries_numerotation.png')))
if veins_analysis
numerotationv_plot = figure(301);
numerotationv_plot.Position = [100 100 600 600];
graphMaskTags(301, M0_disp_image, crossSectionMaskVein, SubImg_locs_vein, labelsVeins,x_center,y_center,Color=[0 0 1]);
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'veins_numerotation.png')));
graphMaskTags(301, M0_disp_image, crossSectionMaskArtery, SubImg_locs_artery, labelsArteries,x_center,y_center);
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'arteries_veins_numerotation.png')));
end
%% 4) Volume Rate FigurePosition
%% 4) 1) Video Generation
%% 4) 2) Average BVR figure and Section widths
volume_rate_plot = figure(420);
volume_rate_plot.Position = [200 200 600 600];
etiquettes_frame_values = round(mean(avgVolumeRateArtery(:, :), 2),1);
graphMaskTags(volume_rate_plot, M0_disp_image,crossSectionMaskArtery, SubImg_locs_artery, etiquettes_frame_values,x_center,y_center);
title(sprintf("%s : %02.0f %s",'Average total blood volume rate in arteries', round(mean(avgVolumeRateArtery_total),1),'µL/min'));
set(gca, 'FontSize', 14)
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateArteryImage.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateArteryImage.eps')))
section_width_plot = figure(430);
section_width_plot.Position = [200 200 600 600];
etiquettes_frame_values = append(string(round(crossSectionWidthArtery*PW_params.cropSection_pixelSize/(2^PW_params.k)*1000,1)),"µm");
graphMaskTags(section_width_plot, M0_disp_image,crossSectionMaskArtery, SubImg_locs_artery, etiquettes_frame_values,x_center,y_center,Fontsize=12);
title(sprintf("%s",'Cross section width in arteries (µm)'));
set(gca, 'FontSize', 14)
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'crossSectionWidthArteryImage.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'crossSectionWidthArteryImage.eps')))
if veins_analysis
volume_rate_plot = figure(520);
volume_rate_plot.Position = [200 200 600 600];
etiquettes_frame_values = round(mean(avgVolumeRateVein(:, :), 2),1);
graphMaskTags(volume_rate_plot, M0_disp_image,crossSectionMaskVein, SubImg_locs_vein, etiquettes_frame_values,x_center,y_center,Color=[0 0 1]);
title(sprintf("%s : %02.0f %s",'Average total blood volume rate in veins', round(mean(avgVolumeRateVein_total),1),'µL/min'));
set(gca, 'FontSize', 14)
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateVeinImage.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateVeinImage.eps')))
section_width_plot = figure(530);
section_width_plot.Position = [200 200 600 600];
etiquettes_frame_values = append(string(round(crossSectionWidthVein*PW_params.cropSection_pixelSize/(2^PW_params.k)*1000,1)),"µm");
graphMaskTags(section_width_plot, M0_disp_image,crossSectionMaskVein, SubImg_locs_vein, etiquettes_frame_values,x_center,y_center,Color=[0 0 1],Fontsize=12);
title(sprintf("%s",'Cross section width in veins (µm)'));
set(gca, 'FontSize', 14)
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'crossSectionWidthVeinImage.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'crossSectionWidthVeinImage.eps')))
end
%% 5) Plot Volume Rate
%% 5) 1) Artery plot
volumeRateArtery_plot = figure(510);
volumeRateArtery_plot.Position = [200 200 600 300];
graphSignalStd(volumeRateArtery_plot, avgVolumeRateArtery_total, stdVolumeRateArtery_total,ToolBox,numFrames,'Blood volume rate (µL/min)','Time (s)',"Total blood volume rate in arteries","µL/min",ylimm=[0 max(avgVolumeRateArtery_total)])
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateArterySection.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateArterySection.eps')))
plot2txt(fullTime, avgVolumeRateArtery_total, 'AVGVolumeRateArteryTotal', ToolBox)
plot2txt(fullTime, stdVolumeRateArtery_total, 'STDVolumeRateArteryTotal', ToolBox)
%% 5) 2) Vein plot
if veins_analysis
volumeRateVein_plot = figure(520);
volumeRateVein_plot.Position = [200 475 600 300];
graphSignalStd(volumeRateVein_plot, avgVolumeRateVein_total, stdVolumeRateVein_total,ToolBox,numFrames,'Blood volume rate (µL/min)','Time (s)',"Total blood volume rate in veins","µL/min",ylimm=[0 max(avgVolumeRateArtery_total)])
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateVeinSection.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateVeinSection.eps')))
plot2txt(fullTime, avgVolumeRateArtery_total, 'AVGVolumeRateVeinTotal', ToolBox)
plot2txt(fullTime, stdVolumeRateArtery_total, 'STDVolumeRateVeinTotal', ToolBox)
end
%% 5) 3) Artery Plot & Vein Plot progression
graphCombined(M0_disp_video,crossSectionMaskArtery,SubImg_locs_artery,avgVolumeRateArtery,avgVolumeRateArtery_total,stdVolumeRateArtery_total,ToolBox,[],'Blood Volume Rate (µL/min)','Time (s)','Total Blood Volume Rate in arteries','µL/min',skip=~exportVideos);
if veins_analysis
graphCombined(M0_disp_video,crossSectionMaskVein,SubImg_locs_vein,avgVolumeRateVein,avgVolumeRateVein_total,stdVolumeRateVein_total,ToolBox,[],'Blood Volume Rate (µL/min)','Time (s)','Total Blood Volume Rate in veins','µL/min',skip=~exportVideos,Color=[0 0 1]);
end
%% txt file output with measured pulse wave parameters
volumeRateArtery_mean = mean(avgVolumeRateArtery_total);
if veins_analysis
volumeRateVein_mean = mean(avgVolumeRateVein_total);
fileID = fopen(fullfile(ToolBox.PW_path_txt, strcat(ToolBox.main_foldername, '_pulseWaveOutputParameters.txt')), 'a');
fprintf(fileID, [ ...
'Value of total arterial blood volume rate (µL/min) :\n%d\n' ...
'Value of total venous blood volume rate (µL/min) :\n%d\n'], ...
volumeRateArtery_mean, ...
volumeRateVein_mean);
fclose(fileID);
else
fileID = fopen(fullfile(ToolBox.PW_path_txt, strcat(ToolBox.main_foldername, '_pulseWaveOutputParameters.txt')), 'a');
fprintf(fileID, ...
'Value of total arterial blood volume rate (µL/min) :\n%f\n', ...
volumeRateArtery_mean);
fclose(fileID);
end
for sectionIdx = 1:numSectionsArtery
fileID = fopen(fullfile(ToolBox.PW_path_txt, strcat(ToolBox.main_foldername, '_pulseWaveOutputParameters.txt')), 'a');
fprintf(fileID, [ ...
'Artery n°A%d : cross_section (mm^2) : \n %d \n' ...
'Artery n°A%d : vessel diameter (µm) : \n %d \n' ...
'Artery n°A%d : average velocity (mm/s) : \n %d \n' ...
'Artery n°A%d : blood volume rate (µL/min) : \n %d \n \n'], ...
sectionIdx, ...
crossSectionAreaArtery(sectionIdx), ...
sectionIdx, ...
2 * sqrt(crossSectionAreaArtery(sectionIdx) / pi) * 1000, ... % calculation of the diameter knowing the disc area
sectionIdx, ...
avgVelocityArtery(sectionIdx), ...
sectionIdx, ...
avgVolumeRateArtery(sectionIdx)); % mm^3/s -> µL/min
fclose(fileID);
end
if veins_analysis
for sectionIdx = 1:numSectionsVein
fileID = fopen(fullfile(ToolBox.PW_path_txt, strcat(ToolBox.main_foldername, '_pulseWaveOutputParameters.txt')), 'a');
fprintf(fileID, [ ...
'Vein n°V%d : cross_section (mm^2) : \n %d \n ' ...
'Vein n°V%d : vessel diameter (µm) : \n %d \n ' ...
'Vein n°V%d : average velocity (mm/s) : \n %d \n ' ...
'Vein n°V%d : blood volume rate (µL/min) : \n %d \n \n'], ...
sectionIdx, ...
crossSectionAreaVein(sectionIdx), ...
sectionIdx, ...
2 * sqrt(crossSectionAreaVein(sectionIdx) / pi) * 1000, ... % calculation of the diameter knowing the disc area
sectionIdx, ...
avgVelocityVein(sectionIdx), ...
sectionIdx, ...
avgVolumeRateVein(sectionIdx)); % mm^3/s -> µL/min
fclose(fileID);
end
end
close all
%% 6) Arterial Resistivity with Volume Rate
maxVolumeRate = max(avgVolumeRateArtery_total(:));
minVolumeRate = min(avgVolumeRateArtery_total(:));
meanVolumeRate = mean(avgVolumeRateArtery_total(:));
%% 6) 1) Arterial Resisitivity Index
ARI = (maxVolumeRate - minVolumeRate) / maxVolumeRate;
figure(610)
curve1 = avgVolumeRateArtery_total + 0.5 * stdVolumeRateArtery_total;
curve2 = avgVolumeRateArtery_total - 0.5 * stdVolumeRateArtery_total;
fullTime2 = [fullTime, fliplr(fullTime)];
inBetween = [curve1, fliplr(curve2)];
hold on
fill(fullTime2, inBetween, Color_std);
plot(fullTime, curve1, "Color", Color_std, 'LineWidth', 2);
plot(fullTime, curve2, "Color", Color_std, 'LineWidth', 2);
plot(fullTime, avgVolumeRateArtery_total, '-k', 'LineWidth', 2);
yline(volumeRateArtery_mean, '--k', 'LineWidth', 2)
yline(maxVolumeRate, '--r', 'Linewidth', 2)
yline(minVolumeRate, '--r', 'Linewidth', 2)
axis tight;
volumeRateArtery_ax = axis;
volumeRateArtery_ax(3) = 0;
hold off
ylabel('Blood volume rate (µL/min)')
xlabel('Time (s)')
title(sprintf("Arterial Resistivity Index %0.2f ", ARI))
axis([volumeRateArtery_ax(1) volumeRateArtery_ax(2) volumeRateArtery_ax(3) volumeRateArtery_ax(4)]);
fontsize(gca, 14, "points");
box on
set(gca, 'Linewidth', 2)
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateARI.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateARI.eps')))
%% 6) 2) Arterial Pulsatility Index
API = (maxVolumeRate - minVolumeRate) / meanVolumeRate;
figure(620)
curve1 = avgVolumeRateArtery_total + 0.5 * stdVolumeRateArtery_total;
curve2 = avgVolumeRateArtery_total - 0.5 * stdVolumeRateArtery_total;
fullTime2 = [fullTime, fliplr(fullTime)];
inBetween = [curve1, fliplr(curve2)];
hold on
fill(fullTime2, inBetween, Color_std);
plot(fullTime, curve1, "Color", Color_std, 'LineWidth', 2);
plot(fullTime, curve2, "Color", Color_std, 'LineWidth', 2);
plot(fullTime, avgVolumeRateArtery_total, '-k', 'LineWidth', 2);
yline(maxVolumeRate, '--r', 'Linewidth', 2)
yline(meanVolumeRate, '--r', 'Linewidth', 2)
yline(minVolumeRate, '--r', 'Linewidth', 2)
axis tight;
volumeRateArtery_ax = axis;
volumeRateArtery_ax(3) = 0;
hold off
ylabel('Blood volume rate (µL/min)')
xlabel('Time (s)')
title(sprintf("Arterial Pulsatility Index %0.2f ", API))
axis([volumeRateArtery_ax(1) volumeRateArtery_ax(2) volumeRateArtery_ax(3) volumeRateArtery_ax(4)]);
fontsize(gca, 14, "points");
box on
set(gca, 'Linewidth', 2)
exportgraphics(gca, fullfile(ToolBox.PW_path_png, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateAPI.png')))
exportgraphics(gca, fullfile(ToolBox.PW_path_eps, 'volumeRate', sprintf("%s_%s", ToolBox.main_foldername, 'volumeRateAPI.eps')))
close all
end