x=session(10).sitabs;
g=session(10).glu;

sg=splinapp(fs(:,1),fs(:,3),ones(size(fs,1),1)*5e7,st);
ax=x;
ax(:,66)=sg;

clear loop
loop=[];
for i=1:size(ax,1)/6
    % cid=logical(ones(size(ax,1),1));
    % cid(i)=0;
    cid=logical(ones(6,1)*ones(1,size(ax,1)/6));
    cid(:,i)=0;
    ccid=cid;
    % ccid(:,[9,23,29,33,34])=0;
    cid=cid(:);
    ccid=ccid(:);
    
    % [hr,rcal]=rba(ax(cid,1:64),ax(cid,end),500,50);
    % [mbr2bbcr,ysipreds,bvects]=jpredosic(avp(ax(cid,1:256)',4)',ax(cid,68),1,avp(ax(:,1:64)',4)',ax(:,258),7);
    % loop(i,:)=ysipreds(i,:);

    % [hr,rcal]=rba(ax(ccid,1:64),ax(ccid,end),1000,500);
    % [hr,rcal]=rba(ax(ccid,1:64),ax(ccid,end),1000,50);
    [mbr2bbcr,ysipreds,bvects]=jpredosic(ax(ccid,[1:28,35:64]),ax(ccid,66),1,ax(:,[1:28,35:64]),ax(:,66),1);
    % [mbr2bbcr,ysipreds,bvects]=jpredosic(ax(ccid,[1:64]),ax(ccid,66),1,ax(:,[1:64]),ax(:,66),1);
    % [mbr2bbcr,ysipreds,bvects]=jpredosic(rcal(:,[1:28,35:64]),hr,1,ax(:,[1:28,35:64]),ax(:,66),1);
%    loop(i,:)=ysipreds(i,:);
    loop=[loop;ysipreds(~cid,:)];
end

figure
plot(ax(:,end-1),ax(:,end),avp(ax(:,end-1),7),avp(loop(:,64),1),fs(:,1),fs(:,3),'bo');grid
xlabel('Time')
ylabel('Blood Glucose Concentration (mg/dL)')
legend('FS Spline','ProtoData','FS')
title('Proto Measurements: Pam June 22, 2024, (Jake''s Glucometer as Reference Values)')
%ylim([50 140]);