image thumbnail

eogui – a software to analyze electro-oculogram (EOG) recordings

by

 

10 Aug 2011 (Updated )

detects blinks and saccadic eye movements in EOG recordings

unifilter_iir.m
function [sigout ,offset]=unifilter(sigin,filterlist)
%   Funktion zum Filtern des Signals
%   @Parameter: 
%        sigin  = Signal
%        preprocess_filter = Liste mit Filterparametern
%
%   @Rckgabe:   
%        sigout = gefiltetes Signal
%        offset = entstandene Verschiebung zum orginal Signal
% $Id: unifilter_iir.m 6 2004-12-13 12:28:39Z maik $



signal=sigin;

% gehe durch alle filterstufen 
offset=0;
for i=1:length(filterlist)

    switch lower(filterlist(i).type)
        case 'median', disp('Filter: median');         
	    if(filterlist(i).para<=length(signal))            
	    	span=filterlist(i).para;
	    	N=length(signal)+1-filterlist(i).para;
	    	index=cumsum([(1:span); ones(N-1,span)]);
	    	signal=reshape(median(signal(index),2),1,N);
            %signal=rngmed(sigin,preprocess_filter(i).windowsize);
                        
            offset=offset+fix(filterlist(i).para/2);
        end

                   
        case 'mean', disp('Filter: mean')        
	    if(filterlist(i).para < length(signal))            
            fenster=filterlist(i).para(1);
            if(fenster>0)            
                a=1;
                b=(ones(1,fenster) / fenster);                       
                signal=filter(b,a,signal);
                signal=signal(fenster:end);
                offset=offset+fix(fenster/2);
            end
	    end
            
        case 'notch', disp('Filter: notch ')
            
            start = filterlist(i).para(1);
            ende = filterlist(i).para(2);            

            [b,a]=butter(8,start,'low');
            x1=filtfilt(b,a,signal);
   
            [b,a]=butter(8,ende,'high');
            x2=filtfilt(b,a,signal);              
            
            signal=x1+x2;
            
        
        case 'lowpass', disp('Filter: lowpass')
            start = filterlist(i).para;
            [b,a]=butter(8,start,'low');
            signal=filtfilt(b,a,signal);
                        

        case 'highpass', disp('Filter: highpass')
            start = filterlist(i).para;            
            [b,a]=butter(8,start,'high');
            signal=filtfilt(b,a,signal);
        
        case 'none'
                                   
        otherwise, disp('Filter: unknown')    
    end
end
sigout=signal;

Contact us