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

kanalauswahl(varargin)
function varargout = kanalauswahl(varargin)
% KANALAUSWAHL M-file for kanalauswahl.fig
%      KANALAUSWAHL, by itself, creates a new KANALAUSWAHL or raises the existing
%      singleton*.
%
%      H = KANALAUSWAHL returns the handle to a new KANALAUSWAHL or the handle to
%      the existing singleton*.
%
%      KANALAUSWAHL('CALLBACK',hObject,eventData,handles,...) calls the
%      local
%      function named CALLBACK in KANALAUSWAHL.M with the given input
%      arguments.
%
%      KANALAUSWAHL('Property','Value',...) creates a new KANALAUSWAHL or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before kanalauswahl_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property
%      application
%      stop.  All inputs are passed to kanalauswahl_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help kanalauswahl

% Last Modified by GUIDE v2.5 23-Nov-2008 11:49:04

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @kanalauswahl_OpeningFcn, ...
                   'gui_OutputFcn',  @kanalauswahl_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


%function FileMenu_Callback(hObject, eventdata, handles, varargin)

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

handles.output = hObject;
handles.data = varargin{1};
handles.winsize = 10000;
handles.samples = size(handles.data,1);

% Update handles structure
guidata(hObject, handles);


channels = size(handles.data,2);
if channels>1
    lines = {};
    for i=2:channels
        lines = [lines, {sprintf('Channel %d',i-1)} ];
    end
    if channels<4
        lines = [lines, {sprintf('Empty')}];
    end
    set(handles.popupmenu2, 'String', lines);
    set(handles.popupmenu5, 'String', lines);  
    set(handles.popupmenu6, 'String', lines);
end


if length(varargin) > 1
    handles.mapping = varargin{2};
    if ~(max(handles.mapping)> channels) 
        set(handles.popupmenu2, 'Value', handles.mapping(1));
        set(handles.popupmenu5, 'Value', handles.mapping(2));
        set(handles.popupmenu6, 'Value', handles.mapping(3));   
        set(handles.checkbox1, 'Value' ,  handles.mapping(4));
        set(handles.checkbox2, 'Value' ,  handles.mapping(5));
        set(handles.checkbox3, 'Value' ,  handles.mapping(6));    
    end
end

if length(varargin) > 2
    strings = varargin{3};
    set(handles.text1,'String',strings{1});
    set(handles.text2,'String',strings{2});
    set(handles.text3,'String',strings{3});
end


samples = size(handles.data,1);
if samples > 1
    %set(handles.slider1,'Min',1);
    %set(handles.slider1,'Max',samples);
    %set(handles.slider1,'Value',1);    
    %h = 100/samples;
    %set(handles.slider1,'SliderStep',[h*10,h*100]);
	
	stepratio = .1; 
    steptrough=handles.winsize / (samples - handles.winsize); % Fensterbreite        
    steparrow =stepratio * steptrough;    % 10 % der fensterbreite
    set(handles.slider1,'sliderstep', [steparrow steptrough]);	
end

renderScreen(hObject, eventdata, handles);
maximize(gcf);
uiwait(hObject);



% UIWAIT makes kanalauswahl wait for user response (see UIRESUME)
% uiwait(handles.figure1);


function renderScreen(hObject, eventdata, handles)
    %curpos = round(get(handles.slider1,'Value'));
    curpos=1+fix(get(handles.slider1,'Value') * (handles.samples-handles.winsize) );    
    set(handles.edit1,'String',sprintf('%d',curpos));
    start = curpos;
    ende = min(curpos+ handles.winsize,size(handles.data,1));
    ax = [handles.axes1,handles.axes2,handles.axes3];
    pu = [handles.popupmenu2,handles.popupmenu5,handles.popupmenu6];
    cb = [handles.checkbox1,handles.checkbox2,handles.checkbox3];
    point2 = get(gca,'CurrentPoint');    % button up detected 
    if size(handles.data,2)<4 %RS: 7.8.11 - if no trigger signal is present
        emptytrigger=zeros(length(handles.data),1);
        handles.data=[handles.data emptytrigger];
        % Update handles structure
        guidata(hObject, handles);
    end   
    for i=1:length(ax)
        axes(ax(i));
        p = get(pu(i),'Value');
        inv = get(cb(i),'Value');
        data = handles.data(start:ende,p+1);
        if inv == 1
            data = data * -1;
        end
        plot(start:ende,data);
        set(ax(i),'xlimmode','manual','xlim',[start,ende]);
        hold on;
        dim = get(ax(i),'ylim');
        plot([point2(1,1),point2(1,1)],dim,'-.r');
        hold off;
        
    end
    
    



% --- Outputs from this function are returned to the command line.
function varargout = kanalauswahl_OutputFcn(hObject, eventdata, handles)

if(isfield(handles,'output'))
    varargout{1} = handles.output;
else
    varargout{1} = [];
end

if ishandle(hObject)
    delete(hObject);
end



% --------------------------------------------------------------------
function CloseMenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to CloseMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],...
                     ['Close ' get(handles.figure1,'Name') '...'],...
                     'Yes','No','Yes');
if strcmp(selection,'No')
    return;
end

delete(handles.figure1)


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


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

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

set(hObject, 'String', {'plot(rand(5))', 'plot(sin(1:0.01:25))', 'bar(1:.5:10)', 'plot(membrane)', 'surf(peaks)'});



% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
renderScreen(hObject, eventdata, handles);



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

% Hint: popupmenu 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







% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3


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

% Hint: popupmenu 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


% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu4


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

% Hint: popupmenu 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


% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
renderScreen(hObject, eventdata, handles);


% --- Executes on selection change in popupmenu5.
function popupmenu5_Callback(hObject, eventdata, handles)
renderScreen(hObject, eventdata, handles);


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

% Hint: popupmenu 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


% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
renderScreen(hObject, eventdata, handles);


% --- Executes on selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
renderScreen(hObject, eventdata, handles);


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

% Hint: popupmenu 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


% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
renderScreen(hObject, eventdata, handles);


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
renderScreen(hObject, eventdata, handles)

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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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 edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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


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


% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
renderScreen(hObject, eventdata, handles)



% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
delete(hObject);





% --- Executes on button press in bOK.
function bOK_Callback(hObject, eventdata, handles)
handles.output =  [get(handles.popupmenu2, 'Value'),get(handles.popupmenu5, 'Value'),get(handles.popupmenu6, 'Value'),get(handles.checkbox1, 'Value'),get(handles.checkbox2, 'Value'),get(handles.checkbox3, 'Value')  ];
guidata(hObject, handles);
uiresume(handles.figure1);

% --- Executes on button press in bCancel.
function bCancel_Callback(hObject, eventdata, handles)
handles.output =  [];
guidata(hObject, handles);
uiresume(handles.figure1);

Contact us