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

findTreshold(datavector,threshold,varargin)
function result = findTreshold(datavector,threshold,varargin)
% $Id: findTreshold.m 11 2004-12-16 13:44:46Z maik $

% varagin
%       1 = n- Treffer suchen
%       2 = offset verwenden

result=[];

if(nargin>2)
    k=varargin{1};
else
    k=inf;
end

if(nargin>3)
    offset=varargin{2};
else
    offset=0;
end

kc=0;
isin=false;

maxim=abs(datavector(1+offset));
maxpos=1+offset;

for i=1+offset:length(datavector)    
    
    if(maxim<abs(datavector(i)))
        maxim=abs(datavector(i));        
        maxpos=i;
    end
    
    if(abs(datavector(i))>threshold)        
        if ~isin  % starte neuen Wert
            lastsign=sign(datavector(i));
            isin=true;
            startidx=i;
            maxim=abs(datavector(i));
            maxpos=i;
        else
            if sign(datavector(i))~=lastsign  % Vorzeichenwechsel ?
                result=[result;[startidx i lastsign maxpos]];            
                isin=false;
                kc=kc+1;            
            if(kc==k) return; end
                
            end            
        end
    else
        if isin % Unterschreitung
            result=[result;[startidx i sign(datavector(startidx)) maxpos]];            
            isin=false;
            kc=kc+1;
            
            if(kc==k) return; end
        end
    end
end

Contact us