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

uigetblink.m
function varargout = uigetblink(varargin)
% $Id: uigetblink.m 6 2004-12-13 12:28:39Z maik $
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @uigetblink_OpeningFcn, ...
                   'gui_OutputFcn',  @uigetblink_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT



% --- Executes just before uigetblink is made visible.
function uigetblink_OpeningFcn(hObject, eventdata, handles, varargin)

% prft zuerst ob wir auch eine gltige datenmatrix bekommen haben
if (nargin<5)
    return;
end
%varargin(1)
indim=size(varargin{1});

%ist die Eingabe auch eine Matrix ?
if(length(indim)~=2)   
    return;
end

%sind weniger als 3 Kanle vorhanden, kein Auswerten mglich
if(indim(2)<3)
    return;
end



% Wenn alles ok, sichere Matrix fr sptere zugriffe und setze
% Fensterbreite, ist diese zu gro ....
handles.data = varargin{1};
parameter=varargin{2};
handles.data(:,2)=handles.data(:,2)*parameter.wfakt.x;
handles.data(:,3)=handles.data(:,3)*parameter.wfakt.y;

handles.winsize=4000;

if(indim(1)<handles.winsize)
    handles.winsize=indim(1);
end


% Update handles structure
guidata(hObject, handles);

% Positioniere die GUI im Mittelpunkt
dlgRes=get(handles.fschritt3,'position');
monRes=get(0,'ScreenSize');
dlgRes(1)=(monRes(3)-dlgRes(3))/2;  %x-achse
dlgRes(2)=(monRes(4)/2)-(dlgRes(4)/2);  %x-achse
set(handles.fschritt3,'position',dlgRes);



% Position slider einstellen
width=indim(1);
if(handles.winsize<width)            
    %Schrittweite einstellen
    stepratio = .1;                
    steptrough=handles.winsize / (width - handles.winsize); % Fensterbreite        
    steparrow =stepratio * steptrough;    % 10 % der fensterbreite
    set(handles.slider,'sliderstep', [steparrow steptrough]);
else
    set(handles.slider,'Visible','off');    
end


% X Kanal darstellen, zeichne ersten teil
axes(handles.Graph);
h=handles.Graph;
r=1:handles.winsize;
plot(handles.data(r,1),handles.data(r,3));
set(h,'xlim',[handles.data(1,1) handles.data(handles.winsize,1)]);
set(h,'ButtonDownFcn','uigetblink(''Graph_ButtonDownFcn'',gcbo,[],guidata(gcbo))');
setminwinhigh(200);



% UIWAIT makes uigetblink wait for user response (see UIRESUME)
uiwait(handles.fschritt3);


% --- Outputs from this function are returned to the command line.
function varargout = uigetblink_OutputFcn(hObject, eventdata, handles) 
% gibt es das feld ?
if(isfield(handles,'output'))      
    varargout{1} = handles.output;  
    close();
else
    varargout{1} = [];
end
    



% --- Executes on button press in bCancel.
function bCancel_Callback(hObject, eventdata, handles)
% hObject    handle to bCancel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

handles.output=[];  
guidata(hObject, handles);

uiresume(handles.fschritt3);


% --- Executes on button press in bNext.
function bNext_Callback(hObject, eventdata, handles)
% hObject    handle to bNext (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% prfe Daten
l=str2num(get(handles.eAmp,'String'));
if isnan(l) 
    return;
end


% sichere result
handles.output=l;  
guidata(hObject, handles);

%beende Dialog
uiresume(handles.fschritt3);



function editL_Callback(hObject, eventdata, handles)



% --- Executes during object creation, after setting all properties.
function editL_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function editR_Callback(hObject, eventdata, handles)



% --- Executes during object creation, after setting all properties.
function editR_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

% --- Executes on slider movement.
function slider_Callback(hObject, eventdata, handles)
v2=1+fix(get(handles.slider,'Value')* (length(handles.data(:,1))-handles.winsize) );  % workaround matlab 7
r=v2:v2+handles.winsize-1;
h=handles.Graph;
axes(h);
plot(handles.data(r,1),handles.data(r,3));
set(h,'xlim',[handles.data(r(1),1) handles.data(r(end),1)]); 
setminwinhigh(200);  
set(h,'ButtonDownFcn','uigetblink(''Graph_ButtonDownFcn'',gcbo,[],guidata(gcbo))');



% --- Executes during object creation, after setting all properties.
function slider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



% --- Executes on mouse press over axes background.
function Graph_ButtonDownFcn(hObject, eventdata, handles)

point1 = get(gca,'CurrentPoint');    % button down detected
rec=mousesel();
if(~isempty(rec))
    delete(rec);
end
point2 = get(gca,'CurrentPoint');    % button up detected


xrage=sort([point1(1,1) point2(1,1)]);

start=find(handles.data(:,1)>=xrage(1),1);   % suche startsample
ende=find(handles.data(:,1)>=xrage(2),1);   % suche endsample

amp=max(handles.data(start:ende,3))-min(handles.data(start:ende,3));

set(handles.editL,'String',num2str(start));
set(handles.editR,'String',num2str(ende));
set(handles.eAmp,'String',num2str(amp));



function eAmp_Callback(hObject, eventdata, handles)
% hObject    handle to eAmp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of eAmp as text
%        str2double(get(hObject,'String')) returns contents of eAmp as a double


% --- Executes during object creation, after setting all properties.
function eAmp_CreateFcn(hObject, eventdata, handles)
% hObject    handle to eAmp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


Contact us