x=sitabs;
ax=avp(x,8);

clear loop
sg=splinapp(fs(:,1),fs(:,2),ones(size(fs,1),1)*5e7,st);
ax(:,258)=avp(sg,8);

for i=1:size(ax,1)/7
    % cid=logical(ones(size(ax,1),1));
    % cid(i)=0;
    cid=logical(ones(7,1)*ones(1,size(ax,1)/7));
    cid(:,i)=0;
    cid=cid(:);
    
    % [hr,rcal]=rba(ax(cid,1:256),ax(cid,end),500,25);
    [mbr2bbcr,ysipreds,bvects]=jpredosic(avp(ax(cid,1:256)',4)',ax(cid,258),1,avp(ax(:,1:256)',4)',ax(:,258),7);
    loop(i,:)=ysipreds(i,:);
end

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

sg=splinapp(fs(:,1),fs(:,3),ones(size(fs,1),1)*5e7,st);
ax(:,258)=avp(sg,8);

clear loop
for i=1:size(ax,1)/7
    % cid=logical(ones(size(ax,1),1));
    % cid(i)=0;
    cid=logical(ones(7,1)*ones(1,size(ax,1)/7));
    cid(:,i)=0;
    cid=cid(:);
    
    % [hr,rcal]=rba(ax(cid,1:256),ax(cid,end),500,25);
    [mbr2bbcr,ysipreds,bvects]=jpredosic(avp(ax(cid,1:256)',4)',ax(cid,258),1,avp(ax(:,1:256)',4)',ax(:,258),7);
    loop(i,:)=ysipreds(i,:);
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]);