function Filtrace(handles, pocetmereni)

    global signal emgfiltrovany silavyhlazena;
    
    %Parametry pro filtraci pohybovych artefaktu
    fvz = 1000;
    fmez = 18;
    b=fir1(150, fmez/(fvz/2), 'high');
    a = 1;
    
    %Parametry pro filtraci sitoveho ruseni
    fmez1 = 49.7;
    fmez2 = 50.3;
    dm = fmez1/(fvz/2);
    hm = fmez2/(fvz/2);
    b50 = fir1(150, [dm hm], 'stop');
    a50 = 1; 

    %Parametry pro vypocet max Amplitudy
    pocetuseku = 512;
    hranice = round(0:(length(signal) / pocetuseku):length(signal));        %Vypocet hranic mezi oblastmi mereni
    hranice(1) = 1;
    
    %Parametry pro vypocet vyhlazene sily
    rozdeleni = 20;                  
    okno = floor(length(signal)/rozdeleni);

    amplitudy = zeros(pocetmereni, pocetuseku);
    plochy = zeros(pocetmereni, 1);
    emgfiltrovany = zeros(pocetmereni, length(signal));
    silavyhlazena = [];
    
    
    for i = 1:pocetmereni

        emg = signal(:, 3 * i);                            %Vyber emg signalu z matice celeho mereni (vzdy ve 3, 6, 9 sloupci)
       
        %Filtrace pohybovych artefaktu
        emgfiltrovany(i, :) = filtfilt(b,a,emg);
 %      Filtrace síťového rušení 
        emgfiltrovany(i, :) = filtfilt(b50,a50,emgfiltrovany(i, :));
        
        sila = signal(:, (3 * i) - 1);                     %Vyber signalu sily (vzdy ve 2, 5, 8 sloupci)    
        
        %Prochazeni jednotlivych oblasti
        for j = 1:length(hranice) - 1
            %Nalezeni maxima v danem oblasti
            [hodnotamax, pozicemax] = max(emgfiltrovany(i, hranice(j):hranice(j+1)));
            pozicemax = pozicemax + hranice(j) - 1;
            
            %Vytvoreni okna kolem nalezeneho maxima a hledani minima
            hranicemin = 10;
            hranicemax = 10;
                                            
            if pozicemax-hranicemin < 1                                   
                hranicemin = pozicemax - 1;
            end
            if pozicemax+hranicemax > length(emgfiltrovany)              
               hranicemax = length(emgfiltrovany) - pozicemax;
            end
            
            hodnotamin = min(emgfiltrovany(i, (pozicemax-hranicemin):(pozicemax+hranicemax)));
           
            %Vypocet amplitudy mezi minimem a maximem
            amplitudy(i, j) = abs(hodnotamax - hodnotamin);
        end
        %Uprava signalu pro vypocet plochy pod krivkou 
        startintervaly = 1:100:length(emgfiltrovany) - 100;
        stopintervaly = 100:100:length(emgfiltrovany);
        
        prumerovanysignal = zeros(1, length(startintervaly));
        
        for j = 1:length(startintervaly)
        
            prumerovanysignal(j) = mean(emgfiltrovany(i, startintervaly(j):stopintervaly(j)));
        end
        
        interpolovanysignal = abs(spline(startintervaly, prumerovanysignal, 1:length(emgfiltrovany)));
        %Vypocet plochy pod krivkou - energie stahu 
        plochy(i) = trapz(interpolovanysignal);
        
        %Vyhlazeni sily
        index = 1;  
        for k=1:okno:length(signal)
            if k+okno-1<length(signal);
                casti = sila(k:k+okno-1);
                prumer = (sum(casti)/length(casti));
                silavyhlazena(i, index) = prumer;
                index = index + 1;
            end
        end
    end

    %Vypocet prumeru maximalnich amplitud z celeho signalu 
    prumermaxamplitudy = mean(amplitudy, 2);
    
    %Vypocet prumeru sily
    prumersily = mean(silavyhlazena, 2);

    
   %Zobrazeni v gui
    set(handles.PP1, 'String', ['1: ' num2str(prumermaxamplitudy(1)) ' [V]']);
    set(handles.PP2, 'String', ['2: ' num2str(prumermaxamplitudy(2)) ' [V]']);
    set(handles.PP3, 'String', ['3: ' num2str(prumermaxamplitudy(3)) ' [V]']);
    
    set(handles.E1, 'String', ['1: ' num2str(plochy(1) / 60) ' [V/s]']);         %Deli se 60 protoze je to ve voltech za sekundu (vypocet byl jen ve voltech)  
    set(handles.E2, 'String', ['2: ' num2str(plochy(2) / 60) ' [V/s]']);
    set(handles.E3, 'String', ['3: ' num2str(plochy(3) / 60) ' [V/s]']);
    
    set(handles.S1, 'String', ['1: ' num2str(prumersily(1)) ' [kg]']);
    set(handles.S2, 'String', ['2: ' num2str(prumersily(2)) ' [kg]']);
    set(handles.S3, 'String', ['3: ' num2str(prumersily(3)) ' [kg]']);
end