Home > SaliencyToolbox > guiLevelParams.m

guiLevelParams

PURPOSE ^

guiLevelParams - a graphical user interface (GUI) to adjust parameter level parameters.

SYNOPSIS ^

function varargout = guiLevelParams(varargin)

DESCRIPTION ^

 guiLevelParams - a graphical user interface (GUI) to adjust parameter level parameters.

 newLevelParams = guiLevelParams(oldLevelParams)
    Lets the user adjust the old parameters and returns them as new parameters.
    If oldLevelParams are ommitted, defaultLevelParams are used.

 See also defaultLevelParams, guiSaliency, defaultSaliencyParams,
          centerSurround, winnerToImgCoords, dataStructures.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % guiLevelParams - a graphical user interface (GUI) to adjust parameter level parameters.
0002 %
0003 % newLevelParams = guiLevelParams(oldLevelParams)
0004 %    Lets the user adjust the old parameters and returns them as new parameters.
0005 %    If oldLevelParams are ommitted, defaultLevelParams are used.
0006 %
0007 % See also defaultLevelParams, guiSaliency, defaultSaliencyParams,
0008 %          centerSurround, winnerToImgCoords, dataStructures.
0009 
0010 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2013
0011 % by Dirk B. Walther and the California Institute of Technology.
0012 % See the enclosed LICENSE.TXT document for the license agreement.
0013 % More information about this project is available at:
0014 % http://www.saliencytoolbox.net
0015 
0016 function varargout = guiLevelParams(varargin)
0017 
0018 % GUI initialization code
0019 gui_Singleton = 1;
0020 gui_State = struct('gui_Name',       mfilename, ...
0021                    'gui_Singleton',  gui_Singleton, ...
0022                    'gui_OpeningFcn', @guiLevelParams_OpeningFcn, ...
0023                    'gui_OutputFcn',  @guiLevelParams_OutputFcn, ...
0024                    'gui_LayoutFcn',  [] , ...
0025                    'gui_Callback',   []);
0026 if nargin && ischar(varargin{1})
0027     gui_State.gui_Callback = str2func(varargin{1});
0028 end
0029 
0030 if nargout
0031     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0032 else
0033     gui_mainfcn(gui_State, varargin{:});
0034 end
0035 
0036 
0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0038 % opening code executes just before guiLevelParams is made visible.
0039 function guiLevelParams_OpeningFcn(hObject, eventdata, handles, varargin)
0040 
0041 handles.output = hObject;
0042 guidata(hObject, handles);
0043 
0044 % get the old parameters from the command line or use default?
0045 global lparams;
0046 if isempty(varargin)
0047   lparams = defaultLevelParams('dyadic');
0048 else
0049   lparams = varargin{1};
0050 end
0051 
0052 fillParams(handles);
0053 
0054 % this waits for the user to press 'cancel' or 'ok'
0055 set(handles.figure1,'WindowStyle','modal')
0056 uiwait(handles.figure1);
0057 
0058 % clean up
0059 try
0060   delete(handles.figure1);
0061 catch
0062   % nothing to do
0063 end
0064 return;
0065 
0066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0067 % fill the GUI with the parameters from the global variable params
0068 function fillParams(handles)
0069 global lparams;
0070 set(handles.minLevel,'String',num2str(lparams.minLevel));
0071 set(handles.minLevel,'UserData',lparams.minLevel);
0072 set(handles.maxLevel,'String',num2str(lparams.maxLevel));
0073 set(handles.maxLevel,'UserData',lparams.maxLevel);
0074 set(handles.minDelta,'String',num2str(lparams.minDelta));
0075 set(handles.minDelta,'UserData',lparams.minDelta);
0076 set(handles.maxDelta,'String',num2str(lparams.maxDelta));
0077 set(handles.maxDelta,'UserData',lparams.maxDelta);
0078 set(handles.mapLevel,'String',num2str(lparams.mapLevel));
0079 set(handles.mapLevel,'UserData',lparams.mapLevel);
0080 return;
0081 
0082 
0083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0084 % Set command line output to the new parameters and clean up
0085 function varargout = guiLevelParams_OutputFcn(hObject, eventdata, handles) 
0086 global lparams;
0087 varargout{1} = lparams;
0088 clear global lparams;
0089 
0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0091 % make sure that the text field hObject contains a valid integer >1,
0092 % store the valid value in the text field's UserData
0093 function checkNumber(hObject)
0094 num = str2num(get(hObject,'String'));
0095 if ~isempty(num)
0096   num = round(num(1));
0097   if (num < 1) num = 1; end
0098   set(hObject,'UserData',num);
0099 end
0100 set(hObject,'String',num2str(get(hObject,'UserData')));
0101 return;
0102 
0103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0104 % the text fields with the values
0105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0106 
0107 % minLevel
0108 function minLevel_Callback(hObject, eventdata, handles)
0109 checkNumber(hObject);
0110 
0111 function minLevel_CreateFcn(hObject, eventdata, handles)
0112 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0113     set(hObject,'BackgroundColor','white');
0114 end
0115 
0116 % maxLevel
0117 function maxLevel_Callback(hObject, eventdata, handles)
0118 checkNumber(hObject);
0119 
0120 function maxLevel_CreateFcn(hObject, eventdata, handles)
0121 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0122     set(hObject,'BackgroundColor','white');
0123 end
0124 
0125 
0126 % minDelta
0127 function minDelta_Callback(hObject, eventdata, handles)
0128 checkNumber(hObject);
0129 
0130 function minDelta_CreateFcn(hObject, eventdata, handles)
0131 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0132     set(hObject,'BackgroundColor','white');
0133 end
0134 
0135 % maxDelta
0136 function maxDelta_Callback(hObject, eventdata, handles)
0137 checkNumber(hObject);
0138 
0139 function maxDelta_CreateFcn(hObject, eventdata, handles)
0140 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0141     set(hObject,'BackgroundColor','white');
0142 end
0143 
0144 % mapLevel
0145 function mapLevel_Callback(hObject, eventdata, handles)
0146 checkNumber(hObject);
0147 
0148 function mapLevel_CreateFcn(hObject, eventdata, handles)
0149 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0150     set(hObject,'BackgroundColor','white');
0151 end
0152 
0153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0154 % buttons
0155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0156 
0157 % Defaults button
0158 function defaults_Callback(hObject, eventdata, handles)
0159 global lparams;
0160 lparams = defaultLevelParams('dyadic');
0161 fillParams(handles);
0162 
0163 % Cancel button
0164 function cancel_Callback(hObject, eventdata, handles)
0165 uiresume(handles.figure1);
0166 
0167 % OK button
0168 function ok_Callback(hObject, eventdata, handles)
0169 global params lparams;
0170 
0171 % read the new parameters from the text fields
0172 lparams.minLevel = get(handles.minLevel,'UserData');
0173 lparams.maxLevel = get(handles.maxLevel,'UserData');
0174 lparams.minDelta = get(handles.minDelta,'UserData');
0175 lparams.maxDelta = get(handles.maxDelta,'UserData');
0176 lparams.mapLevel = get(handles.mapLevel,'UserData');
0177 
0178 % check that surround levels are okay
0179 if (lparams.minLevel > lparams.maxLevel)
0180   uiwait(warndlg('''lowest center level'' must be lower than ''highest center level''!',...
0181                  'Please correct!','modal'));
0182   return;
0183 end
0184 
0185 % check that c-s delta range is valid
0186 if (lparams.minDelta > lparams.maxDelta)
0187   uiwait(warndlg('''smallest c-s delta'' must be smaller than ''largest c-s delta''!',...
0188                  'Please correct!','modal'));
0189   return;
0190 end
0191 uiresume(handles.figure1);

Generated on Thu 18-Jul-2013 06:10:46 by m2html © 2005