function GUI_pwv(data,fvz)


scrsz = get(0,'ScreenSize');   

% veci ohledne okna

w_pwv = figure('Units','characters',...
            'HandleVisibility','callback',...
            'Renderer','painters',...
            'MenuBar','none', ...
            'numbertitle','off', ...
            'name','GUI_Automatic PWV', ...
            'Units','pixels', ...
            'Resize','off', ...
            'Position',[scrsz(3)/4 scrsz(4)/4 scrsz(3)/2 scrsz(4)/2]);
        
    %%    
% Okno rozdelene do 2 panelu

L_Panel_sirka = scrsz(3)/5;
L_Panel_vyska = scrsz(4)/2-10;
L_Panel_odsazeni = 10;

L_Panel = uipanel('BorderType','etchedin',...
		'Units','characters',...
		'Parent',w_pwv, ...
        'Title','Parameters', ...
        'Units','pixels', ...
		'Position',[L_Panel_odsazeni L_Panel_odsazeni L_Panel_sirka L_Panel_vyska],...
        'TitlePosition','centertop');
   
Podrobnosti_odsazeni = 10;
Podrobnosti_sirka = L_Panel_sirka;
Podrobnosti_vyska = L_Panel_vyska;
    
Podrobnosti = uipanel('BorderType','etchedin',...
            'Units','characters',...
            'Parent',w_pwv, ...
            'Title','Graph', ...
            'Units','pixels', ...
            'Position', ...
            [3*Podrobnosti_odsazeni+L_Panel_sirka Podrobnosti_odsazeni Podrobnosti_sirka*1.3 Podrobnosti_vyska],...
            'TitlePosition','centertop'); 
        
 %% vytvoreni popisku a zadani vzdalenosti
 
        
nadpis_JugBif = uicontrol(L_Panel,'Style','text','String','Jugulum - Aortic bifurcation [mm]',...
                     'Units','pixels', ...
                     'Position',[15 scrsz(4)/2-80 L_Panel_sirka-30 20]);        
      
set_JugBif = uicontrol(L_Panel,'Style','edit','String','Distance','Units','pixels', ...
                     'BackgroundColor','white', ...
                     'Enable', 'inactive',...
                     'ButtonDownFcn', @clearJugBif,...
                     'Position',[15 scrsz(4)/2-100 L_Panel_sirka-30 20]);  
       
count_button = uicontrol('Style','pushbutton','String','Count PWV',...
                          'Parent',L_Panel,...
                          'Position',[15 scrsz(4)/2-290 L_Panel_sirka-30 40],...
                          'Callback',{@count_Callback});  
                      
set_delka = uicontrol(L_Panel,'Style','text','String','','Units','pixels', ...
                     'BackgroundColor','white', ...
                     'Position',[15 scrsz(4)/2-325 L_Panel_sirka-30 30]);                       
                      
set_PWV = uicontrol(L_Panel,'Style','text','String','','Units','pixels', ...
                     'BackgroundColor','white', ...
                     'Position',[15 scrsz(4)/2-360 L_Panel_sirka-30 30]);                        
                 
                 
%% osa pro vykresleni nalezlych peaku

 axes_data = axes('Units','pixels','Position',[40 40 Podrobnosti_sirka,Podrobnosti_vyska-70], ...
                  'Parent',Podrobnosti);   

%%                    
       
    function clearJugBif(set_JugBif,~)

    set(set_JugBif, 'String', '', 'Enable', 'on');
    uicontrol(set_JugBif); % This activates the edit box and 
                   % places the cursor in the box,
                   % ready for user input.
    end

    function count_Callback(~,~)  

