1 %> @ingroup guigroup sheware mainguis
3 %> @brief datatool, see also @ref
objtool.m
4 %> @image html Screenshot-datatool.png
9 function varargout = datatool(varargin)
10 % Last Modified by GUIDE v2.5 08-Nov-2012 12:32:56
12 % Begin initialization code - DO NOT EDIT
14 gui_State =
struct(
'gui_Name', mfilename, ...
15 'gui_Singleton', gui_Singleton, ...
16 'gui_OpeningFcn', @datatool_OpeningFcn, ...
17 'gui_OutputFcn', @datatool_OutputFcn, ...
18 'gui_LayoutFcn', [] , ...
20 if nargin && ischar(varargin{1})
21 gui_State.gui_Callback = str2func(varargin{1});
25 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
27 gui_mainfcn(gui_State, varargin{:});
29 % End initialization code - DO NOT EDIT
31 % --- Executes just before datatool is made visible.
32 function datatool_OpeningFcn(hObject, eventdata, handles, varargin) %#ok<*INUSL>
34 % Choose
default command line output
for datatool
35 handles.output = hObject;
37 handles.which_listbox = [handles.listboxDatasets, handles.listboxBlocks];
40 % Update handles structure
41 guidata(hObject, handles);
43 % UIWAIT makes datatool wait
for user response (see UIRESUME)
44 % uiwait(handles.figure1);
46 global handles_datatool;
47 handles_datatool = handles;
48 handles_datatool.classname =
'irdata';
57 % --- Outputs from
this function are returned to the command line.
58 function varargout = datatool_OutputFcn(hObject, eventdata, handles)
59 varargout{1} = handles.output;
64 %##########################################################################
66 %##########################################################################
69 %######################################
73 function datatool_refresh(which)
74 global handles_datatool;
75 datatool_load_from_workspace();
76 datatool_show_description(which);
78 data = eval([handles_datatool.classname, ';']);
79 set(handles_datatool.figure1, 'Color', data.color);
83 function datatool_load_from_workspace()
84 global handles_datatool;
89 function datatool_status(s)
90 global handles_datatool;
91 set(handles_datatool.text_status, 'String', s);
95 function datatool_populate_block_more()
96 global handles_datatool;
97 blockname = get_selected_1stname(2);
98 a = {
'More Actions>>'};
99 if ~isempty(blockname)
100 block = evalin('base', [blockname, ';']);
101 ma = block.moreactions;
102 handles_datatool.block_moreactions = ma;
103 guidata(handles_datatool.figure1, handles_datatool);
108 if get(handles_datatool.popupmenuBlockMore,
'Value') > numel(a)
109 set(handles_datatool.popupmenuBlockMore,
'Value', 1);
111 set(handles_datatool.popupmenuBlockMore,
'String', a);
116 function datatool_show_description(which)
117 global handles_datatool;
118 show_description(handles_datatool.which_listbox(which), handles_datatool.editDescription);
120 datatool_populate_block_more();
124 function a = get_selected_names(which)
125 global handles_datatool;
129 function s = get_selected_1stname(which)
130 global handles_datatool;
134 %
######################################
135 % Applies block that still doesn
't exist.
136 function do_block(which, classname)
137 dsnames = get_selected_names(which);
140 r = do_blockmenu(classname, dsnames);
143 og.flag_leave_block = which == 1; % Will leave the block in the workspace only if the button if from the left (data) panel
157 datatool_status('No object, can
''t
do anything!
');
161 %######################################
162 %> This if for the "boot", "train", and "use" block options
163 function do_block2(what)
164 % global handles_datatool;
165 blockname = get_selected_1stname(2);
166 if ~isempty(blockname)
168 dsnames = get_selected_names(1);
171 og.blockname = blockname;
172 og.dsnames = dsnames;
173 og.flag_leave_block = 0;
175 if ismember(what, {'boot
', 'train
', 'use
'})
176 og = og.(['m_
', what])();
178 og = og.m_generic(what);
187 datatool_status('Cannot
do anything: there is no block!
');
191 %######################################
192 function change_class_from_edit()
193 global handles_datatool;
194 classname = get(handles_datatool.edit_class, 'String
');
197 data = eval([classname, ';
']);
201 s = sprintf('Class not accepted:
"%s"', ME.message);
207 handles_datatool.classname = classname;
208 guidata(handles_datatool.figure1, handles_datatool);
212 %##########################################################################
213 %##########################################################################
217 % --- Executes during object creation, after setting all properties.
218 function listboxDatasets_CreateFcn(hObject, eventdata, handles)
219 if ispc && isequal(get(hObject,'BackgroundColor
'), get(0,'defaultUicontrolBackgroundColor
'))
220 set(hObject,'BackgroundColor
','white
');
223 % --- Executes during object creation, after setting all properties.
224 function editDescription_CreateFcn(hObject, eventdata, handles)
226 function editDescription_Callback(hObject, eventdata, handles)
230 % --- Executes on button press in pushbuttonLoad.
231 function pushbuttonLoad_Callback(hObject, eventdata, handles) %#ok<*INUSD,*DEFNU>
235 global ATRTOOL_LOAD_OK ATRTOOL_LOAD_RANGE;
237 types = {'mat
', 'txt
'};
238 [name, path, filterindex] = uigetfile({'*.mat;*.txt
', 'Supported file types (*.mat;*.txt)
'; ...
239 '*.*
', 'All files (*.*)
'; ...
240 '*.mat
', 'MAT-files (*.mat)
'; ...
241 '*.txt
', 'TXT-files (*.txt)
'; ...
242 '*.0
', 'OPUS-files (*.txt)
'; ...
243 }, 'Select file to open
', PATH.data_load); %#ok<*NASGU>
245 name_full = fullfile(path, name);
246 classname = detect_file_type(name_full);
248 % Either way, will update the path
249 PATH.data_load = path;
252 if isempty(classname)
253 irerrordlg(sprintf('Could not detect type of file
''%s
''', name),
'Sorry');
255 oio = eval(classname);
260 if ~isempty(ATRTOOL_LOAD_OK)
262 if ~isempty(ATRTOOL_LOAD_RANGE)
263 s_range = [mat2str(ATRTOOL_LOAD_RANGE)]; %
#ok<NBRAK>
274 code = sprintf(
'o = %s();\no.filename = ''%s'';\n%s = o.load(%s);', classname, name_full, name_new, s_range);
288 % --- Executes on button press in pushbuttonRename.
289 function pushbuttonRename_Callback(hObject, eventdata, handles)
291 s = get_selected_1stname(1);
296 datatool_status('No dataset to rename!');
299 % --- Executes on selection change in listboxDatasets.
300 function listboxDatasets_Callback(hObject, eventdata, handles)
302 datatool_show_description(1);
304 % --- Executes on button press in pushbuttonClear.
305 function pushbuttonClear_Callback(hObject, eventdata, handles)
307 names = get_selected_names(1);
309 code = sprintf('clear %s;', sprintf('%s ', names{:}));
318 datatool_status(
'No dataset to clear!');
321 % --- Executes on button press in pushbuttonRefresh.
322 function pushbuttonRefresh_Callback(hObject, eventdata, handles)
326 % --- Executes on button press in pushbuttonVisualize.
327 function pushbuttonVisualize_Callback(hObject, eventdata, handles)
332 % --- Executes on button press in pushbuttonTransform.
333 function pushbuttonTransform_Callback(hObject, eventdata, handles)
337 % --- Executes on button press in pushbuttonPre.
338 function pushbuttonPre_Callback(hObject, eventdata, handles)
342 % --- Executes on button press in pushbuttonMisc.
343 function pushbuttonMisc_Callback(hObject, eventdata, handles)
347 % --- Executes on button press in pushbutton_fsel.
348 function pushbutton_fsel_Callback(hObject, eventdata, handles)
352 % --- Executes on button press in pushbuttonCascade.
353 function pushbuttonCascade_Callback(hObject, eventdata, handles)
358 % --- Executes on button press in pushbuttonSaveas.
359 function pushbuttonSaveas_Callback(hObject, eventdata, handles)
363 dsname = get_selected_1stname(1);
365 datatool_status('No dataset to save!');
368 ds = evalin('base', [dsname ';']);
370 [pa, na, ex] = fileparts(ds.filename);
373 classnames = {
'dataio_mat',
'dataio_txt_irootlab',
'dataio_txt_pir',
'dataio_txt_basic'};
374 [name, path, filterindex] = uiputfile({
'*.mat',
'MAT file (*.mat)'; ...
375 '*.txt',
'TXT file (IRootLab format) (*.txt)'; ...
376 '*.txt',
'TXT file (pir format) (*.txt)'; ...
377 '*.txt',
'TXT file (basic format) (*.txt)' ...
378 },
'Save as', fullfile(PATH.data_save, [na, ex]));
381 % ds.filename = fullfile(path, name)
382 % evalin(
'base', [dsname
'.filename = ''' ds.filename
''';
']);
383 filename = fullfile(path, name);
384 o = eval(classnames{filterindex}); % creates instance of some dataio class
385 o.filename = filename;
388 % If reached this point, will celebrate and write the path as default data path to the setup file
389 PATH.data_save = path;
397 % --- Executes on button press in pushbuttonBlockRename.
398 function pushbuttonBlockRename_Callback(hObject, eventdata, handles)
400 s = get_selected_1stname(2);
405 datatool_status('There is no block to rename!
');
408 % --- Executes on selection change in listboxBlocks.
409 function listboxBlocks_Callback(hObject, eventdata, handles)
411 datatool_show_description(2);
413 % --- Executes during object creation, after setting all properties.
414 function listboxBlocks_CreateFcn(hObject, eventdata, handles)
415 if ispc && isequal(get(hObject,'BackgroundColor
'), get(0,'defaultUicontrolBackgroundColor
'))
416 set(hObject,'BackgroundColor
','white
');
419 % --- Executes on button press in pushbuttonBlockClear.
420 function pushbuttonBlockClear_Callback(hObject, eventdata, handles)
422 names = get_selected_names(2);
425 code = sprintf('clear %s;
', sprintf('%s
', names{:}));
426 ircode_eval(code, 'Clearing blocks
');
433 datatool_status('There is no block to clear!
');
436 % --- Executes on button press in pushbuttonBlockRefresh.
437 function pushbuttonBlockRefresh_Callback(hObject, eventdata, handles)
441 % --- Executes on button press in pushbuttonBlockVisualize.
442 function pushbuttonBlockVisualize_Callback(hObject, eventdata, handles)
446 % --- Executes on button press in pushbuttonBlockUse.
447 function pushbuttonBlockUse_Callback(hObject, eventdata, handles)
451 % --- Executes on button press in pushbuttonBlockTrain.
452 function pushbuttonBlockTrain_Callback(hObject, eventdata, handles)
454 s = get_selected_1stname(2);
456 o = evalin('base
', [s, ';
']); % gets object to see if it is trainable
457 if o.flag_trainable < 1
458 datatool_status('Cannot train: block not trainable!
');
463 datatool_status('Cannot train: there is no block!
');
466 % --- Executes on button press in pushbuttonBlockBoot.
467 function pushbuttonBlockBoot_Callback(hObject, eventdata, handles)
469 s = get_selected_1stname(2);
471 o = evalin('base
', [s, ';
']); % gets object to see if it is bootable
473 datatool_status('Cannot boot: block not bootable!
');
478 datatool_status('Cannot boot: there is no block!
');
481 % --- Executes on selection change in popupmenu_sheware.
482 function popupmenu_sheware_Callback(hObject, eventdata, handles)
484 idx = get(handles.popupmenu_sheware, 'Value
');
491 % --- Executes during object creation, after setting all properties.
492 function popupmenu_sheware_CreateFcn(hObject, eventdata, handles)
493 if ispc && isequal(get(hObject,'BackgroundColor
'), get(0,'defaultUicontrolBackgroundColor
'))
494 set(hObject,'BackgroundColor
','white
');
498 % --- Executes on selection change in popupmenuBlockMore.
499 function popupmenuBlockMore_Callback(hObject, eventdata, handles)
501 idx = get(handles.popupmenuBlockMore, 'Value
');
503 aa = get(handles.popupmenuBlockMore, 'String
');
506 datatool_status('There is no block!
');
510 % --- Executes during object creation, after setting all properties.
511 function popupmenuBlockMore_CreateFcn(hObject, eventdata, handles)
512 if ispc && isequal(get(hObject,'BackgroundColor
'), get(0,'defaultUicontrolBackgroundColor
'))
513 set(hObject,'BackgroundColor
','white
');
517 % --- Executes on button press in pushbuttonBlockOperate.
518 function pushbuttonBlockOperate_Callback(hObject, eventdata, handles)
520 do_block(2, ['blbl']);
524 function edit_class_Callback(hObject, eventdata, handles)
525 change_class_from_edit();
527 function edit_class_CreateFcn(hObject, eventdata, handles)
528 if ispc && isequal(get(hObject,'BackgroundColor
'), get(0,'defaultUicontrolBackgroundColor
'))
529 set(hObject,'BackgroundColor
','white
');
532 function pushbutton_all_Callback(hObject, eventdata, handles)
534 do_block(1, 'block
');
function send_error(in ME)
Feature Selection (FSel) class.
function show_description(in h_list, in h_edit)
Visualization base class.
function listbox_get_selected_1stname(in h_listbox)
Pre-processing block base class.
function get_varnames(in classname, in input)
Feature Construction (FCon) base class.
function ircode_eval(in s, in title)
function listbox_load_from_workspace(in classname, in h_list, in flag_blank, in string_empty, in input)
function listbox_get_selected_names(in h_listbox)
function colors_markers()
function gui_set_position(in hObject)
function find_varname(in prefix)
Cascade block: sequence of blocks represented by a block.
function rename_object(in s)