Home > src > sos_gui.m

sos_gui

PURPOSE ^

- sos main GUI

SYNOPSIS ^

function varargout = sos_gui(varargin)

DESCRIPTION ^

 - sos main GUI 

 copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut

    This file is part of SOS

    SOS is free software: you can redistribute it and/or modify
    it for academic and non-commercial purposes
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.  For commercial or for-profit
    uses, please contact the authors (sos@cnbc.cmu.edu).

    SOS is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % - sos main GUI
0002 %
0003 % copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut
0004 %
0005 %    This file is part of SOS
0006 %
0007 %    SOS is free software: you can redistribute it and/or modify
0008 %    it for academic and non-commercial purposes
0009 %    under the terms of the GNU General Public License as published by
0010 %    the Free Software Foundation, either version 3 of the License, or
0011 %    (at your option) any later version.  For commercial or for-profit
0012 %    uses, please contact the authors (sos@cnbc.cmu.edu).
0013 %
0014 %    SOS is distributed in the hope that it will be useful,
0015 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 %    GNU General Public License for more details.
0018 
0019 %    You should have received a copy of the GNU General Public License
0020 %    along with SOS (see COPYING.txt).
0021 %    If not, see <http://www.gnu.org/licenses/>.
0022 
0023 
0024 function varargout = sos_gui(varargin)
0025 % SOS_GUI M-file for sos_gui.fig
0026 %      SOS_GUI, by itself, creates a new SOS_GUI or raises the existing
0027 %      singleton*.
0028 %
0029 %      H = SOS_GUI returns the handle to a new SOS_GUI or the handle to
0030 %      the existing singleton*.
0031 %
0032 %      SOS_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
0033 %      function named CALLBACK in SOS_GUI.M with the given input arguments.
0034 %
0035 %      SOS_GUI('Property','Value',...) creates a new SOS_GUI or raises the
0036 %      existing singleton*.  Starting from the left, property value pairs are
0037 %      applied to the GUI before sos_gui_OpeningFcn gets called.  An
0038 %      unrecognized property name or invalid value makes property application
0039 %      stop.  All inputs are passed to sos_gui_OpeningFcn via varargin.
0040 %
0041 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0042 %      instance to run (singleton)".
0043 %
0044 % See also: GUIDE, GUIDATA, GUIHANDLES
0045 
0046 % Edit the above text to modify the response to help sos_gui
0047 
0048 % Last Modified by GUIDE v2.5 16-Aug-2011 17:46:24
0049 
0050 %
0051 % BCA:
0052 % Note: the following warning has been disabled.
0053 % warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');
0054 % It occurs when the active population/sample lists are empty.
0055 %
0056 
0057 
0058 
0059 % Begin initialization code - DO NOT EDIT
0060 gui_Singleton = 1;
0061 gui_State = struct('gui_Name',       mfilename, ...
0062                    'gui_Singleton',  gui_Singleton, ...
0063                    'gui_OpeningFcn', @sos_gui_OpeningFcn, ...
0064                    'gui_OutputFcn',  @sos_gui_OutputFcn, ...
0065                    'gui_LayoutFcn',  [] , ...
0066                    'gui_Callback',   []);
0067 if nargin && ischar(varargin{1})
0068     gui_State.gui_Callback = str2func(varargin{1});
0069 end
0070 
0071 if nargout
0072     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0073 else
0074     gui_mainfcn(gui_State, varargin{:});
0075 end
0076 % End initialization code - DO NOT EDIT
0077 
0078 
0079 
0080 
0081 % --- Executes just before sos_gui is made visible.
0082 function sos_gui_OpeningFcn(hObject, eventdata, handles, varargin)
0083 % This function has no output args, see OutputFcn.
0084 % hObject    handle to figure
0085 % eventdata  reserved - to be defined in a future version of MATLAB
0086 % handles    structure with handles and user data (see GUIDATA)
0087 % varargin   command line arguments to sos_gui (see VARARGIN)
0088 
0089 % Choose default command line output for sos_gui
0090 handles.output = hObject;
0091 
0092 % Update handles structure
0093 guidata(hObject, handles);
0094 
0095 % UIWAIT makes sos_gui wait for user response (see UIRESUME)
0096 % uiwait(handles.figure1);
0097 
0098 disp([char(10),char(10),'SOS: Stochastic Optimization of Stimuli',char(10),... 
0099 '    Copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut',char(10),... 
0100 char(10),... 
0101 '    This binary executable is part of SOS',char(10),... 
0102 char(10),...
0103 '    SOS is free software: you can redistribute it and/or modify',char(10),... 
0104 '    it for academic and non-commercial purposes',char(10),... 
0105 '    under the terms of the GNU General Public License as published by',char(10),... 
0106 '    the Free Software Foundation, either version 3 of the License, or',char(10),... 
0107 '    (at your option) any later version.  For commercial or for-profit',char(10),... 
0108 '    uses, please contact the authors (sos@cnbc.cmu.edu).',char(10),... 
0109 char(10),...
0110 '    SOS is distributed in the hope that it will be useful,',char(10),... 
0111 '    but WITHOUT ANY WARRANTY; without even the implied warranty of',char(10),... 
0112 '    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the',char(10),... 
0113 '    GNU General Public License for more details.',char(10),... 
0114 char(10),...
0115 '    You should have received a copy of the GNU General Public License',char(10),... 
0116 '    along with SOS (see COPYING.txt).',char(10),... 
0117 '    If not, see <http://www.gnu.org/licenses/>.',char(10),char(10),char(10)]);
0118 
0119 
0120 % --- Outputs from this function are returned to the command line.
0121 function varargout = sos_gui_OutputFcn(hObject, eventdata, handles) 
0122 % varargout  cell array for returning output args (see VARARGOUT);
0123 % hObject    handle to figure
0124 % eventdata  reserved - to be defined in a future version of MATLAB
0125 % handles    structure with handles and user data (see GUIDATA)
0126 
0127 % Get default command line output from handles structure
0128 varargout{1} = handles.output;
0129 
0130 
0131 
0132 function edit_CmdWindow_Callback(hObject, eventdata, handles)
0133 % hObject    handle to edit_CmdWindow (see GCBO)
0134 % eventdata  reserved - to be defined in a future version of MATLAB
0135 % handles    structure with handles and user data (see GUIDATA)
0136 
0137 % Hints: get(hObject,'String') returns contents of edit_CmdWindow as text
0138 %        str2double(get(hObject,'String')) returns contents of edit_CmdWindow as a double
0139 
0140 
0141     % technically, the command line will try to run whenever you loose
0142     % focus.  However, there doesn't seem to be an easy workaround (e.g.,
0143     % conditioning on carriage returns didn't seem to stop the call back).
0144 
0145     command = get(hObject,'String');
0146     
0147     verbosePrint(['Evaluating GUI command: ', command], ...
0148             'sos_gui_cmdWindow_CallBack_runcmd');       
0149 
0150     evalin('base',command);
0151 
0152     set(hObject,'String','');
0153 
0154     % END edit_CmdWindow CALLBACK
0155 
0156         
0157 
0158 % --- Executes during object creation, after setting all properties.
0159 function edit_CmdWindow_CreateFcn(hObject, eventdata, handles)
0160 % hObject    handle to edit_CmdWindow (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     set(hObject, 'KeyPressFcn', @edit_CmdWindow_KeyPressFcn);
0171 
0172 
0173 % --- Executes on button press in pushbutton_runScript.
0174 function pushbutton_runScript_Callback(hObject, eventdata, handles)
0175     % hObject    handle to pushbutton_runScript (see GCBO)
0176     % eventdata  reserved - to be defined in a future version of MATLAB
0177     % handles    structure with handles and user data (see GUIDATA)
0178 
0179     % let user navigate to the script to run
0180     [fileName,pathName] = uigetfile('*','Run Script...');
0181     
0182     if fileName ~= 0
0183         
0184 
0185         fullName = strcat(pathName,fileName);
0186 
0187 
0188         % try to run the script...
0189         verbosePrint(['Running script: ', fullName], ...
0190                     'sos_gui_runScript_CallBack_runScript');
0191 
0192         cd(pathName);
0193         %first, read in the script:
0194         try
0195             fid = fopen(fullName,'r');
0196         catch exception
0197             error(['Could not open file: ', fullName]);
0198         end
0199 
0200         try
0201             script = fscanf(fid,'%c');
0202         catch
0203              error(['Error while reading file: ', fullName]);
0204         end
0205 
0206         %run the script
0207         evalin('base',script);
0208     end
0209     % END runScript CALLBACK
0210     
0211 
0212 
0213 % --- Executes on button press in pushbutton_CreatePopulation.
0214 function pushbutton_CreatePopulation_Callback(hObject, eventdata, handles)
0215 % hObject    handle to pushbutton_CreatePopulation (see GCBO)
0216 % eventdata  reserved - to be defined in a future version of MATLAB
0217 % handles    structure with handles and user data (see GUIDATA)
0218 
0219     createPop_Dialog();
0220 
0221 % --- Executes on key press with focus on edit_CmdWindow and none of its controls.
0222 function edit_CmdWindow_KeyPressFcn(hObject, eventdata, handles)
0223 % hObject    handle to edit_CmdWindow (see GCBO)
0224 % eventdata  structure with the following fields (see UICONTROL)
0225 %    Key: name of the key that was pressed, in lower case
0226 %    Character: character interpretation of the key(s) that was pressed
0227 %    Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
0228 % handles    structure with handles and user data (see GUIDATA)
0229  
0230 
0231 
0232 % --- Executes on selection change in popupmenu_popSelector.
0233 function popupmenu_popSelector_Callback(hObject, eventdata, handles)
0234 % hObject    handle to popupmenu_popSelector (see GCBO)
0235 % eventdata  reserved - to be defined in a future version of MATLAB
0236 % handles    structure with handles and user data (see GUIDATA)
0237 
0238 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_popSelector contents as cell array
0239 %        contents{get(hObject,'Value')} returns selected item from popupmenu_popSelector
0240 
0241     populatePopList(hObject);
0242 
0243 
0244 % --- Executes during object creation, after setting all properties.
0245 function popupmenu_popSelector_CreateFcn(hObject, eventdata, handles)
0246 % hObject    handle to popupmenu_popSelector (see GCBO)
0247 % eventdata  reserved - to be defined in a future version of MATLAB
0248 % handles    empty - handles not created until after all CreateFcns called
0249 
0250 % Hint: popupmenu controls usually have a white background on Windows.
0251 %       See ISPC and COMPUTER.
0252 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0253     set(hObject,'BackgroundColor','white');
0254 end
0255 
0256     %populatePopList(hObject);
0257 
0258 
0259     
0260 % populates the population list
0261 function populatePopList(hObject)    
0262     % get a list of all populations in the base workspace:
0263     vars = evalin('base','whos()');
0264     
0265     pops = [];
0266     for i=1:length(vars)
0267         if strcmp(vars(i).class,'population')
0268             pops = [pops; {vars(i).name}]; %#ok<AGROW>
0269         end
0270     end
0271     
0272     %in case no populations are present, set to the empty string:
0273     if isempty(pops)
0274         pops = '';
0275     end
0276     
0277     
0278     % assign that list to the options in the pop up menu.  Disable warnings
0279     % if the list is empty and then re-enable them.
0280     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');
0281     set(hObject,'String',pops);            
0282 
0283     
0284 % populates the sample list
0285 function populateSampleList(hObject)    
0286     % get a list of all populations in the base workspace:
0287     vars = evalin('base','whos()');
0288     
0289     samples = [];
0290     for i=1:length(vars)
0291         if strcmp(vars(i).class,'sample')
0292             samples = [samples; {vars(i).name}]; %#ok<AGROW>
0293         end
0294     end
0295     
0296     
0297     
0298     % assign that list to the options in the pop up menu
0299     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');    
0300     set(hObject,'String',samples); 
0301     
0302     
0303 
0304 % --- Executes on button press in pushbutton_popWriteData.
0305 function pushbutton_popWriteData_Callback(hObject, eventdata, handles)
0306 % hObject    handle to pushbutton_popWriteData (see GCBO)
0307 % eventdata  reserved - to be defined in a future version of MATLAB
0308 % handles    structure with handles and user data (see GUIDATA)
0309     
0310     menuHandle = handles.popupmenu_popSelector;
0311     writedf(menuHandle,'population');
0312 
0313     
0314  
0315 function writedf(handle,dfType)
0316     % get the active population's name
0317     dfNum = get(handle,'Value');
0318     dfNames = get(handle,'String');
0319     
0320     if isempty(dfNames) == 0
0321         dfName = dfNames{dfNum};
0322     else
0323         dfName = '';
0324     end
0325     
0326     %make sure there is an active population
0327     if isempty(dfName) == 0
0328         command = strcat(dfName,'.writeData()');
0329         verbosePrint(['Executing command: ','''',command,''''],'sosGui_writeDF');
0330         evalin('base',command);
0331     else
0332         msgbox(['A ',dfType,' must be active to write data'],...
0333                 ['No active ',dfType]);
0334     end
0335 
0336 
0337     
0338 
0339 
0340 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
0341 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_popSelector.
0342 function popupmenu_popSelector_ButtonDownFcn(hObject, eventdata, handles)
0343 % hObject    handle to popupmenu_popSelector (see GCBO)
0344 % eventdata  reserved - to be defined in a future version of MATLAB
0345 % handles    structure with handles and user data (see GUIDATA)
0346     populatePopList(hObject);
0347 
0348 
0349 % --- Executes on key press with focus on popupmenu_popSelector and none of its controls.
0350 function popupmenu_popSelector_KeyPressFcn(hObject, eventdata, handles)
0351 % hObject    handle to popupmenu_popSelector (see GCBO)
0352 % eventdata  structure with the following fields (see UICONTROL)
0353 %    Key: name of the key that was pressed, in lower case
0354 %    Character: character interpretation of the key(s) that was pressed
0355 %    Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
0356 % handles    structure with handles and user data (see GUIDATA)
0357 
0358 
0359 % --- Executes on button press in pushbutton_refreshPopList.
0360 function pushbutton_refreshPopList_Callback(hObject, eventdata, handles)
0361 % hObject    handle to pushbutton_refreshPopList (see GCBO)
0362 % eventdata  reserved - to be defined in a future version of MATLAB
0363 % handles    structure with handles and user data (see GUIDATA)
0364 
0365     % refresh the list of populations
0366     populatePopList(handles.popupmenu_popSelector);
0367 
0368 
0369 % --- Executes on button press in pushbutton_createSample.
0370 function pushbutton_createSample_Callback(hObject, eventdata, handles)
0371 % hObject    handle to pushbutton_createSample (see GCBO)
0372 % eventdata  reserved - to be defined in a future version of MATLAB
0373 % handles    structure with handles and user data (see GUIDATA)
0374     createSample_Dialog();
0375 
0376 % --- Executes on selection change in popupmenu_sampleSelector.
0377 function popupmenu_sampleSelector_Callback(hObject, eventdata, handles)
0378 % hObject    handle to popupmenu_sampleSelector (see GCBO)
0379 % eventdata  reserved - to be defined in a future version of MATLAB
0380 % handles    structure with handles and user data (see GUIDATA)
0381 
0382 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sampleSelector contents as cell array
0383 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sampleSelector
0384     populateSampleList(hObject);
0385 
0386 % --- Executes during object creation, after setting all properties.
0387 function popupmenu_sampleSelector_CreateFcn(hObject, eventdata, handles)
0388 % hObject    handle to popupmenu_sampleSelector (see GCBO)
0389 % eventdata  reserved - to be defined in a future version of MATLAB
0390 % handles    empty - handles not created until after all CreateFcns called
0391 
0392 % Hint: popupmenu controls usually have a white background on Windows.
0393 %       See ISPC and COMPUTER.
0394 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0395     set(hObject,'BackgroundColor','white');
0396 end
0397 
0398 
0399 % --- Executes on button press in pushbutton_writeSampleData.
0400 function pushbutton_writeSampleData_Callback(hObject, eventdata, handles)
0401 % hObject    handle to pushbutton_writeSampleData (see GCBO)
0402 % eventdata  reserved - to be defined in a future version of MATLAB
0403 % handles    structure with handles and user data (see GUIDATA)
0404     menuHandle = handles.popupmenu_sampleSelector;
0405     writedf(menuHandle,'sample');
0406 
0407 % --- Executes on button press in pushbutton_refreshSampleList.
0408 function pushbutton_refreshSampleList_Callback(hObject, eventdata, handles)
0409 % hObject    handle to pushbutton_refreshSampleList (see GCBO)
0410 % eventdata  reserved - to be defined in a future version of MATLAB
0411 % handles    structure with handles and user data (see GUIDATA)
0412     populateSampleList(handles.popupmenu_sampleSelector);
0413 
0414 % --- Executes during object creation, after setting all properties.
0415 function pushbutton_createSample_CreateFcn(hObject, eventdata, handles)
0416 % hObject    handle to pushbutton_createSample (see GCBO)
0417 % eventdata  reserved - to be defined in a future version of MATLAB
0418 % handles    empty - handles not created until after all CreateFcns called
0419 
0420 
0421 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
0422 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sampleSelector.
0423 function popupmenu_sampleSelector_ButtonDownFcn(hObject, eventdata, handles)
0424 % hObject    handle to popupmenu_sampleSelector (see GCBO)
0425 % eventdata  reserved - to be defined in a future version of MATLAB
0426 % handles    structure with handles and user data (see GUIDATA)
0427     populateSampleList(hObject);
0428 
0429 
0430 % --- Executes on button press in pushbutton_setPop.
0431 function pushbutton_setPop_Callback(hObject, eventdata, handles)
0432 % hObject    handle to pushbutton_setPop (see GCBO)
0433 % eventdata  reserved - to be defined in a future version of MATLAB
0434 % handles    structure with handles and user data (see GUIDATA)
0435 
0436     %two things to do: first, make sure that there is an active population.
0437     % Second, make sure that there is an active sample.
0438     
0439     link = true;
0440    
0441     popMenuHandle = handles.popupmenu_popSelector;
0442     popName = getdfName(popMenuHandle,'population');
0443     
0444     if isempty(popName)
0445         link = false;
0446     end
0447     
0448     if link == true    
0449         sampleMenuHandle = handles.popupmenu_sampleSelector;
0450         sampleName = getdfName(sampleMenuHandle,'sample');
0451         
0452         if isempty(sampleName)
0453             link = false;
0454         end
0455         
0456         if link == true
0457             % we have valid samples and populations.  Link them.
0458             
0459             command = [sampleName,'.setPop(',popName,');'];
0460             
0461             verbosePrint(['Executing command: ','''',command,''''],'sosGui_links2p');
0462             evalin('base',command);
0463         end
0464     end
0465  
0466     
0467 % retrieves the name of a dataframe from the active lists of data frames
0468 % function dfName = getdfName(handle,dfType)
0469 %     dfNum = get(handle,'Value');
0470 %     dfNames = get(handle,'String');
0471 %
0472 %     if isempty(dfNames) == 0
0473 %         dfName = dfNames{dfNum};
0474 %     else
0475 %         dfName = '';
0476 %     end
0477 %
0478 %     %make sure there is an active df
0479 %     if isempty(dfName) == 0
0480 %         % success
0481 %     else
0482 %         msgbox(['A ',dfType,' must be active'],...
0483 %                 ['No active ',dfType]);
0484 %     end
0485 %
0486 
0487 
0488 % --- Executes on button press in pushbutton_sampleLock.
0489 function pushbutton_sampleLock_Callback(hObject, eventdata, handles)
0490 % hObject    handle to pushbutton_sampleLock (see GCBO)
0491 % eventdata  reserved - to be defined in a future version of MATLAB
0492 % handles    structure with handles and user data (see GUIDATA)
0493     menuHandle = handles.popupmenu_sampleSelector;
0494     execSimpleCmd(menuHandle,'sample','lockAll()');
0495 
0496 
0497 % provides functiona
0498 function execSimpleCmd(handle,dfType,cmd)
0499     % get the active population's name
0500     dfNum = get(handle,'Value');
0501     dfNames = get(handle,'String');
0502     
0503     if isempty(dfNames) == 0
0504         dfName = dfNames{dfNum};
0505     else
0506         dfName = '';
0507     end
0508     
0509     %make sure there is an active population
0510     if isempty(dfName) == 0
0511         command = strcat(dfName,'.',cmd);
0512         
0513         verbosePrint(['Executing command: ','''',command,''''],'sosGui_simpleCmd');
0514         evalin('base',command);
0515     else
0516         msgbox(['A ',dfType,' must be active to run: ',cmd],...
0517                 ['No active ',dfType]);
0518     end
0519     
0520     
0521 
0522 
0523 % --- Executes on button press in pushbutton_sampleUnlock.
0524 function pushbutton_sampleUnlock_Callback(hObject, eventdata, handles)
0525 % hObject    handle to pushbutton_sampleUnlock (see GCBO)
0526 % eventdata  reserved - to be defined in a future version of MATLAB
0527 % handles    structure with handles and user data (see GUIDATA)
0528     menuHandle = handles.popupmenu_sampleSelector;
0529     execSimpleCmd(menuHandle,'sample','unlockAll()');
0530 
0531 
0532 % --- Executes on button press in pushbutton_createSOS.
0533 function pushbutton_createSOS_Callback(hObject, eventdata, handles)
0534 % hObject    handle to pushbutton_createSOS (see GCBO)
0535 % eventdata  reserved - to be defined in a future version of MATLAB
0536 % handles    structure with handles and user data (see GUIDATA)
0537     createSOS_dialog();
0538 
0539 
0540 % --- Executes on button press in pushbutton_refresh_SOSlist.
0541 function pushbutton_refresh_SOSlist_Callback(hObject, eventdata, handles)
0542 % hObject    handle to pushbutton_refresh_SOSlist (see GCBO)
0543 % eventdata  reserved - to be defined in a future version of MATLAB
0544 % handles    structure with handles and user data (see GUIDATA)
0545     populateSOSList(handles.popupmenu_SOSSelector);
0546 
0547     
0548 % --- Executes on selection change in popupmenu_SOSSelector.
0549 function popupmenu_SOSSelector_Callback(hObject, eventdata, handles)
0550 % hObject    handle to popupmenu_SOSSelector (see GCBO)
0551 % eventdata  reserved - to be defined in a future version of MATLAB
0552 % handles    structure with handles and user data (see GUIDATA)
0553 
0554 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_SOSSelector contents as cell array
0555 %        contents{get(hObject,'Value')} returns selected item from popupmenu_SOSSelector
0556     populateSOSList(hObject);
0557     
0558 % --- Executes during object creation, after setting all properties.
0559 function popupmenu_SOSSelector_CreateFcn(hObject, eventdata, handles)
0560 % hObject    handle to popupmenu_SOSSelector (see GCBO)
0561 % eventdata  reserved - to be defined in a future version of MATLAB
0562 % handles    empty - handles not created until after all CreateFcns called
0563 
0564 % Hint: popupmenu controls usually have a white background on Windows.
0565 %       See ISPC and COMPUTER.
0566 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0567     set(hObject,'BackgroundColor','white');
0568 end
0569 
0570 
0571 function populateSOSList(hObject)    
0572     % get a list of all populations in the base workspace:
0573     vars = evalin('base','whos()');
0574     
0575     sosObjs = [];
0576     for i=1:length(vars)
0577         if strcmp(vars(i).class,'sos')
0578             sosObjs = [sosObjs; {vars(i).name}]; %#ok<AGROW>
0579         end
0580     end
0581     
0582     
0583     
0584     % assign that list to the options in the pop up menu
0585     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');    
0586     set(hObject,'String',sosObjs); 
0587 
0588 
0589 % --- Executes on key press with focus on popupmenu_sampleSelector and none of its controls.
0590 function popupmenu_sampleSelector_KeyPressFcn(hObject, eventdata, handles)
0591 % hObject    handle to popupmenu_sampleSelector (see GCBO)
0592 % eventdata  structure with the following fields (see UICONTROL)
0593 %    Key: name of the key that was pressed, in lower case
0594 %    Character: character interpretation of the key(s) that was pressed
0595 %    Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
0596 % handles    structure with handles and user data (see GUIDATA)
0597 
0598 
0599 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
0600 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_SOSSelector.
0601 function popupmenu_SOSSelector_ButtonDownFcn(hObject, eventdata, handles)
0602 % hObject    handle to popupmenu_SOSSelector (see GCBO)
0603 % eventdata  reserved - to be defined in a future version of MATLAB
0604 % handles    structure with handles and user data (see GUIDATA)
0605     populateSOSList(hObject);
0606 
0607 
0608 % --- Executes on button press in pushbutton_addSample.
0609 function pushbutton_addSample_Callback(hObject, eventdata, handles)
0610 % hObject    handle to pushbutton_addSample (see GCBO)
0611 % eventdata  reserved - to be defined in a future version of MATLAB
0612 % handles    structure with handles and user data (see GUIDATA)
0613 
0614     add = true;
0615     
0616     %retrieve name of active sample
0617     sampleMenuHandle = handles.popupmenu_sampleSelector;
0618     sampleName = getdfName(sampleMenuHandle,'sample');
0619     
0620     if isempty(sampleName)
0621         add = false;
0622     end
0623     
0624     % if there is a valid active sample, add it.
0625     
0626     if add == true
0627         sosMenuHandle = handles.popupmenu_SOSSelector;
0628         sosName = getdfName(sosMenuHandle,'SOS');
0629         
0630         if isempty(sosName)
0631             add = false;
0632         end
0633         
0634         if add == true
0635             % we have a valid sample and a valid SOS object.  Add the
0636             % sample to the sos object
0637             
0638             command = [sosName,'.addSample(',sampleName,');'];
0639             
0640             verbosePrint(['Executing command: ','''',command,''''],'sosGui_addSample');
0641             evalin('base',command);
0642         end
0643     end
0644     
0645 
0646 
0647 % --- Executes on button press in pushbutton_createHistory.
0648 function pushbutton_createHistory_Callback(hObject, eventdata, handles)
0649 % hObject    handle to pushbutton_createHistory (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         create = true;
0654     
0655         sosMenuHandle = handles.popupmenu_SOSSelector;
0656         sosName = getdfName(sosMenuHandle,'SOS');
0657         
0658         if isempty(sosName)
0659             create = false;
0660         end
0661         
0662         if create == true   
0663             % create the history
0664             command = [sosName,'.createHistory();'];
0665             
0666             verbosePrint(['Executing command: ','''',command,''''],'sosGui_createHistory');
0667             evalin('base',command);         
0668         end
0669         
0670             
0671             
0672 
0673 
0674 % --- Executes on button press in pushbutton_createPlots.
0675 function pushbutton_createPlots_Callback(hObject, eventdata, handles)
0676 % hObject    handle to pushbutton_createPlots (see GCBO)
0677 % eventdata  reserved - to be defined in a future version of MATLAB
0678 % handles    structure with handles and user data (see GUIDATA)
0679 
0680     create = true;
0681     
0682         sosMenuHandle = handles.popupmenu_SOSSelector;
0683         sosName = getdfName(sosMenuHandle,'SOS');
0684         
0685         if isempty(sosName)
0686             create = false;
0687         end
0688         
0689         if create == true   
0690             % run the createPlots dialog to give users choice of optional
0691             % params
0692             createPlots_Dialog();
0693         end
0694         
0695 
0696 
0697 
0698 function edit_dispIt_Callback(hObject, eventdata, handles)
0699 % hObject    handle to edit_dispIt (see GCBO)
0700 % eventdata  reserved - to be defined in a future version of MATLAB
0701 % handles    structure with handles and user data (see GUIDATA)
0702 
0703 % Hints: get(hObject,'String') returns contents of edit_dispIt as text
0704 %        str2double(get(hObject,'String')) returns contents of edit_dispIt as a double
0705 
0706 
0707 % --- Executes during object creation, after setting all properties.
0708 function edit_dispIt_CreateFcn(hObject, eventdata, handles)
0709 % hObject    handle to edit_dispIt (see GCBO)
0710 % eventdata  reserved - to be defined in a future version of MATLAB
0711 % handles    empty - handles not created until after all CreateFcns called
0712 
0713 % Hint: edit controls usually have a white background on Windows.
0714 %       See ISPC and COMPUTER.
0715 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0716     set(hObject,'BackgroundColor','white');
0717 end
0718 
0719 
0720 % --- Executes on button press in pushbutton_deltaCostPercentiles.
0721 function pushbutton_deltaCostPercentiles_Callback(hObject, eventdata, handles)
0722 % hObject    handle to pushbutton_deltaCostPercentiles (see GCBO)
0723 % eventdata  reserved - to be defined in a future version of MATLAB
0724 % handles    structure with handles and user data (see GUIDATA)
0725         run = true;
0726     
0727         sosMenuHandle = handles.popupmenu_SOSSelector;
0728         sosName = getdfName(sosMenuHandle,'SOS');
0729         
0730         if isempty(sosName)
0731             run = false;
0732         end
0733         
0734         if run == true   
0735             % create the history
0736             command = [sosName,'.deltaCostPercentiles();'];
0737             
0738             verbosePrint(['Executing command: ','''',command,''''],'sosGui_deltaCostDeciles');
0739             evalin('base',command);         
0740         end
0741 
0742 
0743 % --- Executes on button press in pushbutton_writeHistory.
0744 function pushbutton_writeHistory_Callback(hObject, eventdata, handles)
0745 % hObject    handle to pushbutton_writeHistory (see GCBO)
0746 % eventdata  reserved - to be defined in a future version of MATLAB
0747 % handles    structure with handles and user data (see GUIDATA)
0748     saveHistory_Dialog();
0749 
0750 
0751 % --- Executes on button press in pushbutton_writeSamples.
0752 function pushbutton_writeSamples_Callback(hObject, eventdata, handles)
0753 % hObject    handle to pushbutton_writeSamples (see GCBO)
0754 % eventdata  reserved - to be defined in a future version of MATLAB
0755 % handles    structure with handles and user data (see GUIDATA)
0756         write = true;
0757     
0758         sosMenuHandle = handles.popupmenu_SOSSelector;
0759         sosName = getdfName(sosMenuHandle,'SOS');
0760         
0761         if isempty(sosName)
0762             write = false;
0763         end
0764         
0765         if write == true   
0766             % create the history
0767             command = [sosName,'.writeSamples();'];
0768             
0769             verbosePrint(['Executing command: ','''',command,''''],'sosGui_writeSamples');
0770             evalin('base',command);         
0771         end
0772         
0773 
0774 
0775 % --- Executes on button press in pushbutton_writePopulations.
0776 function pushbutton_writePopulations_Callback(hObject, eventdata, handles)
0777 % hObject    handle to pushbutton_writePopulations (see GCBO)
0778 % eventdata  reserved - to be defined in a future version of MATLAB
0779 % handles    structure with handles and user data (see GUIDATA)
0780         write = true;
0781     
0782         sosMenuHandle = handles.popupmenu_SOSSelector;
0783         sosName = getdfName(sosMenuHandle,'SOS');
0784         
0785         if isempty(sosName)
0786             write = false;
0787         end
0788         
0789         if write == true   
0790             % create the history
0791             command = [sosName,'.writePopulations();'];
0792             
0793             verbosePrint(['Executing command: ','''',command,''''],'sosGui_writePopulations');
0794             evalin('base',command);         
0795         end
0796 
0797 
0798 % --- Executes on button press in pushbutton_dispCost.
0799 function pushbutton_dispCost_Callback(hObject, eventdata, handles)
0800 % hObject    handle to pushbutton_dispCost (see GCBO)
0801 % eventdata  reserved - to be defined in a future version of MATLAB
0802 % handles    structure with handles and user data (see GUIDATA)
0803         write = true;
0804     
0805         sosMenuHandle = handles.popupmenu_SOSSelector;
0806         sosName = getdfName(sosMenuHandle,'SOS');
0807         
0808         if isempty(sosName)
0809             write = false;
0810         end
0811         
0812         if write == true   
0813             % create the history
0814             command = [sosName,'.dispCost();'];
0815             
0816             verbosePrint(['Executing command: ','''',command,''''],'sosGui_dispCost');
0817             evalin('base',command);         
0818         end
0819 
0820 
0821 % --- Executes on button press in pushbutton_initCost.
0822 function pushbutton_initCost_Callback(hObject, eventdata, handles)
0823 % hObject    handle to pushbutton_initCost (see GCBO)
0824 % eventdata  reserved - to be defined in a future version of MATLAB
0825 % handles    structure with handles and user data (see GUIDATA)
0826         write = true;
0827     
0828         sosMenuHandle = handles.popupmenu_SOSSelector;
0829         sosName = getdfName(sosMenuHandle,'SOS');
0830         
0831         if isempty(sosName)
0832             write = false;
0833         end
0834         
0835         if write == true   
0836             % create the history
0837             command = [sosName,'.initCost();'];
0838             
0839             verbosePrint(['Executing command: ','''',command,''''],'sosGui_initCost');
0840             evalin('base',command);         
0841         end
0842 
0843 
0844 % --- Executes on button press in pushbutton_writeAll.
0845 function pushbutton_writeAll_Callback(hObject, eventdata, handles)
0846 % hObject    handle to pushbutton_writeAll (see GCBO)
0847 % eventdata  reserved - to be defined in a future version of MATLAB
0848 % handles    structure with handles and user data (see GUIDATA)
0849         write = true;
0850     
0851         sosMenuHandle = handles.popupmenu_SOSSelector;
0852         sosName = getdfName(sosMenuHandle,'SOS');
0853         
0854         if isempty(sosName)
0855             write = false;
0856         end
0857         
0858         if write == true   
0859             % create the history
0860             command = [sosName,'.writeAll();'];
0861             
0862             verbosePrint(['Executing command: ','''',command,''''],'sosGui_writeAll');
0863             evalin('base',command);         
0864         end
0865 
0866 
0867 % --- Executes on button press in pushbutton_initFillSamples.
0868 function pushbutton_initFillSamples_Callback(hObject, eventdata, handles)
0869 % hObject    handle to pushbutton_initFillSamples (see GCBO)
0870 % eventdata  reserved - to be defined in a future version of MATLAB
0871 % handles    structure with handles and user data (see GUIDATA)
0872         write = true;
0873     
0874         sosMenuHandle = handles.popupmenu_SOSSelector;
0875         sosName = getdfName(sosMenuHandle,'SOS');
0876         
0877         if isempty(sosName)
0878             write = false;
0879         end
0880         
0881         if write == true   
0882             % create the history
0883             command = [sosName,'.initFillSamples();'];
0884             
0885             verbosePrint(['Executing command: ','''',command,''''],'sosGui_initFillSamples');
0886             evalin('base',command);         
0887         end
0888 
0889 
0890 % --- Executes on button press in pushbutton_normalizeData.
0891 function pushbutton_normalizeData_Callback(hObject, eventdata, handles)
0892 % hObject    handle to pushbutton_normalizeData (see GCBO)
0893 % eventdata  reserved - to be defined in a future version of MATLAB
0894 % handles    structure with handles and user data (see GUIDATA)
0895         write = true;
0896     
0897         sosMenuHandle = handles.popupmenu_SOSSelector;
0898         sosName = getdfName(sosMenuHandle,'SOS');
0899         
0900         if isempty(sosName)
0901             write = false;
0902         end
0903         
0904         if write == true   
0905             % create the history
0906             command = [sosName,'.normalizeData();'];
0907             
0908             verbosePrint(['Executing command: ','''',command,''''],'sosGui_initFillSamples');
0909             evalin('base',command);         
0910         end
0911 
0912 
0913 % --- Executes on button press in pushbutton_setSeed.
0914 function pushbutton_setSeed_Callback(hObject, eventdata, handles)
0915 % hObject    handle to pushbutton_setSeed (see GCBO)
0916 % eventdata  reserved - to be defined in a future version of MATLAB
0917 % handles    structure with handles and user data (see GUIDATA)
0918     setSeed_Dialog();
0919 
0920 
0921 % --- Executes on button press in pushbutton_setBufferedHistoryOutfile.
0922 function pushbutton_setBufferedHistoryOutfile_Callback(hObject, eventdata, handles)
0923 % hObject    handle to pushbutton_setBufferedHistoryOutfile (see GCBO)
0924 % eventdata  reserved - to be defined in a future version of MATLAB
0925 % handles    structure with handles and user data (see GUIDATA)
0926     setBufferedHistoryOutfile_Dialog();
0927 
0928 
0929 % --- Executes on button press in pushbutton28.
0930 function pushbutton28_Callback(hObject, eventdata, handles)
0931 % hObject    handle to pushbutton28 (see GCBO)
0932 % eventdata  reserved - to be defined in a future version of MATLAB
0933 % handles    structure with handles and user data (see GUIDATA)
0934 
0935 
0936 % --- Executes on button press in pushbutton_enableBufferedHistoryWrite.
0937 function pushbutton_enableBufferedHistoryWrite_Callback(hObject, eventdata, handles)
0938 % hObject    handle to pushbutton_enableBufferedHistoryWrite (see GCBO)
0939 % eventdata  reserved - to be defined in a future version of MATLAB
0940 % handles    structure with handles and user data (see GUIDATA)
0941 
0942         create = true;
0943     
0944         sosMenuHandle = handles.popupmenu_SOSSelector;
0945         sosName = getdfName(sosMenuHandle,'SOS');
0946         
0947         if isempty(sosName)
0948             create = false;
0949         end
0950         
0951         if create == true   
0952             % create the history
0953             command = [sosName,'.enableBufferedHistoryWrite();'];
0954             
0955             
0956             verbosePrint(['Executing command: ','''',command,''''],'sosGui_enableBufferedHistory');
0957             evalin('base',command);         
0958         end
0959 
0960 
0961 % --- Executes on button press in pushbutton_disableBufferedHistoryWrite.
0962 function pushbutton_disableBufferedHistoryWrite_Callback(hObject, eventdata, handles)
0963 % hObject    handle to pushbutton_disableBufferedHistoryWrite (see GCBO)
0964 % eventdata  reserved - to be defined in a future version of MATLAB
0965 % handles    structure with handles and user data (see GUIDATA)
0966         create = true;
0967     
0968         sosMenuHandle = handles.popupmenu_SOSSelector;
0969         sosName = getdfName(sosMenuHandle,'SOS');
0970         
0971         if isempty(sosName)
0972             create = false;
0973         end
0974         
0975         if create == true   
0976             % create the history
0977             command = [sosName,'.disableBufferedHistoryWrite();'];
0978             
0979             verbosePrint(['Executing command: ','''',command,''''],'sosGui_disableBufferedHistory');
0980             evalin('base',command);         
0981         end
0982 
0983 
0984 % --- Executes on selection change in popupmenu_reportStyleSelector.
0985 function popupmenu_reportStyleSelector_Callback(hObject, eventdata, handles)
0986 % hObject    handle to popupmenu_reportStyleSelector (see GCBO)
0987 % eventdata  reserved - to be defined in a future version of MATLAB
0988 % handles    structure with handles and user data (see GUIDATA)
0989 
0990 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_reportStyleSelector contents as cell array
0991 %        contents{get(hObject,'Value')} returns selected item from popupmenu_reportStyleSelector
0992 
0993 
0994 % --- Executes during object creation, after setting all properties.
0995 function popupmenu_reportStyleSelector_CreateFcn(hObject, eventdata, handles)
0996 % hObject    handle to popupmenu_reportStyleSelector (see GCBO)
0997 % eventdata  reserved - to be defined in a future version of MATLAB
0998 % handles    empty - handles not created until after all CreateFcns called
0999 
1000 % Hint: popupmenu controls usually have a white background on Windows.
1001 %       See ISPC and COMPUTER.
1002 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1003     set(hObject,'BackgroundColor','white');
1004 end
1005 
1006 
1007 % --- Executes on button press in pushbutton_doStatsTests.
1008 function pushbutton_doStatsTests_Callback(hObject, eventdata, handles)
1009 % hObject    handle to pushbutton_doStatsTests (see GCBO)
1010 % eventdata  reserved - to be defined in a future version of MATLAB
1011 % handles    structure with handles and user data (see GUIDATA)
1012 
1013         run = true;
1014     
1015         sosMenuHandle = handles.popupmenu_SOSSelector;
1016         sosName = getdfName(sosMenuHandle,'SOS');
1017         
1018         if isempty(sosName)
1019             run = false;
1020         end
1021         
1022         if run == true   
1023             
1024             % retrieve the reportStyle
1025             
1026             styleMenuHandle = handles.popupmenu_reportStyleSelector;
1027             style = getdfName(styleMenuHandle,'reportStyle');
1028             
1029             % create the history
1030             command = [sosName,'.doStatTests(''reportStyle'',''',style,''');'];
1031             
1032             verbosePrint(['Executing command: ','''',command,''''],'sosGui_doStats');
1033             evalin('base',command);         
1034         end
1035 
1036 
1037 % --- Executes on button press in pushbutton_setFeederdfCandidateSelectionMethod.
1038 function pushbutton_setFeederdfCandidateSelectionMethod_Callback(hObject, eventdata, handles)
1039 % hObject    handle to pushbutton_setFeederdfCandidateSelectionMethod (see GCBO)
1040 % eventdata  reserved - to be defined in a future version of MATLAB
1041 % handles    structure with handles and user data (see GUIDATA)
1042         set = true;
1043     
1044         sosMenuHandle = handles.popupmenu_SOSSelector;
1045         sosName = getdfName(sosMenuHandle,'SOS');
1046         
1047         if isempty(sosName)
1048             set = false;
1049         end
1050         
1051         if set == true   
1052             
1053             modeMenuHandle = handles.popupmenu_feederdfCandSelectMethod;
1054             mode = getdfName(modeMenuHandle,'neighborMode');
1055             
1056             % create the history
1057             command = [sosName,'.setFeederdfCandidateSelectionMethod(''',mode,''');'];
1058             
1059             verbosePrint(['Executing command: ','''',command,''''],'sosGui_setFeederdfCandMethod');
1060             evalin('base',command);         
1061         end
1062 
1063 % --- Executes on selection change in popupmenu_feederdfCandSelectMethod.
1064 function popupmenu_feederdfCandSelectMethod_Callback(hObject, eventdata, handles)
1065 % hObject    handle to popupmenu_feederdfCandSelectMethod (see GCBO)
1066 % eventdata  reserved - to be defined in a future version of MATLAB
1067 % handles    structure with handles and user data (see GUIDATA)
1068 
1069 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_feederdfCandSelectMethod contents as cell array
1070 %        contents{get(hObject,'Value')} returns selected item from popupmenu_feederdfCandSelectMethod
1071 
1072 
1073 % --- Executes during object creation, after setting all properties.
1074 function popupmenu_feederdfCandSelectMethod_CreateFcn(hObject, eventdata, handles)
1075 % hObject    handle to popupmenu_feederdfCandSelectMethod (see GCBO)
1076 % eventdata  reserved - to be defined in a future version of MATLAB
1077 % handles    empty - handles not created until after all CreateFcns called
1078 
1079 % Hint: popupmenu controls usually have a white background on Windows.
1080 %       See ISPC and COMPUTER.
1081 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1082     set(hObject,'BackgroundColor','white');
1083 end
1084 
1085 
1086 % --- Executes on button press in pushbutton_greedyAnneal.
1087 function pushbutton_greedyAnneal_Callback(hObject, eventdata, handles)
1088 % hObject    handle to pushbutton_greedyAnneal (see GCBO)
1089 % eventdata  reserved - to be defined in a future version of MATLAB
1090 % handles    structure with handles and user data (see GUIDATA)
1091         set = true;
1092     
1093         sosMenuHandle = handles.popupmenu_SOSSelector;
1094         sosName = getdfName(sosMenuHandle,'SOS');
1095         
1096         if isempty(sosName)
1097             set = false;
1098         end
1099         
1100         if set == true   
1101             % create the history
1102             command = [sosName,'.setAnnealSchedule(''schedule'',''greedy'');'];
1103             
1104             verbosePrint(['Executing command: ','''',command,''''],'sosGui_greedyAnneal');
1105             evalin('base',command);         
1106         end
1107 
1108 
1109 % --- Executes on button press in pushbutton_expAnneal.
1110 function pushbutton_expAnneal_Callback(hObject, eventdata, handles)
1111 % hObject    handle to pushbutton_expAnneal (see GCBO)
1112 % eventdata  reserved - to be defined in a future version of MATLAB
1113 % handles    structure with handles and user data (see GUIDATA)
1114     expAnneal_Dialog();
1115 
1116 
1117 % --- Executes on button press in pushbutton_numSteps.
1118 function pushbutton_numSteps_Callback(hObject, eventdata, handles)
1119 % hObject    handle to pushbutton_numSteps (see GCBO)
1120 % eventdata  reserved - to be defined in a future version of MATLAB
1121 % handles    structure with handles and user data (see GUIDATA)
1122     numSteps_Dialog();
1123 
1124 % --- Executes on button press in pushbutton_maxpDecrease.
1125 function pushbutton_maxpDecrease_Callback(hObject, eventdata, handles)
1126 % hObject    handle to pushbutton_maxpDecrease (see GCBO)
1127 % eventdata  reserved - to be defined in a future version of MATLAB
1128 % handles    structure with handles and user data (see GUIDATA)
1129     maxpDecrease_Dialog();
1130 
1131 
1132 % --- Executes on button press in pushbutton_optimize.
1133 function pushbutton_optimize_Callback(hObject, eventdata, handles)
1134 % hObject    handle to pushbutton_optimize (see GCBO)
1135 % eventdata  reserved - to be defined in a future version of MATLAB
1136 % handles    structure with handles and user data (see GUIDATA)
1137 
1138   %  disp('STOPPING');
1139 
1140 
1141     set(handles.pushbutton_stopOptimize,'UserData',0);
1142     run = true;
1143 
1144     sosMenuHandle = handles.popupmenu_SOSSelector;
1145     sosName = getdfName(sosMenuHandle,'SOS');
1146  
1147     if isempty(sosName)
1148         run = false;
1149     end
1150 
1151     if run == true   
1152 
1153         % if the number of iterations to run for is blank, run
1154         numIt = (get(handles.edit_numIt,'String'));
1155 
1156        set(handles.pushbutton_stopOptimize,'Enable','on');
1157         
1158         if isempty(numIt)
1159         %
1160             command = [sosName,'.optimize(''isGui'',1);'];
1161             verbosePrint(['Executing command: ','''',command,''''],'sosGui_optimize');  
1162             
1163             set(handles.pushbutton_optimize,'Enable','off');
1164             evalin('base',command);      
1165             
1166         elseif validate_numIt(handles)
1167             command = [sosName,'.optimize(',numIt,',''isGui'',1);'];
1168             verbosePrint(['Executing command: ','''',command,''''],'sosGui_optimize');
1169             
1170             set(handles.pushbutton_optimize,'Enable','off');              
1171             evalin('base',command);  
1172           
1173         end
1174     end
1175         
1176 
1177 % --- Executes on button press in pushbutton_stopOptimize.
1178 function pushbutton_stopOptimize_Callback(hObject, eventdata, handles)
1179 % hObject    handle to pushbutton_stopOptimize (see GCBO)
1180 % eventdata  reserved - to be defined in a future version of MATLAB
1181 % handles    structure with handles and user data (see GUIDATA)
1182 
1183   %  disp('STOPPING');
1184     set(handles.pushbutton_stopOptimize,'UserData',1);
1185     %guidata(hObject,handles);
1186     set(handles.pushbutton_stopOptimize,'Enable','off');
1187     set(handles.pushbutton_optimize,'Enable','on');
1188     
1189 
1190 function edit_numIt_Callback(hObject, eventdata, handles)
1191 % hObject    handle to edit_numIt (see GCBO)
1192 % eventdata  reserved - to be defined in a future version of MATLAB
1193 % handles    structure with handles and user data (see GUIDATA)
1194 
1195 % Hints: get(hObject,'String') returns contents of edit_numIt as text
1196 %        str2double(get(hObject,'String')) returns contents of edit_numIt as a double
1197     validate_numIt(handles);
1198 
1199 
1200 function flag = validate_numIt(handles)
1201     str = get(handles.edit_numIt,'String');
1202     
1203     if isempty(str)
1204         flag = 1; % valid if empty
1205     else
1206 
1207         errmsg = 'Number of iterations must be a whole number > 0';
1208         errtitle = 'Invalid numIt!';
1209 
1210         flag = validatePositiveInteger(str,errmsg,errtitle);
1211     end
1212     
1213 
1214 % --- Executes during object creation, after setting all properties.
1215 function edit_numIt_CreateFcn(hObject, eventdata, handles)
1216 % hObject    handle to edit_numIt (see GCBO)
1217 % eventdata  reserved - to be defined in a future version of MATLAB
1218 % handles    empty - handles not created until after all CreateFcns called
1219 
1220 % Hint: edit controls usually have a white background on Windows.
1221 %       See ISPC and COMPUTER.
1222 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1223     set(hObject,'BackgroundColor','white');
1224 end
1225 
1226 
1227 % --- Executes during object creation, after setting all properties.
1228 function pushbutton_stopOptimize_CreateFcn(hObject, eventdata, handles)
1229 % hObject    handle to pushbutton_stopOptimize (see GCBO)
1230 % eventdata  reserved - to be defined in a future version of MATLAB
1231 % handles    empty - handles not created until after all CreateFcns called
1232 
1233 
1234 % --- Executes on button press in pushbutton_2sample_ttest.
1235 function pushbutton_2sample_ttest_Callback(hObject, eventdata, handles)
1236 % hObject    handle to pushbutton_2sample_ttest (see GCBO)
1237 % eventdata  reserved - to be defined in a future version of MATLAB
1238 % handles    structure with handles and user data (see GUIDATA)
1239         create = true;
1240     
1241         sosMenuHandle = handles.popupmenu_SOSSelector;
1242         sosName = getdfName(sosMenuHandle,'SOS');
1243         
1244         if isempty(sosName)
1245             create = false;
1246         end
1247         
1248         if create == true   
1249             create2samplettest_Dialog();        
1250         end
1251 
1252 
1253     
1254     
1255 
1256 
1257 % --- Executes on button press in pushbutton_singlettest.
1258 function pushbutton_singlettest_Callback(hObject, eventdata, handles)
1259 % hObject    handle to pushbutton_singlettest (see GCBO)
1260 % eventdata  reserved - to be defined in a future version of MATLAB
1261 % handles    structure with handles and user data (see GUIDATA)
1262         create = true;
1263     
1264         sosMenuHandle = handles.popupmenu_SOSSelector;
1265         sosName = getdfName(sosMenuHandle,'SOS');
1266         
1267         if isempty(sosName)
1268             create = false;
1269         end
1270         
1271         if create == true   
1272             createsinglesamplettest_Dialog();        
1273         end
1274 
1275 
1276 % --- Executes on button press in pushbutton_createHardBoundConstraint.
1277 function pushbutton_createHardBoundConstraint_Callback(hObject, eventdata, handles)
1278 % hObject    handle to pushbutton_createHardBoundConstraint (see GCBO)
1279 % eventdata  reserved - to be defined in a future version of MATLAB
1280 % handles    structure with handles and user data (see GUIDATA)
1281     createHardBoundConstraint_Dialog();
1282 
1283 % --- Executes on button press in pushbutton_createSingleSampleSoftDistanceConstraint.
1284 function pushbutton_createSingleSampleSoftDistanceConstraint_Callback(hObject, eventdata, handles)
1285 % hObject    handle to pushbutton_createSingleSampleSoftDistanceConstraint (see GCBO)
1286 % eventdata  reserved - to be defined in a future version of MATLAB
1287 % handles    structure with handles and user data (see GUIDATA)
1288     createSingleSampleSoftDistanceConstraint_Dialog();
1289 
1290 % --- Executes on button press in pushbutton_create2SampleSoftDistanceConstraint.
1291 function pushbutton_create2SampleSoftDistanceConstraint_Callback(hObject, eventdata, handles)
1292 % hObject    handle to pushbutton_create2SampleSoftDistanceConstraint (see GCBO)
1293 % eventdata  reserved - to be defined in a future version of MATLAB
1294 % handles    structure with handles and user data (see GUIDATA)
1295     createTwoSampleSoftDistanceConstraint_Dialog();
1296 
1297 
1298 % --- Executes on button press in pushbutton_createSoftEntropyConstraint.
1299 function pushbutton_createSoftEntropyConstraint_Callback(hObject, eventdata, handles)
1300 % hObject    handle to pushbutton_createSoftEntropyConstraint (see GCBO)
1301 % eventdata  reserved - to be defined in a future version of MATLAB
1302 % handles    structure with handles and user data (see GUIDATA)
1303     createSoftEntropyConstraint_Dialog();
1304 
1305 
1306 % --- Executes on selection change in popupmenu_entropyConstraintSelector.
1307 function popupmenu_entropyConstraintSelector_Callback(hObject, eventdata, handles)
1308 % hObject    handle to popupmenu_entropyConstraintSelector (see GCBO)
1309 % eventdata  reserved - to be defined in a future version of MATLAB
1310 % handles    structure with handles and user data (see GUIDATA)
1311     populateEntropyConstraintList(hObject);
1312 
1313 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_entropyConstraintSelector contents as cell array
1314 %        contents{get(hObject,'Value')} returns selected item from popupmenu_entropyConstraintSelector
1315 function populateEntropyConstraintList(hObject)    
1316     % get a list of all populations in the base workspace:
1317     vars = evalin('base','whos()');
1318     
1319     cObjs = [];
1320     for i=1:length(vars)
1321         if strcmp(vars(i).class,'softEntropyConstraint')
1322             cObjs = [cObjs; {vars(i).name}]; %#ok<AGROW>
1323         end
1324     end
1325     
1326     
1327     
1328     % assign that list to the options in the pop up menu
1329     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');    
1330     set(hObject,'String',cObjs); 
1331     
1332     
1333 
1334 % --- Executes during object creation, after setting all properties.
1335 function popupmenu_entropyConstraintSelector_CreateFcn(hObject, eventdata, handles)
1336 % hObject    handle to popupmenu_entropyConstraintSelector (see GCBO)
1337 % eventdata  reserved - to be defined in a future version of MATLAB
1338 % handles    empty - handles not created until after all CreateFcns called
1339 
1340 % Hint: popupmenu controls usually have a white background on Windows.
1341 %       See ISPC and COMPUTER.
1342 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1343     set(hObject,'BackgroundColor','white');
1344 end
1345 
1346 
1347 % --- Executes on button press in pushbutton_plotSoftEntropyConstraint.
1348 function pushbutton_plotSoftEntropyConstraint_Callback(hObject, eventdata, handles)
1349 % hObject    handle to pushbutton_plotSoftEntropyConstraint (see GCBO)
1350 % eventdata  reserved - to be defined in a future version of MATLAB
1351 % handles    structure with handles and user data (see GUIDATA)
1352 
1353         create = true;
1354     
1355         entropyMenuHandle = handles.popupmenu_entropyConstraintSelector;
1356         entName = getdfName(entropyMenuHandle,'Soft entropy constraint');
1357         
1358         if isempty(entName)
1359             create = false;
1360         end
1361         
1362         if create == true   
1363             % create the history
1364             command = [entName,'.plotDistribution();'];
1365             
1366             evalin('base',command);         
1367         end
1368 
1369 % --- Executes on button press in pushbutton_refreshSoftEntropyConstraintSelector.
1370 function pushbutton_refreshSoftEntropyConstraintSelector_Callback(hObject, eventdata, handles)
1371 % hObject    handle to pushbutton_refreshSoftEntropyConstraintSelector (see GCBO)
1372 % eventdata  reserved - to be defined in a future version of MATLAB
1373 % handles    structure with handles and user data (see GUIDATA)
1374     populateEntropyConstraintList(handles.popupmenu_entropyConstraintSelector);
1375 
1376 
1377 % --- Executes on button press in pushbutton_createSoftMetaConstraint.
1378 function pushbutton_createSoftMetaConstraint_Callback(hObject, eventdata, handles)
1379 % hObject    handle to pushbutton_createSoftMetaConstraint (see GCBO)
1380 % eventdata  reserved - to be defined in a future version of MATLAB
1381 % handles    structure with handles and user data (see GUIDATA)
1382     createSoftMetaConstraint_Dialog();
1383 
1384 
1385 % --- Executes on button press in pushbutton_calculateOverlap.
1386 function pushbutton_calculateOverlap_Callback(hObject, eventdata, handles)
1387 % hObject    handle to pushbutton_calculateOverlap (see GCBO)
1388 % eventdata  reserved - to be defined in a future version of MATLAB
1389 % handles    structure with handles and user data (see GUIDATA)
1390     calculateOverlap_Dialog();
1391     
1392 
1393 
1394 % --- Executes on button press in pushbutton_createSoftMatchCorrelConstraint.
1395 function pushbutton_createSoftMatchCorrelConstraint_Callback(hObject, eventdata, handles)
1396 % hObject    handle to pushbutton_createSoftMatchCorrelConstraint (see GCBO)
1397 % eventdata  reserved - to be defined in a future version of MATLAB
1398 % handles    structure with handles and user data (see GUIDATA)
1399     createSoftMatchCorrelDistanceConstraint_Dialog();
1400 
1401 
1402 % --- Executes on button press in pushbutton_matchCorrel_ztest.
1403 function pushbutton_matchCorrel_ztest_Callback(hObject, eventdata, handles)
1404 % hObject    handle to pushbutton_matchCorrel_ztest (see GCBO)
1405 % eventdata  reserved - to be defined in a future version of MATLAB
1406 % handles    structure with handles and user data (see GUIDATA)
1407         create = true;
1408     
1409         sosMenuHandle = handles.popupmenu_SOSSelector;
1410         sosName = getdfName(sosMenuHandle,'SOS');
1411         
1412         if isempty(sosName)
1413             create = false;
1414         end
1415         
1416         if create == true   
1417             createMatchCorrelztest_Dialog();        
1418         end
1419 
1420 
1421 % --- Executes on button press in pushbutton_kstest.
1422 function pushbutton_kstest_Callback(hObject, eventdata, handles)
1423 % hObject    handle to pushbutton_kstest (see GCBO)
1424 % eventdata  reserved - to be defined in a future version of MATLAB
1425 % handles    structure with handles and user data (see GUIDATA)
1426         create = true;
1427     
1428         sosMenuHandle = handles.popupmenu_SOSSelector;
1429         sosName = getdfName(sosMenuHandle,'SOS');
1430         
1431         if isempty(sosName)
1432             create = false;
1433         end
1434         
1435         if create == true   
1436             createMatchUniformkstest_Dialog();        
1437         end

Generated on Fri 27-Jan-2012 16:18:41 by m2html © 2005