IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
objtool.m
Go to the documentation of this file.
1 %>@ingroup guigroup mainguis
2 %>@file
3 %>@brief Object browser
4 %>
5 %> Please read IRootLab manual chapter on objtool (available at http://irootlab.googlecode.com)
6 %
7 %> @param classname='irdata'
8 function varargout = objtool(varargin)
9 % Last Modified by GUIDE v2.5 11-Nov-2012 11:16:48
10 
11 % Begin initialization code - DO NOT EDIT
12 gui_Singleton = 1;
13 gui_State = struct('gui_Name', mfilename, ...
14  'gui_Singleton', gui_Singleton, ...
15  'gui_OpeningFcn', @objtool_OpeningFcn, ...
16  'gui_OutputFcn', @objtool_OutputFcn, ...
17  'gui_LayoutFcn', [] , ...
18  'gui_Callback', []);
19 if nargin && ischar(varargin{1})
20  gui_State.gui_Callback = str2func(varargin{1});
21 end
22 
23 if nargout
24  [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
25 else
26  gui_mainfcn(gui_State, varargin{:});
27 end
28 % End initialization code - DO NOT EDIT
29 
30 %> @cond
31 % --- Executes just before objtool is made visible.
32 function objtool_OpeningFcn(hObject, eventdata, handles, varargin) %#ok<*INUSL>
33 handles.output = hObject;
34 
35 % Default parameters
36 if nargin < 3+1
37  varargin{1} = 'irdata';
38 end;
39 
40 % Initializes classes list
41 handles.classes = {'irdata', 'block', 'pre', 'fcon', 'fsel', 'clssr', 'block_cascade_base', 'sgs', 'fsg', 'peakdetector', 'irlog', 'as', 'vectorcomp', 'soitem'};
42 
43 
44 handles.flag_new = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; % Only irdata cannot be created here
45 for i = 1:length(handles.classes)
46  o = eval([handles.classes{i} ';']);
47  handles.classtitles{i} = o.classtitle;
48 end;
49 [handles.classtitles, ii] = sort(handles.classtitles);
50 handles.classes = handles.classes(ii);
51 handles.flag_new = handles.flag_new(ii);
52 idx = find(strcmp(varargin{1}, handles.classes));
53 if isempty(idx)
54  irerror(sprintf('Class ''%s'' not in list!', s));
55 end;
56 handles.input.rootclassname = varargin{1};
57 handles.input.flag_modal = 0;
58 handles.databuttonclass = 'vis'; % default data button to be down
59 handles.modebutton = 'properties'; % default mode button to be down
60 guidata(hObject, handles);
61 
62 guidata(hObject, handles);
63 set_class(idx);
64 handles = guidata(hObject);
65 
66 fig_assert();
67 gui_set_position(hObject);
68 guidata(hObject, handles);
69 setup_load();
70 
71 refresh();
72 move_popup(idx);
73 
74 check_hsc()
75 % handles = guidata(hObject);
76 % handles.K1 =
77 
78 
79 function varargout = objtool_OutputFcn(hObject, eventdata, handles)
80 
81 if handles.input.flag_modal
82  try
83  uiwait(handles.figure1);
84  handles = guidata(hObject);
85  varargout{1} = handles.output;
86  delete(gcf);
87  catch %#ok<CTCH>
88  output.flag_ok = 0;
89  varargout{1} = output;
90  end;
91 else
92  % Get default command line output from handles structure
93  varargout{1} = handles.output;
94 end;
95 
96 
97 
98 
99 %##########################################################################
100 %##########################################################################
101 % Auxiliary functions
102 
103 %%%%%%%%%%%
104 % Getters %
105 %%%%%%%%%%%
106 
107 %#####
108 function handles = find_handles()
109 H = findall(0, 'Name', 'objtool');
110 if isempty(H)
111  irerror('objtool not open');
112 end;
113 handles = guidata(H);
114 
115 
116 %#####
117 function a = get_selected_names()
118 handles = find_handles();
119 a = listbox_get_selected_names(handles.listbox_objects);
120 
121 %#####
122 function a = get_selected_names2()
123 handles = find_handles();
124 a = listbox_get_selected_names(handles.listbox_blocks);
125 
126 %#####
127 function s = get_selected_1stname()
128 handles = find_handles();
129 s = listbox_get_selected_1stname(handles.listbox_objects);
130 
131 %#####
132 function s = get_selected_1stname2()
133 handles = find_handles();
134 s = listbox_get_selected_1stname(handles.listbox_blocks);
135 
136 
137 
138 
139 
140 
141 
142 %###############
143 % Refreshments %
144 %###############
145 
146 %#####
147 function refresh()
148 read_classes();
149 refresh_modebuttons();
150 refresh_left();
151 
152 %#####
153 function refresh_left()
154 handles = find_handles();
155 set(handles.listbox_classes, 'String', handles.strings_classes);
156 refresh_class();
157 refresh_middle();
158 
159 %#####
160 function refresh_middle()
161 handles = find_handles();
162 listbox_load_from_workspace(handles.rootclassname, handles.listbox_objects);
163 refresh_right();
164 
165 %#####
166 function refresh_right()
167 handles = find_handles();
168 objtool_status();
169 switch handles.modebutton
170  case 'actions'
171  refresh_actionspanel();
172  case 'blocks'
173  refresh_blockspanel();
174  case 'properties'
175  refresh_propertiespanel();
176 end;
177 
178 %#####
179 % Updates GUI to reflect the class that is currently selected
180 % - GUI color
181 % - "New" button (enabled/disabled)
182 function refresh_class()
183 handles = find_handles();
184 onoff = {'off', 'on'};
185 s = handles.rootclassname;
186 o = eval([s ';']);
187 set(handles.figure1, 'Color', o.color);
188 idx = find(strcmp(handles.classes, handles.rootclassname));
189 % set(handles.pushbutton_obj_new, 'Enable', onoff{handles.flag_new(idx)+1});
190 
191 
192 if handles.flag_new(idx) %#ok<FNDSB>
193  % New...
194  set(handles.pushbutton_obj_new, 'String', 'New...');
195  set(handles.pushbutton_obj_save, 'Visible', 'off');
196  p = get(handles.pushbutton_obj_rename, 'position');
197  p(1) = 0.209375;
198  set(handles.pushbutton_obj_rename, 'position', p);
199  p = get(handles.pushbutton_obj_clear, 'position');
200  p(1) = .45;
201  set(handles.pushbutton_obj_clear, 'position', p);
202 else
203  % Load...; Save...
204  set(handles.pushbutton_obj_new, 'String', 'Load...');
205  set(handles.pushbutton_obj_save, 'Visible', 'on');
206  p = get(handles.pushbutton_obj_rename, 'position');
207  p(1) = 0.434375;
208  set(handles.pushbutton_obj_rename, 'position', p);
209  p = get(handles.pushbutton_obj_clear, 'position');
210  p(1) = 0.671875;
211  set(handles.pushbutton_obj_clear, 'position', p);
212 end;
213 set(handles.uipanel_middle, 'Title', sprintf('Existing objects of class "%s"', s));
214 
215 
216 %#####
217 % Updates the up/down status of the mode buttons and visibility of corresponding panel
218 function refresh_modebuttons()
219 handles = find_handles();
220 guys = {'actions', 'blocks', 'properties'};
221 for i = 1:numel(guys)
222  flag = strcmp(handles.modebutton, guys{i});
223  set(handles.(['togglebutton_', guys{i}]), 'value', flag);
224  set(handles.(['uipanel_', guys{i}]), 'visible', iif(flag, 'on', 'off'));
225 end;
226 
227 
228 %#####
229 % Refreshes actions panel completely
230 function refresh_actionspanel()
231 refresh_databuttons();
232 read_actions();
233 filter_actions();
234 populate_actions();
235 read_moreactions();
236 populate_moreactions();
237 
238 %#####
239 % Refreshes blocks panel
240 function refresh_blockspanel()
241 handles = find_handles();
242 objname = get_selected_1stname();
243 if ~isempty(objname)
244  obj = evalin('base', [objname, ';']);
245  a = get_varnames('block', obj);
246 else
247  a = {'(none)'};
248 end;
249 if any(get(handles.listbox_blocks, 'Value') > numel(a))
250  set(handles.listbox_blocks, 'Value', 1);
251 end;
252 set(handles.listbox_blocks, 'string', a);
253 
254 %#####
255 % Refreshes properties panel
256 function refresh_propertiespanel()
257 handles = find_handles();
258 show_description(handles.listbox_objects, handles.edit_properties);
259 
260 %#####
261 % Adjusts
262 % - listbox_actions height,
263 % - data buttons visibility, and
264 % - selected data button "down" status
265 % according to handles.flag_databuttons, handles.handles.databuttonclass
266 function refresh_databuttons()
267 handles = find_handles();
268 flag = handles.flag_databuttons;
269 hei = iif(flag, 0.5114678899082569, 0.573394495412844);
270 guys = {'as', 'fext', 'clus', 'pre', 'fcon', 'fsel', 'blmisc', 'block', 'block_cascade_base', 'vis'};
271 s_flag = iif(flag, 'on', 'off');
272 for i = 1:numel(guys)
273  set(handles.(['pushbutton_', guys{i}]), 'Visible', s_flag);
274  if flag
275  set(handles.(['pushbutton_', guys{i}]), 'Value', strcmp(handles.databuttonclass, guys{i}));
276  end;
277 end;
278 p = get(handles.listbox_actions, 'position');
279 p(4) = hei;
280 set(handles.listbox_actions, 'position', p);
281 
282 %#####
283 function refresh_sliders()
284 handles = find_handles();
285 
286 h1 = handles.uipanel_left;
287 p1 = get(h1, 'position');
288 h2 = handles.uipanel_middle;
289 p2 = get(h2, 'position');
290 h3 = handles.uipanel_right;
291 p3 = get(h3, 'position');
292 
293 
294 
295 
296 % K1 = 0.42;
297 % K2 = 0.
298 
299 psl1 = get(handles.slider1, 'position');
300 psl2 = get(handles.slider2, 'position');
301 
302 mark1 = psl1(3)*get(handles.slider1, 'Value')/get(handles.slider1, 'Max') ;
303 mark2 = psl2(1)+psl2(3)*get(handles.slider2, 'Value')/get(handles.slider2, 'Max');
304 
305 % mark2 = 0.5+0.79*get(handles.slider2, 'Value')/get(handles.slider2, 'Max');
306 
307 p1(3) = mark1;
308 set(h1, 'position', p1);
309 
310 p2(1) = mark1;
311 p2(3) = mark2-mark1;
312 set(h2, 'position', p2);
313 
314 p3(1) = mark2;
315 p3(3) = psl2(1)+psl2(3)-mark2;
316 set(h3, 'position', p3);
317 
318 
319 
320 
321 
322 
323 
324 
325 
326 
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328 % Non-visual, handles-changing %
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 
331 %#####
332 function set_class(idx)
333 handles = find_handles();
334 s = handles.classes{idx};
335 handles.rootclassname = s;
336 handles.flag_databuttons = strcmp(s, 'irdata');
337 guidata(handles.figure1, handles);
338 
339 %#####
340 % Reads class list with counts
341 function read_classes()
342 handles = find_handles();
343 a = handles.classtitles;
344 oldcounts = [];
345 if isfield(handles, 'classcounts')
346  oldcounts = handles.classcounts;
347 end;
348 aa = get_varnames2(handles.classes);
349 for i = 1:numel(a)
350  counts(i) = numel(aa{i});
351  s = iif(~isempty(oldcounts) && oldcounts(i) < counts(i), ' **', '');
352  a{i} = [a{i}, ' (', s, int2str(counts(i)), s, ')'];
353 end;
354 handles.strings_classes = a;
355 handles.classcounts = counts;
356 guidata(handles.figure1, handles);
357 
358 %#####
359 % Reads actions into handles
360 function read_actions()
361 handles = find_handles();
362 classname = iif(handles.flag_databuttons, handles.databuttonclass, 'block'); % This may come from somewhere else, later
363 objname = get_selected_1stname();
364 if ~isempty(objname)
365  obj = evalin('base', [objname, ';']);
366  list = classmap_get_list(classname, class(obj));
367  a = itemlist2cell(list);
368 else
369  list = [];
370  a = {'(none)'};
371 end;
372 handles.a = a;
373 handles.al = lower(a); % for filtering
374 handles.actionslist = list;
375 handles.idxs_in = 1:numel(list); % Indexes of list elements to show
376 guidata(handles.figure1, handles);
377 
378 %#####
379 % Makes handles.idxs_in
380 function filter_actions()
381 handles = find_handles();
382 filter = fel(get(handles.edit_filter, 'String'));
383 if ~isempty(filter)
384  filter = lower(filter);
385  idxs = find(cellfun(@(x) (~isempty(x)), cellfun(@(x) (findstr(filter, x)), handles.al, 'UniformOutput', 0))); %#ok<FSTR>
386  b = zeros(1, numel(handles.a));
387  for i = 1:numel(idxs)
388  if handles.actionslist(idxs(i)).flag_final
389  b(idxs(i)) = 1;
390  ob = handles.actionslist(idxs(i));
391  while 1
392  if ob.level == 1
393  break;
394  end;
395  ob = handles.actionslist(ob.parentindex);
396  b(ob.index) = 1;
397  end;
398  end;
399  end;
400  handles.idxs_in = find(b);
401 else
402  handles.idxs_in = 1:numel(handles.a);
403 end;
404 guidata(handles.figure1, handles);
405 
406 %#####
407 % Reads moreactions into handles
408 function read_moreactions()
409 handles = find_handles();
410 blockname = get_selected_1stname();
411 ma = {};
412 if ~isempty(blockname)
413  block = evalin('base', [blockname, ';']);
414  cla = class(block);
415  freshobj = eval([cla, ';']);
416  ma = unique(freshobj.moreactions);
417  la = ma;
418 end;
419 if isempty(ma)
420  la = [];
421  ma = {'(none)'};
422 end;
423 handles.moreactions_methods = la; % Keeps list of methods for reference
424 handles.moreactions_descriptions = ma; % Keeps list of methods for reference
425 guidata(handles.figure1, handles);
426 
427 
428 
429 
430 
431 
432 
433 
434 
435 %%%%%%%%%%%%%%%%%%%%%
436 % Dumb GUI updaters %
437 %%%%%%%%%%%%%%%%%%%%%
438 % (these functions don't know why they are doing what they are doing)
439 
440 %#####
441 % Populates actions listbox
442 function populate_actions()
443 handles = find_handles();
444 if get(handles.listbox_actions, 'Value') > numel(handles.idxs_in)
445  set(handles.listbox_actions, 'Value', 1);
446 end;
447 set(handles.listbox_actions, 'String', handles.a(handles.idxs_in));
448 
449 %#####
450 % Populates moreactions listbox
451 function populate_moreactions()
452 handles = find_handles();
453 ma = handles.moreactions_descriptions;
454 if get(handles.listbox_moreactions, 'Value') > numel(ma)
455  set(handles.listbox_moreactions, 'Value', 1);
456 end;
457 set(handles.listbox_moreactions, 'String', ma);
458 
459 %#####
460 function move_popup(idx)
461 handles = find_handles();
462 set(handles.listbox_classes, 'Value', idx);
463 
464 %#########
465 function objtool_status(s)
466 handles = find_handles();
467 if nargin < 1
468  s = '';
469 end;
470 set(handles.text_status, 'String', s);
471 
472 
473 
474 
475 
476 %%%%%%%%%%%%%%%%%%%%%
477 % Callback handlers %
478 %%%%%%%%%%%%%%%%%%%%%
479 % (These functions to everything that needs to be done in response to some user's action)
480 
481 %#####
482 function do_moreactions()
483 handles = find_handles();
484 if ~isempty(handles.moreactions_methods)
485  v = get(handles.listbox_moreactions, 'Value');
486  if v > 0
487  s_action = handles.moreactions_methods{v};
488  blockname = get_selected_1stname();
489  try
490  og = gencode();
491  og.blockname = blockname;
492  og.flag_leave_block = 0;
493  og = og.start();
494  og = og.m_generic(s_action);
495  og = og.finish(); %#ok<NASGU>
496  refresh();
497  catch ME
498  refresh();
499  objtool_status(ME.message);
500  send_error(ME);
501  end;
502  end;
503 end;
504 
505 %#####
506 function do_actions(what)
507 handles = find_handles();
508 if ~isempty(handles.idxs_in)
509  v = get(handles.listbox_actions, 'Value');
510  if v > 0
511  which = handles.idxs_in(v);
512  item = handles.actionslist(which);
513  if ~item.flag_final
514  msgbox('Please select a deepest-level option!');
515  else
516  classname = handles.actionslist(which).name;
517  try
518  objnames = get_selected_names();
519  objs = cellfun(@(objname) (evalin('base', [objname, ';'])), objnames, 'UniformOutput', 0);
520  if numel(objs) == 1
521  objs = objs{1};
522  end;
523  vis = eval([classname, ';']);
524  result = vis.get_params(objs);
525 
526  if result.flag_ok
527  og = gencode();
528  og.classname = classname;
529  og.dsnames = objnames;
530  og.params = result.params;
531  og.flag_leave_block = 1;
532 
533  try
534  og = og.start();
535  og = og.m_create();
536  og = og.m_boot();
537  if any(what == 't')
538  og = og.m_train();
539  end;
540  if any(what == 'u')
541  og = og.m_use();
542  end;
543  og.finish();
544  % There is no need to refresh, because we don't expect the workspace to change out of visualization
545  catch ME
546  % refresh();
547  rethrow(ME);
548  end;
549  end;
550  refresh();
551  catch ME
552  refresh();
553  objtool_status(ME.message);
554  send_error(ME);
555  end;
556  end;
557  end;
558 end;
559 
560 
561 %#####
562 function do_block(what)
563 blockname = get_selected_1stname2();
564 if ~isempty(blockname)
565  try
566  dsnames = get_selected_names();
567 
568  og = gencode();
569  og.blockname = blockname;
570  og.dsnames = dsnames;
571  og.flag_leave_block = 0;
572  og = og.start();
573  if ismember(what, {'boot', 'train', 'use'})
574  og = og.(['m_', what])();
575  else
576  og = og.m_generic(what);
577  end;
578  og = og.finish(); %#ok<NASGU>
579  refresh();
580  catch ME
581  refresh();
582  objtool_status(ME.message);
583  send_error(ME);
584  end;
585 else
586  objtool_status('Cannot do anything: no block selected!');
587 end;
588 
589 
590 %#####
591 function set_databutton(s)
592 objtool_status();
593 handles = find_handles();
594 handles.databuttonclass = s;
595 guidata(handles.figure1, handles);
596 read_actions();
597 filter_actions();
598 populate_actions();
599 refresh_databuttons();
600 
601 %#####
602 function set_modebutton(s)
603 handles = find_handles();
604 handles.modebutton = s;
605 guidata(handles.figure1, handles);
606 refresh_modebuttons();
607 refresh_right();
608 
609 
610 %#####
611 function do_new()
612 objtool_status();
613 handles = find_handles();
614 idx = find(strcmp(handles.classes, handles.rootclassname));
615 if handles.flag_new(idx) %#ok<FNDSB>
616  r = do_blockmenu(handles.rootclassname, [], 1);
617  if r.flag_ok
618  try
619  og = r.og;
620  og = og.start();
621  og = og.m_create();
622  og = og.finish();
623  refresh();
624  catch ME
625  refresh();
626  objtool_status(ME.message);
627  send_error(ME);
628  end;
629  end;
630 else
631  % Load data
632 
633  path_assert();
634  global PATH; %#ok<*TLEV>
635  global ATRTOOL_LOAD_OK ATRTOOL_LOAD_RANGE;
636  try
637 % % % types = {'mat', 'txt'};
638  [name, path, filterindex] = uigetfile({'*.*', 'Auto-detect file type'; ...
639  '*.*', 'MAT IRootLab format'; ...
640  '*.*', 'TXT IRootLab format'; ...
641  '*.*', 'TXT "Pirouette-like" format'; ...
642  '*.*', 'TXT Basic format'; ...
643  '*.*', 'OPUS FPA image format (image)'; ...
644  '*.*', 'DPT Data point table format (image)'; ...
645  '*.*', 'TXT "Pirouette-like" format (image)'; ...
646  '*.*', 'TXT Basic format (image)'; ...
647  }, 'Select file to open', PATH.data_load); %#ok<*NASGU>
648  if name > 0
649  flag_continue = 1;
650  name_full = fullfile(path, name);
651  if filterindex == 1
652  classname = detect_file_type(name_full);
653  if isempty(classname)
654  irerrordlg(sprintf('Could not detect type of file ''%s''', name), 'Sorry');
655  flag_continue = 0;
656  end;
657  else
658  suff = {'mat', 'txt_irootlab', 'txt_pir', 'txt_basic', 'opus_nasse', 'txt_dpt', ...
659  'txt_pir_image', 'txt_basic_image'};
660  classname = ['dataio_', suff{filterindex-1}];
661  end;
662 
663  % Either way, will update the path
664  PATH.data_load = path;
665  setup_write();
666 
667  if flag_continue
668  oio = eval(classname);
669  oio.filename = name_full;
670 % % % % %
671 % % % % % % Very old code to ask for wavenumber range for TXT Basic format
672 % % % % % s_range = '';
673 % % % % % if ~oio.flag_xaxis
674 % % % % % datatool_fearange();
675 % % % % % if ~isempty(ATRTOOL_LOAD_OK)
676 % % % % % s_range = '';
677 % % % % % if ~isempty(ATRTOOL_LOAD_RANGE)
678 % % % % % s_range = [mat2str(ATRTOOL_LOAD_RANGE)]; %#ok<NBRAK>
679 % % % % % end;
680 % % % % % else
681 % % % % % flag_continue = 0;
682 % % % % % end;
683 % % % % % end;
684 % % % % % end;
685 % % % % %
686 % % % % if flag_continue
687 
688 
689  % UIP dialog
690  yetmore = '';
691  pp = oio.get_params(oio);
692  if ~pp.flag_ok
693  flag_continue = 0;
694  else
695  if numel(pp.params) > 0
696  eval(['oio = oio.setbatch(', params2str(pp.params), ');']); % Why this line? Check for errors?
697  yetmore = ['o = o.setbatch(', params2str(pp.params), ');', 10];
698  end;
699  end;
700  end;
701 
702  if flag_continue
703  name_new = find_varname('ds');
704  code = sprintf('o = %s();\no.filename = ''%s'';\n%s%s = o.load();\n', classname, name_full, yetmore, name_new);
705 
706  ircode_eval(code, 'Dataset load');
707  refresh();
708 
709  end;
710  end;
711 
712  catch ME
713  refresh();
714  objtool_status(ME.message);
715  send_error(ME);
716  end;
717 end;
718 
719 
720 
721 
722 %#########################################
723 %#########################################
724 
725 %#####
726 function listbox_classes_Callback(hObject, eventdata, handles)
727 if strcmp(get(handles.figure1, 'SelectionType'), 'open') % This is how you detect a double-click in MATLAB
728  do_new();
729 else
730  set_class(get(handles.listbox_classes, 'Value'));
731  refresh_class();
732  refresh_middle();
733 end;
734 
735 %#####
736 function listbox_objects_Callback(hObject, eventdata, handles)
737 refresh_right();
738 
739 %#####
740 function pushbuttonRefreshMS_Callback(hObject, eventdata, handles)
741 refresh();
742 
743 %#####
744 function pushbutton_obj_rename_Callback(hObject, eventdata, handles)
745 objtool_status();
746 s = get_selected_1stname();
747 if ~isempty(s)
748  try
749  rename_object(s);
750  refresh_middle();
751  catch ME
752  refresh_middle();
753  objtool_status(ME.message);
754  send_error(ME);
755  end;
756 end;
757 
758 %#####
759 function pushbutton_obj_clear_Callback(hObject, eventdata, handles)
760 objtool_status();
761 names = get_selected_names();
762 if ~isempty(names)
763  try
764  code = sprintf('clear %s;\n', sprintf('%s ', names{:}));
765  ircode_eval(code, 'Clearing objects');
766  refresh();
767  catch ME
768  refresh();
769  objtool_status(ME.message);
770  send_error(ME);
771  end;
772 end;
773 
774 %#####
775 function pushbutton_obj_new_Callback(hObject, eventdata, handles)
776 do_new();
777 
778 %#####
779 function togglebutton_actions_Callback(hObject, eventdata, handles)
780 set_modebutton('actions');
781 
782 %#####
783 function togglebutton_properties_Callback(hObject, eventdata, handles)
784 set_modebutton('properties');
785 
786 %#####
787 function listbox_actions_Callback(hObject, eventdata, handles)
788 if strcmp(get(handles.figure1, 'SelectionType'), 'open') % This is how you detect a double-click in MATLAB
789  do_actions('ctu');
790 end;
791 
792 %#####
793 function listbox_moreactions_Callback(hObject, eventdata, handles)
794 if strcmp(get(handles.figure1, 'SelectionType'), 'open') % This is how you detect a double-click in MATLAB
795  do_moreactions();
796 end;
797 
798 %#####
799 function pushbutton_create_defaults_Callback(hObject, eventdata, handles)
801 refresh();
802 
803 %#####
804 function edit_filter_Callback(hObject, eventdata, handles)
805 filter_actions();
806 populate_actions();
807 
808 %#####
809 function pushbutton_vis_Callback(hObject, eventdata, handles)
810 set_databutton('vis');
811 
812 %#####
813 function pushbutton_fcon_Callback(hObject, eventdata, handles)
814 set_databutton('fcon');
815 
816 %#####
817 function pushbutton_pre_Callback(hObject, eventdata, handles)
818 set_databutton('pre');
819 
820 %#####
821 function pushbutton_blmisc_Callback(hObject, eventdata, handles)
822 set_databutton('blmisc');
823 
824 %#####
825 function pushbutton_fsel_Callback(hObject, eventdata, handles)
826 set_databutton('fsel');
827 
828 %#####
829 function pushbutton_block_cascade_base_Callback(hObject, eventdata, handles)
830 set_databutton('block_cascade_base');
831 
832 %#####
833 function pushbutton_block_Callback(hObject, eventdata, handles)
834 set_databutton('block');
835 
836 %#####
837 function pushbutton_as_Callback(hObject, eventdata, handles)
838 set_databutton('as');
839 
840 %#####
841 function pushbutton_fext_Callback(hObject, eventdata, handles)
842 set_databutton('fext');
843 
844 %#####
845 function pushbutton_clus_Callback(hObject, eventdata, handles)
846 set_databutton('clus');
847 
848 %#####
849 function togglebutton_blocks_Callback(hObject, eventdata, handles)
850 set_modebutton('blocks');
851 
852 %#####
853 function listbox_blocks_Callback(hObject, eventdata, handles)
854 objtool_status();
855 if strcmp(get(handles.figure1, 'SelectionType'), 'open') % This is how you detect a double-click in MATLAB
856  do_block('use');
857 end;
858 
859 
860 %#####
861 function edit_properties_Callback(hObject, eventdata, handles)
862 objtool_status();
863 
864 %#####
865 function pushbutton_obj_save_Callback(hObject, eventdata, handles)
866 objtool_status();
867 path_assert();
868 global PATH;
869 dsname = get_selected_1stname();
870 if isempty(dsname)
871  objtool_status('No dataset to save!');
872  return;
873 end;
874 ds = evalin('base', [dsname ';']);
875 [pa, na, ex] = fileparts(ds.filename);
876 try
877  classnames = {'dataio_mat', 'dataio_txt_irootlab', 'dataio_txt_pir', 'dataio_txt_basic', 'dataio_txt_libsvm', 'dataio_txt_irootlab2'};
878  [name, path, filterindex] = uiputfile({'*.mat', 'MAT file (*.mat)'; ...
879  '*.txt', 'TXT file (IRootLab format) (*.txt)'; ...
880  '*.txt', 'TXT file (pir format) (*.txt)'; ...
881  '*.txt', 'TXT file (basic format) (*.txt)'; ...
882  '*.txt', 'TXT file (LIBSVM format) (*.txt)'; ...
883  '*.txt', 'TXT file (IRootLab format with labelled classes) (*.txt)'; ...
884  }, 'Save as', fullfile(PATH.data_save, [na, '.mat'])); % Extension is changed to "mat" because it is first option in menu
885 
886  if name > 0
887  filename = fullfile(path, name);
888  o = eval(classnames{filterindex}); % creates instance of some dataio class
889  o.filename = filename;
890  o.save(ds);
891 
892  % If reached this point, will celebrate and write the path as default data path to the setup file
893  PATH.data_save = path;
894  setup_write();
895  end;
896 catch ME
897  objtool_status(ME.message);
898  send_error(ME);
899 end;
900 
901 %#####
902 function pushbutton_filter_enter_Callback(hObject, eventdata, handles)
903 filter_actions();
904 populate_actions();
905 
906 %#####
907 function pushbutton_filter_clear_Callback(hObject, eventdata, handles)
908 set(handles.edit_filter, 'string', '');
909 filter_actions();
910 populate_actions();
911 
912 %#####
913 function pushbutton_block_clear_Callback(hObject, eventdata, handles)
914 objtool_status();
915 names = get_selected_names2();
916 if ~isempty(names)
917  try
918  code = sprintf('clear %s;\n', sprintf('%s ', names{:}));
919  ircode_eval(code, 'Clearing objects');
920  refresh();
921  catch ME
922  refresh();
923  objtool_status(ME.message);
924  send_error(ME);
925  end;
926 end;
927 
928 %#####
929 function pushbutton_block_use_Callback(hObject, eventdata, handles)
930 do_block('use');
931 
932 %#####
933 function pushbutton_block_train_Callback(hObject, eventdata, handles)
934 objtool_status('');
935 s = get_selected_1stname2();
936 if ~isempty(s)
937  o = evalin('base', [s, ';']); % gets object to see if it is trainable
938  if o.flag_trainable < 1
939  objtool_status('Cannot train: block not trainable!');
940  else
941  do_block('train');
942  end;
943 else
944  objtool_status('Cannot train: no block selected!');
945 end;
946 
947 %#####
948 function pushbutton_block_boot_Callback(hObject, eventdata, handles)
949 objtool_status('');
950 s = get_selected_1stname2();
951 if ~isempty(s)
952  o = evalin('base', [s, ';']); % gets object to see if it is bootable
953  if o.flag_bootable < 1
954  objtool_status('Cannot boot: block not bootable!');
955  else
956  do_block('boot');
957  end;
958 else
959  objtool_status('Cannot boot: no block selected!');
960 end;
961 
962 
963 %#####
964 function pushbutton_block_rename_Callback(hObject, eventdata, handles)
965 objtool_status();
966 s = get_selected_1stname2();
967 if ~isempty(s)
968  try
969  rename_object(s);
970  refresh_right();
971  catch ME
972  refresh_right();
973  objtool_status(ME.message);
974  send_error(ME);
975  end;
976 end;
977 
978 %#####
979 function pushbutton_actions_ct_Callback(hObject, eventdata, handles)
980 do_actions('ct');
981 
982 %#####
983 function pushbutton_actions_c_Callback(hObject, eventdata, handles)
984 do_actions('c');
985 
986 %#####
987 function pushbutton_actions_ctu_Callback(hObject, eventdata, handles)
988 do_actions('ctu');
989 
990 %#####
991 function pushbutton_moreactions_execute_Callback(hObject, eventdata, handles)
992 do_moreactions();
993 
994 %#####
995 %#####
996 function listbox_objects_CreateFcn(hObject, eventdata, handles)
997 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
998  set(hObject,'BackgroundColor','white');
999 end
1000 function listbox_classes_CreateFcn(hObject, eventdata, handles) %#ok<*INUSD,*DEFNU>
1001 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1002  set(hObject,'BackgroundColor','white');
1003 end
1004 function listbox_actions_CreateFcn(hObject, eventdata, handles)
1005 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1006  set(hObject,'BackgroundColor','white');
1007 end
1008 function listbox_moreactions_CreateFcn(hObject, eventdata, handles)
1009 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1010  set(hObject,'BackgroundColor','white');
1011 end
1012 function edit_filter_CreateFcn(hObject, eventdata, handles)
1013 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1014  set(hObject,'BackgroundColor','white');
1015 end
1016 function edit_filter_KeyPressFcn(hObject, eventdata, handles)
1017 function listbox_blocks_CreateFcn(hObject, eventdata, handles)
1018 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1019  set(hObject,'BackgroundColor','white');
1020 end
1021 function slider1_Callback(hObject, eventdata, handles)
1022 refresh_sliders();
1023 function slider1_CreateFcn(hObject, eventdata, handles)
1024 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1025  set(hObject,'BackgroundColor',[.9 .9 .9]);
1026 end
1027 function slider2_Callback(hObject, eventdata, handles)
1028 refresh_sliders();
1029 function slider2_CreateFcn(hObject, eventdata, handles)
1030 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1031  set(hObject,'BackgroundColor',[.9 .9 .9]);
1032 end
1033 function edit_properties_CreateFcn(hObject, eventdata, handles)
1034 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1035  set(hObject,'BackgroundColor','white');
1036 end
1037 %> @endcond
function classmap_get_list(in classname, in inputclass)
Clustering base class.
Definition: clus.m:2
function send_error(in ME)
Feature Selection (FSel) class.
Definition: fsel.m:4
function detect_file_type(in filename)
function irerror(in s)
Dataset class.
Definition: irdata.m:30
function objtool(in varargin)
function show_description(in h_list, in h_edit)
Property filename
Definition: dataio.m:12
function params2str(in params, in flag_o)
Visualization base class.
Definition: vis.m:4
function listbox_get_selected_1stname(in h_listbox)
Pre-processing block base class.
Definition: pre.m:2
Miscellaneous block.
Definition: blmisc.m:4
Feature Extraction (Fext) base class.
Definition: fext.m:4
Base Block class.
Definition: block.m:2
function m_generic(in o, in what)
function get_varnames(in classname, in input)
function check_hsc()
Feature Construction (FCon) base class.
Definition: fcon.m:2
function get_varnames2(in classnames)
function fel(in c, in n)
function iif(in cond, in x1, in x2)
function ircode_eval(in s, in title)
Dataset loader/saver common class.
Definition: dataio.m:2
Property classtitle
Class Title. Should have a descriptive name, as short as possible.
Definition: irobj.m:50
function listbox_load_from_workspace(in classname, in h_list, in flag_blank, in string_empty, in input)
function do_blockmenu(in classname, in dsnames, in flag_leave_block)
function listbox_get_selected_names(in h_listbox)
function setup_write()
function gui_set_position(in hObject)
function get_params(in o, in data)
Calls Parameters GUI.
function itemlist2cell(in list, in verboselevel, in style)
Converts an array of mapitem objects to a cell of indented strings.
Analysis Session (AS) base class.
Definition: as.m:6
function create_default_objects()
function path_assert()
function find_varname(in prefix)
function irerrordlg(in errorstring, in dlgname)
function fig_assert()
Cascade block: sequence of blocks represented by a block.
function rename_object(in s)
function setup_load()
MATLAB code generation to create, boot, train and use blocks.
Definition: gencode.m:9