Home > GVSToolbox > simpleGUI.m

simpleGUI

PURPOSE ^

SIMPLEGUI MATLAB code for simpleGUI.fig

SYNOPSIS ^

function varargout = simpleGUI(varargin)

DESCRIPTION ^

 SIMPLEGUI MATLAB code for simpleGUI.fig
      SIMPLEGUI, by itself, creates a new SIMPLEGUI or raises the existing
      singleton*.

      H = SIMPLEGUI returns the handle to a new SIMPLEGUI or the handle to
      the existing singleton*.

      SIMPLEGUI('CALLBACK',hObject,eventData,handles,...) calls the local
      function named CALLBACK in SIMPLEGUI.M with the given input arguments.

      SIMPLEGUI('Property','Value',...) creates a new SIMPLEGUI or raises the
      existing singleton*.  Starting from the left, property value pairs are
      applied to the GUI before simpleGUI_OpeningFcn gets called.  An
      unrecognized property name or invalid value makes property application
      stop.  All inputs are passed to simpleGUI_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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = simpleGUI(varargin)
0002 % SIMPLEGUI MATLAB code for simpleGUI.fig
0003 %      SIMPLEGUI, by itself, creates a new SIMPLEGUI or raises the existing
0004 %      singleton*.
0005 %
0006 %      H = SIMPLEGUI returns the handle to a new SIMPLEGUI or the handle to
0007 %      the existing singleton*.
0008 %
0009 %      SIMPLEGUI('CALLBACK',hObject,eventData,handles,...) calls the local
0010 %      function named CALLBACK in SIMPLEGUI.M with the given input arguments.
0011 %
0012 %      SIMPLEGUI('Property','Value',...) creates a new SIMPLEGUI or raises the
0013 %      existing singleton*.  Starting from the left, property value pairs are
0014 %      applied to the GUI before simpleGUI_OpeningFcn gets called.  An
0015 %      unrecognized property name or invalid value makes property application
0016 %      stop.  All inputs are passed to simpleGUI_OpeningFcn via varargin.
0017 %
0018 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0019 %      instance to run (singleton)".
0020 %
0021 % See also: GUIDE, GUIDATA, GUIHANDLES
0022 
0023 % Edit the above text to modify the response to help simpleGUI
0024 
0025 % Last Modified by GUIDE v2.5 01-Jul-2014 10:07:30
0026 
0027 % Begin initialization code - DO NOT EDIT
0028 gui_Singleton = 1;
0029 gui_State = struct('gui_Name',       mfilename, ...
0030                    'gui_Singleton',  gui_Singleton, ...
0031                    'gui_OpeningFcn', @simpleGUI_OpeningFcn, ...
0032                    'gui_OutputFcn',  @simpleGUI_OutputFcn, ...
0033                    'gui_LayoutFcn',  [] , ...
0034                    'gui_Callback',   []);
0035 if nargin && ischar(varargin{1})
0036     gui_State.gui_Callback = str2func(varargin{1});
0037 end
0038 
0039 if nargout
0040     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0041 else
0042     gui_mainfcn(gui_State, varargin{:});
0043 end
0044 % End initialization code - DO NOT EDIT
0045 
0046 
0047 
0048 
0049 
0050 % --- Executes just before simpleGUI is made visible.
0051 function simpleGUI_OpeningFcn(hObject, eventdata, handles, varargin)
0052 % This function has no output args, see OutputFcn.
0053 % hObject    handle to figure
0054 % eventdata  reserved - to be defined in a future version of MATLAB
0055 % handles    structure with handles and user data (see GUIDATA)
0056 % varargin   command line arguments to simpleGUI (see VARARGIN)
0057 
0058 % Choose default command line output for simpleGUI
0059 handles.output = hObject;
0060 
0061 % Update handles structure
0062 guidata(hObject, handles);
0063 
0064 % UIWAIT makes simpleGUI wait for user response (see UIRESUME)
0065 % uiwait(handles.figure1);
0066 
0067 
0068 % --- Outputs from this function are returned to the command line.
0069 function varargout = simpleGUI_OutputFcn(hObject, eventdata, handles) 
0070 % varargout  cell array for returning output args (see VARARGOUT);
0071 % hObject    handle to figure
0072 % eventdata  reserved - to be defined in a future version of MATLAB
0073 % handles    structure with handles and user data (see GUIDATA)
0074 
0075 % Get default command line output from handles structure
0076 varargout{1} = handles.output;
0077 
0078 
0079 
0080 function sampRate_Callback(hObject, eventdata, handles)
0081 % hObject    handle to sampRate (see GCBO)
0082 % eventdata  reserved - to be defined in a future version of MATLAB
0083 % handles    structure with handles and user data (see GUIDATA)
0084 
0085 % Hints: get(hObject,'String') returns contents of sampRate as text
0086 %        str2double(get(hObject,'String')) returns contents of sampRate as a double
0087 
0088 
0089 % --- Executes during object creation, after setting all properties.
0090 function sampRate_CreateFcn(hObject, eventdata, handles)
0091 % hObject    handle to sampRate (see GCBO)
0092 % eventdata  reserved - to be defined in a future version of MATLAB
0093 % handles    empty - handles not created until after all CreateFcns called
0094 
0095 % Hint: edit controls usually have a white background on Windows.
0096 %       See ISPC and COMPUTER.
0097 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0098     set(hObject,'BackgroundColor','white');
0099 end
0100 
0101 
0102 
0103 function fixDuration_Callback(hObject, eventdata, handles)
0104 % hObject    handle to fixDuration (see GCBO)
0105 % eventdata  reserved - to be defined in a future version of MATLAB
0106 % handles    structure with handles and user data (see GUIDATA)
0107 
0108 % Hints: get(hObject,'String') returns contents of fixDuration as text
0109 %        str2double(get(hObject,'String')) returns contents of fixDuration as a double
0110 
0111 
0112 % --- Executes during object creation, after setting all properties.
0113 function fixDuration_CreateFcn(hObject, eventdata, handles)
0114 % hObject    handle to fixDuration (see GCBO)
0115 % eventdata  reserved - to be defined in a future version of MATLAB
0116 % handles    empty - handles not created until after all CreateFcns called
0117 
0118 % Hint: edit controls usually have a white background on Windows.
0119 %       See ISPC and COMPUTER.
0120 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0121     set(hObject,'BackgroundColor','white');
0122 end
0123 
0124 
0125 
0126 function width_Callback(hObject, eventdata, handles)
0127 % hObject    handle to width (see GCBO)
0128 % eventdata  reserved - to be defined in a future version of MATLAB
0129 % handles    structure with handles and user data (see GUIDATA)
0130 
0131 % Hints: get(hObject,'String') returns contents of width as text
0132 %        str2double(get(hObject,'String')) returns contents of width as a double
0133 
0134 
0135 % --- Executes during object creation, after setting all properties.
0136 function width_CreateFcn(hObject, eventdata, handles)
0137 % hObject    handle to width (see GCBO)
0138 % eventdata  reserved - to be defined in a future version of MATLAB
0139 % handles    empty - handles not created until after all CreateFcns called
0140 
0141 % Hint: edit controls usually have a white background on Windows.
0142 %       See ISPC and COMPUTER.
0143 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0144     set(hObject,'BackgroundColor','white');
0145 end
0146 
0147 
0148 
0149 function height_Callback(hObject, eventdata, handles)
0150 % hObject    handle to height (see GCBO)
0151 % eventdata  reserved - to be defined in a future version of MATLAB
0152 % handles    structure with handles and user data (see GUIDATA)
0153 
0154 % Hints: get(hObject,'String') returns contents of height as text
0155 %        str2double(get(hObject,'String')) returns contents of height as a double
0156 
0157 
0158 % --- Executes during object creation, after setting all properties.
0159 function height_CreateFcn(hObject, eventdata, handles)
0160 % hObject    handle to height (see GCBO)
0161 % eventdata  reserved - to be defined in a future version of MATLAB
0162 % handles    empty - handles not created until after all CreateFcns called
0163 
0164 % Hint: edit controls usually have a white background on Windows.
0165 %       See ISPC and COMPUTER.
0166 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0167     set(hObject,'BackgroundColor','white');
0168 end
0169 
0170 
0171 % --- Executes on button press in pushbutton1.
0172 function pushbutton1_Callback(hObject, eventdata, handles)
0173 % hObject    handle to pushbutton1 (see GCBO)
0174 % eventdata  reserved - to be defined in a future version of MATLAB
0175 % handles    structure with handles and user data (see GUIDATA)
0176 % load up data
0177 
0178 [file,folder]=uigetfile;
0179 handles.dataStruct = loadFromTable( fullfile( folder, file) );  
0180 
0181 % handles.dataStruct = loadFromTable( 'exampleTable.txt');
0182 if isfield(handles, 'dataStructRaw') % reset if reloading data
0183     handles = rmfield(  handles, 'dataStructRaw');
0184 end
0185 handles = getVarParams(handles ); % get default parameters
0186 guidata(hObject,handles)
0187 fprintf( 'Data imported to MATLAB.\n');
0188 
0189 function kParam_Callback(hObject, eventdata, handles)
0190 % hObject    handle to kParam (see GCBO)
0191 % eventdata  reserved - to be defined in a future version of MATLAB
0192 % handles    structure with handles and user data (see GUIDATA)
0193 
0194 % Hints: get(hObject,'String') returns contents of kParam as text
0195 %        str2double(get(hObject,'String')) returns contents of kParam as a double
0196 
0197 
0198 % --- Executes during object creation, after setting all properties.
0199 function kParam_CreateFcn(hObject, eventdata, handles)
0200 % hObject    handle to kParam (see GCBO)
0201 % eventdata  reserved - to be defined in a future version of MATLAB
0202 % handles    empty - handles not created until after all CreateFcns called
0203 
0204 % Hint: edit controls usually have a white background on Windows.
0205 %       See ISPC and COMPUTER.
0206 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0207     set(hObject,'BackgroundColor','white');
0208 end
0209 
0210 
0211 % --- Executes on button press in pushbutton2.
0212 function pushbutton2_Callback(hObject, eventdata, handles)
0213 % hObject    handle to pushbutton2 (see GCBO)
0214 % eventdata  reserved - to be defined in a future version of MATLAB
0215 % handles    structure with handles and user data (see GUIDATA)
0216 % smooth and interpolate
0217 param = str2double( get(handles.kParam, 'string'));
0218 if ~isfield(handles, 'dataStructRaw') 
0219     handles.dataStructRaw = handles.dataStruct;
0220 end
0221 handles.dataStruct = smoothTracks( handles.dataStruct, param );
0222 guidata(hObject,handles)
0223 fprintf( 'Kalman filtering complete.\n');
0224 
0225 % --- Executes on button press in pushbutton5.
0226 function pushbutton5_Callback(hObject, eventdata, handles)
0227 % hObject    handle to pushbutton5 (see GCBO)
0228 % eventdata  reserved - to be defined in a future version of MATLAB
0229 % handles    structure with handles and user data (see GUIDATA)
0230 % show the gaze
0231 
0232 handles = getVarParams(handles );  % load all parameters
0233 guidata(hObject,handles) % set values
0234 
0235 % get stimulus image
0236 imgFile = get( handles.imgFile, 'String');  % if empty, will show on black
0237 
0238 % get trial indices
0239 subj = str2double(get( handles.pNum, 'string'));
0240 
0241 if ~isfield( handles.dataStruct, 'sampsPerSubj' ) % make sure loaded first
0242     error( ['Gaze Toolbox Error: Load source file first!' ]);
0243 end
0244        
0245 sps = handles.dataStruct.sampsPerSubj;
0246 if subj > length(sps); % unknown participant
0247     error( ['Gaze Toolbox Error: Only ' num2str(length(sps))  ' subjects loaded, change participant number']);
0248 elseif subj == 1
0249     trlIdx = 1:sps(1);  % first participant
0250     prevTrial = 0;
0251 else
0252     trlIdx = sum(sps(1:subj-1))+1: sum(sps(1:subj-1))+sps(subj);
0253     prevTrial = sum(sps(1:subj-1));
0254 end
0255 
0256 % visualize tracks
0257 figure(2);
0258 for index = trlIdx;
0259     title( [ 'Trial ' num2str( index-prevTrial )], 'fontsize', 20 );
0260     pause(.5);
0261     
0262     leftEyePos = handles.dataStruct.trackCell{index};
0263     if isfield( handles, 'dataStructRaw')
0264         leftOri = handles.dataStructRaw.trackCell{index};
0265     else
0266         leftOri = [];
0267     end
0268     visualizeTrackDist(  leftEyePos, leftOri, imgFile, handles.dataStruct.varParams,  handles.dataStruct.varParams.imageSize )
0269 end
0270 
0271 function pNum_Callback(hObject, eventdata, handles)
0272 % hObject    handle to pNum (see GCBO)
0273 % eventdata  reserved - to be defined in a future version of MATLAB
0274 % handles    structure with handles and user data (see GUIDATA)
0275 
0276 % Hints: get(hObject,'String') returns contents of pNum as text
0277 %        str2double(get(hObject,'String')) returns contents of pNum as a double
0278 
0279 
0280 % --- Executes during object creation, after setting all properties.
0281 function pNum_CreateFcn(hObject, eventdata, handles)
0282 % hObject    handle to pNum (see GCBO)
0283 % eventdata  reserved - to be defined in a future version of MATLAB
0284 % handles    empty - handles not created until after all CreateFcns called
0285 
0286 % Hint: edit controls usually have a white background on Windows.
0287 %       See ISPC and COMPUTER.
0288 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0289     set(hObject,'BackgroundColor','white');
0290 end
0291 
0292 
0293 
0294 function edit9_Callback(hObject, eventdata, handles)
0295 % hObject    handle to edit9 (see GCBO)
0296 % eventdata  reserved - to be defined in a future version of MATLAB
0297 % handles    structure with handles and user data (see GUIDATA)
0298 
0299 % Hints: get(hObject,'String') returns contents of edit9 as text
0300 %        str2double(get(hObject,'String')) returns contents of edit9 as a double
0301 
0302 
0303 % --- Executes during object creation, after setting all properties.
0304 function edit9_CreateFcn(hObject, eventdata, handles)
0305 % hObject    handle to edit9 (see GCBO)
0306 % eventdata  reserved - to be defined in a future version of MATLAB
0307 % handles    empty - handles not created until after all CreateFcns called
0308 
0309 % Hint: edit controls usually have a white background on Windows.
0310 %       See ISPC and COMPUTER.
0311 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0312     set(hObject,'BackgroundColor','white');
0313 end
0314 
0315 
0316 
0317 function imgFile_Callback(hObject, eventdata, handles)
0318 % hObject    handle to imgFile (see GCBO)
0319 % eventdata  reserved - to be defined in a future version of MATLAB
0320 % handles    structure with handles and user data (see GUIDATA)
0321 
0322 % Hints: get(hObject,'String') returns contents of imgFile as text
0323 %        str2double(get(hObject,'String')) returns contents of imgFile as a double
0324 
0325 
0326 % --- Executes during object creation, after setting all properties.
0327 function imgFile_CreateFcn(hObject, eventdata, handles)
0328 % hObject    handle to imgFile (see GCBO)
0329 % eventdata  reserved - to be defined in a future version of MATLAB
0330 % handles    empty - handles not created until after all CreateFcns called
0331 
0332 % Hint: edit controls usually have a white background on Windows.
0333 %       See ISPC and COMPUTER.
0334 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0335     set(hObject,'BackgroundColor','white');
0336 end
0337 
0338 
0339 
0340 function fixRad_Callback(hObject, eventdata, handles)
0341 % hObject    handle to fixRad (see GCBO)
0342 % eventdata  reserved - to be defined in a future version of MATLAB
0343 % handles    structure with handles and user data (see GUIDATA)
0344 
0345 % Hints: get(hObject,'String') returns contents of fixRad as text
0346 %        str2double(get(hObject,'String')) returns contents of fixRad as a double
0347 
0348 
0349 % --- Executes during object creation, after setting all properties.
0350 function fixRad_CreateFcn(hObject, eventdata, handles)
0351 % hObject    handle to fixRad (see GCBO)
0352 % eventdata  reserved - to be defined in a future version of MATLAB
0353 % handles    empty - handles not created until after all CreateFcns called
0354 
0355 % Hint: edit controls usually have a white background on Windows.
0356 %       See ISPC and COMPUTER.
0357 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0358     set(hObject,'BackgroundColor','white');
0359 end
0360 
0361 
0362 
0363 function sacStartThresh_Callback(hObject, eventdata, handles)
0364 % hObject    handle to sacStartThresh (see GCBO)
0365 % eventdata  reserved - to be defined in a future version of MATLAB
0366 % handles    structure with handles and user data (see GUIDATA)
0367 
0368 % Hints: get(hObject,'String') returns contents of sacStartThresh as text
0369 %        str2double(get(hObject,'String')) returns contents of sacStartThresh as a double
0370 
0371 
0372 % --- Executes during object creation, after setting all properties.
0373 function sacStartThresh_CreateFcn(hObject, eventdata, handles)
0374 % hObject    handle to sacStartThresh (see GCBO)
0375 % eventdata  reserved - to be defined in a future version of MATLAB
0376 % handles    empty - handles not created until after all CreateFcns called
0377 
0378 % Hint: edit controls usually have a white background on Windows.
0379 %       See ISPC and COMPUTER.
0380 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0381     set(hObject,'BackgroundColor','white');
0382 end
0383 
0384 
0385 
0386 function sacStopThresh_Callback(hObject, eventdata, handles)
0387 % hObject    handle to sacStopThresh (see GCBO)
0388 % eventdata  reserved - to be defined in a future version of MATLAB
0389 % handles    structure with handles and user data (see GUIDATA)
0390 
0391 % Hints: get(hObject,'String') returns contents of sacStopThresh as text
0392 %        str2double(get(hObject,'String')) returns contents of sacStopThresh as a double
0393 
0394 
0395 % --- Executes during object creation, after setting all properties.
0396 function sacStopThresh_CreateFcn(hObject, eventdata, handles)
0397 % hObject    handle to sacStopThresh (see GCBO)
0398 % eventdata  reserved - to be defined in a future version of MATLAB
0399 % handles    empty - handles not created until after all CreateFcns called
0400 
0401 % Hint: edit controls usually have a white background on Windows.
0402 %       See ISPC and COMPUTER.
0403 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0404     set(hObject,'BackgroundColor','white');
0405 end
0406 
0407 
0408 % --- Executes on button press in radiobutton1.
0409 function radiobutton1_Callback(hObject, eventdata, handles)
0410 % hObject    handle to radiobutton1 (see GCBO)
0411 % eventdata  reserved - to be defined in a future version of MATLAB
0412 % handles    structure with handles and user data (see GUIDATA)
0413 
0414 % Hint: get(hObject,'Value') returns toggle state of radiobutton1
0415 
0416 
0417 % --- Executes on button press in radiobutton2.
0418 function radiobutton2_Callback(hObject, eventdata, handles)
0419 % hObject    handle to radiobutton2 (see GCBO)
0420 % eventdata  reserved - to be defined in a future version of MATLAB
0421 % handles    structure with handles and user data (see GUIDATA)
0422 
0423 % Hint: get(hObject,'Value') returns toggle state of radiobutton2
0424 
0425 
0426 % --- Executes on button press in radiobutton4.
0427 function radiobutton4_Callback(hObject, eventdata, handles)
0428 % hObject    handle to radiobutton4 (see GCBO)
0429 % eventdata  reserved - to be defined in a future version of MATLAB
0430 % handles    structure with handles and user data (see GUIDATA)
0431 
0432 % Hint: get(hObject,'Value') returns toggle state of radiobutton4
0433 
0434 
0435 % --- Executes on button press in radiobutton5.
0436 function radiobutton5_Callback(hObject, eventdata, handles)
0437 % hObject    handle to radiobutton5 (see GCBO)
0438 % eventdata  reserved - to be defined in a future version of MATLAB
0439 % handles    structure with handles and user data (see GUIDATA)
0440 
0441 % Hint: get(hObject,'Value') returns toggle state of radiobutton5
0442 
0443 
0444 % --- Executes on button press in radiobutton6.
0445 function radiobutton6_Callback(hObject, eventdata, handles)
0446 % hObject    handle to radiobutton6 (see GCBO)
0447 % eventdata  reserved - to be defined in a future version of MATLAB
0448 % handles    structure with handles and user data (see GUIDATA)
0449 
0450 % Hint: get(hObject,'Value') returns toggle state of radiobutton6
0451 
0452 
0453 % --- Executes on button press in pushbutton6.
0454 function pushbutton6_Callback(hObject, eventdata, handles)
0455 % hObject    handle to pushbutton6 (see GCBO)
0456 % eventdata  reserved - to be defined in a future version of MATLAB
0457 % handles    structure with handles and user data (see GUIDATA)
0458 % validate variable
0459 
0460 handles = getVarParams(handles ); % get default parameters
0461 guidata(hObject,handles)
0462 
0463 % if no top variables found
0464 if ~isfield( handles.dataStruct, 'bestVarsIdx');
0465     error( 'Gaze Toolbox Error: First select top variables.');
0466 end
0467 bestVarsIdx = handles.dataStruct.bestVarsIdx;
0468  
0469 % now validate
0470 if get( handles.L1Val, 'Value')  % if doing L1-LR
0471     alg = 'L1-Logistic Regression';
0472     [ percCorrect, w ] = runLRLeave1Out( handles.dataStruct.featureVect(bestVarsIdx,:), ...
0473         handles.dataStruct.allLabels, handles.dataStruct.sampsPerSubj );
0474 elseif get( handles.BayesVal, 'Value')  % if doing L1-LR
0475     alg = 'Bayes Classifier';;
0476     [ percCorrect, w ] = runLDALeave1Out( handles.dataStruct.featureVect(bestVarsIdx,:), ...
0477         handles.dataStruct.allLabels, handles.dataStruct.sampsPerSubj );
0478 else %otherwise SVM
0479     alg = 'SVM Classifier';
0480     [ percCorrect, w  ] = runSVMLeave1Out( handles.dataStruct.featureVect(bestVarsIdx,:), ...
0481         handles.dataStruct.allLabels, handles.dataStruct.sampsPerSubj );    
0482 end
0483 fprintf( '\n%s Leave 1 subject out CV-Accuracy: %f, feature weights:\n', alg, percCorrect)
0484 w
0485 
0486 % --- Executes on button press in pushbutton7.
0487 function pushbutton7_Callback(hObject, eventdata, handles)
0488 % hObject    handle to pushbutton7 (see GCBO)
0489 % eventdata  reserved - to be defined in a future version of MATLAB
0490 % handles    structure with handles and user data (see GUIDATA)
0491 % identify and export
0492 handles = getVarParams(handles ); % get default parameters
0493 guidata(hObject,handles)
0494 
0495 numWanted = str2double( get( handles.numKeep, 'string'));
0496 
0497 % re-calculate feature vectors
0498 fprintf( 'Extracting all gaze variables...')
0499 [  handles.dataStruct.featureVect, handles.dataStruct.varParams ]  ...
0500     = extractVarsDist( handles.dataStruct.trackCell, ...
0501         handles.dataStruct.aoiPos, handles.dataStruct.outSideDist, ...
0502         handles.dataStruct.relAOI, handles.dataStruct.varParams );
0503 fprintf( 'done.\n');
0504 
0505 if get( handles.L1Select, 'Value')  % if doing L1-LR
0506     fprintf( '\nTop L1-LR selected variables:\n');
0507     [ bestVarsIdx ] = sortVariablesLR( handles.dataStruct.featureVect, handles.dataStruct.allLabels, numWanted );                  
0508 else %doing Naive Bayes otherwise
0509     fprintf( '\nTop Naive Bayes selected variables:\n');
0510     [ bestVarsIdx ] = sortVariablesNB( handles.dataStruct.featureVect, handles.dataStruct.allLabels, ...
0511                 handles.dataStruct.sampsPerSubj, numWanted );  
0512 end
0513 % output best variables
0514 describeVariables( handles.dataStruct.varParams, bestVarsIdx ); % to screen
0515 exportToTable( handles.dataStruct, handles.dataStruct.featureVect(bestVarsIdx,:), 'variablesTable.txt' ); % to table
0516 fprintf( 'Exported to file variablesTable.txt\n');
0517 
0518 % add top variables to struct
0519 handles.dataStruct.bestVarsIdx = bestVarsIdx;
0520 guidata(hObject,handles)
0521 
0522 function aoiOut_Callback(hObject, eventdata, handles)
0523 % hObject    handle to aoiOut (see GCBO)
0524 % eventdata  reserved - to be defined in a future version of MATLAB
0525 % handles    structure with handles and user data (see GUIDATA)
0526 
0527 % Hints: get(hObject,'String') returns contents of aoiOut as text
0528 %        str2double(get(hObject,'String')) returns contents of aoiOut as a double
0529 
0530 
0531 % --- Executes during object creation, after setting all properties.
0532 function aoiOut_CreateFcn(hObject, eventdata, handles)
0533 % hObject    handle to aoiOut (see GCBO)
0534 % eventdata  reserved - to be defined in a future version of MATLAB
0535 % handles    empty - handles not created until after all CreateFcns called
0536 
0537 % Hint: edit controls usually have a white background on Windows.
0538 %       See ISPC and COMPUTER.
0539 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0540     set(hObject,'BackgroundColor','white');
0541 end
0542 
0543 
0544 
0545 function aoiX_Callback(hObject, eventdata, handles)
0546 % hObject    handle to aoiX (see GCBO)
0547 % eventdata  reserved - to be defined in a future version of MATLAB
0548 % handles    structure with handles and user data (see GUIDATA)
0549 
0550 % Hints: get(hObject,'String') returns contents of aoiX as text
0551 %        str2double(get(hObject,'String')) returns contents of aoiX as a double
0552 
0553 
0554 % --- Executes during object creation, after setting all properties.
0555 function aoiX_CreateFcn(hObject, eventdata, handles)
0556 % hObject    handle to aoiX (see GCBO)
0557 % eventdata  reserved - to be defined in a future version of MATLAB
0558 % handles    empty - handles not created until after all CreateFcns called
0559 
0560 % Hint: edit controls usually have a white background on Windows.
0561 %       See ISPC and COMPUTER.
0562 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0563     set(hObject,'BackgroundColor','white');
0564 end
0565 
0566 
0567 
0568 function aoiY_Callback(hObject, eventdata, handles)
0569 % hObject    handle to aoiY (see GCBO)
0570 % eventdata  reserved - to be defined in a future version of MATLAB
0571 % handles    structure with handles and user data (see GUIDATA)
0572 
0573 % Hints: get(hObject,'String') returns contents of aoiY as text
0574 %        str2double(get(hObject,'String')) returns contents of aoiY as a double
0575 
0576 
0577 % --- Executes during object creation, after setting all properties.
0578 function aoiY_CreateFcn(hObject, eventdata, handles)
0579 % hObject    handle to aoiY (see GCBO)
0580 % eventdata  reserved - to be defined in a future version of MATLAB
0581 % handles    empty - handles not created until after all CreateFcns called
0582 
0583 % Hint: edit controls usually have a white background on Windows.
0584 %       See ISPC and COMPUTER.
0585 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0586     set(hObject,'BackgroundColor','white');
0587 end
0588 
0589 
0590 
0591 function relAOI_Callback(hObject, eventdata, handles)
0592 % hObject    handle to relAOI (see GCBO)
0593 % eventdata  reserved - to be defined in a future version of MATLAB
0594 % handles    structure with handles and user data (see GUIDATA)
0595 
0596 % Hints: get(hObject,'String') returns contents of relAOI as text
0597 %        str2double(get(hObject,'String')) returns contents of relAOI as a double
0598 
0599 
0600 % --- Executes during object creation, after setting all properties.
0601 function relAOI_CreateFcn(hObject, eventdata, handles)
0602 % hObject    handle to relAOI (see GCBO)
0603 % eventdata  reserved - to be defined in a future version of MATLAB
0604 % handles    empty - handles not created until after all CreateFcns called
0605 
0606 % Hint: edit controls usually have a white background on Windows.
0607 %       See ISPC and COMPUTER.
0608 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0609     set(hObject,'BackgroundColor','white');
0610 end
0611 
0612 
0613 % --------------------------------------------------------------------
0614 function Untitled_1_Callback(hObject, eventdata, handles)
0615 % hObject    handle to Untitled_1 (see GCBO)
0616 % eventdata  reserved - to be defined in a future version of MATLAB
0617 % handles    structure with handles and user data (see GUIDATA)
0618 
0619 
0620 function handles = getVarParams(handles )
0621 
0622 % get screen size
0623 w = str2double( get(handles.width, 'string'));
0624 h = str2double( get(handles.height, 'string'));
0625 handles.dataStruct.varParams.imageSize = [h; w];
0626 
0627 % fixMinNumSamples = duration * sampRate
0628 handles.dataStruct.varParams.fixMinNumSamples = ceil(str2double( get(handles.fixDuration, 'string'))*str2double( get(handles.sampRate, 'string'))/1000);
0629 handles.dataStruct.varParams.fixMaxCircleRadius = str2double( get(handles.fixRad, 'string'));
0630 handles.dataStruct.varParams.velThreshold = str2double( get(handles.sacStartThresh, 'string'));
0631 handles.dataStruct.varParams.stopThreshold = str2double( get(handles.sacStopThresh, 'string'));
0632 handles.dataStruct.varParams.numFixationInSeq = str2double( get(handles.maxFix, 'string'));
0633 handles.dataStruct.varParams.numSaccadesInSeq = str2double( get(handles.maxSac, 'string'));
0634 
0635 % get AOI parameters
0636 aoiX = get( handles.aoiX, 'string');
0637 aoiX = cell2mat( textscan(aoiX, '%f','delimiter', ','))';
0638 aoiY = get( handles.aoiY, 'string');
0639 aoiY = cell2mat( textscan(aoiY, '%f','delimiter', ','))';
0640 aoiPos = [aoiX; aoiY];
0641 outSideDist = str2double( get( handles.aoiOut, 'string'));
0642 handles.dataStruct.aoiPos = aoiPos;
0643 handles.dataStruct.outSideDist = outSideDist;
0644 relAOI = get( handles.relAOI, 'string');
0645 handles.dataStruct.relAOI = cell2mat( textscan(relAOI, '%f','delimiter', ','));
0646 
0647 
0648 function maxFix_Callback(hObject, eventdata, handles)
0649 % hObject    handle to maxFix (see GCBO)
0650 % eventdata  reserved - to be defined in a future version of MATLAB
0651 % handles    structure with handles and user data (see GUIDATA)
0652 
0653 % Hints: get(hObject,'String') returns contents of maxFix as text
0654 %        str2double(get(hObject,'String')) returns contents of maxFix as a double
0655 
0656 
0657 % --- Executes during object creation, after setting all properties.
0658 function maxFix_CreateFcn(hObject, eventdata, handles)
0659 % hObject    handle to maxFix (see GCBO)
0660 % eventdata  reserved - to be defined in a future version of MATLAB
0661 % handles    empty - handles not created until after all CreateFcns called
0662 
0663 % Hint: edit controls usually have a white background on Windows.
0664 %       See ISPC and COMPUTER.
0665 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0666     set(hObject,'BackgroundColor','white');
0667 end
0668 
0669 
0670 
0671 function maxSac_Callback(hObject, eventdata, handles)
0672 % hObject    handle to maxSac (see GCBO)
0673 % eventdata  reserved - to be defined in a future version of MATLAB
0674 % handles    structure with handles and user data (see GUIDATA)
0675 
0676 % Hints: get(hObject,'String') returns contents of maxSac as text
0677 %        str2double(get(hObject,'String')) returns contents of maxSac as a double
0678 
0679 
0680 % --- Executes during object creation, after setting all properties.
0681 function maxSac_CreateFcn(hObject, eventdata, handles)
0682 % hObject    handle to maxSac (see GCBO)
0683 % eventdata  reserved - to be defined in a future version of MATLAB
0684 % handles    empty - handles not created until after all CreateFcns called
0685 
0686 % Hint: edit controls usually have a white background on Windows.
0687 %       See ISPC and COMPUTER.
0688 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0689     set(hObject,'BackgroundColor','white');
0690 end
0691 
0692 
0693 % --- Executes on button press in pushbutton9.
0694 function pushbutton9_Callback(hObject, eventdata, handles)
0695 % hObject    handle to pushbutton9 (see GCBO)
0696 % eventdata  reserved - to be defined in a future version of MATLAB
0697 % handles    structure with handles and user data (see GUIDATA)
0698 % load image
0699 [file,folder]=uigetfile;
0700 set( handles.imgFile, 'String', fullfile( folder, file));
0701 
0702 
0703 % --- Executes on button press in pushbutton10.
0704 function pushbutton10_Callback(hObject, eventdata, handles)
0705 % hObject    handle to pushbutton10 (see GCBO)
0706 % eventdata  reserved - to be defined in a future version of MATLAB
0707 % handles    structure with handles and user data (see GUIDATA)
0708 % visualize AOIs
0709 % load up stuff
0710 handles = getVarParams(handles ); % get default parameters
0711 guidata(hObject,handles)
0712 
0713 % get stimulus image
0714 showFigure =1;
0715 imgFile = get( handles.imgFile, 'String');  % if empty, will show on black
0716 if isempty( imgFile)
0717     stimSize = handles.dataStruct.varParams.imageSize;
0718     A = uint8(zeros( stimSize(1), stimSize(2), 3));
0719 else
0720     A = imread( imgFile );
0721 end
0722 
0723 %show it
0724 figure(2);
0725 AOIimage = viewAOILandscape( handles.dataStruct.aoiPos, handles.dataStruct.outSideDist, A, showFigure );
0726 
0727 
0728 
0729 function numKeep_Callback(hObject, eventdata, handles)
0730 % hObject    handle to numKeep (see GCBO)
0731 % eventdata  reserved - to be defined in a future version of MATLAB
0732 % handles    structure with handles and user data (see GUIDATA)
0733 
0734 % Hints: get(hObject,'String') returns contents of numKeep as text
0735 %        str2double(get(hObject,'String')) returns contents of numKeep as a double
0736 
0737 
0738 % --- Executes during object creation, after setting all properties.
0739 function numKeep_CreateFcn(hObject, eventdata, handles)
0740 % hObject    handle to numKeep (see GCBO)
0741 % eventdata  reserved - to be defined in a future version of MATLAB
0742 % handles    empty - handles not created until after all CreateFcns called
0743 
0744 % Hint: edit controls usually have a white background on Windows.
0745 %       See ISPC and COMPUTER.
0746 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0747     set(hObject,'BackgroundColor','white');
0748 end

Generated on Tue 01-Jul-2014 12:35:04 by m2html © 2005