Home > src > createSoftEntropyConstraint_Dialog.m

createSoftEntropyConstraint_Dialog

PURPOSE ^

- create soft entropy constraint dialog

SYNOPSIS ^

function varargout = createSoftEntropyConstraint_Dialog(varargin)

DESCRIPTION ^

 - create soft entropy constraint dialog
 
 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 % - create soft entropy constraint dialog
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 function varargout = createSoftEntropyConstraint_Dialog(varargin)
0024 % CREATESOFTENTROPYCONSTRAINT_DIALOG M-file for createSoftEntropyConstraint_Dialog.fig
0025 %      CREATESOFTENTROPYCONSTRAINT_DIALOG, by itself, creates a new CREATESOFTENTROPYCONSTRAINT_DIALOG or raises the existing
0026 %      singleton*.
0027 %
0028 %      H = CREATESOFTENTROPYCONSTRAINT_DIALOG returns the handle to a new CREATESOFTENTROPYCONSTRAINT_DIALOG or the handle to
0029 %      the existing singleton*.
0030 %
0031 %      CREATESOFTENTROPYCONSTRAINT_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local
0032 %      function named CALLBACK in CREATESOFTENTROPYCONSTRAINT_DIALOG.M with the given input arguments.
0033 %
0034 %      CREATESOFTENTROPYCONSTRAINT_DIALOG('Property','Value',...) creates a new CREATESOFTENTROPYCONSTRAINT_DIALOG or raises the
0035 %      existing singleton*.  Starting from the left, property value pairs are
0036 %      applied to the GUI before createSoftEntropyConstraint_Dialog_OpeningFcn gets called.  An
0037 %      unrecognized property name or invalid value makes property application
0038 %      stop.  All inputs are passed to createSoftEntropyConstraint_Dialog_OpeningFcn via varargin.
0039 %
0040 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0041 %      instance to run (singleton)".
0042 %
0043 % See also: GUIDE, GUIDATA, GUIHANDLES
0044 
0045 % Edit the above text to modify the response to help createSoftEntropyConstraint_Dialog
0046 
0047 % Last Modified by GUIDE v2.5 17-Sep-2010 13:18:27
0048 
0049 % Begin initialization code - DO NOT EDIT
0050 gui_Singleton = 1;
0051 gui_State = struct('gui_Name',       mfilename, ...
0052                    'gui_Singleton',  gui_Singleton, ...
0053                    'gui_OpeningFcn', @createSoftEntropyConstraint_Dialog_OpeningFcn, ...
0054                    'gui_OutputFcn',  @createSoftEntropyConstraint_Dialog_OutputFcn, ...
0055                    'gui_LayoutFcn',  [] , ...
0056                    'gui_Callback',   []);
0057 if nargin && ischar(varargin{1})
0058     gui_State.gui_Callback = str2func(varargin{1});
0059 end
0060 
0061 if nargout
0062     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0063 else
0064     gui_mainfcn(gui_State, varargin{:});
0065 end
0066 % End initialization code - DO NOT EDIT
0067 
0068 
0069 % --- Executes just before createSoftEntropyConstraint_Dialog is made visible.
0070 function createSoftEntropyConstraint_Dialog_OpeningFcn(hObject, eventdata, handles, varargin)
0071 % This function has no output args, see OutputFcn.
0072 % hObject    handle to figure
0073 % eventdata  reserved - to be defined in a future version of MATLAB
0074 % handles    structure with handles and user data (see GUIDATA)
0075 % varargin   command line arguments to createSoftEntropyConstraint_Dialog (see VARARGIN)
0076 
0077 % Choose default command line output for createSoftEntropyConstraint_Dialog
0078 handles.output = hObject;
0079 
0080 % Update handles structure
0081 guidata(hObject, handles);
0082 
0083 % UIWAIT makes createSoftEntropyConstraint_Dialog wait for user response (see UIRESUME)
0084 % uiwait(handles.figure_createSoftEntropyConstraint_Dialog);
0085 
0086 
0087 % --- Outputs from this function are returned to the command line.
0088 function varargout = createSoftEntropyConstraint_Dialog_OutputFcn(hObject, eventdata, handles) 
0089 % varargout  cell array for returning output args (see VARARGOUT);
0090 % hObject    handle to figure
0091 % eventdata  reserved - to be defined in a future version of MATLAB
0092 % handles    structure with handles and user data (see GUIDATA)
0093 
0094 % Get default command line output from handles structure
0095 varargout{1} = handles.output;
0096 
0097 
0098 
0099 function edit_name_Callback(hObject, eventdata, handles)
0100 % hObject    handle to edit_name (see GCBO)
0101 % eventdata  reserved - to be defined in a future version of MATLAB
0102 % handles    structure with handles and user data (see GUIDATA)
0103 
0104 % Hints: get(hObject,'String') returns contents of edit_name as text
0105 %        str2double(get(hObject,'String')) returns contents of edit_name as a double
0106     validate_name(handles);
0107     
0108 
0109 function flag = validate_name(handles)
0110 
0111     varName = get(handles.edit_name,'String');
0112     
0113     %check to make sure that the name is a valid variable name:
0114     valid = regexp(varName,'^[a-zA-Z]+\w*$', 'once');
0115     
0116     if isempty(valid)
0117         % name is not currently valid, tell the user.
0118         msgbox('Only letters, numbers, and underscores are permitted in the name of the ttest object.  The first character must also be a letter.',...
0119                 'Invalid name!');
0120         flag = false;
0121     else
0122         % check to make sure that the new variable name doesn't already exist.
0123         command = strcat('whos(''',varName,''')');
0124         varExists = evalin('base',command);
0125 
0126 
0127         % if a variable with this name already exists, warns the user
0128         if isempty(varExists) == 0
0129             msgbox('A variable with this name already exists and will be overridden if you continue',...
0130                     'Variable name already in use!');
0131         end
0132         
0133         flag = true;
0134     end
0135     
0136     
0137 
0138 % --- Executes during object creation, after setting all properties.
0139 function edit_name_CreateFcn(hObject, eventdata, handles)
0140 % hObject    handle to edit_name (see GCBO)
0141 % eventdata  reserved - to be defined in a future version of MATLAB
0142 % handles    empty - handles not created until after all CreateFcns called
0143 
0144 % Hint: edit controls usually have a white background on Windows.
0145 %       See ISPC and COMPUTER.
0146 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0147     set(hObject,'BackgroundColor','white');
0148 end
0149 
0150 
0151 % --- Executes on selection change in popupmenu_sample1Selector.
0152 function popupmenu_sample1Selector_Callback(hObject, eventdata, handles)
0153 % hObject    handle to popupmenu_sample1Selector (see GCBO)
0154 % eventdata  reserved - to be defined in a future version of MATLAB
0155 % handles    structure with handles and user data (see GUIDATA)
0156 
0157 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample1Selector contents as cell array
0158 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sample1Selector
0159     populateSampleList(hObject);
0160 
0161 
0162 function populateSampleList(hObject)    
0163     % get a list of all populations in the base workspace:
0164     vars = evalin('base','whos()');
0165     
0166     samples = [];
0167     for i=1:length(vars)
0168         if strcmp(vars(i).class,'sample')
0169             samples = [samples; {vars(i).name}]; %#ok<AGROW>
0170         end
0171     end
0172     
0173     
0174     
0175     % assign that list to the options in the pop up menu
0176     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');    
0177     set(hObject,'String',samples); 
0178 
0179 % --- Executes during object creation, after setting all properties.
0180 function popupmenu_sample1Selector_CreateFcn(hObject, eventdata, handles)
0181 % hObject    handle to popupmenu_sample1Selector (see GCBO)
0182 % eventdata  reserved - to be defined in a future version of MATLAB
0183 % handles    empty - handles not created until after all CreateFcns called
0184 
0185 % Hint: popupmenu controls usually have a white background on Windows.
0186 %       See ISPC and COMPUTER.
0187 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0188     set(hObject,'BackgroundColor','white');
0189 end
0190 
0191 
0192 % --- Executes on button press in pushbutton_refreshSample1List.
0193 function pushbutton_refreshSample1List_Callback(hObject, eventdata, handles)
0194 % hObject    handle to pushbutton_refreshSample1List (see GCBO)
0195 % eventdata  reserved - to be defined in a future version of MATLAB
0196 % handles    structure with handles and user data (see GUIDATA)
0197     populateSampleList(handles.popupmenu_sample1Selector);
0198 
0199 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
0200 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample1Selector.
0201 function popupmenu_sample1Selector_ButtonDownFcn(hObject, eventdata, handles)
0202 % hObject    handle to popupmenu_sample1Selector (see GCBO)
0203 % eventdata  reserved - to be defined in a future version of MATLAB
0204 % handles    structure with handles and user data (see GUIDATA)
0205     populateSampleList(hObject);
0206 
0207 
0208 % --- Executes on selection change in popupmenu_sample1ColSelector.
0209 function popupmenu_sample1ColSelector_Callback(hObject, eventdata, handles)
0210 % hObject    handle to popupmenu_sample1ColSelector (see GCBO)
0211 % eventdata  reserved - to be defined in a future version of MATLAB
0212 % handles    structure with handles and user data (see GUIDATA)
0213     populateColumnList(hObject,handles.popupmenu_sample1Selector);
0214 
0215 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample1ColSelector contents as cell array
0216 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sample1ColSelector
0217 function populateColumnList(hObject,sampleSelector)    
0218     % get a list of all populations in the base workspace:
0219 
0220     create = true;
0221     
0222     % get the sample in the first list.
0223     sampleMenuHandle = sampleSelector;
0224     sampleName = getdfName(sampleMenuHandle,'sample 1');    
0225     
0226     if isempty(sampleName)
0227         create = false;
0228     end
0229     
0230     if create == true
0231         % add in all of the header names associated with that sample.
0232         tmpColNames = evalin('base',[sampleName,'.header']);
0233         
0234         % melt and refreeze cells
0235         colNames = {};
0236         
0237         for i=1:length(tmpColNames)
0238             colNames = [colNames ; tmpColNames{i}]; %#ok<AGROW>
0239         end
0240         
0241     
0242     % assign that list to the options in the pop up menu
0243         warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');    
0244         set(hObject,'String',colNames);
0245     end
0246 
0247 % --- Executes during object creation, after setting all properties.
0248 function popupmenu_sample1ColSelector_CreateFcn(hObject, eventdata, handles)
0249 % hObject    handle to popupmenu_sample1ColSelector (see GCBO)
0250 % eventdata  reserved - to be defined in a future version of MATLAB
0251 % handles    empty - handles not created until after all CreateFcns called
0252 
0253 % Hint: popupmenu controls usually have a white background on Windows.
0254 %       See ISPC and COMPUTER.
0255 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0256     set(hObject,'BackgroundColor','white');
0257 end
0258 
0259 
0260 % --- Executes on button press in pushbutton_refreshsample1ColSelector.
0261 function pushbutton_refreshsample1ColSelector_Callback(hObject, eventdata, handles)
0262 % hObject    handle to pushbutton_refreshsample1ColSelector (see GCBO)
0263 % eventdata  reserved - to be defined in a future version of MATLAB
0264 % handles    structure with handles and user data (see GUIDATA)
0265     populateColumnList(handles.popupmenu_sample1ColSelector,handles.popupmenu_sample1Selector);
0266 
0267 
0268 % --- Executes on selection change in popupmenu_sample2Selector.
0269 function popupmenu_sample2Selector_Callback(hObject, eventdata, handles)
0270 % hObject    handle to popupmenu_sample2Selector (see GCBO)
0271 % eventdata  reserved - to be defined in a future version of MATLAB
0272 % handles    structure with handles and user data (see GUIDATA)
0273 
0274 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample2Selector contents as cell array
0275 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sample2Selector
0276     populateSampleList(hObject);
0277 
0278 
0279 % --- Executes during object creation, after setting all properties.
0280 function popupmenu_sample2Selector_CreateFcn(hObject, eventdata, handles)
0281 % hObject    handle to popupmenu_sample2Selector (see GCBO)
0282 % eventdata  reserved - to be defined in a future version of MATLAB
0283 % handles    empty - handles not created until after all CreateFcns called
0284 
0285 % Hint: popupmenu controls usually have a white background on Windows.
0286 %       See ISPC and COMPUTER.
0287 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0288     set(hObject,'BackgroundColor','white');
0289 end
0290 
0291 
0292 % --- Executes on button press in pushbutton_refreshSample2List.
0293 function pushbutton_refreshSample2List_Callback(hObject, eventdata, handles)
0294 % hObject    handle to pushbutton_refreshSample2List (see GCBO)
0295 % eventdata  reserved - to be defined in a future version of MATLAB
0296 % handles    structure with handles and user data (see GUIDATA)
0297     populateSampleList(handles.popupmenu_sample2Selector);
0298 
0299 % --- Executes on selection change in popupmenu_sample2ColSelector.
0300 function popupmenu_sample2ColSelector_Callback(hObject, eventdata, handles)
0301 % hObject    handle to popupmenu_sample2ColSelector (see GCBO)
0302 % eventdata  reserved - to be defined in a future version of MATLAB
0303 % handles    structure with handles and user data (see GUIDATA)
0304 
0305 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample2ColSelector contents as cell array
0306 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sample2ColSelector
0307     populateColumnList(hObject,handles.popupmenu_sample2Selector);
0308 
0309 
0310 % --- Executes during object creation, after setting all properties.
0311 function popupmenu_sample2ColSelector_CreateFcn(hObject, eventdata, handles)
0312 % hObject    handle to popupmenu_sample2ColSelector (see GCBO)
0313 % eventdata  reserved - to be defined in a future version of MATLAB
0314 % handles    empty - handles not created until after all CreateFcns called
0315 
0316 % Hint: popupmenu controls usually have a white background on Windows.
0317 %       See ISPC and COMPUTER.
0318 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0319     set(hObject,'BackgroundColor','white');
0320 end
0321 
0322 
0323 % --- Executes on button press in pushbutton_refreshsample2ColSelector.
0324 function pushbutton_refreshsample2ColSelector_Callback(hObject, eventdata, handles)
0325 % hObject    handle to pushbutton_refreshsample2ColSelector (see GCBO)
0326 % eventdata  reserved - to be defined in a future version of MATLAB
0327 % handles    structure with handles and user data (see GUIDATA)
0328     populateColumnList(handles.popupmenu_sample2ColSelector,handles.popupmenu_sample2Selector);
0329 
0330 
0331 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
0332 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample1ColSelector.
0333 function popupmenu_sample1ColSelector_ButtonDownFcn(hObject, eventdata, handles)
0334 % hObject    handle to popupmenu_sample1ColSelector (see GCBO)
0335 % eventdata  reserved - to be defined in a future version of MATLAB
0336 % handles    structure with handles and user data (see GUIDATA)
0337     populateColumnList(hObject,handles.popupmenu_sample1Selector);
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_sample2Selector.
0342 function popupmenu_sample2Selector_ButtonDownFcn(hObject, eventdata, handles)
0343 % hObject    handle to popupmenu_sample2Selector (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     populateSampleList(hObject);
0347 
0348 
0349 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
0350 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample2ColSelector.
0351 function popupmenu_sample2ColSelector_ButtonDownFcn(hObject, eventdata, handles)
0352 % hObject    handle to popupmenu_sample2ColSelector (see GCBO)
0353 % eventdata  reserved - to be defined in a future version of MATLAB
0354 % handles    structure with handles and user data (see GUIDATA)
0355     populateColumnList(hObject,handles.popupmenu_sample2Selector);
0356 
0357 
0358 
0359 function edit_nbin_Callback(hObject, eventdata, handles)
0360 % hObject    handle to edit_nbin (see GCBO)
0361 % eventdata  reserved - to be defined in a future version of MATLAB
0362 % handles    structure with handles and user data (see GUIDATA)
0363 
0364 % Hints: get(hObject,'String') returns contents of edit_nbin as text
0365 %        str2double(get(hObject,'String')) returns contents of edit_nbin as a double
0366     validate_nbin(handles);
0367     
0368     
0369 function flag = validate_nbin(handles)
0370      str = get(handles.edit_nbin,'String');
0371     
0372     errmsg = 'Bound value must be a number';
0373     errtitle = 'Invalid bound value!';
0374     
0375     if isempty(str)
0376         flag = true;
0377     else    
0378         flag = validatePositiveInteger(str,errmsg,errtitle);    
0379     end
0380     
0381     
0382 
0383 % --- Executes during object creation, after setting all properties.
0384 function edit_nbin_CreateFcn(hObject, eventdata, handles)
0385 % hObject    handle to edit_nbin (see GCBO)
0386 % eventdata  reserved - to be defined in a future version of MATLAB
0387 % handles    empty - handles not created until after all CreateFcns called
0388 
0389 % Hint: edit controls usually have a white background on Windows.
0390 %       See ISPC and COMPUTER.
0391 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0392     set(hObject,'BackgroundColor','white');
0393 end
0394 
0395 
0396 % --- Executes on selection change in popupmenu_desiredpvalCondition.
0397 function popupmenu_desiredpvalCondition_Callback(hObject, eventdata, handles)
0398 % hObject    handle to popupmenu_desiredpvalCondition (see GCBO)
0399 % eventdata  reserved - to be defined in a future version of MATLAB
0400 % handles    structure with handles and user data (see GUIDATA)
0401 
0402 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_desiredpvalCondition contents as cell array
0403 %        contents{get(hObject,'Value')} returns selected item from popupmenu_desiredpvalCondition
0404 
0405 
0406 % --- Executes during object creation, after setting all properties.
0407 function popupmenu_desiredpvalCondition_CreateFcn(hObject, eventdata, handles)
0408 % hObject    handle to popupmenu_desiredpvalCondition (see GCBO)
0409 % eventdata  reserved - to be defined in a future version of MATLAB
0410 % handles    empty - handles not created until after all CreateFcns called
0411 
0412 % Hint: popupmenu controls usually have a white background on Windows.
0413 %       See ISPC and COMPUTER.
0414 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0415     set(hObject,'BackgroundColor','white');
0416 end
0417 
0418 
0419 % --- Executes on selection change in popupmenu_tails.
0420 function popupmenu_tails_Callback(hObject, eventdata, handles)
0421 % hObject    handle to popupmenu_tails (see GCBO)
0422 % eventdata  reserved - to be defined in a future version of MATLAB
0423 % handles    structure with handles and user data (see GUIDATA)
0424 
0425 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_tails contents as cell array
0426 %        contents{get(hObject,'Value')} returns selected item from popupmenu_tails
0427 
0428 
0429 % --- Executes during object creation, after setting all properties.
0430 function popupmenu_tails_CreateFcn(hObject, eventdata, handles)
0431 % hObject    handle to popupmenu_tails (see GCBO)
0432 % eventdata  reserved - to be defined in a future version of MATLAB
0433 % handles    empty - handles not created until after all CreateFcns called
0434 
0435 % Hint: popupmenu controls usually have a white background on Windows.
0436 %       See ISPC and COMPUTER.
0437 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0438     set(hObject,'BackgroundColor','white');
0439 end
0440 
0441 
0442 % --- Executes on button press in pushbutton_createSoftEntropyConstraint.
0443 function pushbutton_createSoftEntropyConstraint_Callback(hObject, eventdata, handles)
0444 % hObject    handle to pushbutton_createSoftEntropyConstraint (see GCBO)
0445 % eventdata  reserved - to be defined in a future version of MATLAB
0446 % handles    structure with handles and user data (see GUIDATA)
0447 
0448     type = getdfName(handles.popupmenu_type,'type');
0449 
0450     mainWindowHandle = sos_gui;
0451     mainWindowData = guidata(mainWindowHandle);
0452 
0453     sosObjName = getdfName(mainWindowData.popupmenu_SOSSelector,'SOS');
0454 
0455     if isempty(sosObjName) == 0
0456         % we have a valid SOS object to add the test to
0457         % validate all of the parameters for the test
0458         create = validate_name(handles);
0459         name = get(handles.edit_name,'String');
0460         
0461         if create == true
0462             sample1 = getdfName(handles.popupmenu_sample1Selector,'sample 1');
0463             
0464             if isempty(sample1) == 0
0465                 sample1Col = getdfName(handles.popupmenu_sample1ColSelector','sample 1 column');
0466                 
0467                 if isempty(sample1Col) == 0
0468                    create = validate_nbin(handles);
0469                    
0470                    if create == true
0471                        %
0472                         nbin = get(handles.edit_nbin,'String');
0473                         
0474                         % check weight
0475                         create = validate_weight(handles);
0476                         if create == true
0477                             weight = get(handles.edit_weight,'String');
0478                             
0479                             create = validate_exp(handles);
0480                             if create == true
0481                                 exp = get (handles.edit_exp,'String');
0482                                 
0483                                     %all functions passed, retrieve the
0484                                     %hard-coded popup menu data
0485 
0486                                     fnc = getdfName(handles.popupmenu_fncSelector,...
0487                                                     'fnc');
0488                                     pdSpread = getdfName(handles.popupmenu_pdSpreadSelector,...
0489                                                     'stat');
0490 
0491 
0492                                     %all of the other options are in drop-down
0493                                     %menus and as such necessarily will pass.
0494                                     %run the command.
0495                                     
0496                                     if isempty(nbin)
0497                                         % run abbreviated command if no bin
0498                                         % information supplied
0499 
0500                                     command = [name,'=',sosObjName,'.addConstraint(',...
0501                                         '''name'',''',name,''',',...
0502                                         '''constraintType'',''',type,''',',...
0503                                         '''pdSpread'',''',pdSpread,''',',...
0504                                         '''fnc'',''',fnc,''',',...
0505                                         '''sample1'',',sample1,',',...
0506                                         '''s1ColName'',''',sample1Col,''',',...
0507                                         '''weight'',',weight,','...
0508                                         '''exponent'',',exp,');',...
0509                                         ];
0510                                     
0511                                     else
0512                                         command = [name,'=',sosObjName,'.addConstraint(',...
0513                                         '''name'',''',name,''',',...
0514                                         '''constraintType'',''',type,''',',...
0515                                         '''pdSpread'',''',pdSpread,''',',...
0516                                         '''fnc'',''',fnc,''',',...
0517                                         '''sample1'',',sample1,',',...
0518                                         '''s1ColName'',''',sample1Col,''',',...
0519                                         '''nbin'',',nbin,',',...
0520                                         '''weight'',',weight,','...
0521                                         '''exponent'',',exp,');',...
0522                                         ]; 
0523                                     end
0524 
0525                                     verbosePrint(['Executing command: ','''',command,''''],'createSoftEntropyConstraint_Dialog_create');
0526                                     evalin('base',command);      
0527                                     close(handles.figure_createSoftEntropyConstraint_Dialog);   
0528                             end
0529                         end
0530                    end
0531                 end
0532             end 
0533         end
0534     end
0535 
0536 
0537 % --- Executes on selection change in popupmenu_type.
0538 function popupmenu_type_Callback(hObject, eventdata, handles)
0539 % hObject    handle to popupmenu_type (see GCBO)
0540 % eventdata  reserved - to be defined in a future version of MATLAB
0541 % handles    structure with handles and user data (see GUIDATA)
0542 
0543 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_type contents as cell array
0544 %        contents{get(hObject,'Value')} returns selected item from popupmenu_type
0545 
0546 
0547 % --- Executes during object creation, after setting all properties.
0548 function popupmenu_type_CreateFcn(hObject, eventdata, handles)
0549 % hObject    handle to popupmenu_type (see GCBO)
0550 % eventdata  reserved - to be defined in a future version of MATLAB
0551 % handles    empty - handles not created until after all CreateFcns called
0552 
0553 % Hint: popupmenu controls usually have a white background on Windows.
0554 %       See ISPC and COMPUTER.
0555 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0556     set(hObject,'BackgroundColor','white');
0557 end
0558 
0559 
0560 % --- Executes on selection change in popupmenu_fncSelector.
0561 function popupmenu_fncSelector_Callback(hObject, eventdata, handles)
0562 % hObject    handle to popupmenu_fncSelector (see GCBO)
0563 % eventdata  reserved - to be defined in a future version of MATLAB
0564 % handles    structure with handles and user data (see GUIDATA)
0565 
0566 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_fncSelector contents as cell array
0567 %        contents{get(hObject,'Value')} returns selected item from popupmenu_fncSelector
0568 
0569 
0570 % --- Executes during object creation, after setting all properties.
0571 function popupmenu_fncSelector_CreateFcn(hObject, eventdata, handles)
0572 % hObject    handle to popupmenu_fncSelector (see GCBO)
0573 % eventdata  reserved - to be defined in a future version of MATLAB
0574 % handles    empty - handles not created until after all CreateFcns called
0575 
0576 % Hint: popupmenu controls usually have a white background on Windows.
0577 %       See ISPC and COMPUTER.
0578 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0579     set(hObject,'BackgroundColor','white');
0580 end
0581 
0582 
0583 
0584 function edit_weight_Callback(hObject, eventdata, handles)
0585 % hObject    handle to edit_weight (see GCBO)
0586 % eventdata  reserved - to be defined in a future version of MATLAB
0587 % handles    structure with handles and user data (see GUIDATA)
0588 
0589 % Hints: get(hObject,'String') returns contents of edit_weight as text
0590 %        str2double(get(hObject,'String')) returns contents of edit_weight as a double
0591     validate_weight(handles);
0592     
0593     
0594 function flag = validate_weight(handles)
0595      str = get(handles.edit_weight,'String');
0596     
0597     errmsg = 'Weight must be a number';
0598     errtitle = 'Invalid weight!';
0599     
0600     flag = validateRealNumber(str,errmsg,errtitle); 
0601 
0602 % --- Executes during object creation, after setting all properties.
0603 function edit_weight_CreateFcn(hObject, eventdata, handles)
0604 % hObject    handle to edit_weight (see GCBO)
0605 % eventdata  reserved - to be defined in a future version of MATLAB
0606 % handles    empty - handles not created until after all CreateFcns called
0607 
0608 % Hint: edit controls usually have a white background on Windows.
0609 %       See ISPC and COMPUTER.
0610 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0611     set(hObject,'BackgroundColor','white');
0612 end
0613 
0614 
0615 
0616 function edit_exp_Callback(hObject, eventdata, handles)
0617 % hObject    handle to edit_exp (see GCBO)
0618 % eventdata  reserved - to be defined in a future version of MATLAB
0619 % handles    structure with handles and user data (see GUIDATA)
0620 
0621 % Hints: get(hObject,'String') returns contents of edit_exp as text
0622 %        str2double(get(hObject,'String')) returns contents of edit_exp as a double
0623     validate_exp(handles);
0624     
0625     
0626 function flag = validate_exp(handles)
0627      str = get(handles.edit_exp,'String');
0628     
0629     errmsg = 'Exponent must be a number';
0630     errtitle = 'Invalid exponent!';
0631     
0632     flag = validateRealNumber(str,errmsg,errtitle); 
0633 
0634 % --- Executes during object creation, after setting all properties.
0635 function edit_exp_CreateFcn(hObject, eventdata, handles)
0636 % hObject    handle to edit_exp (see GCBO)
0637 % eventdata  reserved - to be defined in a future version of MATLAB
0638 % handles    empty - handles not created until after all CreateFcns called
0639 
0640 % Hint: edit controls usually have a white background on Windows.
0641 %       See ISPC and COMPUTER.
0642 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0643     set(hObject,'BackgroundColor','white');
0644 end
0645 
0646 
0647 % --- Executes on selection change in popupmenu_pdSpreadSelector.
0648 function popupmenu_pdSpreadSelector_Callback(hObject, eventdata, handles)
0649 % hObject    handle to popupmenu_pdSpreadSelector (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: contents = cellstr(get(hObject,'String')) returns popupmenu_pdSpreadSelector contents as cell array
0654 %        contents{get(hObject,'Value')} returns selected item from popupmenu_pdSpreadSelector
0655 
0656 
0657 % --- Executes during object creation, after setting all properties.
0658 function popupmenu_pdSpreadSelector_CreateFcn(hObject, eventdata, handles)
0659 % hObject    handle to popupmenu_pdSpreadSelector (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: popupmenu 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

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