function [SeGroup, SpGroup, SeOverall, SpOverall, AccOverall]=AccuraciesMulti3(OutTarget, OutClassif, TargetV)
% Accuracy matrix for 4 groups od data

% OutTarget= Vector fo Output Targets; %paramOut(TestIdx);
% OutClassif=Vector of Classifier Output; %outputFold;
% TargetV = [0 1];

    N1=sum(OutTarget==TargetV(1)); % all '0' WAKE
    N2=sum(OutTarget==TargetV(2)); % all '1' N1
    N3=sum(OutTarget==TargetV(3)); % all '2' N2
    N4=sum(OutTarget==TargetV(4)); % all '3' N3
    N5=sum(OutTarget==TargetV(5)); % all '5' REM
    
    Se1=round(100*sum((OutTarget==TargetV(1))&(OutClassif==OutTarget))/N1);
    Se2=round(100*sum((OutTarget==TargetV(2))&(OutClassif==OutTarget))/N2);
    Se3=round(100*sum((OutTarget==TargetV(3))&(OutClassif==OutTarget))/N3);
    Se4=round(100*sum((OutTarget==TargetV(4))&(OutClassif==OutTarget))/N4); 
    Se5=round(100*sum((OutTarget==TargetV(5))&(OutClassif==OutTarget))/N5); 
    
    Sp1=round(100*sum((OutTarget~=TargetV(1))&(OutClassif==OutTarget))/(N2+N3+N4+N5));
    Sp2=round(100*sum((OutTarget~=TargetV(2))&(OutClassif==OutTarget))/(N1+N3+N4+N5));
    Sp3=round(100*sum((OutTarget~=TargetV(3))&(OutClassif==OutTarget))/(N1+N2+N4+N5));
    Sp4=round(100*sum((OutTarget~=TargetV(4))&(OutClassif==OutTarget))/(N1+N2+N3+N5));
    Sp5=round(100*sum((OutTarget~=TargetV(5))&(OutClassif==OutTarget))/(N1+N2+N3+N4));
    
    SeGroup=[Se1 Se2 Se3 Se4 Se5];
    SpGroup=[Sp1 Sp2 Sp3 Sp4 Se5];
        
    SeOverall = (Se1+Se2+Se3+Se4+Se5)/5;
    SpOverall = (Sp1+Sp2+Sp3+Sp4+Se5)/5;
    
    AccOverall = round(100*(sum((OutTarget==TargetV(1))&(OutClassif==OutTarget))+sum((OutTarget==TargetV(2))&(OutClassif==OutTarget))+...
                  sum((OutTarget==TargetV(3))&(OutClassif==OutTarget))+sum((OutTarget==TargetV(4))&(OutClassif==OutTarget))+...
                  sum((OutTarget==TargetV(5))&(OutClassif==OutTarget)))/(N1+N2+N3+N4+N5));
   