%% kontrola formatu pro vzdalenost juglum-bifurkace

        S = get(set_JugBif, 'String');
        % Exclude characters, which are accepted by sscanf:
        S(ismember(S, '-+eEgG')) = '';
        % Convert to one number and back to a string:
        S2 = sprintf('%g', sscanf(S, '%g', 1));
        set(set_JugBif, 'String', S2);
        % Perhaps a small warning in WARNDLG or inside the GUI:
        if ~all(ismember(S, '.1234567890'))    
            msgbox('Insert a number, please');
            set(set_JugBif, 'String', 'Distance');
            set(set_JugBif,'Enable', 'inactive');
        else
            JugBif = str2double(get(set_JugBif,'String')); 
        end



 %% pokus 2  
 
        d_d = data;
        time = 1/fvz:1/fvz:(length(data))/fvz;
        [v p] = findpeaks(d_d);
        plot(axes_data,time,data);
        xlabel('t [s]');
        ylabel('Amplitudde [-]');
        yMax = get(axes_data,'YLim');
        hold on;
        zoom on;
        p_n = p(diff(p)<fvz/4 & diff(p)>fvz/20);
        v_n = v(diff(p)<fvz/4 & diff(p)>fvz/20);
        v_new = v_n(v_n > mean(v_n));
        p_new = p_n(v_n > mean(v_n));
      % parametry  

        pom = 1;
        pom2 = 1;
        suma = 0;
        pocet = 0;
        for i=1:length(p_n)-1
            if(p_n(i)==p_new(pom))
                if(p_n(i+1)-p_n(i)>fvz/20 && p_n(i+1)-p_n(i)<fvz/4)
                    p_fin(pom2)=p_n(i);
                    p_fin(pom2+1)=p_n(i+1);
                    pom2 = pom2 + 2;
                    % nacitani sumy
                    value = p_n(i+1)-p_n(i);
                    vlny(pocet+1) = value;
%                     vlny
%                     suma = suma + value;
                    pocet = pocet +1 ;
                end
                pom = pom +1;
                if(pom==length(p_new))
                    break;
                end
            end    
        end

%%
        for i=1:length(p_fin)
        line([p_fin(i)/fvz,p_fin(i)/fvz],yMax,'Color','g','Parent',axes_data)
        end

%% udelam, ze se to nsemi li3it od prumeru o dve smerodatne odchylky
% %         mean(vlny)
% %         2*std(vlny)
        pom = 1;
        index = [];
        mean(vlny)
        std(vlny)
        mean(vlny)+2*std(vlny)
        mean(vlny)-2*std(vlny)
        for j=1:length(vlny)
            if(vlny(j)>mean(vlny)+2*std(vlny) || vlny(j)<mean(vlny)-2*std(vlny))
                index(pom) = j;
                pom = pom+1;
                'prilis mimo'
            end
        end
        
        
      % vymazani vln, co se nevejdou do intervalu pro vypocet
        vlny(index) = [];
        p_fin
        vlny
%       % vypocet prumerne vlny  
%       
        PWV = median(vlny)/fvz;
        PWVmean = mean(vlny)/fvz;
        PWV
        PWVmean
        index
    
%         %% pouziti Dixonova testu pro odstrraneni odelhelych hodnot
%         R = max(vlny)-min(vlny)
%         VlnyS = sort(vlny);
%         for i=length(vlny)-1
%             Q(i) = (vlny(i+1)-vlny(i))/R
%             
%         
        
%       % vymazani velkych markrku
%       
%         for i=1:length(p_fin)
%             if((find(index)==i)>0)
%                 'mimo rozsah'
%             else
%                 line([p_fin(i)/fvz,p_fin(i)/fvz],yMax,'Color','g','Parent',axes_data);
%             end
%         end

 
 %%       
  % spocitani rychlosti a dani do labelu, 
        value_f = (2*JugBif/1000)/PWV; % 1000 je tadz kvuli prevodu z mm na metry
        odch = (value_f/PWV)*(std(vlny)/fvz)
        odch_cas = (std(vlny)/fvz)
        value_final = [num2str(value_f) '  m/s'];
        set(set_delka,'String',PWV);
        set(set_PWV,'String',value_final);

        
        
    end
        


end