%Výběr příznaků SFFS za použití kNN klasifikátoru
%Vstup:"P_muz.xls","K_muz.xls"
%Výstup:
  %cislo_priznaku- číslo příznaku, který byl vybrán v určitém kroku SFFS
  %nazev_priznaku- název příznaku, který byl vybrán v určitém kroku SFFS
  %label_priznaku- label, ve kterém se vybraný příznak nachází
  %uspesnost_rozpoznani_priznaku- procento úspěšnosti určení vybraného příznaku

clear all
clc

lab= {'7.1_1_a','7.1_1_e','7.1_1_i','7.1_1_o','7.1_1_u','7.1_2_a','7.1_2_e',...
    '7.1_2_i','7.1_2_o','7.1_2_u','ParkinsonPr'};
AA=[];
BB=[];
priznak=[];
uspesnost_rozpoznani1=[]
K = length(lab);  %pocet labelu v jednotlivych nahravkach
   for c = 1:K   %cyklus pro label  
     
[ndata, text, alldata] = xlsread('P_muz.xls',lab{c});
[ndata1, text1, alldata1] = xlsread('K_muz.xls',lab{c});
   
AA=[AA,ndata];
BB=[BB,ndata1];
   end
  % C=[A;B];
  
  kontrolni=[1:455];

