d=dir('Dark*');
m=dir('mike*');
dtim=cat(1,d.datenum);
mtim=cat(1,m.datenum);

for i=1:length(m)
    dkid=abs(dtim-mtim(i))==min(abs(dtim-mtim(i)));
    dark=load(d(dkid).name);
    skin=load(m(i).name);

    if std(skin(:,9))>.00065
        skinids=9:264;
    else
        skinids=10:265;
    end

    if std(dark(:,9))>.00065
        darkids=9:264;
    else
        darkids=10:265;
    end

    sd=skin(:,skinids)-ones(size(skin,1),1)*mean(dark(5:end,darkids));

    [sitdatapersec,pds,pds01]=sit2pdsloop(sd);
    
    save(['sit',num2str(i,'%03.0f')],'sit*','sd','pds*','d','dkid','m','*tim');
    clear s* dark skin *id *ids pds*
end
