function StateAnalysis=SingleStateAnalyser(struct SingleStates)

for i=1:12
    k=1
    while SChange(i,k)>0
StateAnalysis(k,i).StartIndex=SingleStates(i,k).startindex;
StateAnalysis(k,i).Photons=sum(SingleStates(i,k).counts);
StateAnalysis(k,i).Emean(1)=mean(SingleStates(i,k).efficiency(:,1));
StateAnalysis(k,i).Emean(2)=mean(SingleStates(i,k).efficiency(:,2));
StateAnalysis(k,i).Emean(3)=mean(SingleStates(i,k).efficiency(:,3));
StateAnalysis(k,i).Emean(4)=mean(SingleStates(i,k).efficiency(:,4));
StateAnalysis(k,i).Evar(1)=var(SingleStates(i,k).efficiency(:,1));
StateAnalysis(k,i).Evar(2)=var(SingleStates(i,k).efficiency(:,2));
StateAnalysis(k,i).Evar(3)=var(SingleStates(i,k).efficiency(:,3));
StateAnalysis(k,i).Evar(4)=var(SingleStates(i,k).efficiency(:,4));
StateAnalysis(k,i).Estd(1)=std(SingleStates(i,k).efficiency(:,1));
StateAnalysis(k,i).Estd(2)=std(SingleStates(i,k).efficiency(:,2));
StateAnalysis(k,i).Estd(3)=std(SingleStates(i,k).efficiency(:,3));
StateAnalysis(k,i).Estd(4)=std(SingleStates(i,k).efficiency(:,4));
    k=k+1
    i
    end
end
for i=1:12
    k=1;
    while SChange(i,k)>0;
StateAnalysis(k,i).Imean(1,1:2)=mean(SingleStates(i,k).intensities(:,1:2));
StateAnalysis(k,i).Imean(2,1:2)=mean(SingleStates(i,k).intensities(:,3:4));
StateAnalysis(k,i).Imean(3,1:2)=mean(SingleStates(i,k).intensities(:,5:6));
StateAnalysis(k,i).Imean(4,1:2)=mean(SingleStates(i,k).intensities(:,7:8));
StateAnalysis(k,i).Ivar(1,1:2)=var(SingleStates(i,k).intensities(:,1:2));
StateAnalysis(k,i).Ivar(2,1:2)=var(SingleStates(i,k).intensities(:,3:4));
StateAnalysis(k,i).Ivar(3,1:2)=var(SingleStates(i,k).intensities(:,5:6));
StateAnalysis(k,i).Ivar(4,1:2)=var(SingleStates(i,k).intensities(:,7:8));
StateAnalysis(k,i).Istd(1,1:2)=std(SingleStates(i,k).intensities(:,1:2));
StateAnalysis(k,i).Istd(2,1:2)=std(SingleStates(i,k).intensities(:,3:4));
StateAnalysis(k,i).Istd(3,1:2)=std(SingleStates(i,k).intensities(:,5:6));
StateAnalysis(k,i).Istd(4,1:2)=std(SingleStates(i,k).intensities(:,7:8));
    k=k+1;
    end
end
