load protosessions.mat session

xcal=cat(1,session([6]).sitabs);
ycal=cat(1,session([6]).glu(:,3));
axcol=[1:28,35:64];
[~,u,b,v,xav,yav] = pls2(xcal(:,axcol),ycal);
[resc,~,~,~,~,~,~] = plsout(u,b,v,xav,ycal,20);
did=abs(resc)<=1.5*mean(abs(resc));
pw=pws(xcal(did,axcol),ycal(did));
%load gvector gvector ... from https://coraluma.com/data/Calibration/gvector/
l64=protowave(mean(1:4,2):4:256);
l=protowave(1:256);

plot(l64(axcol),zeroone(-pw),l,zeroone(gvector));grid;shg
title('Session 6 PWS and G-Vector vs Wavelength: Res < 39mg/dL')
xlabel('Wavelength (nm)')
ylabel('Absorbance Profile (normalized between 0 and 1)')
legend('-PWS64','GVector');%NOTE, the PWS is negative, so supports waterdispalacement concerns