function errorcorr(nuFRET)
%% Reads structured Array with bleaching markers (A_bleached,D_bleached)
%% and calculates background, crosstalk and gamma correction
for k=1:127
tA=nuFRET(1,k).A_bleached;
tD=nuFRET(1,k).D_bleached;
IDsolo=sum(nuFRET(1,k).counts(tA:tD,1));
IAsolo=sum(nuFRET(1,k).counts(tA:tD,2));
length=size(nuFRET(1,k).counts,1);
tdark=length-tD;
nuFRET(1,k).bgsum=sum(nuFRET(1,k).counts(tD:end,:));
bg=nuFRET(1,k).bgsum/tdark;

nuFRET(1,k).bg=bg;
nuFRET(1,k).cross=(IAsolo-bg(1,2))/IDsolo;
nuFRET(1,k).machine_gamma=1;
clear tA tD IDsolo IAsolo length tdark bg
k
end




