function GUI_analysis_new(data,freq)

scrsz = get(0,'ScreenSize');

% vytvoreni noveho okna pro zobrazeni segmentu

main_window = figure('Units','characters',...
            'HandleVisibility','callback',...
            'Renderer','painters',...
            'MenuBar','none', ...
            'numbertitle','off', ...
            'name','Segment', ...
            'Units','pixels', ... 
            'Position',[scrsz(3)/6 scrsz(4)/5 scrsz(3)/1.5 scrsz(4)/1.5]);


menu_new1 = uimenu(main_window,'Label','PWV'); 
% menu_new2 = uimenu(main_window,'Label','PWV-automat'); 
menu_new3 = uimenu(main_window,'Label','CO'); 
menu_new4 = uimenu(main_window,'Label','AI'); 
menu_new5 = uimenu(main_window,'Label','Mean Wave',...
            'Callback',{@wave_Callback}); 

% create_marks = uimenu(menu_new,'Label','Create marks',... 
%               'Callback',{@create_Callback});
% 
% delete_marks = uimenu(menu_new,'Label','Delete marks',... 
%               'Callback',{@delete_Callback});          
%           
% mean_wave = uimenu(menu_new,'Label','Mean wave',... 
%               'Callback',{@wave_Callback});    
% 
% save_wave = uimenu(menu_new,'Label','Save wave',... 
%               'Callback',{@save_Callback});    
%          
% reload_wave = uimenu(menu_new,'Label','Reaload wave',... 
%               'Callback',{@reload_Callback});    

pwv_manual = uimenu(menu_new1,'Label','Manual PWV',... 
              'Callback',{@manual_Callback});          
          
pwv_wave = uimenu(menu_new1,'Label','Automatic PWV',... 
              'Callback',{@pwv_Callback});    
          
sv_volume = uimenu(menu_new3,'Label','Manual CO',... 
              'Callback',{@sv_Callback});    

ai_index_gui = uimenu(menu_new4,'Label','Manual AI',... 
              'Callback',{@ai_Callback});    

            
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Globální promìnné
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% variables for marks
 marks = [];
 i = 1;    
 time = (1/freq:1/freq:length(data)/freq);
 
          
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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)
                                    line([(marks(k)),(marks(k))],yLim,'Color','r');
                                end
                            end
            end
    end

% then we have to do marks for every wave
% 
% %% choosing a place for a mark
% 
%     function create_Callback(source,eventdata)
%          pocet_markru = 10;
%  
%          % msgbox('Click the start (begin of a systole) and the end (dicrotic notch)');
% 
%          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');
%         %          marks(i) = x*freq;
%          end
% 
%          plot_signals();     
%     end 
%         
% %% counting a mean wave with using interpolation
% 
%     function wave_Callback(source,eventdata)
%         
%         max = 0;
%         pom = 1;
%         
%         for j=1:length(marks)-1       
%             if(mod(j,2)==1)
%             waves{pom} = data(round(marks(j)*freq):round((marks(j+1)*freq)));      
%                 if(max<length(waves{pom}))
%                     max = length(waves{pom});
%                 end
%             pom = pom+1;     
%             end
%         end
%         
%        % provedeni inteprolace na stejnou delku
%        
%        for j=1:length(waves)     
%             waves_m(j,:) = resample(waves{j},max,length(waves{j}));
%        end
%        
%        m_wave = mean(waves_m); 
%        time_wave = (1/freq:1/freq:length(m_wave)/freq);
%        plot(time_wave,m_wave);
% %        hold on;
% %        plot(waves_m(1,:),'r')
% %        plot(waves_m(2,:),'g')   
% %        hold off;
%     end
%        
% %% saving the mean wave
% 
%     function save_Callback(source,eventdata)  
% 
%       uisave({'m_wave'},'vlna');
%     end
%       
%     function reload_Callback(source,eventdata)  
% 
%       plot_signals();
%         
%     end
% 
%     function delete_Callback(source,eventdata)  
% 
%       marks = [];  
%       plot_signals();
%         
%     end

%% vypocteni prumerne vlny pro daneho pacienta
    
    function wave_Callback(source,eventdata)  

        GUI_analysis(data,freq);
        
    end


%%  manualni ryschlost sireni pulzni vlny

    function manual_Callback(source,eventdata)  

        GUI_pwv_manual(data,freq);
        
    end

%% rychlost sireni pulsni vlny - automat


    function pwv_Callback(source,eventdata)  

        GUI_pwv(data,freq);
        
    end

%% index zesileni, augmentation index

    function ai_Callback(source,eventdata)  

        GUI_ai(data,freq);
        
    end


%% tepovy objem 

    

    function sv_Callback(source,eventdata)  

%         msgbox('GUI for stroke volume');
        Final_SV_GUI(data,freq);
        % automatcika detekce na zaklade
        % GUI_sv(data,freq);
        
    end

end