for x=1:10
    if x==1
        pokA=AA(3:8,1:455);
        pokA1=AA(9:11,1:455);
        pokB=BB(3:8,1:455);
        pokB1=BB(9:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==2
        pokA=AA(1:1,1:455);
        pokA1=AA(4:11,1:455);
        pokB=BB(1:1,1:455);
        pokB1=BB(4:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==3
        pokA=AA(1:2,1:455);
        pokA1=AA(5:11,1:455);
        pokB=BB(1:2,1:455);
        pokB1=BB(5:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==4
        pokA=AA(1:3,1:455);
        pokA1=AA(6:11,1:455);
        pokB=BB(1:3,1:455);
        pokB1=BB(6:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==5
        pokA=AA(1:4,1:455);
        pokA1=AA(7:11,1:455);
        pokB=BB(1:4,1:455);
        pokB1=BB(7:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==6
        pokA=AA(1:5,1:455);
        pokA1=AA(8:11,1:455);
        pokB=BB(1:5,1:455);
        pokB1=BB(8:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==7
        pokA=AA(1:6,1:455);
        pokA1=AA(9:11,1:455);
        pokB=BB(1:6,1:455);
        pokB1=BB(9:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==8
        pokA=AA(1:7,1:455);
        pokA1=AA(10:11,1:455);
        pokB=BB(1:7,1:455);
        pokB1=BB(10:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==9
        pokA=AA(1:8,1:455);
        pokA1=AA(11:11,1:455);
        pokB=BB(1:8,1:455);
        pokB1=BB(11:11,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end
    
    if x==10
        pokA=AA(1:7,1:455);
        pokA1=AA(8:9,1:455);
        pokB=BB(1:7,1:455);
        pokB1=BB(8:9,1:455);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
    end

  X=[];
  XK=[];

%1.KROK
for p=1:455
    
traindata1=pokA3(:,p); %trenovaci mnozina parkinsonu
traindata2=pokB3(:,p); %trenovaci mnozina kontrolnich

traindata1=traindata1';
traindata2=traindata2';
% Train GMM models
itarations = 50; % Number of iterations
nmix = 1; % Number of mixtures
res = ['P', 'K'];

model_P = creategmmmodel(traindata1(:,1:9), itarations, nmix);
model_K = creategmmmodel(traindata2(:,1:9), itarations, nmix);


if x==1
for p1=1:2 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=1:2 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
testdata2=BB(p2,p); %zdravy jedinec

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==2
for p1=2:3 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=2:3 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==3
for p1=3:4 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=3:4 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==4
for p1=4:5 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=4:5 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==5
for p1=5:6 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=5:6 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==6
for p1=6:7 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=6:7 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==7
for p1=7:8 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=7:8 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==8
for p1=8:9 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=8:9 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==9
for p1=9:10 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=9:10 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end

if x==10
for p1=10:11 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data
testdata1=AA(p1,p); %nemocny jedinec 

a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata1);
a(2) = gmmclassifier(model_K, testdata1);

if a(1)>a(2)
   X(p1,p)=1;
else X(p1,p)=2;
end
end

for p2=10:11 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data
a = zeros(1,2);
a(1) = gmmclassifier(model_P, testdata2);
a(2) = gmmclassifier(model_K, testdata2);

if a(1)<a(2)
   XK(p2,p)=2;
else XK(p2,p)=1;
end
end
end
end

%procentualni uspesnost parkinsonu
procentualni_uspesnost=[];
for p=1:450
    
O=X(:,p);
v1{p}=find(O==1);
v2=length(v1{p});
U=XK(:,p);
u1{p}=find(U==2);
u2=length(u1{p});
cel=((v2+u2)/4)*100; 
procentualni_uspesnost=[procentualni_uspesnost,cel];
end
uspesnost_rozpoznani=procentualni_uspesnost';
uspesnost_rozpoznani1=[uspesnost_rozpoznani1,uspesnost_rozpoznani];
end
SUMA=[];
for y=1:450
   rad=uspesnost_rozpoznani1(y,:);
   d=sum(rad)/10;
    SUMA= [SUMA;d];
end


[C,I]=max(SUMA);


A=AA(:,I);  %zapsani nejlepsiho priznaku do matice A
B=BB(:,I);
priznak=kontrolni(I);
AA(:,I)=[];  %odmazani nejlepsiho priznaku z ndata
BB(:,I)=[];
kontrolni(I)=[];

GGG=I;
CCC=C;

%--------------------------------------------------------------------------
%2. až 20. KROK


R=length(AA(1:454));


for rr=1:20
    uspesnost_rozpoznani3=[]
    

    for x=1:10
        
    X1=[];
    XK1=[];
 for r=1:R    
    
        
    if x==1
        pokA=AA(3:8,1:end);
        pokA1=AA(9:11,1:end);
        pokB=BB(3:8,1:end);
        pokB1=BB(9:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(3:8,1:end);
        pA1=A(9:11,1:end);
        pB=B(3:8,1:end);
        pB1=B(9:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==2
        pokA=AA(1:1,1:end);
        pokA1=AA(4:11,1:end);
        pokB=BB(1:1,1:end);
        pokB1=BB(4:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:1,1:end);
        pA1=A(4:11,1:end);
        pB=B(1:1,1:end);
        pB1=B(4:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==3
        pokA=AA(1:2,1:end);
        pokA1=AA(5:11,1:end);
        pokB=BB(1:2,1:end);
        pokB1=BB(5:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:2,1:end);
        pA1=A(5:11,1:end);
        pB=B(1:2,1:end);
        pB1=B(5:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==4
        pokA=AA(1:3,1:end);
        pokA1=AA(6:11,1:end);
        pokB=BB(1:3,1:end);
        pokB1=BB(6:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:3,1:end);
        pA1=A(6:11,1:end);
        pB=B(1:3,1:end);
        pB1=B(6:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==5
        pokA=AA(1:4,1:end);
        pokA1=AA(7:11,1:end);
        pokB=BB(1:4,1:end);
        pokB1=BB(7:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:4,1:end);
        pA1=A(7:11,1:end);
        pB=B(1:4,1:end);
        pB1=B(7:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==6
        pokA=AA(1:5,1:end);
        pokA1=AA(8:11,1:end);
        pokB=BB(1:5,1:end);
        pokB1=BB(8:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:5,1:end);
        pA1=A(8:11,1:end);
        pB=B(1:5,1:end);
        pB1=B(8:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==7
        pokA=AA(1:6,1:end);
        pokA1=AA(9:11,1:end);
        pokB=BB(1:6,1:end);
        pokB1=BB(9:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:6,1:end);
        pA1=A(9:11,1:end);
        pB=B(1:6,1:end);
        pB1=B(9:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==8
        pokA=AA(1:7,1:end);
        pokA1=AA(10:11,1:end);
        pokB=BB(1:7,1:end);
        pokB1=BB(10:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:7,1:end);
        pA1=A(10:11,1:end);
        pB=B(1:7,1:end);
        pB1=B(10:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==9
        pokA=AA(1:8,1:end);
        pokA1=AA(11:11,1:end);
        pokB=BB(1:8,1:end);
        pokB1=BB(11:11,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:8,1:end);
        pA1=A(11:11,1:end);
        pB=B(1:8,1:end);
        pB1=B(11:11,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
    if x==10
        pokA=AA(1:7,1:end);
        pokA1=AA(8:9,1:end);
        pokB=BB(1:7,1:end);
        pokB1=BB(8:9,1:end);
        pokA3=[pokA;pokA1];
        pokB3=[pokB;pokB1];
        
        pA=A(1:7,1:end);
        pA1=A(8:9,1:end);
        pB=B(1:7,1:end);
        pB1=B(8:9,1:end);
        pA3=[pA;pA1];
        pB3=[pB;pB1];
    end
    
   
  
    Ftr=pokA3(:,r);
    Ftr1=pokB3(:,r);
    Atr=pA3;
    Atr1=pB3;
    train1data1=[Atr,Ftr]; %trenovaci mnozina parkinsonu
    train1data2=[Atr1,Ftr1]; %trenovaci mnozina kontrolnich
    
    train1data1=train1data1';
    train1data2=train1data2';
  % Train GMM models
    itarations = 50; % Number of iterations
    nmix = 1; % Number of mixtures
    res = ['P', 'K'];

    model_P = creategmmmodel(train1data1(:,1:9), itarations, nmix);
    model_K = creategmmmodel(train1data2(:,1:9), itarations, nmix);
    
    
if x==1   
for p1=1:2 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=1:2 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==2   
for p1=2:3 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=2:3 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==3   
for p1=3:4 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=3:4 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==4   
for p1=4:5 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=4:5 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==5   
for p1=5:6 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=5:6 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==6   
for p1=6:7 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=6:7 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==7   
for p1=7:8 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=7:8 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==8   
for p1=8:9 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=8:9 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==9   
for p1=9:10 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=9:10 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

if x==10   
for p1=10:11 %cyklus pro testovaci mnozinu parkinsonu 
%testovaci data nemocny jedinec  
Fte=AA(p1,r);
Ate=A(p1,:);
test1data1=[Ate,Fte];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data1);
a(2) = gmmclassifier(model_K, test1data1);

if a(1)>a(2)
   X1(p1,r)=1;
else X1(p1,r)=2;
end
end

for p2=10:11 %cyklus pro testovaci mnozinu kontrolnich
%testovaci data zdravy jedinec
Fte1=BB(p2,r);
Ate1=B(p2,:);
test1data2=[Ate1,Fte1];

a = zeros(1,2);
a(1) = gmmclassifier(model_P, test1data2);
a(2) = gmmclassifier(model_K, test1data2);

if a(1)<a(2)
   XK1(p2,r)=2;
else XK1(p2,r)=1;
end
end 
end

end

%procentualni uspesnost parkinsonu
procentualni_uspesnost2=[];
for r=1:R
    
O1=X1(:,r);
v11{r}=find(O1==1);
v21=length(v11{r});
U1=XK1(:,r);
u11{r}=find(U1==2);
u21=length(u11{r});
cel1=((v21+u21)/4)*100; 
procentualni_uspesnost2=[procentualni_uspesnost2,cel1];
end
uspesnost_rozpoznani2=procentualni_uspesnost2';
uspesnost_rozpoznani3=[uspesnost_rozpoznani3,uspesnost_rozpoznani2];
    end
    
    SUMA1=[];
for y=1:R
   rad=uspesnost_rozpoznani3(y,:);
   d=sum(rad)/10;
    SUMA1= [SUMA1;d];
end

[C1,I1]=max(SUMA1);


A=[A,AA(:,I1)];
B=[B,BB(:,I1)];
priznak=[priznak, kontrolni(I1)];

AA(:,I1)=[];
BB(:,I1)=[];
kontrolni(I1)=[];

GGG=[GGG,I1];
CCC=[CCC,C1];

R=R-1; % z duvodu odmazani nejlepsiho priznaku z ndata
end

pr={'F0_median','F0_mean','F0_std','F0_min','F0_max','F0_max_min','relF0VR','relF0SD','voicing_frac',...
'jitter_local','jitter_localabs','jitter_rap','jitter_ppq5','jitter_ddp','hnr_aut','hnr_nh','hnr_hn',...
'F1_mean','F1_var','F1_std','F1_max','F1_min','F1_med','F1_max_min','F1b_mean','F1b_var','F1b_std','F1b_max',...
'F1b_min','F1b_med','F1b_max_min','F2_mean','F2_var','F2_std','F2_max','F2_min','F2_med','F2_max_min',...
'F2b_mean','F2b_var','F2b_std','F2b_max','F2b_min','F2b_med','F2b_max_min'};
pr1={'VSA','lnVSA','FCR','VAI','F2i/F2u'};

pr1=[pr,pr,pr,pr,pr,pr,pr,pr,pr,pr,pr1];
priznaky=[];
labely=[];
l=[];
for p=1:45
   l=[l,lab(1)]; 
end

for p=1:45
     l=[l,lab(2)]; 
end

for p=1:45
     l=[l,lab(3)]; 
end

for p=1:45
     l=[l,lab(4)]; 
end

for p=1:45
     l=[l,lab(5)]; 
end

for p=1:45
     l=[l,lab(6)]; 
end

for p=1:45
     l=[l,lab(7)]; 
end

for p=1:45
     l=[l,lab(8)]; 
end

for p=1:45
     l=[l,lab(9)]; 
end

for p=1:45
     l=[l,lab(10)]; 
end

for p=1:5
     l=[l,lab(11)]; 
end

for p=1:20
   
    PP=priznak(p);
    PPP=pr1(PP);
    priznaky= [priznaky, PPP];
    
    LLL=l(PP);
    labely=[labely, LLL];
   
end


cislo_priznaku=priznak';
nazev_priznaku=priznaky';
label_priznaku=labely';
uspesnost_rozpoznani_priznaku=CCC';
