function GUI_pwv_manual(data,fvz)


scrsz = get(0,'ScreenSize');   

% vytvoreni noveho okna pro zobrazeni segmentu

w_pwv = figure('Units','characters',...
            'HandleVisibility','callback',...
            'Renderer','painters',...
            'MenuBar','none', ...
            'numbertitle','off', ...
            'name','PWV_manual', ...
            'Units','pixels', ... 
            'Position',[70 80 scrsz(3)/1.1 scrsz(4)/1.2]);
        
    %%    
% Okno rozdelene do 2 panelu, v levem jsou parametry, v pravem je grpah,
% ktery se prekresluje

L_Panel_sirka = scrsz(3)/5;
L_Panel_vyska = scrsz(4)/1.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 = 2.6*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_pocet_marks = uicontrol(L_Panel,'Style','text','String','Number of Waves for counting PWV',...
                     'Units','pixels', ...
                     'Position',[15 scrsz(4)/1.4 L_Panel_sirka-30 20]);        
      
set_pocet_marks = uicontrol(L_Panel,'Style','edit','String','5','Units','pixels', ...
                     'BackgroundColor','white','Callback',{@Pocet_Callback}, ...
                     'Position',[15 scrsz(4)/1.4-20 L_Panel_sirka-30 20]);   
 
create_marks = uicontrol('Style','pushbutton','String','Create marks',...
                          'Parent',L_Panel,...
                          'Position',[15 scrsz(4)/1.6 L_Panel_sirka-30 30],...
                          'Callback',{@create_Callback}); 
                      
delete_marks_button = uicontrol('Style','pushbutton','String','Delete marks',...
                          'Parent',L_Panel,...
                          'Position',[15 scrsz(4)/1.6-40 L_Panel_sirka-30 30],...
                          'Callback',{@delete_Callback});  
 
%% prumerna doba mezi systolou a odrazenou vlnou

nadpis_vlna = uicontrol(L_Panel,'Style','text','String','Mean time distance Forward-Reflected wave [s]',...
                     'Units','pixels', ...
                     'Position',[15 scrsz(4)/1.6-80 L_Panel_sirka-30 20]);                        
                      
set_delka = uicontrol(L_Panel,'Style','text','String','','Units','pixels', ...
                     'BackgroundColor','white', ...
                     'Position',[15 scrsz(4)/1.6-110 L_Panel_sirka-30 30]);                       
                      
 
%% nastaveni vzdalenosti Juglum-Bifurkace  
                 
nadpis_JF = uicontrol(L_Panel,'Style','text','String','Jugulum - Aortic bifurcation [mm]',...
                     'Units','pixels', ...
                     'Position',[15 scrsz(4)/2-80 L_Panel_sirka-30 20]);        
      
set_JF = uicontrol(L_Panel,'Style','edit','String','Distance','Units','pixels', ...
                     'BackgroundColor','white',...
                     'Enable', 'inactive',...
                     'ButtonDownFcn', @clearJF,...
                     'Position',[15 scrsz(4)/2-100 L_Panel_sirka-30 20]);  
                 
%% Tlacitko pro vypocet PWV
                 
count_button = uicontrol('Style','pushbutton','String','Count PWV',...
                          'Parent',L_Panel,...
                          'Position',[15 scrsz(4)/2-280 L_Panel_sirka-30 40],...
                          'Callback',{@count_Callback});   

%% Vypsani PWV do labelu                      
                      
nadpis_PWV = uicontrol(L_Panel,'Style','text','String','PWV [m*s-1]',...
                     'Units','pixels', ...
                     'Position',[15 scrsz(4)/2-325 L_Panel_sirka-30 20]);  
                      
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 nalezenych peaku

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

%% vymazani pole pro hodnotu Juglum-Bifurkace                    
    
    function clearJF(set_JF,~)

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

    pocet = str2double(get(set_pocet_marks,'String')); 
    pocet_markru = 2*pocet;
        
    end 
          
%% globalni promenne pro markry
 pocet = 5;
 marks = [];
 i = 1;    
 time = (1/fvz:1/fvz:length(data)/fvz);
 pocet_markru = 10;
 PWV = 0;
 
          
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FUNCTIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% only plot the signals

plot_signals();

    function plot_signals()

            plot(time,data);
            xlabel('t [s]');
            ylabel('amplitude [-]')
            zoom on;
            min_bound = 0;
            max_bound = length(data);

            %% showing the marks        
            if(~isempty(marks))
                          
                yLim = get(gca,'YLim');
                
                            for k=1:length(marks)
                                if(marks(k)>=min_bound && marks(k)<=max_bound)
                                    if(rem(k,2)==1)
                                    line([(marks(k)),(marks(k))],yLim,'Color','r');
                                    else
                                    line([(marks(k)),(marks(k))],yLim,'Color','g');
                                    end
                                end
                            end
            end

    end


%% vybrani pozic markru

    function create_Callback(source,eventdata)
 
         for i=1:pocet_markru
%                  [x,y] = ginput(1);        
%                  marks(i) = round((x*1000))/1000; 
%                  line([(marks(i)),(marks(i))],[min(data) max(data)],'Color','r');                 
                 switch rem(i,2)
                   case 1
                     msg = msgbox('Systolic peak');
                     pause(1);
                     delete(msg);
                     [x,y] = ginput(1);        
                     marks(i) = round((x*1000))/1000;
                     line([(marks(i)),(marks(i))],[min(data) max(data)],'Color','r');
                   case 0
                     msg = msgbox('Reflected peak');
                     pause(1);
                     delete(msg);
                     [x,y] = ginput(1);        
                     marks(i) = round((x*1000))/1000;
                     line([(marks(i)),(marks(i))],[min(data) max(data)],'Color','g');
                 end
         end

         plot_signals();  
         
         % vypocet prumerne vlny
         delka = 0;
        
         for j=0:pocet-1
           delka_val = marks(2*j+2)-marks(2*j+1);
           vlny(j+1)=delka_val;
           delka = delka + delka_val; 
         end
        
         % vypsani prumerne vlny do labelu
         PWV = delka/pocet;
         value_f = [num2str(PWV) '  s'];
         set(set_delka,'String',value_f);
         
        
    end 
        
%% vymazani markru

    function delete_Callback(source,eventdata)  

      marks = [];  
      plot_signals();
        
    end



    function count_Callback(~,~)  
 %%     kontrola, jestli je spravnej format pro vzdalenost
        S = get(set_JF, '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_JF, 'String', S2);
        % Perhaps a small warning in WARNDLG or inside the GUI:
        if ~all(ismember(S, '.1234567890'))    
            msgbox('Insert a number, please');
            set(set_JF, 'String', 'Distance');
            set(set_JF,'Enable', 'inactive');
        else
            JugBif = str2double(get(set_JF,'String')); 
        end
        
        % vypsani rychlosti do labelu
        value_f = (2*JugBif/1000)/PWV;
        vlny
        std(vlny)
        odch = (value_f/PWV)*(std(vlny))
        value_final = [num2str(value_f) '  m/s'];
        set(set_PWV,'String',value_final);

               
    end
        


end