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

mousesel.m
% Hilfstool, Auswahl eines Bereichs via Maus

% zu verwenden innerhalb eines buttondown axes handles,
% lt den Benutzer ein Rechteck (XORMODE) aufziehen. 
% Rckgabe ist der handle des Rechtecks.
%
% $Id: mousesel.m 6 2004-12-13 12:28:39Z maik $
function ret=mousesel(varargin)

if(nargin==1)
    
    cmd=varargin{1};
    switch (cmd)                              
        case 'stop'
            % bei mouse up
            % Restauriere alte Event Funtion
            set(gcf,'WindowButtonUpFcn',getappdata(gca,'mousesel_WindowButtonUpFcn'));
            set(gcf,'WindowButtonMotionFcn',getappdata(gca,'mousesel_WindowButtonMotionFcn'));

            rmappdata(gca,'mousesel_pos1');       
            rmappdata(gca,'mousesel_WindowButtonUpFcn');
            rmappdata(gca,'mousesel_WindowButtonMotionFcn');
            set(gca,'UserData',1)
            return;


        case 'move'                

            % gibt es schon ein Rechteck, dann dieses verndern
            if isappdata(gca,'mousesel_fill')
                hfill=getappdata(gca,'mousesel_fill');

                %fill([rstart rende rende rstart],[start_amp start_amp stop_amp stop_amp],[1 0 0],'EraseMode','xor','LineStyle',':');
                rende=get(gca,'currentpoint');
                rende=rende(1,1);
                xdat=get(hfill,'XData');

                xdat(2)=rende;
                xdat(3)=rende;
                set(hfill,'XData',xdat);

                ydim=ylim;        
                start_amp=ydim(1); 
                stop_amp=ydim(2);              
                set(hfill,'YData',[start_amp start_amp stop_amp stop_amp]);


            else
                rstart=getappdata(gca,'mousesel_pos1'); % das ist der startpunkt
                rende=get(gca,'currentpoint');
                rende=rende(1,1);

                ydim=ylim;        
                start_amp=ydim(1); 
                stop_amp=ydim(2);                        
                hold on;
                hfill=fill([rstart rende rende rstart],...
                    [start_amp start_amp stop_amp stop_amp],[1 0 0],...
                    'EraseMode','xor','LineStyle',':',...
                    'buttondownfcn','mousesel(''start'')');
                hold off;    
                setappdata(gca,'mousesel_fill',hfill);
            end                

            return;

    end
end

%1. ermittel aktuellen punkt.
pos1=get(gca,'currentpoint');    

setappdata(gca,'mousesel_pos1',pos1(1,1));

%sichere alte Funktionen
% sichere alte Funtionen
setappdata(gca,'mousesel_WindowButtonUpFcn',get(gcf,'WindowButtonUpFcn'));
setappdata(gca,'mousesel_WindowButtonMotionFcn',get(gcf,'WindowButtonMotionFcn'));

set(gcf,'WindowButtonUpFcn','mousesel(''stop'')');
set(gcf,'WindowButtonMotionFcn','mousesel(''move'')');

if isappdata(gca,'mousesel_fill')
    delete(getappdata(gca,'mousesel_fill'));
    rmappdata(gca,'mousesel_fill');        
end

%blockiere bis das Rechteck komplett ist
oldUserData=get(gca,'UserData');
set(gca,'UserData',0);
waitfor(gca,'UserData');
set(gca,'UserData',oldUserData);


if isappdata(gca,'mousesel_fill')
    ret=getappdata(gca,'mousesel_fill');
    rmappdata(gca,'mousesel_fill');
    return;
end

ret=[];        

Contact us