function [HR0,FAR0]=vyhodnotROC(vst_sig,dat,numbervad,modifik,zasum,roc,delka_ramce,inite,initi,initc,initd,pe,pi,pc,alfae,alfai,alfac,bef,bel,blsf,bzc)

% Tato funkce je pomocna pro uzivatelske rozhrani.
% Samostatna funkce je umistena ve slozce ROC na CD
% Funkce pro vyhodnoceni ROC charakteristik jednotlivych detektoru
%
% roc - pri volbe 1, se zobrazi krivky ROC
% zasum - pri volbe 1 dojde k zasumneni signalu (SNR = 30, 20, 10, 5, 0, -5 dB)
%
% ve stejne slozce musi byt funkce idealni.m, vst_sig.wav a soubor vst_sig.dat
%
% 2008   Michal Adamec VUT Brno (v ramci Diplomove prace - Moderni rozpoznavace reci)

[y,Fvz] = wavread(vst_sig);                     %nacteni signalu

%% Vytvoreni ROC %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if zasum==1
    for i = 1:6
        snr=[30 20 10 5 0 -5];
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%% zasumneni signalu, pro snizeni SNR%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        z = awgn(y,snr(i),'measured');                 	 %pridani white Gaussian noise (bily sum), odstup sig sum je nastaven dle cisla v zavorce
        wavwrite(z,Fvz,'sum');                           %ulozeni zasumneleho signalu

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%% detetekce pomoci vybraneho detektoru %%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% s pridanym bilym sumem
        switch numbervad
            case 1
                [v]=vadenerg('sum',delka_ramce,inite,pe,alfae,0,0);
            case 2
                [v]=vadintenz('sum',delka_ramce,initi,pi,alfai,0,0);
            case 3
                [v]=vadcepstralni('sum',delka_ramce,initc,pc,alfac,0,0);
            case 4
                [v]=detektor('sum',delka_ramce,modifik,initd,pc,alfac,pi,alfai,pe,alfae,0);
            case 5
                [v]=g729('sum',bef,bel,blsf,bzc,0);
        end
        if i==1
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %%%% Idealni/rucni detekce%%%%%
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            lv = length(v);
            ideal = idealni(dat,lv);
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        end

        a          = sum(ideal.*v);
        idealpauza = double(~ideal);
        vpauza     = double(~v);
        b          = sum(idealpauza.*vpauza);
        delka   = length(v);
        HR0(i)  = b/sum(idealpauza)*100;
        HR1(i)  = a/sum(ideal)*100;
        FAR0(i) = 100-HR1(i);
        %  FAR1(i) = 100-HR0(i);

    end
    HR0=HR0'
    HR1=HR1'
    FAR0=FAR0'
    %FAR1=FAR1'

elseif zasum==0
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%% detetekce pomoci vybraneho detektoru %%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bez pridaneho bileho sumu
    switch numbervad
        case 1
            [v]=vadenerg(vst_sig,delka_ramce,inite,pe,alfae,0,0);
        case 2
            [v]=vadintenz(vst_sig,delka_ramce,initi,pi,alfai,0,0);
        case 3
            [v]=vadcepstralni(vst_sig,delka_ramce,initc,pc,alfac,0,0);
        case 4
            [v]=detektor(vst_sig,delka_ramce,modifik,initd,pc,alfac,pi,alfai,pe,alfae,0);
        case 5
            [v]=g729(vst_sig,bef,bel,blsf,bzc,0);
    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%% Idealni/rucni detekce%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    lv = length(v);
    ideal = idealni(dat,lv);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    a          = sum(ideal.*v);
    idealpauza = double(~ideal);
    vpauza     = double(~v);
    b          = sum(idealpauza.*vpauza);
    delka   = length(v);
    HR0  = b/sum(idealpauza)*100;
    HR1  = a/sum(ideal)*100;
    FAR0 = 100-HR1;
    %     FAR1 = 100-HR0;

    HR0=HR0'
    HR1=HR1'
    FAR0=FAR0'
    %  FAR1=FAR1'
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Grafické znázornění ROC křivek %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if roc==1
    if zasum==1
        figure(9)
        subplot(2,1,1)
        plot(FAR0,HR0,'x')
        %   plot(FAR1,HR1,'x')
        title('ROC');xlabel('FAR0 (%)');ylabel('HR0 (%)');
        subplot(2,1,2)
        plot(snr,HR1,'x-')
        %    plot(snr,HR1,'x-')
        title('Závislost HR1 na SNR ');xlabel('SNR (dB)');ylabel('HR1 (%)');
        grid on;
    else
        figure(9)
        plot(FAR0,HR0,'x')
        %  plot(FAR1,HR1,'x')
        title('ROC');xlabel('FAR0 (%)');ylabel('HR0 (%)');
        grid on;
    end
end