% Changing the path from main_folder to a particular chapter
main_path=fileparts(which('Main_Content.mlx'));
%addpath(append(main_path,'/Chapter2'))
cd (append(main_path,'/Chapter6/SimulatingLightPropagation'))
addpath(append(main_path,'/Service'))
SAVE_FLAG=1; % saving the figures in a file
clear_all_but('SAVE_FLAG')
Example4_BloodVessel_Pulse
model = runMonteCarlo(model);
detFraction = 100*mean(mean(sum(model.MC.LC.image,3)))*model.MC.LC.fieldSize^2;
detFraction = 100*sum(model.MC.LC.image,3);
save('SPulse_660_001_1.mat','S')
% Increasing the air gap to 0.2 mm
Example4_BloodVessel_Pulse
model = runMonteCarlo(model);
detFraction = 100*mean(mean(sum(model.MC.LC.image,3)))*model.MC.LC.fieldSize^2;
detFraction = 100*sum(model.MC.LC.image,3);
save('SPulse_660_02_1.mat','S')
ylabel('Ilumination fraction (%)', 'FontSize', 10)
xlabel('Time (sec)', 'FontSize', 10)
%load("SPulse_660_02_1.mat")
load("SPulse_660_001_1.mat")
[xData, yData] = prepareCurveData( t, S );
% Set up fittype and options.
[fitresult, gof] = fit( xData, yData, ft );
legend('MCMatlab simulation at discrete points','4th order polynomial fit')
ylabel('Ilumination fraction (%)', 'FontSize', 10)
xlabel('Time (s)', 'FontSize', 10)
title('Simulated and fitted pulse during a cardiac cycle')
annonation_save('',"Fig6.10.jpg", SAVE_FLAG);
disp('Percentage of the AC component is:')
Percentage of the AC component is:
100*(max(fitresult(t))-min(fitresult(t)))/max(fitresult(t))
depth=[0.001, 0.01, 0.2, 0.3]; % 0.4 is too much
clear_all_but('zsurf','wave_l','B_Cutaneous', 'i', 'j', 'k', 'S','depth','wavelen','B');
Example4_BloodVessel_changeS_barrier1
model = runMonteCarlo(model);
detFraction = 100*mean(mean(sum(model.MC.LC.image,3)))*model.MC.LC.fieldSize^2;
detFraction = 100*sum(model.MC.LC.image,3);
end
-----------------Monte Carlo Simulation------------------
Simulation duration = 1.000 min
Calculating... 100% done
Simulated 2.04e+06 photons at a rate of 2.04e+06 photons per minute
----------------------plotMCmatlab-----------------------
55.1% of incident light hits the cuboid boundaries.
44.9% of incident light was absorbed within the cuboid.
0.449% of incident light ends up on the detector.
save('SBarrier1.mat','S')
depth=[0.001, 0.01, 0.2, 0.3]; % 0.4 is too much
Dia660=reshape(S(1,1,:),[4,1]);
Sys660=reshape(S(1,2,:),[4,1]);
Dia940=reshape(S(2,1,:),[4,1]);
Sys940=reshape(S(2,2,:),[4,1]);
plot(depth(1:N),Dia660(1:N))
plot(depth(1:N),Sys660(1:N))
plot(depth(1:N),Dia940(1:N))
plot(depth(1:N),Sys940(1:N))
legend('660 nm diastolic point','660 nm systolic point','940 nm diastolic point','940 nm systolic point')
ylabel('Ilumination fraction (%)', 'FontSize', 10)
xlabel('Barrier depth (mm)', 'FontSize', 10)
plot(depth(1:N),((Dia660(1:N)-Sys660(1:N))./Dia660(1:N))./((Dia940(1:N)-Sys940(1:N))./Dia940(1:N)),'o-')
ylabel('Ratio of ratios', 'FontSize', 10)
xlabel('Air gap depth (mm)', 'FontSize', 10)
title('Ratio of ratios vs. the air gap depth')
annonation_save('b)',"Fig6.7b.jpg", SAVE_FLAG);
plot(depth(1:N),100*((Dia660(1:N)-Sys660(1:N))./Dia660(1:N)),'o-')
plot(depth(1:N),100*((Dia940(1:N)-Sys940(1:N))./Dia940(1:N)),'*-')
legend('660 nm','940 nm')
ylabel('Ratio AC over DC (%)', 'FontSize', 10)
xlabel('Air gap depth (mm)', 'FontSize', 10)
title('AC over DC ratios for red and infrared light')
annonation_save('a)',"Fig6.7a.jpg", SAVE_FLAG);
clear_all_but('wave_l','B_Cutaneous', 'i1', 'j', 'k', 'S','B','wavelen','ii');
Example4_BloodVessel_changeS_new1
model = runMonteCarlo(model);
detFraction = 100*mean(mean(sum(model.MC.LC.image,3)))*model.MC.LC.fieldSize^2;
detFraction = 100*sum(model.MC.LC.image,3);
end
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.40e+07 photons at a rate of 2.40e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.34e+07 photons at a rate of 2.34e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.46e+07 photons at a rate of 2.46e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.36e+07 photons at a rate of 2.36e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.35e+07 photons at a rate of 2.35e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.39e+07 photons at a rate of 2.39e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.59e+07 photons at a rate of 2.59e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 76% done
100% done
Simulated 2.48e+07 photons at a rate of 2.48e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.34e+07 photons at a rate of 2.34e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.32e+07 photons at a rate of 2.32e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.37e+07 photons at a rate of 2.37e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.77e+07 photons at a rate of 2.77e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.71e+07 photons at a rate of 2.71e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.66e+07 photons at a rate of 2.66e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.77e+07 photons at a rate of 2.77e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.67e+07 photons at a rate of 2.67e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.66e+07 photons at a rate of 2.66e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.78e+07 photons at a rate of 2.78e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.70e+07 photons at a rate of 2.70e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.65e+07 photons at a rate of 2.65e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.77e+07 photons at a rate of 2.77e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.68e+07 photons at a rate of 2.68e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.19e+07 photons at a rate of 3.19e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.37e+07 photons at a rate of 3.37e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 91% done
100% done
Simulated 3.22e+07 photons at a rate of 3.22e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.09e+07 photons at a rate of 3.08e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.05e+07 photons at a rate of 3.05e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 2.97e+07 photons at a rate of 2.97e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.29e+07 photons at a rate of 3.29e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.36e+07 photons at a rate of 3.36e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.26e+07 photons at a rate of 3.26e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.46e+07 photons at a rate of 3.46e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.35e+07 photons at a rate of 3.35e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.18e+07 photons at a rate of 3.18e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.44e+07 photons at a rate of 3.44e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.33e+07 photons at a rate of 3.33e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.25e+07 photons at a rate of 3.25e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.43e+07 photons at a rate of 3.43e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.33e+07 photons at a rate of 3.33e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.24e+07 photons at a rate of 3.24e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.44e+07 photons at a rate of 3.44e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.33e+07 photons at a rate of 3.33e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.05e+07 photons at a rate of 3.05e+06 photons per minute
-----------------Monte Carlo Simulation------------------
Simulation duration = 10.000 min
Calculating... 100% done
Simulated 3.42e+07 photons at a rate of 3.42e+06 photons per minute
RatioOfRatios=((reshape(S(1,2,:),[11,1])-reshape(S(1,1,:),[11,1]))./reshape(S(1,2,:),[11,1]))./((reshape(S(2,2,:),[11,1])-reshape(S(2,1,:),[11,1]))./reshape(S(2,2,:),[11,1]));
%% Fit: 'untitled fit 1'.
p = polyfit(RatioOfRatios',SpO2,1);
y1 = polyval(p,RatioOfRatios');
plot(RatioOfRatios,SpO2,'o')
plot(RatioOfRatios,y1,'-')
xlabel('Ratio of ratios', 'FontSize', 10)
ylabel('Saturation (%)', 'FontSize', 10)
legend('SpO_2 estimate','SpO_2=C_B*R+C_A')
title('Estimated and fitted SpO_2 vs. the ratio of ratios')
annonation_save('b)',"Fig6.9b.jpg", SAVE_FLAG);
plot(SpO2,reshape(S(1,1,:),[11,1]),'o-')
plot(SpO2,reshape(S(1,2,:),[11,1]),'*-')
plot(SpO2,reshape(S(2,1,:),[11,1]),'o-')
plot(SpO2,reshape(S(2,2,:),[11,1]),'*-')
legend('660 nm diastolic','660 nm systolic','940 nm diastolic','940 nm systolic',"Location","best")
ylabel('Ilumination fraction (%)', 'FontSize', 10)
xlabel('Saturation (%)', 'FontSize', 10)
title('Illumination vs SpO_2 for systolic and diastolic points')
annonation_save('a)',"Fig6.9a.jpg", SAVE_FLAG);