IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
uip_gridsearch.m
Go to the documentation of this file.
1 %> @ingroup guigroup
2 %> @file
3 %> @brief Grid Search Properties Window
4 %>
5 %> @sa gridsearch
6 
7 %> @cond
8 function varargout = uip_gridsearch(varargin)
9 % Begin initialization code - DO NOT EDIT
10 gui_Singleton = 0;
11 gui_State = struct('gui_Name', mfilename, ...
12  'gui_Singleton', gui_Singleton, ...
13  'gui_OpeningFcn', @uip_gridsearch_OpeningFcn, ...
14  'gui_OutputFcn', @uip_gridsearch_OutputFcn, ...
15  'gui_LayoutFcn', [] , ...
16  'gui_Callback', []);
17 if nargin && ischar(varargin{1})
18  gui_State.gui_Callback = str2func(varargin{1});
19 end
20 
21 if nargout
22  [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
23 else
24  gui_mainfcn(gui_State, varargin{:});
25 end
26 % End initialization code - DO NOT EDIT
27 
28 % --- Executes just before uip_gridsearch is made visible.
29 function uip_gridsearch_OpeningFcn(hObject, eventdata, handles, varargin)
30 handles.output.flag_ok = 0;
31 handles.names_log_mold = {};
32 guidata(hObject, handles);
33 gui_set_position(hObject);
34 refresh(handles);
35 
36 % --- Outputs from this function are returned to the command line.
37 function varargout = uip_gridsearch_OutputFcn(hObject, eventdata, handles)
38 try
39  uiwait(handles.figure1);
40  handles = guidata(hObject); % Handles is not a handle(!), so gotta retrieve it again to see changes in .output
41  varargout{1} = handles.output;
42  delete(gcf);
43 catch %#ok<*CTCH>
44  output.flag_ok = 0;
45  output.params = {};
46  varargout{1} = output;
47 end;
48 
49 
50 %-----------------------------------------------------------------------------------------------------------
51 
52 %############
53 function refresh(handles)
54 
55 % logs
56 listbox_load_from_workspace('ttlog', handles.listbox_log_mold, 0);
57 v = get(handles.listbox_log_mold, 'Value');
58 if sum(v > length(handles.names_log_mold)) > 0 && ~isempty(handles.names_log_mold)
59  set(handles.listbox_log_mold, 'Value', 1);
60 end;
61 set(handles.edit_log_mold, 'String', handles.names_log_mold);
62 
63 % others
64 listbox_load_from_workspace('block', handles.popupmenu_postpr_est, 1, {'Use default decider', 'Leave blank'});
65 listbox_load_from_workspace('block', handles.popupmenu_postpr_test, 1, 'Leave blank');
66 listbox_load_from_workspace({'block_cascade_base', 'clssr'}, handles.popupmenu_clssr, 0);
67 listbox_load_from_workspace('chooser', handles.popupmenu_chooser, 1, 'Use default');
68 listbox_load_from_workspace('sgs', handles.popupmenu_sgs, 1, 'Use none');
69 
70 local_show_description(handles, []);
71 
72 %############
73 function local_show_description(handles, listbox)
74 if isempty(listbox)
75  set(handles.edit_description, 'String', {});
76 end;
77 show_description(listbox, handles.edit_description);
78 
79 
80 %-----------------------------------------------------------------------------------------------------------
81 
82 
83 % --- Executes on button press in pushbuttonOk.
84 function pushbuttonOk_Callback(hObject, eventdata, handles)
85 try
86  ssgs = listbox_get_selected_1stname(handles.popupmenu_sgs);
87  if isempty(ssgs)
88  ssgs = '[]';
89  end;
90  schooser = listbox_get_selected_1stname(handles.popupmenu_chooser);
91  if isempty(schooser)
92  schooser = '[]';
93  end;
94  spostpr_test = listbox_get_selected_1stname(handles.popupmenu_postpr_test);
95  if isempty(spostpr_test)
96  spostpr_test = '[]';
97  end;
98  spostpr_est = listbox_get_selected_1stname(handles.popupmenu_postpr_est);
99  if isempty(spostpr_est)
100  if get(handles.popupmenu_postpr_est, 'Value') == 1
101  spostpr_est = 'decider()';
102  else
103  spostpr_est = '[]';
104  end;
105  end;
106  sclssr = listbox_get_selected_1stname(handles.popupmenu_clssr);
107  if isempty(sclssr)
108  irerror('Classifier not specified!');
109  end;
110 
111  if isempty(handles.names_log_mold)
112  % irerror('No mold Train-Test Logs specified!');
113  end;
114 
115  s = get(handles.edit_paramspecs, 'String');
116 
117  % Effort to make s into something that can be eval()'ed
118  if iscell(s)
119  s = sprintf('%s\n', s{:});
120  end;
121  if size(s, 1) > 1
122  s(:, end+1) = 10; % line feed
123  s = reshape(s', 1, numel(s));
124  end;
125 
126  handles.output.params = {...
127  'sgs', ssgs, ...
128  'clssr', sclssr, ...
129  'chooser', schooser, ...
130  'postpr_test', spostpr_test, ...
131  'postpr_est', spostpr_est, ...
132  'log_mold', params2str2(handles.names_log_mold) ...
133  'no_refinements', int2str(eval(fel(get(handles.edit_no_iterations, 'String')))), ...
134  'maxmoves', int2str(eval(fel(get(handles.edit_maxtries, 'String')))), ...
135  'paramspecs', cell2str(eval(s)), ...
136  'flag_parallel', int2str(get(handles.checkbox_flag_parallel, 'Value')), ...
137  };
138  handles.output.flag_ok = 1;
139  guidata(hObject, handles);
140  uiresume();
141 catch ME
142  irerrordlg(ME.message, 'Cannot continue');
143  rethrow(ME);
144 end;
145 
146 %#####
147 function listbox_log_mold_Callback(hObject, eventdata, handles) %#ok<*INUSL,*DEFNU>
148 local_show_description(handles, handles.listbox_log_mold);
149 
150 %#####
151 function pushbutton_log_mold_add_Callback(hObject, eventdata, handles)
152 nn = listbox_get_selected_1stname(handles.listbox_log_mold);
153 if ~isempty(nn)
154  handles.names_log_mold{end+1} = nn;
155  guidata(hObject, handles);
156  refresh(handles);
157 end;
158 
159 %#####
160 function pushbutton_log_mold_restart_Callback(hObject, eventdata, handles)
161 set(handles.edit_log_mold, 'String', {});
162 handles.names_log_mold = [];
163 guidata(hObject, handles);
164 refresh(handles);
165 
166 %#####
167 function popupmenu_clssr_Callback(hObject, eventdata, handles)
168 local_show_description(handles, handles.popupmenu_clssr);
169 
170 %#####
171 function popupmenu_postpr_test_Callback(hObject, eventdata, handles)
172 local_show_description(handles, handles.popupmenu_postpr_test);
173 
174 %#####
175 function popupmenu_postpr_est_Callback(hObject, eventdata, handles)
176 local_show_description(handles, handles.popupmenu_postpr_est);
177 
178 %#####
179 function popupmenu_sgs_Callback(hObject, eventdata, handles)
180 local_show_description(handles, handles.popupmenu_sgs);
181 
182 %#####
183 function popupmenu_chooser_Callback(hObject, eventdata, handles)
184 local_show_description(handles, handles.popupmenu_chooser);
185 %-------------------------------------------------------------------------------
186 
187 
188 %#####
189 function pushbutton_t_knn_Callback(hObject, eventdata, handles)
190 set(handles.edit_paramspecs, 'string', sprintf('{''k'', 1:2:20, 0}'));
191 
192 %#####
193 function pushbutton_t_svm_Callback(hObject, eventdata, handles)
194 set(handles.edit_paramspecs, 'string', sprintf('{''c'', 10.^[-1:2:7], 1; ...\n''gamma'', 10.^[-7:2:1], 1}'));
195 
196 %#####
197 function pushbutton_t_pcasvm_Callback(hObject, eventdata, handles)
198 set(handles.edit_paramspecs, 'string', sprintf('{''blocks{1}.no_factors'', 10:10:100, 0; ...\n''blocks{2}.c'', 10.^[-1:2:7], 1; ...\n''blocks{2}.gamma'', 10.^[-7:2:1], 1}'));
199 
200 
201 function popupmenu_sgs_CreateFcn(hObject, eventdata, handles)
202 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
203  set(hObject,'BackgroundColor','white');
204 end
205 function checkbox_flag_parallel_Callback(hObject, eventdata, handles)
206 function popupmenu_clssr_CreateFcn(hObject, eventdata, handles)
207 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
208  set(hObject,'BackgroundColor','white');
209 end
210 function popupmenu_chooser_CreateFcn(hObject, eventdata, handles)
211 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
212  set(hObject,'BackgroundColor','white');
213 end
214 function edit_no_iterations_Callback(hObject, eventdata, handles)
215 function edit_no_iterations_CreateFcn(hObject, eventdata, handles)
216 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
217  set(hObject,'BackgroundColor','white');
218 end
219 function edit_paramspecs_Callback(hObject, eventdata, handles)
220 function edit_paramspecs_CreateFcn(hObject, eventdata, handles)
221 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
222  set(hObject,'BackgroundColor','white');
223 end
224 function edit_description_Callback(hObject, eventdata, handles) %#ok<*INUSD>
225 function edit_description_CreateFcn(hObject, eventdata, handles)
226 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
227  set(hObject,'BackgroundColor','white');
228 end
229 function popupmenu_postpr_test_CreateFcn(hObject, eventdata, handles)
230 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
231  set(hObject,'BackgroundColor','white');
232 end
233 function popupmenu_postpr_est_CreateFcn(hObject, eventdata, handles)
234 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
235  set(hObject,'BackgroundColor','white');
236 end
237 function edit_block_mold_Callback(hObject, eventdata, handles)
238 function edit_block_mold_CreateFcn(hObject, eventdata, handles)
239 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
240  set(hObject,'BackgroundColor','white');
241 end
242 function listbox_log_mold_CreateFcn(hObject, eventdata, handles)
243 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
244  set(hObject,'BackgroundColor','white');
245 end
246 function edit_log_mold_Callback(hObject, eventdata, handles)
247 function edit_log_mold_CreateFcn(hObject, eventdata, handles)
248 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
249  set(hObject,'BackgroundColor','white');
250 end
251 function listbox_block_mold_CreateFcn(hObject, eventdata, handles)
252 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
253  set(hObject,'BackgroundColor','white');
254 end
255 function edit_maxtries_Callback(hObject, eventdata, handles)
256 function edit_maxtries_CreateFcn(hObject, eventdata, handles)
257 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
258  set(hObject,'BackgroundColor','white');
259 end
260 %> @endcond
Base Sub-dataset Generation Specification (SGS) class.
Definition: sgs.m:6
function irerror(in s)
function show_description(in h_list, in h_edit)
function listbox_get_selected_1stname(in h_listbox)
Block that resolves estimato posterior probabilities into classes.
Definition: decider.m:10
Base Block class.
Definition: block.m:2
Classifiers base class.
Definition: clssr.m:6
function listbox_load_from_workspace(in classname, in h_list, in flag_blank, in string_empty, in input)
function gui_set_position(in hObject)
Grid Search.
Definition: gridsearch.m:20