comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/preprocess.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function preprocess(sData,arg2)
2
3 %PREPROCESS A GUI for data preprocessing.
4 %
5 % preprocess(sData)
6 %
7 % preprocess(sData)
8 %
9 % Launches a preprocessing GUI. The optional input argument can be
10 % either a data struct or a struct array of such. However, primarily
11 % the processed data sets are loaded to the application using the
12 % tools in the GUI. Also, the only way to get the preprocessed data
13 % sets back into the workspace is to use the tools in the GUI (press
14 % the button DATA SET MANAGEMENT).
15 %
16 % For a more throughout description, see online documentation.
17 % See also SOM_GUI.
18
19 %%%%%%%%%%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 %
21 % IN FILES: preprocess.html,preproc.jpg,sDman.jpg,clip.jpg,delay.jpg,window.jpg,selVect.jpg
22
23 % Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Parhankangas
24 % Copyright (c) by Juha Parhankangas and the SOM Toolbox team
25
26 % http://www.cis.hut.fi/projects/somtoolbox/
27
28 % Juha Parhankangas 050100
29
30 global no_of_sc % every Nth component in 'relative values' is drawn stronger.
31 no_of_sc=5;
32
33 if nargin < 1 | nargin > 2
34 error('Invalid number of input arguments');
35 return;
36 end
37
38 if nargin == 1, arg2=[]; end
39
40 if ~isstr(sData) %%% Preprocess is started...
41 data.LOG{1}='% Starting the ''Preprocess'' -window...';
42 data.LOG{2}=cat(2,'preprocess(',...
43 sprintf('%s);',inputname(1)));
44
45 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
46 if ~isempty(pre_h)
47 figure(pre_h);
48 msgbox('''Preprocess''-figure already exists.');
49 return;
50 end
51
52 h0 = figure('Color',[0.8 0.8 0.8], ...
53 'PaperPosition',[18 180 576 432], ...
54 'PaperUnits','points', ...
55 'Position',[595 216 600 775], ...
56 'Tag','Preprocess');
57
58 h1 = uicontrol('Parent',h0, ...
59 'Units','normalized', ...
60 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
61 'FontWeight','demi', ...
62 'HorizontalAlignment','left', ...
63 'ListboxTop',0, ...
64 'Position',[0.015 0.06064516129032258 0.9550000000000001 0.1458064516129032], ...
65 'Style','text', ...
66 'Tag','StaticText1');
67
68 data.results_h = h1;
69
70 h1 = uicontrol('Parent',h0, ...
71 'Units','normalized', ...
72 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
73 'Callback','preprocess close', ...
74 'FontWeight','demi', ...
75 'ListboxTop',0, ...
76 'Position',[0.8067 0.0142 0.1667 0.0348],...
77 'String','CLOSE', ...
78 'Tag','Pushbutton1');
79
80 h1 = uicontrol('Parent',h0, ...
81 'Units','normalized', ...
82 'BackgroundColor',[0.8 0.8 0.8], ...
83 'FontWeight','demi', ...
84 'HorizontalAlignment','left', ...
85 'ListboxTop',0, ...
86 'Position',[0.01833333333333333 0.2141935483870968 0.07000000000000001 0.01806451612903226], ...
87 'String','LOG', ...
88 'Style','text', ...
89 'Tag','StaticText2');
90
91 h1 = uicontrol('Parent',h0, ...
92 'Units','normalized', ...
93 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
94 'Callback','preprocess sel_comp',...
95 'FontWeight','demi', ...
96 'ListboxTop',0, ...
97 'Position',[0.7983333333333333 0.2090322580645161 0.1666666666666667 0.03483870967741935], ...
98 'String',' ', ...
99 'Style','popupmenu', ...
100 'Tag','sel_comp_h', ...
101 'Value',1);
102
103 data.sel_comp_h=h1;
104
105 h1 = uicontrol('Parent',h0, ...
106 'Units','normalized', ...
107 'BackgroundColor',[1 1 1], ...
108 'ListboxTop',0, ...
109 'Position',[0.0183 0.2568 0.2133 0.1290], ...
110 'Style','text', ...
111 'Tag','StaticText3');
112
113 data.sel_cdata_h=h1;
114
115 h1 = axes('Parent',h0, ...
116 'CameraUpVector',[0 1 0], ...
117 'CameraUpVectorMode','manual', ...
118 'Color',[1 1 1], ...
119 'Position',[0.2583 0.2568 0.2133 0.1290], ...
120 'Tag','Axes1', ...
121 'XColor',[0 0 0], ...
122 'XTickLabel',['0 ';'0.5';'1 '], ...
123 'XTickLabelMode','manual', ...
124 'XTickMode','manual', ...
125 'YColor',[0 0 0], ...
126 'YTickMode','manual', ...
127 'ZColor',[0 0 0]);
128
129 data.sel_chist_h=h1;
130
131 h2 = text('Parent',h1, ...
132 'Color',[0 0 0], ...
133 'HandleVisibility','off', ...
134 'HorizontalAlignment','center', ...
135 'Position',[0.4960629921259843 -0.08080808080808044 9.160254037844386], ...
136 'Tag','Axes1Text4', ...
137 'VerticalAlignment','cap');
138 set(get(h2,'Parent'),'XLabel',h2);
139 h2 = text('Parent',h1, ...
140 'Color',[0 0 0], ...
141 'HandleVisibility','off', ...
142 'HorizontalAlignment','center', ...
143 'Position',[-0.0551181102362206 0.4848484848484853 9.160254037844386], ...
144 'Rotation',90, ...
145 'Tag','Axes1Text3', ...
146 'VerticalAlignment','baseline');
147 set(get(h2,'Parent'),'YLabel',h2);
148 h2 = text('Parent',h1, ...
149 'Color',[0 0 0], ...
150 'HandleVisibility','off', ...
151 'HorizontalAlignment','right', ...
152 'Position',[-1.2283 5.7980 9.1603], ...
153 'Tag','Axes1Text2', ...
154 'Visible','off');
155 set(get(h2,'Parent'),'ZLabel',h2);
156 h2 = text('Parent',h1, ...
157 'Color',[0 0 0], ...
158 'HandleVisibility','off', ...
159 'HorizontalAlignment','center', ...
160 'Position',[0.4960629921259843 1.070707070707071 9.160254037844386], ...
161 'Tag','Axes1Text1', ...
162 'VerticalAlignment','bottom');
163 set(get(h2,'Parent'),'Title',h2);
164
165 h1 = axes('Parent',h0, ...
166 'CameraUpVector',[0 1 0], ...
167 'CameraUpVectorMode','manual', ...
168 'Color',[0.7529 0.7529 0.7529], ...
169 'Position',[0.4950000000000001 0.2567741935483871 0.4766666666666667 0.1290322580645161], ...
170 'Tag','Axes2', ...
171 'XColor',[0 0 0], ...
172 'XTickMode','manual', ...
173 'YColor',[0 0 0], ...
174 'YTick',[0 0.5 1], ...
175 'YTickMode','manual', ...
176 'ZColor',[0 0 0]);
177
178 data.vector_h=h1;
179
180 h2 = text('Parent',h1, ...
181 'Color',[0 0 0], ...
182 'HandleVisibility','off', ...
183 'HorizontalAlignment','center', ...
184 'Position',[0.4982456140350879 -0.08080808080808044 9.160254037844386], ...
185 'Tag','Axes2Text4', ...
186 'VerticalAlignment','cap');
187 set(get(h2,'Parent'),'XLabel',h2);
188 h2 = text('Parent',h1, ...
189 'Color',[0 0 0], ...
190 'HandleVisibility','off', ...
191 'HorizontalAlignment','center', ...
192 'Position',[-0.1018 0.4848 9.1603], ...
193 'Rotation',90, ...
194 'Tag','Axes2Text3', ...
195 'VerticalAlignment','baseline');
196 set(get(h2,'Parent'),'YLabel',h2);
197 h2 = text('Parent',h1, ...
198 'Color',[0 0 0], ...
199 'HandleVisibility','off', ...
200 'HorizontalAlignment','right', ...
201 'Position',[-1.045614035087719 5.797979797979799 9.160254037844386], ...
202 'Tag','Axes2Text2', ...
203 'Visible','off');
204 set(get(h2,'Parent'),'ZLabel',h2);
205 h2 = text('Parent',h1, ...
206 'Color',[0 0 0], ...
207 'HandleVisibility','off', ...
208 'HorizontalAlignment','center', ...
209 'Position',[0.4982456140350879 1.070707070707071 9.160254037844386], ...
210 'Tag','Axes2Text1', ...
211 'VerticalAlignment','bottom');
212 set(get(h2,'Parent'),'Title',h2);
213
214 h1 = uicontrol('Parent',h0, ...
215 'Units','normalized', ...
216 'BackgroundColor',[0.8 0.8 0.8], ...
217 'FontWeight','demi', ...
218 'HorizontalAlignment','left', ...
219 'ListboxTop',0, ...
220 'Position',[0.01833333333333333 0.3922580645161291 0.17 0.01806451612903226], ...
221 'String','STATISTICS', ...
222 'Style','text', ...
223 'Tag','StaticText4');
224
225 h1 = uicontrol('Parent',h0, ...
226 'Units','normalized', ...
227 'BackgroundColor',[0.8 0.8 0.8], ...
228 'FontWeight','demi', ...
229 'HorizontalAlignment','left', ...
230 'ListboxTop',0, ...
231 'Position',[0.2583333333333334 0.3922580645161291 0.1633333333333333 0.01806451612903226], ...
232 'String','HISTOGRAM', ...
233 'Style','text', ...
234 'Tag','StaticText5');
235
236 h1 = uicontrol('Parent',h0, ...
237 'Units','normalized', ...
238 'BackgroundColor',[0.8 0.8 0.8], ...
239 'FontWeight','demi',...
240 'FontSize',6,...
241 'HorizontalAlignment','left',...
242 'String',{'LEFT: NEW SELECTION';'RIGHT: ADD TO SELECTION'}, ...
243 'ListboxTop',0, ...
244 'Position',[0.5016666666666667 0.38 0.235 0.03741935483870968], ...
245 'Style','text', ...
246 'Tag','StaticText6', ...
247 'UserData','[ ]');
248
249 h1 = uicontrol('Parent',h0, ...
250 'Units','normalized', ...
251 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
252 'Callback','preprocess selall', ...
253 'FontWeight','demi', ...
254 'ListboxTop',0, ...
255 'Position',[0.8066666666666668 0.3922580645161291 0.1666666666666667 0.03483870967741935], ...
256 'String','SELECT ALL', ...
257 'Tag','Pushbutton2', ...
258 'UserData','[ ]');
259
260 h1 = uicontrol('Parent',h0, ...
261 'Units','normalized', ...
262 'BackgroundColor',[0.7529 0.7529 0.7529], ...
263 'Position',[0.01833333333333333 0.4503225806451613 0.23 0.3225806451612903], ...
264 'String',' ', ...
265 'Style','listbox', ...
266 'Tag','Listbox1', ...
267 'Value',1);
268
269 data.comp_names_h=h1;
270
271 h1 = uicontrol('Parent',h0, ...
272 'Units','normalized', ...
273 'BackgroundColor',[1 1 1], ...
274 'Position',[0.4950000000000001 0.4503225806451613 0.2333333333333333 0.3225806451612903], ...
275 'String',' ', ...
276 'Style','listbox', ...
277 'Tag','Listbox2', ...
278 'Value',1);
279
280 data.vect_mean_h = h1;
281
282 h1 = axes('Parent',h0, ...
283 'CameraUpVector',[0 1 0], ...
284 'CameraUpVectorMode','manual', ...
285 'Color',[1 1 1], ...
286 'Position',[0.7383333333333334 0.4503225806451613 0.2333333333333333 0.3225806451612903], ...
287 'Tag','Axes3', ...
288 'XColor',[0 0 0], ...
289 'XTickMode','manual', ...
290 'YColor',[0 0 0], ...
291 'YTickMode','manual', ...
292 'ZColor',[0 0 0]);
293
294 data.sel_cplot_h = h1;
295
296 h2 = text('Parent',h1, ...
297 'Color',[0 0 0], ...
298 'HandleVisibility','off', ...
299 'HorizontalAlignment','center', ...
300 'Position',[0.4964028776978418 -0.03212851405622486 9.160254037844386], ...
301 'Tag','Axes3Text4', ...
302 'VerticalAlignment','cap');
303 set(get(h2,'Parent'),'XLabel',h2);
304 h2 = text('Parent',h1, ...
305 'Color',[0 0 0], ...
306 'HandleVisibility','off', ...
307 'HorizontalAlignment','center', ...
308 'Position',[-0.05035971223021596 0.493975903614458 9.160254037844386], ...
309 'Rotation',90, ...
310 'Tag','Axes3Text3', ...
311 'VerticalAlignment','baseline');
312 set(get(h2,'Parent'),'YLabel',h2);
313 h2 = text('Parent',h1, ...
314 'Color',[0 0 0], ...
315 'HandleVisibility','off', ...
316 'HorizontalAlignment','right', ...
317 'Position',[-3.1942 1.7028 9.1603], ...
318 'Tag','Axes3Text2', ...
319 'Visible','off');
320 set(get(h2,'Parent'),'ZLabel',h2);
321 h2 = text('Parent',h1, ...
322 'Color',[0 0 0], ...
323 'HandleVisibility','off', ...
324 'HorizontalAlignment','center', ...
325 'Position',[0.4964028776978418 1.028112449799197 9.160254037844386], ...
326 'Tag','Axes3Text1', ...
327 'VerticalAlignment','bottom');
328 set(get(h2,'Parent'),'Title',h2);
329
330 h1 = uicontrol('Parent',h0, ...
331 'Units','normalized', ...
332 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
333 'Callback','preprocess plxy', ...
334 'FontWeight','demi', ...
335 'ListboxTop',0, ...
336 'Position',[0.265 0.4683870967741936 0.125 0.03483870967741935], ...
337 'String','XY-PLOT', ...
338 'Tag','Pushbutton3');
339
340 h1 = uicontrol('Parent',h0, ...
341 'Units','normalized', ...
342 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
343 'Callback','preprocess hist', ...
344 'FontWeight','demi', ...
345 'ListboxTop',0, ...
346 'Position',[0.265 0.5303225806451613 0.125 0.03483870967741935], ...
347 'String','HISTOGRAM', ...
348 'Tag','Pushbutton4');
349
350 h1 = uicontrol('Parent',h0, ...
351 'Units','normalized', ...
352 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
353 'Callback','preprocess bplo', ...
354 'FontWeight','demi', ...
355 'ListboxTop',0, ...
356 'Position',[0.265 0.5922580645161291 0.125 0.03483870967741935], ...
357 'String','BOX PLOT', ...
358 'Tag','Pushbutton5');
359
360 h1 = uicontrol('Parent',h0, ...
361 'Units','normalized', ...
362 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
363 'Callback','preprocess plot', ...
364 'FontWeight','demi', ...
365 'ListboxTop',0, ...
366 'Position',[0.265 0.654195483870968 0.125 0.03483870967741935], ...
367 'String','PLOT', ...
368 'Tag','Pushbutton6');
369
370 h1 = uicontrol('Parent',h0, ...
371 'Units','normalized', ...
372 'BackgroundColor',[1 1 1], ...
373 'ListboxTop',0, ...
374 'Position',[0.4088888888888889 0.5333333333333333 0.06 0.03268817204301075], ...
375 'String','30', ...
376 'Style','edit', ...
377 'Tag','EditText1');
378
379 data.no_of_bins_h = h1;
380
381
382 h1 = uicontrol('Parent',h0, ...
383 'Units','normalized', ...
384 'BackgroundColor',[0.8 0.8 0.8], ...
385 'FontWeight','demi', ...
386 'HorizontalAlignment','left', ...
387 'ListboxTop',0, ...
388 'Position',[0.01833333333333333 0.775483870967742 0.2016666666666667 0.01806451612903226], ...
389 'String','COMPONENT LIST', ...
390 'Style','text', ...
391 'Tag','StaticText7');
392
393 h1 = uicontrol('Parent',h0, ...
394 'Units','normalized', ...
395 'BackgroundColor',[0.8 0.8 0.8], ...
396 'FontWeight','demi', ...
397 'HorizontalAlignment','left', ...
398 'ListboxTop',0, ...
399 'Position',[0.4950000000000001 0.775483870967742 0.1966666666666667 0.01806451612903226], ...
400 'String','AVERAGE', ...
401 'Style','text', ...
402 'Tag','StaticText8');
403
404 h1 = uicontrol('Parent',h0, ...
405 'Units','normalized', ...
406 'BackgroundColor',[0.8 0.8 0.8], ...
407 'FontWeight','demi', ...
408 'HorizontalAlignment','left', ...
409 'ListboxTop',0, ...
410 'Position',[0.7383333333333334 0.775483870967742 0.225 0.01806451612903226], ...
411 'String','RELATIVE VALUES', ...
412 'Style','text', ...
413 'Tag','StaticText9');
414
415 h1 = uicontrol('Parent',h0, ...
416 'Units','normalized', ...
417 'BackgroundColor',[0.8 0.8 0.8], ...
418 'FontSize',10, ...
419 'FontWeight','demi', ...
420 'HorizontalAlignment','left', ...
421 'ListboxTop',0, ...
422 'Position',[0.01833333333333333 0.8154838709677419 0.2033333333333333 0.0232258064516129], ...
423 'String','COMPONENTS', ...
424 'Style','text', ...
425 'Tag','StaticText10');
426
427 h1 = uicontrol('Parent',h0, ...
428 'Units','normalized', ...
429 'BackgroundColor',[0.8 0.8 0.8], ...
430 'FontSize',10, ...
431 'FontWeight','demi', ...
432 'HorizontalAlignment','left', ...
433 'ListboxTop',0, ...
434 'Position',[0.4950000000000001 0.8154838709677419 0.2 0.0232258064516129], ...
435 'String','VECTORS', ...
436 'Style','text', ...
437 'Tag','StaticText11');
438
439 h1 = uicontrol('Parent',h0, ...
440 'Units','normalized', ...
441 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
442 'Callback','preprocess sD_management', ...
443 'FontSize',5, ...
444 'FontWeight','demi', ...
445 'ListboxTop',0, ...
446 'Position',[0.01833333333333333 0.8503225806451613 0.1666666666666667 0.03483870967741935], ...
447 'String','DATA SET MANAGEMENT', ...
448 'Tag','Pushbutton7');
449
450 h1 = uicontrol('Parent',h0, ...
451 'Units','normalized', ...
452 'Callback','preprocess sel_sD', ...
453 'ListboxTop',0, ...
454 'Position',[0.01833333333333333 0.8890322580645161 0.1666666666666667 0.03483870967741935], ...
455 'String',' ', ...
456 'Style','popupmenu', ...
457 'Tag','PopupMenu2', ...
458 'Value',1);
459
460 data.sD_set_h = h1;
461
462 h1 = uicontrol('Parent',h0, ...
463 'Units','normalized', ...
464 'BackgroundColor',[1 1 1], ...
465 'ListboxTop',0, ...
466 'Position',[0.2516666666666667 0.8503225806451613 0.7216666666666667 0.07354838709677419], ...
467 'Style','text', ...
468 'Tag','StaticText12');
469
470 data.sD_name_h = h1;
471
472 h1 = uicontrol('Parent',h0, ...
473 'Units','normalized', ...
474 'BackgroundColor',[0.8 0.8 0.8], ...
475 'FontSize',10, ...
476 'FontWeight','demi', ...
477 'HorizontalAlignment','left', ...
478 'ListboxTop',0, ...
479 'Position',[0.01833333333333333 0.9341935483870968 0.1616666666666667 0.02064516129032258], ...
480 'String','DATA SETS', ...
481 'Style','text', ...
482 'Tag','StaticText13');
483
484 h1 = uicontrol('Parent',h0, ...
485 'Units','normalized', ...
486 'BackgroundColor',[0.8 0.8 0.8], ...
487 'FontSize',10, ...
488 'FontWeight','demi', ...
489 'HorizontalAlignment','left', ...
490 'ListboxTop',0, ...
491 'Position',[0.2516666666666667 0.9341935483870968 0.2833333333333333 0.02064516129032258], ...
492 'String','SELECTED DATA SET', ...
493 'Style','text', ...
494 'Tag','StaticText14');
495
496 if ~isstruct(sData),
497 sData=som_data_struct(sData);
498 end
499
500 ui_h=uimenu('Label','&Normalization');
501 uimenu(ui_h,'Label','Scale [0,1]','Callback','preprocess zscale');
502 uimenu(ui_h,'Label','Scale var=1','Callback','preprocess vscale');
503 uimenu(ui_h,'Label','HistD','Callback','preprocess histeq');
504 uimenu(ui_h,'Label','HistC','Callback','preprocess histeq2');
505 uimenu(ui_h,'Label','Log','Callback','preprocess log');
506 uimenu(ui_h,'Label','Eval (1-comp)','Callback','preprocess eval1');
507
508 ui_h=uimenu('Label','&Components');
509 uimenu(ui_h,'Label','Move component','Callback','preprocess move');
510 uimenu(ui_h,'Label','Copy component','Callback','preprocess copy');
511 uimenu(ui_h,'Label','Add: N binary types','Callback','preprocess oneo');
512 uimenu(ui_h,'Label','Add: zeros','Callback','preprocess zero');
513 uimenu(ui_h,'Label','Remove component','Callback','preprocess remove');
514 uimenu(ui_h,'Label','Remove selected vectors',...
515 'Callback','preprocess remove_vects');
516 uimenu(ui_h,'Label','Select all components',...
517 'Callback','preprocess sel_all_comps');
518
519 ui_h=uimenu('Label','&Misc');
520 ui_h1=uimenu(ui_h,'Label','Calculate');
521 ui_h2=uimenu(ui_h,'Label','Process');
522
523 uimenu(ui_h,'Label','Get LOG-file','Callback','preprocess LOG');
524 uimenu(ui_h,'Label','Indices of the selected vectors',...
525 'Callback','preprocess get_inds');
526 uimenu(ui_h,'Label','Undo','Callback','preprocess undo');
527 uimenu(ui_h1,'Label','Number of values','Callback','preprocess noof');
528 uimenu(ui_h1,'Label','Number of selected vectors',...
529 'Callback','preprocess no_of_sel');
530 uimenu(ui_h1,'Label','Correlation','Callback','preprocess corr');
531 uimenu(ui_h2,'Label','Unit length','Callback','preprocess unit');
532 uimenu(ui_h2,'Label','Eval','Callback','preprocess eval2');
533 uimenu(ui_h2,'Label','Clipping','Callback','preprocess clipping');
534 uimenu(ui_h2,'Label','Delay','Callback','preprocess delay');
535 uimenu(ui_h2,'Label','Windowed','Callback','preprocess window');
536 uimenu(ui_h2,'Label','Select vectors','Callback','preprocess select');
537
538 len=getfield(size(sData(1).data),{1});
539 data.selected_vects=find(ones(1,len));
540 data.sD_set=sData;
541 set(data.vector_h,'ButtonDownFcn','preprocess(''vector_bdf'',''down'')');
542 set(gcf,'UserData',data);
543 if ~set_sD_stats;
544 return;
545 end
546 sel_sD;
547 return; %%% Preprocess-window is ready.
548
549 else
550 arg=sData;
551 if strcmp(arg,'rename')
552 rename(arg2);
553 elseif strcmp(arg,'sel_sD')
554 if isempty(arg2)
555 sel_sD;
556 else
557 sel_sD(arg2);
558 end
559 elseif strcmp(arg,'zscale')
560 if isempty(arg2)
561 zero2one_scale;
562 else
563 zero2one_scale(arg2);
564 end
565 elseif strcmp(arg,'vscale');
566 if isempty(arg2)
567 var_scale;
568 else
569 var_scale(arg2);
570 end
571 elseif strcmp(arg,'histeq2')
572 if isempty(arg2)
573 hist_eq2;
574 else
575 hist_eq2(arg2);
576 end
577 elseif strcmp(arg,'log')
578 if isempty(arg2)
579 logarithm;
580 else
581 logarithm(arg2);
582 end
583 elseif strcmp(arg,'eval1')
584 if isempty(arg2)
585 eval1;
586 else
587 eval1(arg2);
588 end
589 elseif strcmp(arg,'eval2')
590 if isempty(arg2)
591 eval2;
592 else
593 eval2(arg2);
594 end
595 elseif strcmp(arg,'histeq');
596 if isempty(arg2)
597 hist_eq;
598 else
599 hist_eq(arg2);
600 end
601 elseif strcmp(arg,'selall')
602 if isempty(arg2)
603 select_all;
604 else
605 select_all(arg2);
606 end
607 elseif strcmp(arg,'sel_button');
608 if isempty(arg2)
609 sel_button;
610 else
611 sel_button(arg2);
612 end
613 elseif strcmp(arg,'clear_button')
614 if isempty(arg2)
615 clear_button;
616 else
617 clear_button(arg2)
618 end
619 elseif(strcmp(arg,'move'))
620 if isempty(arg2)
621 move_component;
622 else
623 move_component(arg2);
624 end
625 elseif(strcmp(arg,'copy'))
626 if isempty(arg2)
627 copy_component;
628 else
629 copy_component(arg2);
630 end
631 elseif strcmp(arg,'oneo')
632 if isempty(arg2)
633 one_of_n;
634 else
635 one_of_n(arg2);
636 end
637 elseif strcmp(arg,'zero')
638 if isempty(arg2)
639 add_zeros;
640 else
641 add_zeros(arg2);
642 end
643 elseif strcmp(arg,'remove')
644 if isempty(arg2)
645 remove_component;
646 else
647 remove_component(arg2);
648 end
649 elseif strcmp(arg,'remove_vects')
650 if isempty(arg2)
651 remove_vects;
652 else
653 remove_vects(arg2);
654 end
655 elseif strcmp(arg,'noof')
656 if isempty(arg2)
657 no_of_values;
658 else
659 no_of_values(arg2);
660 end
661 elseif strcmp(arg,'corr');
662 if isempty(arg2)
663 correlation;
664 else
665 correlation(arg2);
666 end
667 elseif strcmp(arg,'unit')
668 if isempty(arg2)
669 unit_length;
670 else
671 unit_length(arg2);
672 end
673 elseif strcmp(arg,'clip_data')
674 clip_data(arg2);
675 elseif strcmp(arg,'copy_delete')
676 copy_delete(arg2);
677 elseif strcmp(arg,'and_or_cb')
678 and_or_cb(arg2);
679 elseif strcmp(arg,'all_sel_cb')
680 all_sel_cb(arg2);
681 elseif strcmp(arg,'clip_exp_cb')
682 clip_exp_cb(arg2);
683 elseif strcmp(arg,'window_cb')
684 window_cb(arg2);
685 elseif strcmp(arg,'set_state_vals')
686 set_state_vals(arg2);
687 elseif strcmp(arg,'vector_bdf')
688 vector_bdf(arg2);
689 elseif strcmp(arg,'sD_management');
690 if isempty(arg2)
691 sD_management;
692 else
693 sD_management(arg2);
694 end
695 elseif strcmp(arg,'clipping')
696 if isempty(arg2)
697 clipping;
698 else
699 clipping(arg2);
700 end
701 elseif strcmp(arg,'delay')
702 if isempty(arg2)
703 delay;
704 else
705 delay(arg2);
706 end
707 elseif strcmp(arg,'window');
708 if isempty(arg2)
709 window;
710 else
711 window(arg2);
712 end
713 elseif strcmp(arg,'select');
714 if isempty(arg2)
715 select;
716 else
717 select(arg2);
718 end
719 elseif strcmp(arg,'import')
720 if isempty(arg2)
721 import;
722 else
723 import(arg2);
724 end
725 elseif strcmp(arg,'export')
726 if isempty(arg2)
727 export;
728 else
729 export(arg2);
730 end
731 elseif strcmp(arg,'undo');
732 if isempty(arg2)
733 undo;
734 else
735 undo(arg2);
736 end
737 elseif strcmp(arg,'delay_data')
738 if isempty(arg2)
739 delay_data;
740 else
741 delay_data(arg2);
742 end
743 elseif strcmp(arg,'eval_windowed')
744 if isempty(arg2)
745 eval_windowed;
746 else
747 eval_windowed(arg2);
748 end
749 elseif strcmp(arg,'get_inds')
750 if isempty(arg2)
751 get_selected_inds;
752 else
753 get_selected_inds(arg2);
754 end
755 elseif strcmp(arg,'no_of_sel')
756 if isempty(arg2)
757 no_of_selected;
758 else
759 no_of_selected(arg2);
760 end
761 elseif strcmp(arg,'sel_comp');
762 if isempty(arg2)
763 sel_comp;
764 else
765 sel_comp(arg2);
766 end
767 elseif strcmp(arg,'sel_all_comps')
768 if isempty(arg2)
769 select_all_comps;
770 else
771 select_all_comps(arg2);
772 end
773 elseif strcmp(arg,'refresh')
774 set_var_names;
775 elseif any(strcmp(arg,{'close_c','close_d','close_s','close_w','close_sD'}))
776 if isempty(arg2)
777 close_func(arg)
778 else
779 close_func(arg,arg2);
780 end
781 end
782
783
784 switch arg
785 case 'sD_stats'
786 sD_stats;
787 case 'LOG'
788 log_file;
789 otherwise
790 pro_tools(arg);
791 end
792 end
793
794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
795
796 function set_compnames(sData,h)
797
798 %SET_COMPNAMES
799 %
800 % set_compnames(sData,h)
801 %
802 % ARGUMENTS
803 %
804 % sData (struct) som_data_struct
805 % h (scalar) handle to a list box object
806 %
807 %
808 % This function sets the component names of sData to the list box
809 % indicated by 'h'.
810 %
811
812 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
813
814 if isempty(pre_h)
815 error('Figure ''Preprocess'' does not exist. Closing program...');
816 close_preprocess;
817 end
818
819 udata=get(pre_h,'UserData');
820
821 set(h,'Value',[]);
822 for i=1:length(sData.comp_names)
823 tmp=sprintf('#%d: ',i);
824 names{i,1}=cat(2,tmp, sData.comp_names{i});
825 end
826
827
828 set(h,'String',names,'Max',2);
829 set(udata.sel_comp_h,'String',names);
830
831 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832
833 function draw_vectors(vectors,h)
834
835 %DRAW_VECTORS
836 %
837 % draw_vectors(vectors,h)
838 %
839 % ARGUMENTS
840 %
841 % vectors (vector) vector of 0's and 1's
842 % h (scalar) handle to an axis object
843 %
844 %
845 % This function draws an horizontal bar of 'vectors' in the axis
846 % indicated by 'h'.
847 %
848 %
849
850 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
851 subplot(h);
852 hold off;
853 cla;
854
855 set(h,'YLim',[0 1]);
856 set(h,'YTick',[]);
857 set(h,'XLim',[0 length(vectors)+1]);
858 hold on;
859
860 comp_no=get(getfield(get(pre_h,'UserData'),'sel_comp_h'),'Value');
861 comp=getfield(get(pre_h,'UserData'),'sData');
862 comp=comp.data(:,comp_no);
863 Max = max(comp);
864 Min = min(comp);
865 lims=get(gca,'YLim');
866 lims(1)=Min;
867 h=abs(0.1*Max);
868 lims(2)=Max;
869 if Max - Min <= eps
870 tmp=Max;
871 lims(1)=tmp-1;
872 lims(2)=tmp+1;
873 end
874 lims(2)=lims(2)+h;
875 if ~all(isnan(lims))
876 set(gca,'YLim',lims);
877 end
878 h=(lims(2)-lims(1))/4;
879 set(gca,'YTickMode','auto');
880 t=1:length(vectors);
881 h=plot(t,comp);
882 set(h,'ButtonDownFcn','preprocess(''vector_bdf'',''down'')');
883 indices =find(vectors);
884 vectors(indices)=0.1*(getfield(get(gca,'YLim'),...
885 {2})-getfield(get(gca,'YLim'),{1}));
886 plot(indices,vectors(indices)+getfield(get(gca,'YLim'),{1}),...
887 'ored','MarkerSize',4);
888
889 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
890
891 function vect_means(sData,handle,indices)
892
893 %VECT_MEANS
894 %
895 % vect_means(sData,handle,indices)
896 %
897 % ARGUMENTS
898 %
899 % sData (struct) som_data_struct
900 % handle (scalar) handle to the static text box object
901 % indices (vector) indices of selected vectors
902 %
903 %
904 % This function calculates means of selected vectors' components
905 % and writes them in the static text box indicated by 'handle'.
906 %
907 %
908
909 sData= sData.data(indices,:);
910
911 for i=1:length(sData(1,:))
912 names{i}=sprintf('#%d: ',i);
913 end
914
915
916 for i=1:length(sData(1,:))
917 tmp=sData(:,i);
918 tmp=cat(2,names{i},sprintf('%-10.3g',mean(tmp(find(~isnan(tmp))))));
919 string{i}=tmp;
920 end
921
922 set(handle,'String',string);
923 set(handle,'HorizontalAlignment','left');
924
925 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
926
927 function vector_bdf(arg)
928
929 %VECTOR_BDF A button down function.
930 %
931 % vector_bdf(arg)
932 %
933 % ARGUMENTS
934 %
935 % arg (string) 'down' or 'up', tells the mouse button's state.
936 %
937 %
938 % This function selects vectors in the vector-window and plots maxima,
939 % minima and means of the selected vectors. It also writes means of the
940 % selected vectors' components in a static text box and takes care of
941 % changes of the chosen component's data.
942 %
943 % See also VECTOR_MEANS, SEL_COMP
944 %
945 %
946
947
948 arg2=arg(6:length(arg));
949 if ~isempty(arg2)
950 LOG=1;
951 else
952 LOG=0;
953 end
954 arg=arg(1:4);
955
956 %%% arg's first "word" is 4 letters long and it can be:
957 %%%
958 %%% 'key '
959 %%% 'down'
960 %%% 'drag'
961 %%% 'up '
962
963 if strcmp(arg,'key ') %string is 'key' + 1 space!!!
964 if ~LOG
965 key=get(gcf,'CurrentCharacter');
966 else
967 key=arg2
968 end
969 if ~strcmp(key,'<') & ~strcmp(key,'>')
970 return;
971 end
972 data=get(gcf,'UserData');
973 sel=data.selected_vects;
974 if length(sel) == 1
975 if strcmp(key,'<') & sel ~= 1
976 data.selected_vects=sel-1;
977 set(gcf,'UserData',data);
978 elseif strcmp(key,'>') & sel ~= length(data.sData.data(:,1))
979 data.selected_vects = sel + 1;
980 set(gcf,'UserData',data);
981 end
982 else
983 if strcmp(key,'<') & sel(1) ~= 1
984 data.selected_vects=cat(2,sel(1)-1,sel);
985 set(gcf,'UserData',data);
986 elseif strcmp(key,'>') & sel(length(sel)) ~= length(sel)
987 data.selected_vects=cat(2,sel,sel(length(sel))+1);
988 set(gcf,'UserData',data);
989 end
990 end
991 cplot_mimema;
992 pro_tools('plot_hist');
993 pro_tools('c_stat');
994 vects=zeros(1,length(data.sData.data(:,1)));
995 vects(data.selected_vects)=1;
996 draw_vectors(vects,data.vector_h);
997
998 if ~LOG
999 data=get(gcf,'UserData');
1000 data.LOG{length(data.LOG)+1}=...
1001 sprintf('preprocess(''vector_bdf'',''key %s'');',key);
1002 %string is 'key'+2spaces+%s
1003 set(gcf,'UserData',data);
1004 end
1005 return;
1006 end
1007
1008 switch arg
1009 case 'down'
1010 set(gcf,'WindowButtonUpFcn','preprocess(''vector_bdf'',''up '')');
1011 set(gcf,'WindowButtonMotionFcn','preprocess(''vector_bdf'',''drag'')');
1012 switch get(gcf,'SelectionType')
1013 case 'normal'
1014 data.lims1=round(getfield(get(gca,'CurrentPoint'),{1,1}));
1015 data.lims2=[];
1016 case 'alt'
1017 tmp=round(getfield(get(gca,'CurrentPoint'),{1,1}));
1018 if isempty(get(gca,'UserData'))
1019 data.lims1=tmp;
1020 data.lims2=[];
1021 else
1022 data.lims1=cat(2,getfield(get(gca,'UserData'),'lims1'),tmp);
1023 data.lims2=getfield(get(gca,'UserData'),'lims2');
1024 end
1025 end
1026 coords=get(gca,'CurrentPoint');
1027 h=line([coords(1),coords(1)],get(gca,'YLim'),'EraseMode','xor');
1028 set(h,'Color','red');
1029 h2=line([coords(1),coords(1)],get(gca,'YLim'),'EraseMode','xor');
1030 set(h2,'Color','red');
1031 data.h=h;
1032 data.h2=h2;
1033 set(gca,'UserData',data);
1034
1035 case 'drag'
1036 coords=get(gca,'CurrentPoint');
1037 lim=get(gca,'XLim');
1038 h2=getfield(get(gca,'UserData'),'h2');
1039 if lim(1) >= coords(1)
1040 set(h2,'XData',[lim(1) lim(1)]);
1041 elseif lim(2) <= coords(2)
1042 set(h2,'XData',[lim(2) lim(2)]);
1043 else
1044 set(h2,'XData',[coords(1) coords(1)]);
1045 end
1046 case 'up ' % string is 'up' + 2 spaces!!!
1047 set(gcf,'WindowButtonUpFcn','');
1048 set(gcf,'WindowButtonMotionFcn','');
1049 if ~LOG
1050 data=get(gca,'UserData');
1051 delete(data.h);
1052 delete(data.h2);
1053 tmp=round(getfield(get(gca,'CurrentPoint'),{1,1}));
1054 data.lims2=cat(2,data.lims2,tmp);
1055 tmp_data=sort(cat(1,data.lims1,data.lims2));
1056 high=getfield(get(gca,'XLim'),{2})-1;
1057 vectors=zeros(1,high);
1058 tmp_data(find(tmp_data<1))=1;
1059 tmp_data(find(tmp_data>high))=high;
1060
1061 for i=1:getfield(size(tmp_data),{2})
1062 vectors(tmp_data(1,i):tmp_data(2,i))=1;
1063 end
1064 selected_vects=find(vectors);
1065 else
1066 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1067 len=size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data'));
1068 vectors=zeros(1,len(1));
1069 i=1;
1070 while i <= length(arg2) & (isspace(arg2(i)) | ~isletter(arg2(i)))
1071 i=i+1;
1072 end
1073 arg3=arg2(i:length(arg2));
1074 selected_vects=str2num(arg2(1:i-1));
1075 if ~isempty(arg3) & ~all(isspace(arg3))
1076 selected_vects=unique(cat(2,selected_vects,...
1077 getfield(get(pre_h,'UserData'),'selected_vects')));
1078 end
1079 vectors(selected_vects)=1;
1080 set(pre_h,'CurrentAxes',getfield(get(pre_h,'UserData'),'vector_h'));
1081 set(0,'CurrentFigure',pre_h);
1082 end
1083 draw_vectors(vectors,gca);
1084 sData=getfield(get(gcf,'UserData'),'sData');
1085 h=getfield(get(gcf,'UserData'),'vect_mean_h');
1086 vect_means(sData,h,selected_vects);
1087 if ~LOG
1088 set(gca,'UserData',data);
1089 end
1090 data=get(gcf,'UserData');
1091 data.undo.sData=data.sData;
1092 data.undo.selected=data.selected_vects;
1093 data.selected_vects=selected_vects;
1094 if ~LOG
1095 data.LOG{length(data.LOG)+1}='% Vector selection by using the mouse...';
1096 tmp=sprintf('preprocess(''vector_bdf'',''up %s'');',...
1097 num2str(data.selected_vects));
1098 if length(tmp) > 500
1099 tmp=textwrap({tmp},500);
1100 data.LOG{length(data.LOG)+1}=cat(2,tmp{1},''');');
1101 for i=2:length(tmp)-1
1102 data.LOG{length(data.LOG)+1}=...
1103 cat(2,sprintf('preprocess(''vector_bdf'',''up %s',...
1104 tmp{i}),'add'');');
1105 end
1106 data.LOG{length(data.LOG)+1}=...
1107 cat(2,sprintf('preprocess(''vector_bdf'',''up %s',...
1108 tmp{length(tmp)}(1:length(tmp{length(tmp)})-3)),' add'');');
1109 else
1110 data.LOG{length(data.LOG)+1}=tmp;
1111 end
1112 end
1113 set(gcf,'UserData',data);
1114 cplot_mimema;
1115 sel_comp;
1116 end
1117
1118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1119
1120 function sel_button(varargin)
1121
1122 %SEL_BUTTON A Callback function. It performs the operations needed
1123 % when vector components are selected.
1124 %
1125 % See also SEL_COMP
1126 %
1127
1128 if nargin == 1
1129 LOG=1;
1130 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1131 string=getfield(get(pre_h,'UserData'),'comp_names_h');
1132 string=getfield(get(string,'String'),{str2num(varargin{1})});
1133 set(0,'CurrentFigure',pre_h);
1134 else
1135 LOG=0;
1136 val=get(getfield(get(gcf,'UserData'),'comp_names_h'),'Value');
1137 end
1138
1139 sel_button_h=getfield(get(gcf,'UserData'),'sel_button_h');
1140 sel_comps_h=getfield(get(gcf,'UserData'),'sel_comps_h');
1141 comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h');
1142 if ~LOG
1143 string=getfield(get(comp_names_h,'String'),{get(comp_names_h,'Value')});
1144 end
1145 tmp_string=get(sel_comps_h,'String');
1146
1147 if iscell(tmp_string)
1148
1149 for i=1:length(string)
1150 if ~any(strcmp(string{i},tmp_string))
1151 tmp_string=cat(1,tmp_string,string(i));
1152 end
1153 end
1154 string=tmp_string;
1155 end
1156
1157 set(sel_comps_h,'String',string);
1158 set(comp_names_h,'Value',[]);
1159 sel_comp;
1160 if ~LOG
1161 data=get(gcf,'UserData');
1162 data.LOG{length(data.LOG)+1}='% Select components';
1163 data.LOG{length(data.LOG)+1}=sprintf('preprocess(''sel_button'',''%s'');',...
1164 num2str(val));
1165 set(gcf,'UserData',data);
1166 end
1167
1168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1169
1170 function clear_button(varargin)
1171
1172 %CLEAR_BUTTON Function callback evaluated when a 'Clear'-button is
1173 % pressed. It removes texts from the 'selected components'
1174 % -window and the 'selected component data' -window and
1175 % clears the 'histogram' -axis.
1176 %
1177 %
1178
1179 if nargin==1
1180 LOG=1;
1181 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1182 set(0,'CurrentFigure',pre_h);
1183 else
1184 LOG=0;
1185 end
1186
1187 sel_comp_h=getfield(get(gcf,'UserData'),'sel_comp_h');
1188 sel_cdata_h=getfield(get(gcf,'UserData'),'sel_cdata_h');
1189 sel_cplot_h=getfield(get(gcf,'UserData'),'sel_cplot_h');
1190 sel_chist_h=getfield(get(gcf,'UserData'),'sel_chist_h');
1191 vector_h=getfield(get(gcf,'UserData'),'vector_h');
1192
1193 set(sel_comp_h,'Value',1);
1194 set(sel_cdata_h,'String',' ');
1195 subplot(sel_chist_h);
1196 hold off;
1197 cla;
1198
1199 selected=getfield(get(gcf,'UserData'),'selected_vects');
1200 dims=size(getfield(getfield(get(gcf,'UserData'),'sData'),'data'));
1201 vectors=zeros(1,dims(1));
1202 vectors(selected)=1;
1203 subplot(vector_h);
1204 draw_vectors(vectors,vector_h);
1205 if ~LOG
1206 data=get(gcf,'UserData');
1207 data.LOG{length(data.LOG)+1}='% Remove components from the selected list.';
1208 data.LOG{length(data.LOG)+1}='preprocess(''clear_button'',''foo'');';
1209 set(gcf,'UserData',data);
1210 end
1211
1212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1213
1214 function sel_comp(varargin)
1215
1216 %SEL_COMP performs the operations needed when vector components are
1217 % chosen. It writes maxima, minima, mean and standard deviation
1218 % of the chosen component to a text box window and draws a
1219 % histogram of the chosen component of selected vectors'
1220 %
1221 %
1222
1223 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1224 set(0,'CurrentFigure',pre_h);
1225 sel_comp_h=getfield(get(pre_h,'UserData'),'sel_comp_h');
1226
1227 if nargin == 1
1228 set(sel_comp_h,'Value',str2num(varargin{1}));
1229 elseif ~isempty(gcbo)
1230 no=get(sel_comp_h,'Value');
1231 data=get(gcf,'UserData');
1232 data.LOG{length(data.LOG)+1}='% Select one component';
1233 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''sel_comp'',''',...
1234 num2str(no),''');');
1235 set(gcf,'UserData',data);
1236 end
1237
1238 pro_tools('c_stat');
1239 pro_tools('plot_hist');
1240 data=get(gcf,'UserData');
1241 sData=data.sData;
1242 vector_h=data.vector_h;
1243 len=length(sData.data(:,1));
1244 vects=zeros(1,len);
1245 vects(data.selected_vects)=1;
1246 draw_vectors(vects,vector_h);
1247
1248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1249
1250 function cplot_mimema
1251
1252 global no_of_sc
1253
1254 sData=getfield(get(gcf,'UserData'),'sData');
1255 sel_cplot_h=getfield(get(gcf,'UserData'),'sel_cplot_h');
1256 selected=getfield(get(gcf,'UserData'),'selected_vects');
1257
1258 set(sel_cplot_h,'YLim',[0 length(sData.data(1,:))+1]);
1259
1260 subplot(sel_cplot_h);
1261 hold off;
1262 cla;
1263 hold on;
1264
1265 for i=1:length(sData.data(1,:))
1266 Max=max(sData.data(:,i));
1267 Min=min(sData.data(:,i));
1268 tmp=sData.data(selected,i);
1269
1270 selMax=max(tmp);
1271 selMin=min(tmp);
1272 Mean=abs(mean(tmp(find(~isnan(tmp)))));
1273 Median=abs(median(tmp(find(~isnan(tmp)))));
1274
1275 if Max ~= Min & ~all(isnan(sData.data(:,i)))
1276
1277 if rem(i,no_of_sc) % no_of_sc is defined in the beginning of this file...
1278
1279 line([abs(selMin-Min)/(Max-Min) (selMax-Min)/(Max-Min)],...
1280 [i i],'Color','black');
1281 plot(abs(Mean-Min)/(Max-Min),i,'oblack');
1282 plot(abs(Median-Min)/(Max-Min),i,'xblack');
1283 else
1284 line([abs(selMin-Min)/(Max-Min) (selMax-Min)/(Max-Min)],...
1285 [i i],'Color','black','LineWidth',2);
1286 plot(abs(Mean-Min)/(Max-Min),i,'oblack','LineWidth',2);
1287 plot(abs(Median-Min)/(Max-Min),i,'xblack','LineWidth',2);
1288 end
1289 else
1290
1291 if rem(i,no_of_sc) % N is defined in the beginning of this file.
1292
1293 plot(mean(get(gca,'XLim')),i,'oblack');
1294 plot(mean(get(gca,'XLim')),i,'xblack');
1295 else
1296 plot(mean(get(gca,'XLim')),i,'oblack','LineWidth',2);
1297 plot(mean(get(gca,'XLim')),i,'xblack','LineWidth',2);
1298 end
1299 end
1300 end
1301
1302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1303
1304
1305 function bool=set_sD_stats
1306
1307 %SET_SD_STATS Writes the data set names to popup menu.
1308 %
1309 %
1310
1311 bool=1;
1312 data=get(gcf,'UserData');
1313
1314 for i=1:length(data.sD_set)
1315 % if ~isvalid_var_name({data.sD_set(i).name})
1316 % close_preprocess;
1317 % bool=0;
1318 % return;
1319 % end
1320 string{i}=cat(2,sprintf('#%d: ',i),data.sD_set(i).name);
1321 end
1322
1323 set(data.sD_set_h,'String',string);
1324 data.sData=data.sD_set(get(data.sD_set_h,'Value'));
1325 data.sData.MODIFIED=0;
1326 data.sData.INDEX=1;
1327 set(gcf,'UserData',data);
1328 write_sD_stats;
1329
1330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1331
1332 function write_sD_stats
1333
1334 %WRITE_SD_STATS writes data's name, length and dimension to text box.
1335 %
1336 %
1337
1338 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1339
1340
1341 sD_name_h=getfield(get(pre_h,'UserData'),'sD_name_h');
1342 sData=getfield(get(pre_h,'UserData'),'sData');
1343 dims=size(sData.data);
1344 string{1}=cat(2,'Name: ',sData.name);
1345 string{2}=cat(2,'Length: ',sprintf('%d',dims(1)));
1346 string{3}=cat(2,'Dim: ',sprintf('%d',dims(2)));
1347
1348 set(sD_name_h,'String',string);
1349 set(sD_name_h,'HorizontalAlignment','left');
1350
1351 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1352
1353
1354
1355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1356
1357 function sel_sD(varargin)
1358
1359 %SEL_SD sets new data to UserData's 'sData'.
1360 %
1361 %
1362
1363 if nargin==1
1364 LOG=1;
1365 index=str2num(varargin{1});
1366 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1367 set(0,'CurrentFigure',pre_h);
1368 else
1369 LOG=0;
1370 end
1371
1372 sD_set_h=getfield(get(gcf,'UserData'),'sD_set_h');
1373 comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h');
1374 vector_h=getfield(get(gcf,'UserData'),'vector_h');
1375 vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h');
1376
1377 if ~LOG
1378 index=get(sD_set_h,'Value');
1379 end
1380 data=get(gcf,'UserData');
1381 data.undo = [];
1382 INDEX=data.sData.INDEX;
1383 data.sData=rmfield(data.sData,'MODIFIED');
1384 data.sData=rmfield(data.sData,'INDEX');
1385
1386 tmp=data.sD_set(index);
1387 tmp.MODIFIED=0;
1388 tmp.INDEX=index;
1389 data.sD_set(INDEX)=data.sData;
1390 data.sData=tmp;
1391
1392 len=getfield(size(tmp.data),{1});
1393
1394 data.selected_vects=find(ones(1,len));
1395 if ~LOG
1396 data.LOG{length(data.LOG)+1}='% Select a new data set.';
1397 data.LOG{length(data.LOG)+1}=sprintf('preprocess(''sel_sD'',''%s'');',...
1398 num2str(index));
1399 end
1400 set(gcf,'UserData',data);
1401 write_sD_stats;
1402 set_compnames(tmp,comp_names_h);
1403 draw_vectors(ones(1,len),vector_h);
1404 vect_means(tmp,vect_mean_h,data.selected_vects);
1405 clear_button;
1406 sel_comp;
1407 cplot_mimema;
1408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1409
1410 function indices=get_indices
1411
1412 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1413
1414 comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h');
1415 indices = get(comp_names_h,'Value');
1416
1417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1418
1419
1420
1421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1422
1423 function sD_management(varargin)
1424
1425 if nargin ~= 1
1426 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1427 preh_udata=get(pre_h,'UserData');
1428 preh_udata.LOG{length(preh_udata.LOG)+1}=...
1429 '% Starting the ''Data Set Management'' -window...';
1430 preh_udata.LOG{length(preh_udata.LOG)+1}=...
1431 'preprocess(''sD_management'',''foo'');';
1432 set(pre_h,'UserData',preh_udata);
1433 end
1434
1435 man_h=findobj(get(0,'Children'),'Tag','Management');
1436 if ~isempty(man_h)
1437 figure(man_h);
1438 return;
1439 end
1440
1441 h0 = figure('BackingStore','off', ...
1442 'Color',[0.8 0.8 0.8], ...
1443 'Name','Data Set Management', ...
1444 'PaperPosition',[18 180 576 432], ...
1445 'PaperUnits','points', ...
1446 'Position',[753 523 324 470], ...
1447 'RendererMode','manual', ...
1448 'Tag','Management');
1449 h1 = uicontrol('Parent',h0, ...
1450 'Units','normalized', ...
1451 'BackgroundColor',[1 1 1], ...
1452 'FontWeight','demi', ...
1453 'HorizontalAlignment','left', ...
1454 'ListboxTop',0, ...
1455 'Max',2, ...
1456 'Position',[0.02777777777777778 0.0723404255319149 0.7716049382716049 0.1914893617021277], ...
1457 'String',' ', ...
1458 'Style','edit', ...
1459 'Tag','EditText1');
1460
1461 data.new_c_name_h = h1;
1462
1463 h1 = uicontrol('Parent',h0, ...
1464 'Callback','preprocess rename comp',...
1465 'Units','normalized', ...
1466 'FontSize',6, ...
1467 'FontWeight','demi', ...
1468 'ListboxTop',0, ...
1469 'Position',[0.8240740740740741 0.2106382978723404 0.154320987654321 0.05319148936170213], ...
1470 'String','RENAME', ...
1471 'Tag','Pushbutton1');
1472
1473 h1 = uicontrol('Parent',h0, ...
1474 'Callback','preprocess close_sD',...
1475 'Units','normalized', ...
1476 'FontWeight','demi', ...
1477 'ListboxTop',0, ...
1478 'Position',[0.8240740740740741 0.01914893617021277 0.154320987654321 0.05319148936170213], ...
1479 'String','CLOSE', ...
1480 'Tag','Pushbutton2');
1481 h1 = uicontrol('Parent',h0, ...
1482 'Units','normalized', ...
1483 'BackgroundColor',[0.8 0.8 0.8], ...
1484 'FontWeight','demi', ...
1485 'HorizontalAlignment','left', ...
1486 'ListboxTop',0, ...
1487 'Position',[0.02777777777777778 0.2680851063829787 0.345679012345679 0.02978723404255319], ...
1488 'String','COMPONENTS:', ...
1489 'Style','text', ...
1490 'Tag','StaticText1');
1491 h1 = uicontrol('Parent',h0, ...
1492 'Units','normalized', ...
1493 'BackgroundColor',[1 1 1], ...
1494 'HorizontalAlignment','left', ...
1495 'Position',[0.02777777777777778 0.3170212765957447 0.3549382716049382 0.5319148936170213], ...
1496 'String',' ', ...
1497 'Style','listbox', ...
1498 'Tag','Listbox1', ...
1499 'Value',1);
1500
1501 data.sets_h=h1;
1502
1503 h1 = uicontrol('Parent',h0, ...
1504 'Units','normalized', ...
1505 'BackgroundColor',[1 1 1], ...
1506 'HorizontalAlignment','left', ...
1507 'Position',[0.6234567901234568 0.3170212765957447 0.3549382716049382 0.5319148936170213], ...
1508 'String',' ', ...
1509 'Style','listbox', ...
1510 'Tag','Listbox2', ...
1511 'Value',1);
1512
1513
1514 data.variables_h = h1;
1515
1516 h1 = uicontrol('Parent',h0, ...
1517 'Callback','preprocess export',...
1518 'Units','normalized', ...
1519 'FontWeight','demi', ...
1520 'ListboxTop',0, ...
1521 'Position',[0.4259259259259259 0.551063829787234 0.154320987654321 0.0425531914893617], ...
1522 'String','->', ...
1523 'Tag','Pushbutton4');
1524
1525 h1 = uicontrol('Parent',h0, ...
1526 'Callback','preprocess import',...
1527 'Units','normalized', ...
1528 'FontWeight','demi', ...
1529 'ListboxTop',0, ...
1530 'Position',[0.4259259259259259 0.625531914893617 0.154320987654321 0.0425531914893617], ...
1531 'String','<-', ...
1532 'Tag','Pushbutton3');
1533
1534
1535
1536 h1 = uicontrol('Parent',h0, ...
1537 'Units','normalized', ...
1538 'BackgroundColor',[0.8 0.8 0.8], ...
1539 'FontWeight','demi', ...
1540 'HorizontalAlignment','left', ...
1541 'ListboxTop',0, ...
1542 'Position',[0.02777777777777778 0.8531914893617022 0.2993827160493827 0.02978723404255319], ...
1543 'String','DATA SETS', ...
1544 'Style','text', ...
1545 'Tag','StaticText2');
1546
1547 h1 = uicontrol('Parent',h0, ...
1548 'Units','normalized', ...
1549 'BackgroundColor',[0.8 0.8 0.8], ...
1550 'FontWeight','demi', ...
1551 'HorizontalAlignment','left', ...
1552 'ListboxTop',0, ...
1553 'Position',[0.6234567901234568 0.8531914893617022 0.2561728395061728 0.02978723404255319], ...
1554 'String','WORKSPACE', ...
1555 'Style','text', ...
1556 'Tag','StaticText3');
1557
1558 h1 = uicontrol('Parent',h0, ...
1559 'Callback','preprocess rename set',...
1560 'Units','normalized', ...
1561 'BackgroundColor',[1 1 1], ...
1562 'HorizontalAlignment','left', ...
1563 'ListboxTop',0, ...
1564 'Position',[0.1820987654320987 0.9127659574468086 0.7808641975308641 0.0425531914893617], ...
1565 'Style','edit', ...
1566 'Tag','EditText2');
1567
1568 data.new_name_h = h1;
1569
1570
1571 h1 = uicontrol('Parent',h0, ...
1572 'Units','normalized', ...
1573 'BackgroundColor',[0.8 0.8 0.8], ...
1574 'FontWeight','demi', ...
1575 'HorizontalAlignment','left', ...
1576 'ListboxTop',0, ...
1577 'Position',[0.02777777777777778 0.9127659574468086 0.1388888888888889 0.02978723404255319], ...
1578 'String','NAME:', ...
1579 'Style','text', ...
1580 'Tag','StaticText4');
1581
1582
1583 ui_h=uimenu('Label','&Tools');
1584 uimenu(ui_h,'Label','Copy','Callback','preprocess copy_delete copy');
1585 uimenu(ui_h,'Label','Delete','Callback','preprocess copy_delete delete');
1586 uimenu(ui_h,'Label','Refresh','Callback','preprocess refresh');
1587
1588 set(gcf,'UserData',data);
1589 set_var_names;
1590 sD_names;
1591 sD_stats;
1592
1593
1594
1595 %%% Subfunction: set_var_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1596
1597 function set_var_names
1598
1599
1600 variables_h=getfield(get(gcf,'UserData'),'variables_h');
1601 value=get(variables_h,'Value');
1602 len=evalin('base','length(who)');
1603
1604 names=cell(len,1);
1605
1606 for i=1:len
1607 string=cat(2,'getfield(who,{',num2str(i),'})');
1608 names(i)=evalin('base',string);
1609 end
1610
1611 set(variables_h,'String',names);
1612 if(value > length(names))
1613 set(variables_h,'Value',1);
1614 end
1615
1616 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1617
1618 %%% Subfunction: sD_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1619
1620 function sD_names
1621
1622 sets_h=getfield(get(gcf,'UserData'),'sets_h');
1623 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1624
1625 sD_set = getfield(get(pre_h,'UserData'),'sD_set');
1626
1627 for i=1:length(sD_set)
1628 names{i,1}=cat(2,sprintf('#%d: ',i),sD_set(i).name);
1629 end
1630
1631 set(sets_h,'String',names);
1632
1633 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1634
1635 %%% Subfunction: sD_stats %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1636
1637 function sD_stats
1638
1639 man_h=findobj(get(0,'Children'),'Tag','Management');
1640 c_names_h=getfield(get(man_h,'UserData'),'new_c_name_h');
1641 sD_name_h=getfield(get(man_h,'UserData'),'new_name_h');
1642 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1643 INDEX=getfield(getfield(get(pre_h,'UserData'),'sData'),'INDEX');
1644 MODIFIED=getfield(getfield(get(pre_h,'UserData'),'sData'),'MODIFIED');
1645 value=get(getfield(get(man_h,'UserData'),'sets_h'),'Value');
1646
1647 if value==INDEX
1648 data=get(pre_h,'UserData');
1649 sData=rmfield(data.sData,[{'INDEX'};{'MODIFIED'}]);
1650 data.sD_set(INDEX)=sData;
1651 data.sData.MODIFIED=0;
1652 set(pre_h,'UserData',data);
1653 end
1654
1655 sData=getfield(getfield(get(pre_h,'UserData'),'sD_set'),{value});
1656 string1=[{sData.name}];
1657
1658
1659 set(sD_name_h,'String',string1);
1660 set(c_names_h,'String',sData.comp_names);
1661
1662 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1663
1664 %%% Subfunction: import %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1665
1666 function import(varargin)
1667
1668 if nargin==1
1669 LOG=1;
1670 man_h=findobj(get(0,'Children'),'Tag','Management');
1671 set(0,'CurrentFigure',man_h);
1672 name=varargin;
1673 else
1674 LOG=0;
1675 end
1676
1677 variables_h=getfield(get(gcf,'UserData'),'variables_h');
1678 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1679 if ~LOG
1680 name=getfield(get(variables_h,'String'),{get(variables_h,'Value')});
1681 end
1682 errstr='Data to be imported must be real matrix or ''som_data_struct''.';
1683 new_sD=evalin('base',name{1});
1684
1685 if isempty(pre_h)
1686 errordlg('''Preprocess'' -figure does not exist. Terminating program...');
1687 close_preprocess;
1688 return;
1689 end
1690
1691 if isstr(new_sD) | (~isstruct(new_sD) & ~isreal(new_sD))
1692 errordlg(errstr);
1693 return;
1694 elseif isstruct(new_sD) & length(new_sD) > 1
1695 errordlg(errstr)
1696 return;
1697 elseif ~isstruct(new_sD)
1698 new_sD=som_data_struct(new_sD);
1699 new_sD.name=name{1};
1700 end
1701
1702 new_sD_names=fieldnames(new_sD);
1703 right_names=fieldnames(som_data_struct(1));
1704 for i=1:length(new_sD_names)
1705 if ~any(strcmp(new_sD_names(i),right_names));
1706 errordlg(errstr);
1707 return;
1708 end
1709 end
1710
1711 data=get(pre_h,'UserData');
1712 data.sD_set(length(data.sD_set) + 1)=new_sD;
1713 if ~LOG
1714 data.LOG{length(data.LOG)+1}='% Import a data set from the workspace.';
1715 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''import'',''',...
1716 name{1},''');');
1717 end
1718 set(pre_h,'UserData',data);
1719 sD_names;
1720 sD_stats;
1721 old =gcf;
1722 set(0,'CurrentFigure',pre_h);
1723 set_sD_stats;
1724 set(0,'CurrentFigure',old);
1725
1726 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1727
1728 %%% Subfunction: export %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1729
1730 function export(varargin)
1731
1732 if nargin == 1
1733 LOG=1;
1734 man_h=findobj(get(0,'Children'),'Tag','Management');
1735 set(0,'CurrentFigure',man_h);
1736 index=str2num(varargin{1});
1737 else
1738 LOG=0;
1739 end
1740
1741 sets_h=getfield(get(gcf,'UserData'),'sets_h');
1742 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1743
1744 if ~LOG
1745 index=get(sets_h,'Value');
1746 end
1747
1748 if isempty(pre_h)
1749 errordlg('''Preprocess''-figure does not exist. Terminating program...');
1750 close(findobj(get(0,'Children'),'Tag','Management'));
1751 close(findobj(get(0,'Children'),'Tag','PlotWin'));
1752 return;
1753 end
1754
1755 sData=getfield(getfield(get(pre_h,'UserData'),'sD_set'),{index});
1756
1757 if ~isvalid_var_name({sData.name})
1758 return;
1759 end
1760
1761 assignin('base',sData.name,sData);
1762 disp(sprintf('Data set ''%s'' is set to the workspace.',sData.name));
1763 if ~LOG
1764 data=get(pre_h,'UserData');
1765 data.LOG{length(data.LOG)+1}='% Export a data set to the workspace.';
1766 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''export'',''',...
1767 num2str(index),''');');
1768 set(pre_h,'UserData',data);
1769 end
1770 set_var_names;
1771
1772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1773
1774 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1775 %%% Subfunction: rename %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1776
1777 function rename(arg)
1778
1779 i=1;
1780 while i <= length(arg) & arg(i) ~= ' '
1781 i=i+1;
1782 end
1783
1784 arg2=arg(i+1:length(arg));
1785 arg=arg(1:i-1);
1786 if ~isempty(arg2)
1787 LOG=1;
1788 i=1;
1789 if arg2(1) ~= '{'
1790 while i <= length(arg2) & arg2(i) ~= ' '
1791 i=i+1;
1792 end
1793 index=str2num(arg2(i+1:length(arg2)));
1794 arg2=arg2(1:i-1);
1795 else
1796 while i <= length(arg2) & arg2(i) ~= '}'
1797 i=i+1;
1798 end
1799 index=str2num(arg2(i+1:length(arg2)));
1800 arg2=arg2(1:i);
1801 end
1802 else
1803 LOG=0;
1804 end
1805
1806 new_name_h=getfield(get(gcf,'UserData'),'new_name_h');
1807 new_c_name_h=getfield(get(gcf,'UserData'),'new_c_name_h');
1808 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1809
1810 if isempty(pre_h)
1811 errordlg('''Preprocess'' -figure does not exist. Terminating program...');
1812 close_preprocess;
1813 return;
1814 end
1815
1816 switch arg
1817 case 'set'
1818 if LOG
1819 name={arg2};
1820 else
1821 name=get(new_name_h,'String');
1822 end
1823 if ~isempty(name{1}) & ~any(isspace(name{1}))
1824 if ~isvalid_var_name(name)
1825 sD_stats;
1826 return;
1827 end
1828 if ~LOG
1829 index=get(getfield(get(gcf,'UserData'),'sets_h'),'Value');
1830 end
1831 data=get(pre_h,'UserData');
1832 tmp_set.name=name{1};
1833 data.sD_set(index).name=name{1};
1834 if data.sData.INDEX == index
1835 data.sData.name=name{1};
1836 end
1837 if ~LOG
1838 data.LOG{length(data.LOG)+1}='% Rename a data set.';
1839 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''rename'',''set ',...
1840 name{1},' ',...
1841 num2str(index),...
1842 ''');');
1843 end
1844
1845 set(pre_h,'UserData',data);
1846 sD_names;
1847 string=get(data.sD_set_h,'String');
1848 string{index}=cat(2,sprintf('#%d: ',index),name{1});
1849 set(data.sD_set_h,'String',string);
1850 string=get(data.sD_name_h,'String');
1851 string{1}=cat(2,'Name: ',name{1});
1852 if index==data.sData.INDEX
1853 set(data.sD_name_h,'String',string);
1854 end
1855 else
1856 sD_stats;
1857 end
1858 case 'comp'
1859 if ~LOG
1860 names=get(new_c_name_h,'String');
1861 index=get(getfield(get(gcf,'UserData'),'sets_h'),'Value');
1862 else
1863 names=eval(arg2);
1864 end
1865 if check_cell_names(names)
1866 data=get(pre_h,'UserData');
1867 sData=data.sD_set(index);
1868 if length(sData.comp_names)==length(names)
1869 data.sD_set(index).comp_names=names;
1870 if index == data.sData.INDEX
1871 for i=1:length(names)
1872 names{i}=cat(2,sprintf('#%d: ',i),names{i});
1873 end
1874 set(data.comp_names_h,'String',names);
1875 set(data.sel_comp_h,'String',names);
1876 end
1877 if ~LOG
1878 data.LOG{length(data.LOG)+1}='% Rename components.';
1879 str='preprocess(''rename'',''comp {';
1880 for i=1:length(names)-1
1881 str=cat(2,str,'''''',names{i},''''',');
1882 end
1883 str=cat(2,str,'''''',names{length(names)},'''''} ',...
1884 num2str(index),''');');
1885 data.LOG{length(data.LOG)+1}=str;
1886 else
1887 set(new_c_name_h,'String',names);
1888 end
1889 set(pre_h,'UserData',data);
1890 else
1891 errordlg('There are less components in data.');
1892 sD_stats;
1893 return;
1894 end
1895 else
1896 sD_stats;
1897 end
1898 end
1899
1900 %%% Subfunction: check_cell_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1901
1902 function bool=check_cell_names(names)
1903
1904 bool = 1;
1905
1906 if isempty(names)
1907 bool= 0;
1908 return;
1909 end
1910 for i=1:length(names)
1911 if isempty(names{i}) | isspace(names{i})
1912 bool = 0;
1913 return;
1914 end
1915 end
1916
1917 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1918
1919 %%% Subfunction: isvalid_var_name %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1920
1921 function bool=isvalid_var_name(name)
1922
1923 bool=1;
1924
1925 tmp=name{1};
1926 if ~((tmp(1)>='a' & tmp(1)<='z') | (tmp(1)>='A' & tmp(1)<='Z'))
1927 errordlg('Invalid name.');
1928 bool=0;
1929 return;
1930 end
1931 for j=1:length(tmp)
1932 if ~((tmp(j)>='a' & tmp(j)<='z') | ...
1933 (tmp(j)>='A' & tmp(j)<='Z') | ...
1934 (j>1 & tmp(j) == '_') | ...
1935 (tmp(j)>='0' & tmp(j) <= '9')) | tmp(j) == '.'
1936 errordlg('Invalid name.');
1937 bool=0;
1938 return;
1939 end
1940 if j == length(tmp) & tmp(j) == '_'
1941 errordlg('Invalid name.');
1942 bool=0;
1943 return;
1944 end
1945 end
1946
1947 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1948 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1949
1950 %%% Subfunction: copy_delete %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1951
1952 function copy_delete(arg)
1953
1954 i=1;
1955 while i <= length(arg) & arg(i) ~= ' '
1956 i=i+1;
1957 end
1958
1959 arg2=arg(i+1:length(arg));
1960 arg=arg(1:i-1);
1961
1962 if ~isempty(arg2)
1963 index=str2num(arg2);
1964 LOG=1;
1965 else
1966 LOG=0;
1967 end
1968
1969 sets_h=getfield(get(gcf,'UserData'),'sets_h');
1970 if ~LOG
1971 index=get(sets_h,'Value');
1972 end
1973 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
1974
1975 if isempty(pre_h)
1976 errordlg('''Preprocess'' -figure does not exist. Terminating program.');
1977 close_preprocess;
1978 return;
1979 end
1980
1981 switch arg
1982 case 'copy'
1983 data=get(pre_h,'UserData');
1984 data.sD_set(length(data.sD_set)+1)=data.sD_set(index);
1985 if ~LOG
1986 data.LOG{length(data.LOG)+1}='% Copy a data set.';
1987 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''copy_delete'',''',...
1988 'copy ',num2str(index),''');');
1989 end
1990 set(pre_h,'UserData',data);
1991 sD_names;
1992 old=gcf;
1993 set(0,'CurrentFigure',pre_h);
1994 set_sD_stats;
1995 set(0,'CurrentFigure',old);
1996 case 'delete'
1997 if length(get(sets_h,'String')) == 1
1998 msgbox('No data left. Closing program...')
1999 close_preprocess;
2000 return;
2001 end
2002 data=get(pre_h,'UserData');
2003 if ~isempty(data.undo) & any(strcmp('index',fieldnames(data.undo)))
2004 if data.undo.index > index
2005 data.undo.index = data.undo.index-1;
2006 elseif data.undo.index==index;
2007 data.undo=[];
2008 end
2009 end
2010 set1=data.sD_set(1:index-1);
2011 set2=data.sD_set(index+1:length(data.sD_set));
2012
2013 if ~isempty(set1)
2014 data.sD_set=[set1 set2];
2015 else
2016 data.sD_set=set2;
2017 end
2018 if ~LOG
2019 data.LOG{length(data.LOG)+1}='% Delete a data set.';
2020 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''copy_delete'',''',...
2021 'delete ',num2str(index),''');');
2022 end
2023 set(pre_h,'UserData',data);
2024
2025 set(sets_h,'Value',1);
2026 sD_names;
2027 sD_stats;
2028 old = gcf;
2029 set(0,'CurrentFigure',pre_h);
2030
2031 for i=1:length(data.sD_set)
2032 string{i}=cat(2,sprintf('#%d: ',i),data.sD_set(i).name);
2033 end
2034
2035 set(data.sD_set_h,'String',string);
2036 data.sData=data.sD_set(get(data.sD_set_h,'Value'));
2037 data.sData.MODIFIED=0;
2038 data.sData.INDEX=1;
2039 set(gcf,'UserData',data);
2040 write_sD_stats;
2041
2042 sData=getfield(get(gcf,'UserData'),'sData');
2043 if sData.INDEX > index
2044 value=get(getfield(get(gcf,'UserData'),'sD_set_h'),'Value');
2045 set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',value-1);
2046 sData.INDEX = sData.INDEX -1;
2047 elseif sData.INDEX == index
2048 set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',1);
2049 end
2050
2051 sel_sD;
2052 set(0,'CurrentFigure',old);
2053 end
2054
2055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2056
2057 function clipping(varargin)
2058
2059 if nargin ~= 1
2060 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
2061 preh_udata=get(pre_h,'UserData');
2062 preh_udata.LOG{length(preh_udata.LOG)+1}=...
2063 '% Starting the ''Clipping'' -window...';
2064 preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''clipping'',''foo'');';
2065 set(pre_h,'UserData',preh_udata);
2066 end
2067
2068 clip_h=findobj(get(0,'Children'),'Tag','Clipping');
2069
2070 if ~isempty(clip_h)
2071 figure(clip_h);
2072 return;
2073 end
2074
2075 h0 = figure('Color',[0.8 0.8 0.8], ...
2076 'PaperPosition',[18 180 575 432], ...
2077 'PaperUnits','points', ...
2078 'Position',[718 389 300 249], ...
2079 'Tag','Clipping');
2080
2081 h1 = uicontrol('Parent',h0, ...
2082 'Units','normalized', ...
2083 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
2084 'ListboxTop',0, ...
2085 'Position',[0.03 0.03614457831325301 0.4666666666666667 0.9236947791164658], ...
2086 'Style','frame', ...
2087 'Tag','Frame1');
2088
2089 h1 = uicontrol('Parent',h0, ...
2090 'Units','normalized', ...
2091 'BackgroundColor',[0.8 0.8 0.8], ...
2092 'ListboxTop',0, ...
2093 'Position',[0.05333333333333334 0.5983935742971887 0.42 0.3333333333333333], ...
2094 'Style','frame', ...
2095 'Tag','Frame2');
2096
2097 h1 = uicontrol('Parent',h0, ...
2098 'Units','normalized', ...
2099 'BackgroundColor',[0.8 0.8 0.8], ...
2100 'ListboxTop',0, ...
2101 'Style','frame', ...
2102 'Position',[0.05333333333333334 0.33 0.42 0.24], ...
2103 'Tag','Frame3');
2104
2105 h1 = uicontrol('Parent',h0, ...
2106 'Units','normalized', ...
2107 'BackgroundColor',[0.8 0.8 0.8], ...
2108 'ListboxTop',0, ...
2109 'Style','frame', ...
2110 'Position',[0.05333333333333334 0.06 0.42 0.24],...
2111 'Tag','Frame4');
2112
2113 h1 = uicontrol('Parent',h0, ...
2114 'Units','normalized', ...
2115 'ListboxTop',0, ...
2116 'Position',[0.5133333333333334 0.6385542168674698 0.4666666666666667 0.321285140562249], ...
2117 'Style','frame', ...
2118 'Tag','Frame5');
2119
2120 h1 = uicontrol('Parent',h0, ...
2121 'Units','normalized', ...
2122 'BackgroundColor',[0.8 0.8 0.8], ...
2123 'ListboxTop',0, ...
2124 'Position',[0.5366666666666667 0.6666666666666666 0.42 0.2650602409638554], ...
2125 'Style','frame', ...
2126 'Tag','Frame6');
2127
2128 h1 = uicontrol('Parent',h0, ...
2129 'Units','normalized', ...
2130 'BackgroundColor',[1 1 1], ...
2131 'ListboxTop',0, ...
2132 'Position',[0.31 0.823293172690763 0.15 0.09638554216867469], ...
2133 'Style','edit', ...
2134 'Tag','EditText1');
2135
2136 data.big_val_h = h1;
2137
2138 h1 = uicontrol('Parent',h0, ...
2139 'Units','normalized', ...
2140 'BackgroundColor',[1 1 1], ...
2141 'ListboxTop',0, ...
2142 'Position',[0.31 0.7148594377510039 0.15 0.09638554216867469], ...
2143 'Style','edit', ...
2144 'Tag','EditText2');
2145
2146 data.small_val_h = h1;
2147
2148 h1 = uicontrol('Parent',h0, ...
2149 'Units','normalized', ...
2150 'BackgroundColor',[1 1 1], ...
2151 'ListboxTop',0, ...
2152 'Position',[0.31 0.606425702811245 0.15 0.09638554216867469], ...
2153 'Style','edit', ...
2154 'Tag','EditText3');
2155
2156 data.equal_val_h=h1;
2157
2158 h1 = uicontrol('Parent',h0, ...
2159 'Units','normalized', ...
2160 'BackgroundColor',[0.8 0.8 0.8], ...
2161 'FontSize',6, ...
2162 'FontWeight','demi', ...
2163 'HorizontalAlignment','left', ...
2164 'ListboxTop',0, ...
2165 'Position',[0.06000000000000001 0.8473895582329316 0.22 0.05622489959839357], ...
2166 'String','Bigger than', ...
2167 'Style','text', ...
2168 'Tag','StaticText1');
2169 h1 = uicontrol('Parent',h0, ...
2170 'Units','normalized', ...
2171 'BackgroundColor',[0.8 0.8 0.8], ...
2172 'FontSize',6, ...
2173 'FontWeight','demi', ...
2174 'HorizontalAlignment','left', ...
2175 'ListboxTop',0, ...
2176 'Position',[0.06000000000000001 0.7389558232931727 0.24 0.04819277108433735], ...
2177 'String','Smaller than', ...
2178 'Style','text', ...
2179 'Tag','StaticText2');
2180 h1 = uicontrol('Parent',h0, ...
2181 'Units','normalized', ...
2182 'BackgroundColor',[0.8 0.8 0.8], ...
2183 'FontSize',6, ...
2184 'FontWeight','demi', ...
2185 'HorizontalAlignment','left', ...
2186 'ListboxTop',0, ...
2187 'Position',[0.06000000000000001 0.610441767068273 0.22 0.07228915662650602], ...
2188 'String','Equal to', ...
2189 'Style','text', ...
2190 'Tag','StaticText3');
2191
2192 h1 = uicontrol('Parent',h0, ...
2193 'Units','normalized', ...
2194 'BackgroundColor',[0.8 0.8 0.8], ...
2195 'ListboxTop',0, ...
2196 'Position',[0.07000000000000001 0.465863453815261 0.06333333333333334 0.07228915662650602], ...
2197 'Style','radiobutton', ...
2198 'Value',1,...
2199 'Tag','Radiobutton1');
2200
2201 data.and_button_h=h1;
2202
2203 h1 = uicontrol('Parent',h0, ...
2204 'Units','normalized', ...
2205 'BackgroundColor',[0.8 0.8 0.8], ...
2206 'ListboxTop',0, ...
2207 'Position',[0.07000000000000001 0.3734939759036144 0.06333333333333334 0.07228915662650602], ...
2208 'Style','radiobutton', ...
2209 'Tag','Radiobutton2');
2210
2211 data.or_button_h=h1;
2212
2213 h1 = uicontrol('Parent',h0, ...
2214 'Units','normalized', ...
2215 'BackgroundColor',[0.8 0.8 0.8], ...
2216 'FontSize',6, ...
2217 'FontWeight','demi', ...
2218 'HorizontalAlignment','left', ...
2219 'Position',[0.1466666666666667 0.45 0.2333333333333333 0.07228915662650602], ...
2220 'String','AND', ...
2221 'Style','text', ...
2222 'Tag','StaticText4');
2223
2224 h1 = uicontrol('Parent',h0, ...
2225 'Units','normalized', ...
2226 'BackgroundColor',[0.8 0.8 0.8], ...
2227 'FontSize',6, ...
2228 'FontWeight','demi', ...
2229 'HorizontalAlignment','left', ...
2230 'ListboxTop',0, ...
2231 'String','OR', ...
2232 'Position',[0.1466666666666667 0.35 0.2333333333333333 0.07228915662650602], ...
2233 'Style','text', ...
2234 'Tag','StaticText5');
2235
2236 h1 = uicontrol('Parent',h0, ...
2237 'Units','normalized', ...
2238 'BackgroundColor',[0.8 0.8 0.8], ...
2239 'ListboxTop',0, ...
2240 'Position',[0.07000000000000001 0.1967871485943775 0.06333333333333334 0.07228915662650602], ...
2241 'Style','radiobutton', ...
2242 'Value',1,...
2243 'Tag','Radiobutton3');
2244
2245 data.all_button_h=h1;
2246
2247 h1 = uicontrol('Parent',h0, ...
2248 'Units','normalized', ...
2249 'BackgroundColor',[0.8 0.8 0.8], ...
2250 'ListboxTop',0, ...
2251 'Position',[0.07000000000000001 0.09236947791164658 0.06333333333333334 0.07228915662650602], ...
2252 'Style','radiobutton', ...
2253 'Tag','Radiobutton4');
2254
2255 data.sel_vects_button_h=h1;
2256
2257 h1 = uicontrol('Parent',h0, ...
2258 'Units','normalized', ...
2259 'BackgroundColor',[0.8 0.8 0.8], ...
2260 'FontSize',6, ...
2261 'FontWeight','demi', ...
2262 'HorizontalAlignment','left', ...
2263 'ListboxTop',0, ...
2264 'Position',[0.1466666666666667 0.1927710843373494 0.2333333333333333 0.07228915662650602], ...
2265 'String','All vectors', ...
2266 'Style','text', ...
2267 'Tag','StaticText6');
2268 h1 = uicontrol('Parent',h0, ...
2269 'Units','normalized', ...
2270 'BackgroundColor',[0.8 0.8 0.8], ...
2271 'FontSize',6, ...
2272 'FontWeight','demi', ...
2273 'HorizontalAlignment','left', ...
2274 'ListboxTop',0, ...
2275 'Position',[0.1466666666666667 0.09638554216867469 0.3133333333333334 0.05622489959839357], ...
2276 'String','Among selected', ...
2277 'Style','text', ...
2278 'Tag','StaticText7');
2279 h1 = uicontrol('Parent',h0, ...
2280 'Units','normalized', ...
2281 'BackgroundColor',[1 1 1], ...
2282 'ListboxTop',0, ...
2283 'Position',[0.7866666666666667 0.823293172690763 0.1366666666666667 0.09236947791164658], ...
2284 'Style','edit', ...
2285 'Tag','EditText4');
2286
2287 data.replace_val_h=h1;
2288
2289 h1 = uicontrol('Parent',h0, ...
2290 'Units','normalized', ...
2291 'BackgroundColor',[0.8 0.8 0.8], ...
2292 'FontSize',6, ...
2293 'FontWeight','demi', ...
2294 'HorizontalAlignment','left', ...
2295 'ListboxTop',0, ...
2296 'Position',[0.5633333333333334 0.8273092369477911 0.2066666666666667 0.07630522088353413], ...
2297 'String','Replace', ...
2298 'Style','text', ...
2299 'Tag','StaticText8');
2300 h1 = uicontrol('Parent',h0, ...
2301 'Units','normalized', ...
2302 'FontWeight','demi', ...
2303 'ListboxTop',0, ...
2304 'Position',[0.5700000000000001 0.6827309236947791 0.3566666666666667 0.08032128514056225], ...
2305 'String','Replace', ...
2306 'Tag','Pushbutton1');
2307
2308 data.OK_button_h=h1;
2309
2310 h1 = uicontrol('Parent',h0, ...
2311 'Units','normalized', ...
2312 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
2313 'Callback','preprocess close_c',...
2314 'FontWeight','demi', ...
2315 'ListboxTop',0, ...
2316 'Position',[0.6633333333333333 0.07228915662650602 0.2833333333333333 0.09638554216867469], ...
2317 'String','Close', ...
2318 'Tag','Pushbutton2');
2319
2320
2321 data.state.and=1;
2322 data.state.all=1;
2323 data.state.big=[];
2324 data.state.small=[];
2325 data.state.equal=[];
2326 data.state.replace=[];
2327
2328 set(data.or_button_h,'Callback','preprocess and_or_cb or');
2329 set(data.and_button_h,'Callback','preprocess and_or_cb and');
2330 set(data.and_button_h,'Value',1);
2331 set(data.all_button_h,'Callback','preprocess all_sel_cb all');
2332 set(data.sel_vects_button_h,'Callback','preprocess all_sel_cb sel');
2333 set(data.big_val_h,'Callback','preprocess set_state_vals big');
2334 set(data.small_val_h,'Callback','preprocess set_state_vals small');
2335 set(data.equal_val_h,'Callback','preprocess set_state_vals equal');
2336 set(data.replace_val_h,'Callback','preprocess set_state_vals replace');
2337 set(data.OK_button_h,'Callback','preprocess clip_data clip');
2338 set(h0,'UserData',data);
2339
2340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2341
2342 function select(varargin)
2343
2344 if nargin ~= 1
2345 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
2346 preh_udata=get(pre_h,'UserData');
2347 preh_udata.LOG{length(preh_udata.LOG)+1}=...
2348 '% Starting the ''Select'' -window...';
2349 preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''select'',''foo'');';
2350 set(pre_h,'UserData',preh_udata);
2351 end
2352
2353 sel_h=findobj(get(0,'Children'),'Tag','Select');
2354
2355 if ~isempty(sel_h)
2356 figure(sel_h);
2357 return;
2358 end
2359
2360 h0 = figure('Color',[0.8 0.8 0.8], ...
2361 'PaperPosition',[18 180 576 432], ...
2362 'PaperUnits','points', ...
2363 'Position',[750 431 168 365], ...
2364 'Tag','Select');
2365 h1 = uicontrol('Parent',h0, ...
2366 'Units','normalized', ...
2367 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
2368 'ListboxTop',0, ...
2369 'Position',[0.05357142857142857 0.2712328767123288 0.8333333333333333 0.6301369863013698], ...
2370 'Style','frame', ...
2371 'Tag','Frame1');
2372
2373 h1 = uicontrol('Parent',h0, ...
2374 'Units','normalized', ...
2375 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
2376 'ListboxTop',0, ...
2377 'Position',[0.05357142857142857 0.1041095890410959 0.8333333333333333 0.1397260273972603], ...
2378 'Style','frame', ...
2379 'Tag','Frame2');
2380
2381 h1 = uicontrol('Parent',h0,...
2382 'Units','normalized', ...
2383 'BackgroundColor',[0.8 0.8 0.8], ...
2384 'ListboxTop',0, ...
2385 'Position',[0.09523809523809523 0.6547945205479452 0.75 0.2273972602739726], ...
2386 'Style','frame', ...
2387 'Tag','Frame3');
2388
2389 h1 = uicontrol('Parent',h0, ...
2390 'Units','normalized', ...
2391 'BackgroundColor',[0.8 0.8 0.8], ...
2392 'ListboxTop',0, ...
2393 'Position',[0.09523809523809523 0.4794520547945206 0.75 0.1506849315068493], ...
2394 'Style','frame', ...
2395 'Tag','Frame4');
2396
2397 h1 = uicontrol('Parent',h0, ...
2398 'Units','normalized', ...
2399 'BackgroundColor',[0.8 0.8 0.8], ...
2400 'ListboxTop',0, ...
2401 'Position',[0.09523809523809523 0.2986301369863014 0.75 0.1506849315068493], ...
2402 'Style','frame', ...
2403 'Tag','Frame5');
2404
2405 h1 = uicontrol('Parent',h0, ...
2406 'Units','normalized', ...
2407 'BackgroundColor',[1 1 1], ...
2408 'ListboxTop',0, ...
2409 'Position',[0.5535714285714285 0.8082191780821918 0.2678571428571429 0.06575342465753425], ...
2410 'Style','edit', ...
2411 'Tag','EditText1');
2412
2413 data.big_val_h=h1;
2414
2415 h1 = uicontrol('Parent',h0, ...
2416 'Units','normalized', ...
2417 'BackgroundColor',[1 1 1], ...
2418 'ListboxTop',0, ...
2419 'Position',[0.5535714285714285 0.7342465753424657 0.2678571428571429 0.06575342465753425], ...
2420 'Style','edit', ...
2421 'Tag','EditText2');
2422
2423 data.small_val_h = h1;
2424
2425 h1 = uicontrol('Parent',h0, ...
2426 'Units','normalized', ...
2427 'BackgroundColor',[1 1 1], ...
2428 'ListboxTop',0, ...
2429 'Position',[0.5535714285714285 0.6602739726027397 0.2678571428571429 0.06575342465753425], ...
2430 'Style','edit', ...
2431 'Tag','EditText3');
2432
2433 data.equal_val_h=h1;
2434
2435 h1 = uicontrol('Parent',h0, ...
2436 'BackgroundColor',[0.8 0.8 0.8], ...
2437 'Units','normalized', ...
2438 'FontWeight','demi', ...
2439 'FontSize',8,...
2440 'HorizontalAlignment','left', ...
2441 'ListboxTop',0, ...
2442 'Position',[0.1071 0.8247 0.3929 0.0384], ...
2443 'String','Bigger than', ...
2444 'Style','text', ...
2445 'Tag','StaticText1');
2446
2447 h1 = uicontrol('Parent',h0, ...
2448 'BackgroundColor',[0.8 0.8 0.8], ...
2449 'Units','normalized', ...
2450 'FontWeight','demi', ...
2451 'FontSize',8,...
2452 'HorizontalAlignment','left', ...
2453 'ListboxTop',0, ...
2454 'Position',[0.1071 0.7507 0.4286 0.0329], ...
2455 'String','Smaller than', ...
2456 'Style','text', ...
2457 'Tag','StaticText2');
2458
2459 h1 = uicontrol('Parent',h0, ...
2460 'Units','normalized', ...
2461 'BackgroundColor',[0.8 0.8 0.8], ...
2462 'FontWeight','demi', ...
2463 'FontSize',8,...
2464 'HorizontalAlignment','left', ...
2465 'ListboxTop',0, ...
2466 'Position',[0.1071 0.6630 0.3929 0.0493], ...
2467 'String','Equal to', ...
2468 'Style','text', ...
2469 'Tag','StaticText3');
2470
2471 h1 = uicontrol('Parent',h0, ...
2472 'Units','normalized', ...
2473 'BackgroundColor',[0.8 0.8 0.8], ...
2474 'ListboxTop',0, ...
2475 'Position',[0.125 0.5643835616438356 0.1130952380952381 0.04931506849315068], ...
2476 'Style','radiobutton', ...
2477 'Tag','Radiobutton1');
2478
2479 data.and_button_h = h1;
2480
2481 h1 = uicontrol('Parent',h0, ...
2482 'Units','normalized', ...
2483 'BackgroundColor',[0.8 0.8 0.8], ...
2484 'ListboxTop',0, ...
2485 'Position',[0.125 0.5013698630136987 0.1130952380952381 0.04931506849315068], ...
2486 'Style','radiobutton', ...
2487 'Tag','Radiobutton2');
2488
2489 data.or_button_h = h1;
2490
2491 h1 = uicontrol('Parent',h0, ...
2492 'Units','normalized', ...
2493 'BackgroundColor',[0.8 0.8 0.8], ...
2494 'FontWeight','demi', ...
2495 'FontSize',8,...
2496 'HorizontalAlignment','left', ...
2497 'ListboxTop',0, ...
2498 'Position',[0.2619047619047619 0.5561643835616439 0.3809523809523809 0.05205479452054795], ...
2499 'String','AND', ...
2500 'Style','text', ...
2501 'Tag','StaticText4');
2502
2503 h1 = uicontrol('Parent',h0, ...
2504 'Units','normalized', ...
2505 'BackgroundColor',[0.8 0.8 0.8], ...
2506 'FontWeight','demi', ...
2507 'FontSize',8,...
2508 'HorizontalAlignment','left', ...
2509 'ListboxTop',0, ...
2510 'Position',[0.2619047619047619 0.4986301369863014 0.3809523809523809 0.04657534246575343], ...
2511 'String','OR', ...
2512 'Style','text', ...
2513 'Tag','StaticText5');
2514
2515 h1 = uicontrol('Parent',h0, ...
2516 'Units','normalized', ...
2517 'BackgroundColor',[0.8 0.8 0.8], ...
2518 'ListboxTop',0, ...
2519 'Position',[0.125 0.3808219178082192 0.1130952380952381 0.04931506849315068], ...
2520 'Style','radiobutton', ...
2521 'Tag','Radiobutton3');
2522
2523 data.all_button_h = h1;
2524
2525 h1 = uicontrol('Parent',h0, ...
2526 'Units','normalized', ...
2527 'BackgroundColor',[0.8 0.8 0.8], ...
2528 'ListboxTop',0, ...
2529 'Position',[0.125 0.3095890410958904 0.1130952380952381 0.04931506849315068], ...
2530 'Style','radiobutton', ...
2531 'Tag','Radiobutton4');
2532
2533 data.sel_vects_button_h = h1;
2534
2535 h1 = uicontrol('Parent',h0, ...
2536 'Units','normalized', ...
2537 'BackgroundColor',[0.8 0.8 0.8], ...
2538 'FontWeight','demi', ...
2539 'FontSize',8,...
2540 'HorizontalAlignment','left', ...
2541 'ListboxTop',0, ...
2542 'Position',[0.2619047619047619 0.3780821917808219 0.4166666666666666 0.04931506849315068], ...
2543 'String','All vectors', ...
2544 'Style','text', ...
2545 'Tag','StaticText6');
2546
2547 h1 = uicontrol('Parent',h0, ...
2548 'Units','normalized', ...
2549 'BackgroundColor',[0.8 0.8 0.8], ...
2550 'FontWeight','demi', ...
2551 'FontSize',8,...
2552 'HorizontalAlignment','left', ...
2553 'ListboxTop',0, ...
2554 'Position',[0.2619047619047619 0.3123287671232877 0.5595238095238095 0.03835616438356165], ...
2555 'String','Among selected', ...
2556 'Style','text', ...
2557 'Tag','StaticText7');
2558
2559 h1 = uicontrol('Parent',h0, ...
2560 'Units','normalized', ...
2561 'BackgroundColor',[0.8 0.8 0.8], ...
2562 'ListboxTop',0, ...
2563 'Position',[0.0952 0.1178 0.7500 0.1068], ...
2564 'Style','frame', ...
2565 'Tag','Frame6');
2566
2567 h1 = uicontrol('Parent',h0, ...
2568 'Units','normalized', ...
2569 'BackgroundColor',[1 1 1], ...
2570 'ListboxTop',0, ...
2571 'Position',[0.5298 0.1342 0.2738 0.0712], ...
2572 'Style','edit', ...
2573 'Tag','EditText4');
2574
2575 data.replace_val_h = h1;
2576
2577 h1 = uicontrol('Parent',h0, ...
2578 'Units','normalized', ...
2579 'BackgroundColor',[0.8 0.8 0.8], ...
2580 'FontSize',8,...
2581 'FontWeight','demi', ...
2582 'HorizontalAlignment','left', ...
2583 'ListboxTop',0, ...
2584 'Position',[0.1369047619047619 0.136986301369863 0.3214285714285714 0.06027397260273973], ...
2585 'String','Vectors', ...
2586 'Style','text', ...
2587 'Tag','StaticText8');
2588
2589 h1 = uicontrol('Parent',h0, ...
2590 'Units','normalized', ...
2591 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
2592 'FontWeight','demi', ...
2593 'ListboxTop',0, ...
2594 'Position',[0.05357142857142857 0.01917808219178082 0.3869047619047619 0.0684931506849315], ...
2595 'String','OK', ...
2596 'Tag','Pushbutton1');
2597
2598 data.OK_button_h = h1;
2599
2600 h1 = uicontrol('Parent',h0, ...
2601 'Units','normalized', ...
2602 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
2603 'Callback','preprocess close_s',...
2604 'FontWeight','demi', ...
2605 'ListboxTop',0, ...
2606 'Position',[0.5 0.01917808219178082 0.3869047619047619 0.0684931506849315], ...
2607 'String','Close', ...
2608 'Tag','Pushbutton2');
2609
2610
2611
2612 data.state.and=1;
2613 data.state.all=1;
2614 data.state.big=[];
2615 data.state.small=[];
2616 data.state.equal=[];
2617 data.state.replace=[];
2618
2619 set(data.or_button_h,'Callback','preprocess and_or_cb or');
2620 set(data.and_button_h,'Callback','preprocess and_or_cb and');
2621 set(data.and_button_h,'Value',1);
2622 set(data.all_button_h,'Callback','preprocess all_sel_cb all');
2623 set(data.sel_vects_button_h,'Callback','preprocess all_sel_cb sel');
2624 set(data.big_val_h,'Callback','preprocess set_state_vals big');
2625 set(data.small_val_h,'Callback','preprocess set_state_vals small');
2626 set(data.equal_val_h,'Callback','preprocess set_state_vals equal');
2627 set(data.replace_val_h,'Callback','preprocess set_state_vals replace');
2628 set(data.OK_button_h,'Callback','preprocess clip_data sel');
2629 set(h0,'UserData',data);
2630
2631
2632
2633 %%% Subfunction: and_or_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2634
2635 function and_or_cb(arg)
2636
2637 %AND_OR_CB A callback function. Checks that only one of the radiobox
2638 % buttons 'AND' and 'OR' is pressed down.
2639 %
2640 %
2641
2642 and_button_h=getfield(get(gcf,'UserData'),'and_button_h');
2643 or_button_h=getfield(get(gcf,'UserData'),'or_button_h');
2644 data=get(gcf,'UserData');
2645
2646 switch arg
2647 case 'or'
2648 set(and_button_h,'Value',0);
2649 set(or_button_h,'Value',1);
2650 data.state.and=0;
2651 case 'and'
2652 set(or_button_h,'Value',0);
2653 set(and_button_h,'Value',1);
2654 data.state.and=1;
2655 end
2656
2657 set(gcf,'UserData',data);
2658
2659 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2660
2661 %%% Subfunction: all_sel_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2662
2663 function all_sel_cb(arg)
2664
2665 all_button_h=getfield(get(gcf,'UserData'),'all_button_h');
2666 sel_vects_button_h=getfield(get(gcf,'UserData'),'sel_vects_button_h');
2667 data=get(gcf,'UserData');
2668
2669 switch arg
2670 case 'all'
2671 set(sel_vects_button_h,'Value',0);
2672 set(all_button_h,'Value',1);
2673 data.state.all=1;
2674 case 'sel'
2675 set(all_button_h,'Value',0);
2676 set(sel_vects_button_h,'Value',1);
2677 data.state.all=0;
2678 end
2679
2680 set(gcf,'UserData',data);
2681
2682 %%% Subfunction: set_state_vals %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2683
2684 function set_state_vals(arg)
2685
2686 %SET_STATE_VALS sets the values to the UserData's state-struct.
2687 %
2688 %
2689
2690
2691 data=get(gcf,'UserData');
2692
2693 switch arg
2694 case 'big'
2695 big_val_h=getfield(get(gcf,'UserData'),'big_val_h');
2696 val =str2num(get(big_val_h,'String'));
2697 dims=size(val);
2698 if dims(1) ~= 1 | dims(2) ~= 1
2699 errordlg('Argument of the operation must be scalar.');
2700 set(big_val_h,'String','');
2701 return;
2702 end
2703 if isreal(val)
2704 data.state.big=val;
2705 else
2706 errordlg('Limits of the operation must be real.');
2707 set(big_val_h,'String','');
2708 return;
2709 end
2710 case 'small'
2711 small_val_h=getfield(get(gcf,'UserData'),'small_val_h');
2712 val=str2num(get(small_val_h,'String'));
2713 dims=size(val);
2714 if dims(1) ~= 1 | dims(2) ~= 1
2715 errordlg('Argument of the operation must be scalar.')
2716 set(small_val_h,'String','');
2717 return;
2718 end
2719 if isreal(val)
2720 data.state.small=val;
2721 else
2722 errordlg('Limits of the operation must be real.');
2723 set(small_val_h,'String','');
2724 return;
2725 end
2726 case 'equal'
2727 equal_val_h=getfield(get(gcf,'UserData'),'equal_val_h');
2728 val = str2num(get(equal_val_h,'String'));
2729 dims=size(val);
2730 if dims(1) ~= 1 | dims(2) ~= 1
2731 errordlg('Argument of the operation must be scalar.');
2732 set(equal_val_h,'String','');
2733 return;
2734 end
2735 if isreal(val)
2736 data.state.equal=val;
2737 else
2738 errordlg('Limits of the operation must be real.');
2739 set(equal_val_h,'String','');
2740 return;
2741 end
2742 case 'replace'
2743 replace_val_h=getfield(get(gcf,'UserData'),'replace_val_h');
2744 val=str2num(get(replace_val_h,'String'));
2745 dims=size(val);
2746 if (dims(1) ~= 1 | dims(2) ~= 1) & ~strcmp(get(gcf,'Tag'),'Select')
2747 errordlg('Argument of the operation must be scalar.');
2748 set(replace_val_h,'String','');
2749 return;
2750 end
2751 if isreal(val)
2752 data.state.replace=val;
2753 else
2754 errordlg('Limits of the operation must be real.');
2755 set(replace_val_h,'String','');
2756 return;
2757 end
2758 end
2759
2760 set(gcf,'UserData',data);
2761
2762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2763
2764 %%% Subfunction: clip_data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2765
2766 function clip_data(arg)
2767
2768 %CLIP_DATA A callback function. Filters the data.
2769 %
2770 %
2771
2772 i=1;
2773 while i <= length(arg) & arg(i) ~= ' '
2774 i=i+1;
2775 end
2776
2777 arg2=arg(i+1:length(arg));
2778 arg=arg(1:i-1);
2779
2780 if ~isempty(arg2)
2781 LOG=1;
2782 if strcmp(arg,'sel')
2783 c_h=findobj(get(0,'Children'),'Tag','Select');
2784 else
2785 c_h=findobj(get(0,'Children'),'Tag','Clipping');
2786 end
2787 set(0,'CurrentFigure',c_h);
2788 i=1;
2789 while i <= length(arg2) & arg2(i) ~= ' '
2790 i=i+1;
2791 end
2792 BT=str2num(arg2(1:i-1));
2793 i=i+1;
2794 j=i;
2795 while i <= length(arg2) & arg2(i) ~= ' '
2796 i=i+1;
2797 end
2798 ST=str2num(arg2(j:i-1));
2799 i=i+1;
2800 j=i;
2801 while i <= length(arg2) & arg2(i) ~= ' '
2802 i=i+1;
2803 end
2804 EQ=str2num(arg2(j:i-1));
2805 i=i+1;
2806 j=i;
2807 while i <= length(arg2) & arg2(i) ~= ' '
2808 i=i+1;
2809 end
2810 AND_OR=str2num(arg2(j:i-1));
2811 i=i+1;
2812 j=i;
2813 while i <= length(arg2) & arg2(i) ~= ' '
2814 i=i+1;
2815 end
2816 ALL_AMONG=str2num(arg2(j:i-1));
2817 i=i+1;
2818 j=i;
2819 while i <= length(arg2)
2820 i=i+1;
2821 end
2822 VECT_REPL=str2num(arg2(j:i-1));
2823 else
2824 LOG=0;
2825 end
2826
2827 if ~LOG
2828 big_val_h=getfield(get(gcf,'UserData'),'big_val_h');
2829 small_val_h=getfield(get(gcf,'UserData'),'small_val_h');
2830 equal_val_h=getfield(get(gcf,'UserData'),'equal_val_h');
2831 replace_val_h=getfield(get(gcf,'UserData'),'replace_val_h');
2832 end
2833
2834 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
2835
2836 if isempty(pre_h)
2837 errordlg('''Preprocess'' -figure does not exist. Terminating program...');
2838 pro_tools('close');
2839 return;
2840 end
2841
2842 comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h');
2843 selected=getfield(get(pre_h,'UserData'),'selected_vects');
2844 sData=getfield(get(pre_h,'UserData'),'sData');
2845 undo = sData;
2846 state=getfield(get(gcf,'UserData'),'state');
2847
2848 if LOG
2849 state.big=BT;
2850 state.small=ST;
2851 state.equal=EQ;
2852 state.replace=VECT_REPL;
2853 state.and=AND_OR;
2854 state.all=ALL_AMONG;
2855 end
2856
2857 if isempty(pre_h)
2858 pro_tools('close');
2859 end
2860
2861 if isempty(get(comp_names_h,'Value'))
2862 clear_state_vals;
2863 errordlg('There must be one component chosen for the operation.');
2864 return;
2865 end
2866
2867 n_th_comp=getfield(get_indices,{1});
2868
2869 if isempty(state.big) & isempty(state.small) & isempty(state.equal) & ...
2870 strcmp(arg,'clip')
2871 clear_state_vals;
2872 errordlg('At least one limit must be chosen for the-operation.');
2873 return;
2874 end
2875
2876 if ~isempty(state.replace) & strcmp(arg,'sel')
2877 if ~all(state.replace == round(state.replace)) | any(state.replace < 1)
2878 errordlg('Indices of vectors must be positive integers.');
2879 return;
2880 elseif any(state.replace > length(sData.data(:,1)))
2881 errordlg('Indices of the vectors to be selected are too big.');
2882 return;
2883 end
2884 end
2885
2886 if isempty(state.replace) & strcmp(arg,'clip')
2887 clear_state_vals;
2888 errordlg('Replace value must be determined for Clipping-operation.');
2889 return;
2890 end
2891
2892 if isempty(state.big) & isempty(state.small) & isempty(state.equal) & ...
2893 isempty(state.replace)
2894 clear_state_vals;
2895 return;
2896 end
2897
2898 bt_indices=[];
2899 lt_indices=[];
2900 equal_indices=[];
2901
2902
2903 if ~isempty(state.big)
2904 if state.all
2905 bt_indices=find(sData.data(:,n_th_comp) > state.big);
2906 else
2907 bt_indices=selected(find(sData.data(selected,n_th_comp) > state.big));
2908 end
2909 end
2910
2911 if ~isempty(state.small)
2912 if state.all
2913 lt_indices=find(sData.data(:,n_th_comp) < state.small);
2914 else
2915 lt_indices=selected(find(sData.data(selected,n_th_comp) < state.small));
2916 end
2917 end
2918
2919 if ~isempty(state.equal)
2920 if isnan(state.equal)
2921 if state.all
2922 equal_indices=find(isnan(sData.data(:,n_th_comp)));
2923 else
2924 equal_indices=selected(find(isnan(sData.data(selected,n_th_comp))));
2925 end
2926 elseif state.all
2927 equal_indices=find(sData.data(:,n_th_comp)==state.equal);
2928 else
2929 equal_indices=selected(find(sData.data(selected,n_th_comp)==state.equal));
2930 end
2931 end
2932
2933 if state.and
2934
2935 if ~isempty(bt_indices) | ~isempty(lt_indices) | ~isempty(equal_indices)...
2936 | strcmp(arg,'sel')
2937
2938 if isempty(bt_indices) & isempty(lt_indices) & isempty(equal_indices) &...
2939 isempty(state.replace)
2940 clear_state_vals;
2941 return;
2942 end
2943 if isempty(bt_indices)
2944 if ~state.all
2945 bt_indices=selected;
2946 else
2947 bt_indices=1:getfield(size(sData.data),{1});
2948 end
2949 end
2950 if isempty(lt_indices)
2951 if ~state.all
2952 lt_indices=selected;
2953 else
2954 lt_indices=1:getfield(size(sData.data),{1});
2955 end
2956 end
2957 if isempty(equal_indices)
2958 if ~state.all
2959 equal_indices=selected;
2960 else
2961 equal_indices=1:getfield(size(sData.data),{1});
2962 end
2963 end
2964
2965 indices=intersect(intersect(bt_indices,lt_indices),equal_indices);
2966 if strcmp(arg,'sel')
2967 if ~isempty(indices) | ~isempty(state.replace)
2968 if isempty(state.replace)
2969 NOTEMPTY=0;
2970 if ~state.all
2971 state.replace=selected;
2972 else
2973 state.replace=1:getfield(size(sData.data),{1});
2974 end
2975 else
2976 NOTEMPTY=1;
2977 end
2978 if isempty(indices)
2979 indices=selected;
2980 end
2981 indices=intersect(indices,state.replace);
2982 if isempty(indices)
2983 indices=selected;
2984 end
2985 data=get(pre_h,'UserData');
2986 data.undo.sData=sData;
2987 data.undo.selected=data.selected_vects;
2988 data.selected_vects=indices;
2989 if ~LOG
2990 if ~NOTEMPTY
2991 data.LOG{length(data.LOG)+1}='% Select vectors.';
2992 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',...
2993 arg,...
2994 ' ',num2str(state.big),...
2995 ' ',num2str(state.small),...
2996 ' ',num2str(state.equal),...
2997 ' ',num2str(state.and),...
2998 ' ',num2str(state.all),...
2999 ''');');
3000 else
3001 code=write_log_code(state.replace,...
3002 arg,...
3003 state.big,...
3004 state.small,...
3005 state.equal,...
3006 state.and,...
3007 state.all);
3008 data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code;
3009 end
3010 end
3011 set(pre_h,'UserData',data);
3012 old=gcf;
3013 set(0,'CurrentFigure',pre_h);
3014 sel_comp;
3015 cplot_mimema;
3016 vect_means(data.sData,data.vect_mean_h,data.selected_vects);
3017 set(0,'CurrentFigure',old);
3018 end
3019 clear_state_vals;
3020 return;
3021 end
3022 sData.data(indices,n_th_comp) = state.replace;
3023 sData.MODIFIED=1;
3024 end
3025 else
3026 indices=union(union(bt_indices,lt_indices),equal_indices);
3027 if ~isempty(indices) | strcmp(arg,'sel')
3028 if strcmp(arg,'sel')
3029 if ~isempty(indices) | ~isempty(state.replace')
3030 data=get(pre_h,'UserData');
3031 data.undo.sData=sData;
3032 data.undo.selected=data.selected_vects;
3033 data.selected_vects=union(indices,state.replace);
3034 if ~LOG
3035 if isempty(state.replace);
3036 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',...
3037 arg,...
3038 ' ',num2str(state.big),...
3039 ' ',num2str(state.small),...
3040 ' ',num2str(state.equal),...
3041 ' ',num2str(state.and),...
3042 ' ',num2str(state.all),...
3043 ''');');
3044 else
3045 code=write_log_code(state.replace,...
3046 arg,...
3047 state.big,...
3048 state.small,...
3049 state.equal,...
3050 state.and,...
3051 state.all);
3052 data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code;
3053 end
3054 end
3055 set(pre_h,'UserData',data);
3056 old=gcf;
3057 set(0,'CurrentFigure',pre_h);
3058 sel_comp;
3059 vect_means(data.sData,data.vect_mean_h,data.selected_vects);
3060 cplot_mimema;
3061 set(0,'CurrentFigure',old);
3062 end
3063 clear_state_vals;
3064 return;
3065 end
3066 sData.data(indices,n_th_comp)=state.replace;
3067 sData.MODIFIED=1;
3068 end
3069 end
3070
3071 if sData.MODIFIED
3072 data=get(pre_h,'UserData');
3073 data.sData=sData;
3074 data.undo.sData=undo;
3075 if ~LOG
3076 if strcmp(arg,'sel')
3077 data.LOG{length(data.LOG)+1}='% Select vectors';
3078 else
3079 data.LOG{length(data.LOG)+1}='% Clip values.';
3080 end
3081 if strcmp(arg,'clip') | isempty(state.replace)
3082 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',arg,...
3083 ' ',num2str(state.big),...
3084 ' ',num2str(state.small),...
3085 ' ',num2str(state.equal),...
3086 ' ',num2str(state.and),...
3087 ' ',num2str(state.all),...
3088 ' ',num2str(state.replace),...
3089 ''');');
3090 else
3091 code=write_log_code(state.replace,...
3092 arg,...
3093 state.big,...
3094 state.small,...
3095 state.equal,...
3096 state.and,...
3097 state.all);
3098 data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code;
3099 end
3100 end
3101 set(pre_h,'UserData',data);
3102 old=gcf;
3103 set(0,'CurrentFigure',pre_h)
3104
3105 vector_h=getfield(get(gcf,'UserData'),'vector_h');
3106 vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h');
3107 set(gcf,'CurrentAxes',vector_h);
3108 vect_means(sData,vect_mean_h,selected);
3109 cplot_mimema;
3110 sel_comp;
3111
3112 set(0,'CurrentFigure',old);
3113 end
3114
3115 clear_state_vals;
3116
3117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3118
3119 %%% Subfunction: clear_state_vals %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3120
3121 function clear_state_vals
3122
3123 %CLEAR_STATE_VALS Sets the fields of the UserData's state-struct empty.
3124 %
3125 %
3126
3127
3128 data=get(gcf,'UserData');
3129 set(data.big_val_h,'String','');
3130 set(data.small_val_h,'String','');
3131 set(data.equal_val_h,'String','');
3132 set(data.replace_val_h,'String','');
3133 data.state.big=[];
3134 data.state.small=[];
3135 data.state.equal=[];
3136 data.state.replace=[];
3137 set(gcf,'UserData',data);
3138
3139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3140
3141 function delay(varargin)
3142
3143 delay_h=findobj(get(0,'Children'),'Tag','Delay');
3144
3145 if nargin ~= 1
3146 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
3147 preh_udata=get(pre_h,'UserData');
3148 preh_udata.LOG{length(preh_udata.LOG)+1}=...
3149 '% Starting the ''Delay'' -window...';
3150 preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''delay'',''foo'');';
3151 set(pre_h,'UserData',preh_udata);
3152 end
3153
3154 if ~isempty(delay_h)
3155 figure(delay_h);
3156 return;
3157 end
3158
3159 h0 = figure('Color',[0.8 0.8 0.8], ...
3160 'PaperPosition',[18 180 576 432], ...
3161 'PaperUnits','points', ...
3162 'Position',[759 664 162 215], ...
3163 'Tag','Delay');
3164
3165 h1 = uicontrol('Parent',h0, ...
3166 'Units','normalized', ...
3167 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
3168 'ListboxTop',0, ...
3169 'Position',[0.05555555555555555 0.2046511627906977 0.8950617283950617 0.7441860465116279], ...
3170 'Style','frame', ...
3171 'Tag','Frame1');
3172
3173 h1 = uicontrol('Parent',h0, ...
3174 'Units','normalized', ...
3175 'BackgroundColor',[0.8 0.8 0.8], ...
3176 'ListboxTop',0, ...
3177 'Position',[0.08641975308641975 0.6976744186046512 0.8333333333333333 0.2232558139534884], ...
3178 'Style','frame', ...
3179 'Tag','Frame2');
3180
3181 h1 = uicontrol('Parent',h0, ...
3182 'Units','normalized', ...
3183 'BackgroundColor',[0.8 0.8 0.8], ...
3184 'ListboxTop',0, ...
3185 'Position',[0.08641975308641975 0.227906976744186 0.8333333333333333 0.4418604651162791], ...
3186 'Style','frame', ...
3187 'Tag','Frame3');
3188
3189 h1 = uicontrol('Parent',h0, ...
3190 'Units','normalized', ...
3191 'Callback','preprocess delay_data',...
3192 'FontWeight','demi', ...
3193 'ListboxTop',0, ...
3194 'Position',[0.0556 0.0326 0.4012 0.1163], ...
3195 'String','OK', ...
3196 'Tag','Pushbutton1');
3197
3198 h1 = uicontrol('Parent',h0, ...
3199 'Units','normalized', ...
3200 'Callback','preprocess close_d',...
3201 'FontWeight','demi', ...
3202 'ListboxTop',0, ...
3203 'Position',[0.5494 0.0326 0.4012 0.1163], ...
3204 'String','Close', ...
3205 'Tag','Pushbutton2');
3206
3207 h1 = uicontrol('Parent',h0, ...
3208 'Units','normalized', ...
3209 'BackgroundColor',[1 1 1], ...
3210 'ListboxTop',0, ...
3211 'Position',[0.4876543209876543 0.7534883720930232 0.3518518518518519 0.1255813953488372], ...
3212 'Style','edit', ...
3213 'Tag','EditText1');
3214
3215 data.delay_val_h = h1;
3216
3217 h1 = uicontrol('Parent',h0, ...
3218 'Units','normalized', ...
3219 'BackgroundColor',[0.8 0.8 0.8], ...
3220 'FontWeight','demi', ...
3221 'HorizontalAlignment','left', ...
3222 'ListboxTop',0, ...
3223 'Position',[0.1173 0.7860 0.3086 0.0651], ...
3224 'String','Delay', ...
3225 'Style','text', ...
3226 'Tag','StaticText1');
3227
3228 h1 = uicontrol('Parent',h0, ...
3229 'Units','normalized', ...
3230 'Callback','preprocess clip_exp_cb c_this',...
3231 'BackgroundColor',[0.8 0.8 0.8], ...
3232 'ListboxTop',0, ...
3233 'Position',[0.1173 0.5349 0.1173 0.0837], ...
3234 'Style','radiobutton', ...
3235 'Tag','Radiobutton1');
3236
3237 data.c_this_button_h=h1;
3238 data.mode='c_this';
3239
3240 h1 = uicontrol('Parent',h0, ...
3241 'Units','normalized', ...
3242 'BackgroundColor',[0.8 0.8 0.8], ...
3243 'Callback','preprocess clip_exp_cb c_all',...
3244 'ListboxTop',0, ...
3245 'Position',[0.1173 0.4047 0.1173 0.0837], ...
3246 'Style','radiobutton', ...
3247 'Tag','Radiobutton2');
3248
3249 data.c_all_button_h=h1;
3250
3251 h1 = uicontrol('Parent',h0, ...
3252 'Units','normalized', ...
3253 'BackgroundColor',[0.8 0.8 0.8], ...
3254 'Callback','preprocess clip_exp_cb e_all',...
3255 'ListboxTop',0, ...
3256 'Position',[0.1173 0.2651 0.1173 0.0837], ...
3257 'Style','radiobutton', ...
3258 'Tag','Radiobutton3');
3259
3260 data.e_all_button_h=h1;
3261
3262
3263 h1 = uicontrol('Parent',h0, ...
3264 'Units','normalized', ...
3265 'BackgroundColor',[0.8 0.8 0.8], ...
3266 'FontWeight','demi', ...
3267 'FontSize',8,...
3268 'HorizontalAlignment','left', ...
3269 'ListboxTop',0, ...
3270 'Position',[0.26 0.5534883720930233 0.4135802469135802 0.06511627906976744], ...
3271 'String','Clip this', ...
3272 'Style','text', ...
3273 'Tag','StaticText2');
3274 h1 = uicontrol('Parent',h0, ...
3275 'Units','normalized', ...
3276 'BackgroundColor',[0.8 0.8 0.8], ...
3277 'FontWeight','demi', ...
3278 'FontSize',8,...
3279 'HorizontalAlignment','left', ...
3280 'ListboxTop',0, ...
3281 'Position',[0.26 0.413953488372093 0.3765432098765432 0.06511627906976744], ...
3282 'String','Clip all', ...
3283 'Style','text', ...
3284 'Tag','StaticText3');
3285 h1 = uicontrol('Parent',h0, ...
3286 'Units','normalized', ...
3287 'BackgroundColor',[0.8 0.8 0.8], ...
3288 'FontWeight','demi', ...
3289 'FontSize',8,...
3290 'HorizontalAlignment','left', ...
3291 'ListboxTop',0, ...
3292 'Position',[0.26 0.2744186046511628 0.4197530864197531 0.06511627906976744], ...
3293 'String','Expand all', ...
3294 'Style','text', ...
3295 'Tag','StaticText4');
3296
3297
3298 set(gcf,'UserData',data);
3299
3300 %%% Subfunction clip_exp_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3301
3302 function clip_exp_cb(arg)
3303
3304 c_this_button_h=getfield(get(gcf,'UserData'),'c_this_button_h');
3305 c_all_button_h=getfield(get(gcf,'UserData'),'c_all_button_h');
3306 e_all_button_h=getfield(get(gcf,'UserData'),'e_all_button_h');
3307 data=get(gcf,'UserData');
3308
3309
3310 switch arg
3311 case 'c_this'
3312 set(c_all_button_h,'Value',0);
3313 set(e_all_button_h,'Value',0);
3314 set(c_this_button_h,'Value',1);
3315 data.mode='c_this';
3316 case 'c_all'
3317 set(c_this_button_h,'Value',0);
3318 set(e_all_button_h,'Value',0);
3319 set(c_all_button_h,'Value',1);
3320 data.mode='c_all';
3321 case 'e_all'
3322 set(c_this_button_h,'Value',0);
3323 set(c_all_button_h,'Value',0);
3324 set(e_all_button_h,'Value',1);
3325 data.mode='e_all';
3326 end
3327
3328 set(gcf,'UserData',data);
3329
3330 %%% Subfunction: delay_data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3331
3332 function delay_data(varargin)
3333
3334 if nargin == 1
3335 del_h=findobj(get(0,'Children'),'Tag','Delay');
3336 set(0,'CurrentFigure',del_h);
3337 LOG=1;
3338 arg=varargin{1};
3339 i=1;
3340 while i <= length(arg) & arg(i) ~= ' '
3341 i=i+1;
3342 end
3343 delay=str2num(arg(1:i-1));
3344 no=str2num(arg(i+1:length(arg)));
3345 else
3346 LOG=0;
3347 end
3348
3349 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
3350 q='Delay operation is not evaluated.';
3351 t='Warning';
3352 if isempty(pre_h)
3353 errordlg('''Preprocess'' -figure does not exist. Terminating program...');
3354 pro_tools('close');
3355 return;
3356 end
3357
3358 sData=getfield(get(pre_h,'UserData'),'sData');
3359 undo = sData;
3360 data=get(gcf,'UserData');
3361 if ~LOG
3362 delay=str2num(get(data.delay_val_h,'String'));
3363 if isempty(delay)
3364 errordlg('Value of ''Delay'' must be defined.');
3365 return
3366 end
3367 set(data.delay_val_h,'String','');
3368 if round(delay) ~= delay
3369 errordlg('Value of ''Delay'' must be integer.');
3370 return;
3371 end
3372 end
3373 comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h');
3374 if isempty(get(comp_names_h,'Value'))
3375 errordlg('There are not components chosen.');
3376 return;
3377 end
3378 n_th_comp=getfield(get_indices,{1});
3379 len=length(sData.data(:,1));
3380
3381 if LOG
3382 switch no
3383 case 1
3384 data.mode='c_this';
3385 preprocess('clip_exp_cb','c_this');
3386 case 2
3387 data.mode='c_all';
3388 preprocess('clip_exp_cb','c_all');
3389 case 3
3390 data.mode='e_all';
3391 preprocess('clip_exp_cb','e_all');
3392 end
3393 end
3394
3395 switch data.mode
3396 case 'c_this'
3397 MODE='1';
3398 if delay > 0
3399 sData.data(delay+1:len,n_th_comp)=sData.data(1:len-delay);
3400 if delay >= len
3401 errordlg(q,t);
3402 return;
3403 else
3404 sData.data(1:delay,n_th_comp)=NaN;
3405 end
3406 elseif delay < 0
3407 sData.data(1:len+delay,n_th_comp)=...
3408 sData.data(abs(delay)+1:len,n_th_comp);
3409 if abs(delay) >= len
3410 errordlg(q,t);
3411 return;
3412 else
3413 sData.data(len+delay+1:len,n_th_comp)=NaN;
3414 end
3415 end
3416 if delay ~= 0
3417 data=get(pre_h,'UserData');
3418 sData.MODIFIED=1;
3419 sData.comp_norm(n_th_comp)=[];
3420 data.sData=sData;
3421 data.undo.sData=undo;
3422 set(pre_h,'UserData',data);
3423 old = gcf;
3424 set(0,'CurrentFigure',pre_h);
3425 sel_comp;
3426 cplot_mimema;
3427 set(0,'CurrentFigure',old);
3428 end
3429 case 'c_all'
3430 MODE='2';
3431 if delay > 0
3432 sData.data(delay+1:len,n_th_comp)=sData.data(1:len-delay,n_th_comp);
3433 if delay >= len
3434 errordlg(q,t);
3435 return;
3436 else
3437 sData.data=sData.data(delay+1:len,:);
3438 end
3439 elseif delay < 0
3440 sData.data(1:len+delay,n_th_comp)=sData.data(abs(delay)+1:len,n_th_comp);
3441 if abs(delay) >= len
3442 errordlg(q,t);
3443 return;
3444 else
3445 sData.data=sData.data(1:len+delay,:);
3446 end
3447 end
3448 if delay ~= 0
3449 data=get(pre_h,'UserData');
3450 sData.MODIFIED=1;
3451 sData.comp_norm(:,:)={[]};
3452 data.sData=sData;
3453 data.undo.sData=undo;
3454 data.undo.selected=data.selected_vects;
3455 if delay > 0
3456 data.selected_vects=...
3457 data.selected_vects(find(data.selected_vects>delay));
3458 data.selected_vects=data.selected_vects-delay;
3459 elseif nargin == 1
3460 data.selected_vects=...
3461 data.selected_vects(find(data.selected_vects<=len-abs(delay)));
3462 end
3463 set(pre_h,'UserData',data);
3464 old=gcf;
3465 set(0,'CurrentFigure',pre_h);
3466 vects=zeros(1,length(sData.data(:,1)));
3467 vects(data.selected_vects)=1;
3468 write_sD_stats;
3469 draw_vectors(vects,data.vector_h);
3470 sel_comp;
3471 cplot_mimema;
3472 set(0,'CurrentFigure',old);
3473 end
3474 case 'e_all'
3475 MODE='3';
3476 if delay > 0
3477 sData.data(len+1:len+delay,:)=NaN;
3478 sData.data(1+delay:delay+len,n_th_comp)=sData.data(1:len,n_th_comp);
3479 sData.data(1:delay,n_th_comp)=NaN;
3480 elseif delay < 0
3481 delay=abs(delay);
3482 sData.data(delay+1:len+delay,:)=sData.data;
3483 sData.data(1:delay,:)=NaN;
3484 sData.data(1:len,n_th_comp)=sData.data(delay+1:len+delay,n_th_comp);
3485 sData.data(len+1:len+delay,n_th_comp)=NaN;
3486 end
3487 if delay ~= 0
3488 data=get(pre_h,'UserData');
3489 sData.MODIFIED=1;
3490 sData.comp_norm(:,:)={[]};
3491 data.sData=sData;
3492 data.undo.sData=undo;
3493 data.undo.selected=data.selected_vects;
3494 set(pre_h,'UserData',data);
3495 old=gcf;
3496 set(0,'CurrentFigure',pre_h);
3497 write_sD_stats;
3498 pro_tools('selall');
3499 set(0,'CurrentFigure',old);
3500 end
3501 end
3502
3503 if ~LOG
3504 data=get(pre_h,'UserData');
3505 data.LOG{length(data.LOG)+1}='% Delay a component.';
3506 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''delay_data'',''',...
3507 num2str(delay),' ',MODE,''');');
3508 set(pre_h,'UserData',data);
3509 end
3510
3511 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3512
3513 function window(varargin)
3514
3515 if nargin ~= 1
3516 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
3517 preh_udata=get(pre_h,'UserData');
3518 preh_udata.LOG{length(preh_udata.LOG)+1}=...
3519 '% Starting the ''Windowed'' -window...';
3520 preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''window'',''foo'');';
3521 set(pre_h,'UserData',preh_udata);
3522 end
3523
3524 win_h=findobj(get(0,'Children'),'Tag','Window');
3525
3526 if ~isempty(win_h)
3527 figure(win_h);
3528 return;
3529 end
3530
3531 h0 = figure('Color',[0.8 0.8 0.8], ...
3532 'PaperPosition',[18 180 576 432], ...
3533 'PaperUnits','points', ...
3534 'Position',[513 703 288 219], ...
3535 'Tag','Window');
3536
3537 h1 = uicontrol('Parent',h0, ...
3538 'Units','normalized', ...
3539 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
3540 'ListboxTop',0, ...
3541 'Position',[0.03125 0.1552511415525114 0.9375 0.7990867579908676], ...
3542 'Style','frame', ...
3543 'Tag','Frame1');
3544 h1 = uicontrol('Parent',h0, ...
3545 'Units','normalized', ...
3546 'BackgroundColor',[0.8 0.8 0.8], ...
3547 'ListboxTop',0, ...
3548 'Position',[0.04861111111111111 0.7214611872146118 0.9027777777777777 0.2009132420091324], ...
3549 'Style','frame', ...
3550 'Tag','Frame2');
3551 h1 = uicontrol('Parent',h0, ...
3552 'Units','normalized', ...
3553 'BackgroundColor',[0.8 0.8 0.8], ...
3554 'ListboxTop',0, ...
3555 'Position',[0.04861111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ...
3556 'Style','frame', ...
3557 'Tag','Frame3');
3558 h1 = uicontrol('Parent',h0, ...
3559 'Units','normalized', ...
3560 'BackgroundColor',[0.8 0.8 0.8], ...
3561 'ListboxTop',0, ...
3562 'Position',[0.3611111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ...
3563 'Style','frame', ...
3564 'Tag','Frame4');
3565 h1 = uicontrol('Parent',h0, ...
3566 'Units','normalized', ...
3567 'BackgroundColor',[0.8 0.8 0.8], ...
3568 'ListboxTop',0, ...
3569 'Position',[0.6736111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ...
3570 'Style','frame', ...
3571 'Tag','Frame5');
3572
3573 h1 = uicontrol('Parent',h0, ...
3574 'Callback','preprocess eval_windowed',...
3575 'Units','normalized', ...
3576 'FontWeight','demi', ...
3577 'ListboxTop',0, ...
3578 'Position',[0.03125 0.0319634703196347 0.2256944444444444 0.091324200913242], ...
3579 'String','OK', ...
3580 'Tag','Pushbutton1');
3581
3582 h1 = uicontrol('Parent',h0, ...
3583 'Callback','preprocess close_w', ...
3584 'Units','normalized', ...
3585 'FontWeight','demi', ...
3586 'ListboxTop',0, ...
3587 'Position',[0.7430555555555555 0.0319634703196347 0.2256944444444444 0.091324200913242], ...
3588 'String','Close', ...
3589 'Tag','Pushbutton2');
3590
3591 h1 = uicontrol('Parent',h0, ...
3592 'Units','normalized', ...
3593 'BackgroundColor',[1 1 1], ...
3594 'ListboxTop',0, ...
3595 'Position',[0.7083333333333333 0.7625570776255708 0.2083333333333333 0.1232876712328767], ...
3596 'Style','edit', ...
3597 'Tag','EditText1');
3598
3599 data.win_len_h=h1;
3600
3601 h1 = uicontrol('Parent',h0, ...
3602 'Units','normalized', ...
3603 'BackgroundColor',[0.8 0.8 0.8], ...
3604 'FontWeight','demi', ...
3605 'HorizontalAlignment','left', ...
3606 'ListboxTop',0, ...
3607 'Position',[0.07638888888888888 0.8036529680365296 0.3784722222222222 0.0547945205479452], ...
3608 'String','Window length', ...
3609 'Style','text', ...
3610 'Tag','StaticText1');
3611
3612 h1 = uicontrol('Parent',h0, ...
3613 'Units','normalized', ...
3614 'BackgroundColor',[0.8 0.8 0.8], ...
3615 'Callback','preprocess window_cb centered',...
3616 'ListboxTop',0, ...
3617 'Position',[0.06597222222222222 0.5616438356164384 0.06597222222222222 0.0821917808219178], ...
3618 'Style','radiobutton', ...
3619 'Tag','Radiobutton1');
3620
3621 data.centered_h=h1;
3622 data.position='center';
3623
3624 h1 = uicontrol('Parent',h0, ...
3625 'Units','normalized', ...
3626 'BackgroundColor',[0.8 0.8 0.8], ...
3627 'Callback','preprocess window_cb previous',...
3628 'ListboxTop',0, ...
3629 'Position',[0.06597222222222222 0.4018264840182648 0.06597222222222222 0.0821917808219178], ...
3630 'Style','radiobutton', ...
3631 'Tag','Radiobutton2');
3632
3633 data.previous_h=h1;
3634
3635 h1 = uicontrol('Parent',h0, ...
3636 'Units','normalized', ...
3637 'BackgroundColor',[0.8 0.8 0.8], ...
3638 'Callback','preprocess window_cb next',...
3639 'ListboxTop',0, ...
3640 'Position',[0.06597222222222222 0.2465753424657534 0.06597222222222222 0.0821917808219178], ...
3641 'Style','radiobutton', ...
3642 'Tag','Radiobutton3');
3643
3644 data.next_h=h1;
3645
3646 h1 = uicontrol('Parent',h0, ...
3647 'Units','normalized', ...
3648 'BackgroundColor',[0.8 0.8 0.8], ...
3649 'Callback','preprocess window_cb mean',...
3650 'ListboxTop',0, ...
3651 'Position',[0.3784722222222222 0.5799086757990868 0.06597222222222222 0.0821917808219178], ...
3652 'Style','radiobutton', ...
3653 'Tag','Radiobutton4');
3654
3655 data.mean_h=h1;
3656 data.mode='mean';
3657
3658
3659 h1 = uicontrol('Parent',h0, ...
3660 'Units','normalized', ...
3661 'BackgroundColor',[0.8 0.8 0.8], ...
3662 'Callback','preprocess window_cb median',...
3663 'ListboxTop',0, ...
3664 'Position',[0.3784722222222222 0.4611872146118721 0.06597222222222222 0.0821917808219178], ...
3665 'Style','radiobutton', ...
3666 'Tag','Radiobutton5');
3667
3668
3669 data.median_h=h1;
3670
3671 h1 = uicontrol('Parent',h0, ...
3672 'Units','normalized', ...
3673 'BackgroundColor',[0.8 0.8 0.8], ...
3674 'Callback','preprocess window_cb max',...
3675 'ListboxTop',0, ...
3676 'Position',[0.3784722222222222 0.3515981735159817 0.06597222222222222 0.0821917808219178], ...
3677 'Style','radiobutton', ...
3678 'Tag','Radiobutton6');
3679
3680 data.max_h=h1;
3681
3682 h1 = uicontrol('Parent',h0, ...
3683 'Units','normalized', ...
3684 'Callback','preprocess window_cb min',...
3685 'BackgroundColor',[0.8 0.8 0.8], ...
3686 'ListboxTop',0, ...
3687 'Position',[0.3784722222222222 0.2374429223744292 0.06597222222222222 0.0821917808219178], ...
3688 'Style','radiobutton', ...
3689 'Tag','Radiobutton7');
3690
3691 data.min_h = h1;
3692
3693 h1 = uicontrol('Parent',h0, ...
3694 'Units','normalized', ...
3695 'BackgroundColor',[0.8 0.8 0.8], ...
3696 'Callback','preprocess window_cb clip',...
3697 'ListboxTop',0, ...
3698 'Position',[0.6909722222222222 0.5525114155251141 0.06597222222222222 0.0821917808219178], ...
3699 'Style','radiobutton', ...
3700 'Tag','Radiobutton8');
3701
3702 data.clip_h=h1;
3703 data.eval_mode='clip';
3704
3705 h1 = uicontrol('Parent',h0, ...
3706 'Units','normalized', ...
3707 'BackgroundColor',[0.8 0.8 0.8], ...
3708 'Callback','preprocess window_cb expand',...
3709 'ListboxTop',0, ...
3710 'Position',[0.6909722222222222 0.2922374429223744 0.06597222222222222 0.0821917808219178], ...
3711 'Style','radiobutton', ...
3712 'Tag','Radiobutton9');
3713
3714 data.expand_h=h1;
3715
3716 h1 = uicontrol('Parent',h0, ...
3717 'Units','normalized', ...
3718 'BackgroundColor',[0.8 0.8 0.8], ...
3719 'FontWeight','demi', ...
3720 'FontSize',8,...
3721 'HorizontalAlignment','left', ...
3722 'ListboxTop',0, ...
3723 'Position',[0.132 0.5799 0.19 0.0548], ...
3724 'String','Centered', ...
3725 'Style','text', ...
3726 'Tag','StaticText2');
3727 h1 = uicontrol('Parent',h0, ...
3728 'Units','normalized', ...
3729 'BackgroundColor',[0.8 0.8 0.8], ...
3730 'FontWeight','demi', ...
3731 'FontSize',8,...
3732 'HorizontalAlignment','left', ...
3733 'ListboxTop',0, ...
3734 'Position',[0.132 0.4247 0.1667 0.0548], ...
3735 'String','Previous', ...
3736 'Style','text', ...
3737 'Tag','StaticText3');
3738 h1 = uicontrol('Parent',h0, ...
3739 'Units','normalized', ...
3740 'BackgroundColor',[0.8 0.8 0.8], ...
3741 'FontWeight','demi', ...
3742 'FontSize',8,...
3743 'HorizontalAlignment','left', ...
3744 'ListboxTop',0, ...
3745 'Position',[0.132 0.2648 0.1632 0.0548], ...
3746 'String','Next', ...
3747 'Style','text', ...
3748 'Tag','StaticText4');
3749 h1 = uicontrol('Parent',h0, ...,
3750 'Units','normalized', ...
3751 'BackgroundColor',[0.8 0.8 0.8], ...
3752 'FontWeight','demi', ...
3753 'FontSize',8,...
3754 'HorizontalAlignment','left', ...
3755 'ListboxTop',0, ...
3756 'Position',[0.445 0.6027397260273972 0.19 0.0547945205479452], ...
3757 'String','Mean', ...
3758 'Style','text', ...
3759 'Tag','StaticText5');
3760 h1 = uicontrol('Parent',h0, ...
3761 'Units','normalized', ...
3762 'BackgroundColor',[0.8 0.8 0.8], ...
3763 'FontWeight','demi', ...
3764 'FontSize',8,...
3765 'HorizontalAlignment','left', ...
3766 'ListboxTop',0, ...
3767 'Position',[0.445 0.4795 0.1806 0.0548], ...
3768 'String','Median', ...
3769 'Style','text', ...
3770 'Tag','StaticText6');
3771
3772 h1 = uicontrol('Parent',h0, ...
3773 'Units','normalized', ...
3774 'BackgroundColor',[0.8 0.8 0.8], ...
3775 'FontWeight','demi', ...
3776 'FontSize',8,...
3777 'HorizontalAlignment','left', ...
3778 'ListboxTop',0, ...
3779 'Position',[0.445 0.3699 0.1667 0.0548], ...
3780 'String','Max', ...
3781 'Style','text', ...
3782 'Tag','StaticText7');
3783 h1 = uicontrol('Parent',h0, ...
3784 'Units','normalized', ...
3785 'BackgroundColor',[0.8 0.8 0.8], ...
3786 'FontWeight','demi', ...
3787 'FontSize',8,...
3788 'HorizontalAlignment','left', ...
3789 'ListboxTop',0, ...
3790 'Position',[0.445 0.2557077625570776 0.1597222222222222 0.0547945205479452], ...
3791 'String','Min', ...
3792 'Style','text', ...
3793 'Tag','StaticText8');
3794 h1 = uicontrol('Parent',h0, ...
3795 'Units','normalized', ...
3796 'BackgroundColor',[0.8 0.8 0.8], ...
3797 'FontWeight','demi', ...
3798 'FontSize',8,...
3799 'HorizontalAlignment','left', ...
3800 'ListboxTop',0, ...
3801 'Position',[0.7535 0.5753 0.1354 0.054], ...
3802 'String','Clip', ...
3803 'Style','text', ...
3804 'Tag','StaticText9');
3805 h1 = uicontrol('Parent',h0, ...
3806 'Units','normalized', ...
3807 'BackgroundColor',[0.8 0.8 0.8], ...
3808 'FontWeight','demi', ...
3809 'FontSize',8,...
3810 'HorizontalAlignment','left', ...
3811 'ListboxTop',0, ...
3812 'Position',[0.7534722222222222 0.3150684931506849 0.1527777777777778 0.0547945205479452], ...
3813 'String','Expand', ...
3814 'Style','text', ...
3815 'Tag','StaticText10');
3816
3817
3818
3819 set(gcf,'UserData',data);
3820
3821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3822
3823 function window_cb(arg)
3824
3825 data=get(gcf,'UserData');
3826
3827 if any(strcmp(arg,[{'centered'},{'previous'},{'next'}]))
3828 switch arg
3829 case 'centered'
3830 data.position='center';
3831 set(data.previous_h,'Value',0);
3832 set(data.next_h,'Value',0);
3833 set(data.centered_h,'Value',1);
3834 case 'previous'
3835 data.position='previous';
3836 set(data.centered_h,'Value',0);
3837 set(data.next_h,'Value',0);
3838 set(data.previous_h,'Value',1);
3839 case 'next'
3840 data.position='next';
3841 set(data.centered_h,'Value',0);
3842 set(data.previous_h,'Value',0);
3843 set(data.next_h,'Value',1);
3844 end
3845 elseif any(strcmp(arg,[{'mean'},{'median'},{'min'},{'max'}]))
3846 switch arg
3847 case 'mean'
3848 data.mode='mean';
3849 set(data.median_h,'Value',0);
3850 set(data.min_h,'Value',0);
3851 set(data.max_h,'Value',0);
3852 set(data.mean_h,'Value',1);
3853 case 'median'
3854 data.mode='median';
3855 set(data.mean_h,'Value',0);
3856 set(data.max_h,'Value',0);
3857 set(data.min_h,'Value',0);
3858 set(data.median_h,'Value',1);
3859 case 'max'
3860 data.mode='max';
3861 set(data.mean_h,'Value',0);
3862 set(data.median_h,'Value',0);
3863 set(data.min_h,'Value',0);
3864 set(data.max_h,'Value',1);
3865 case 'min'
3866 data.mode='min';
3867 set(data.mean_h,'Value',0);
3868 set(data.median_h,'Value',0);
3869 set(data.max_h,'Value',0);
3870 set(data.min_h,'Value',1);
3871 end
3872 elseif any(strcmp(arg,[{'clip','expand'}]))
3873 switch arg
3874 case 'clip'
3875 data.eval_mode='clip';
3876 set(data.expand_h,'Value',0);
3877 set(data.clip_h,'Value',1);
3878 case 'expand'
3879 data.eval_mode='expand';
3880 set(data.clip_h,'Value',0);
3881 set(data.expand_h,'Value',1);
3882 end
3883 end
3884
3885 set(gcf,'UserData',data);
3886
3887 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3888
3889 function eval_windowed(varargin)
3890
3891 if nargin == 1
3892 LOG=1;
3893 i=1;
3894 arg=varargin{1};
3895 while i <= length(arg) & arg(i) ~= ' '
3896 i=i+1;
3897 end
3898 value=str2num(arg(1:i-1));
3899 i=i+1;
3900 j=i;
3901 while i <= length(arg) & arg(i) ~= ' '
3902 i=i+1;
3903 end
3904 position=arg(j:i-1);
3905 i=i+1;
3906 j=i;
3907 while i <= length(arg) & arg(i) ~= ' '
3908 i=i+1;
3909 end
3910 mode=arg(j:i-1);
3911 i=i+1;
3912 j=i;
3913 while i <= length(arg) & arg(i) ~= ' '
3914 i=i+1;
3915 end
3916 eval_mode=arg(j:i-1);
3917 else
3918 LOG=0;
3919 end
3920
3921 data=get(gcf,'UserData');
3922 if LOG
3923 data.position=position;
3924 data.eval_mode=eval_mode;
3925 data.mode=mode;
3926 end
3927 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
3928
3929 if isempty(pre_h)
3930 errordlg('''Preprocess''-window does not exist. Terminating program...');
3931 pro_tools('close');
3932 return;
3933 end
3934
3935 comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h');
3936 sData=getfield(get(pre_h,'UserData'),'sData');
3937 undo=sData;
3938
3939 if isempty(get(comp_names_h,'Value'))
3940 errordlg('There are not components chosen.');
3941 return;
3942 end
3943
3944 if ~LOG
3945 if isempty(get(data.win_len_h,'String'))
3946 errordlg('Window length must be defined');
3947 return;
3948 end
3949
3950 value=str2num(get(data.win_len_h,'String'));
3951 end
3952
3953 set(data.win_len_h,'String','');
3954
3955 if ~LOG
3956 if isempty(value) | value < 0 | value ~= round(value)
3957 errordlg('Window length must be positive integer.');
3958 return;
3959 end
3960
3961 if value > length(sData.data(:,1))
3962 errordlg('Length of window is too big.');
3963 return;
3964 end
3965 end
3966
3967 index=getfield(get_indices,{1});
3968
3969 sData=eval_operation(sData,value,data.mode,data.eval_mode,data.position,index);
3970 sData.comp_norm(index)={[]};
3971 u_data=get(pre_h,'UserData');
3972 u_data.sData=sData;
3973 u_data.undo.sData=undo;
3974 u_data.undo.selected=u_data.selected_vects;
3975
3976 if ~LOG
3977 u_data.LOG{length(u_data.LOG)+1}=...
3978 '% Evaluating the wanted ''windowed'' -operation.';
3979 u_data.LOG{length(u_data.LOG)+1}=cat(2,'preprocess(''eval_windowed'',',...
3980 '''',num2str(value),...
3981 ' ',data.position,' ',data.mode,...
3982 ' ',data.eval_mode,''');');
3983 end
3984
3985 set(pre_h,'UserData',u_data);
3986 old=gcf;
3987 set(0,'CurrentFigure',pre_h);
3988
3989 if strcmp(data.eval_mode,'expand');
3990 write_sD_stats;
3991 pro_tools('selall');
3992 else
3993 sel_comp;
3994 cplot_mimema;
3995 end
3996
3997 set(0,'CurrentFigure',old);
3998
3999
4000
4001 %%% Subfunction: eval_operation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4002
4003
4004 function sData=eval_operation(sData,winlen,mode,evalmode,position,n)
4005
4006
4007 len=length(sData.data(:,1));
4008 dim=length(sData.data(1,:));
4009
4010 switch(position)
4011 case 'center'
4012 prev=round(winlen/2)-1;
4013 next=winlen-round(winlen/2);
4014 case 'previous'
4015 prev=winlen-1;
4016 next=0;
4017 case 'next'
4018 prev=0;
4019 next=winlen-1;
4020 end
4021
4022 switch(evalmode)
4023 case 'clip'
4024 for center=1:len
4025 win=center-prev:center-prev+winlen-1;
4026 win=win(find(win > 0 & win <= len));
4027 str=cat(2,mode,'(sData.data(win(find(~isnan(sData.data(win,n)))),n))');
4028 tmp(center)=eval(str);
4029 end
4030 sData.data(:,n)=tmp;
4031 case 'expand'
4032 for i=1:len+winlen-1
4033 win=i-(winlen-1):i;
4034 win=win(find(win > 0 & win <= len));
4035 str=cat(2,mode,'(sData.data(win(find(~isnan(sData.data(win,n)))),n))');
4036 tmp(i)=eval(str);
4037 end
4038 sData.data=cat(1,repmat(NaN,next,dim),sData.data,repmat(NaN,prev,dim));
4039 sData.data(:,n)=tmp;
4040 end
4041
4042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4043
4044
4045
4046 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4047
4048 function pro_tools(arg)
4049
4050 switch arg
4051 case 'close'
4052 close_preprocess;
4053 case 'c_stat'
4054 write_c_stats;
4055 case 'plot_hist'
4056 plot_hist;
4057 case 'plot'
4058 plot_button;
4059 case 'plxy'
4060 plxy_button;
4061 case 'bplo'
4062 bplo_button;
4063 case 'hist'
4064 hist_button;
4065 end
4066
4067
4068 %%% Subfunction close_preprocess %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4069
4070 function close_preprocess
4071
4072
4073 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
4074 man_h=findobj(get(0,'Children'),'Tag','Management');
4075 clip_h=findobj(get(0,'Children'),'Tag','Clipping');
4076 plot_h=findobj(get(0,'Children'),'Tag','PlotWin');
4077 delay_h=findobj(get(0,'Children'),'Tag','Delay');
4078 window_h=findobj(get(0,'Children'),'Tag','Window');
4079 sel_h=findobj(get(0,'Children'),'Tag','Select');
4080
4081 if ~isempty(man_h)
4082 close(man_h);
4083 end
4084 if ~isempty(clip_h)
4085 close(clip_h);
4086 end
4087 if ~isempty(plot_h)
4088 close(plot_h);
4089 end
4090 if ~isempty(delay_h)
4091 close(delay_h);
4092 end
4093 if ~isempty(window_h)
4094 close(window_h);
4095 end
4096 if ~isempty(sel_h)
4097 close(sel_h);
4098 end
4099 if ~isempty(pre_h)
4100 close(pre_h);
4101 end
4102
4103
4104
4105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4106
4107 %%% Subfunction: undo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4108
4109 function undo(varargin)
4110
4111 if nargin == 1
4112 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
4113 set(0,'CurrentFigure',pre_h);
4114 LOG=1;
4115 else
4116 LOG=0;
4117 end
4118
4119 data=get(gcf,'UserData');
4120 if ~isempty(data.undo)
4121 if any(strcmp('selected',fieldnames(data.undo)))
4122 data.selected_vects=data.undo.selected;
4123 end
4124 if ~any(strcmp('index',fieldnames(data.undo)))
4125 data.sData=data.undo.sData;
4126 data.undo=[];
4127 if ~LOG
4128 data.LOG{length(data.LOG)+1}='% Undo the most recent operation.';
4129 data.LOG{length(data.LOG)+1}='preprocess(''undo'',''foo'');';
4130 end
4131 set(gcf,'UserData',data);
4132 set_compnames(data.sData,data.comp_names_h);
4133 write_sD_stats;
4134 vect_means(data.sData,data.vect_mean_h,data.selected_vects);
4135 sel_comp;
4136 cplot_mimema;
4137 return;
4138 end
4139
4140 % 'undo.sData' does not exist in sD_set - array
4141
4142 index=data.undo.index;
4143 data.undo.sData=rmfield(data.undo.sData,[{'INDEX'};{'MODIFIED'}]);
4144 if index<=length(data.sD_set)
4145 rest=data.sD_set(index:length(data.sD_set));
4146 else
4147 rest=[];
4148 end
4149 data.sD_set=cat(2,data.sD_set(1:index-1),data.undo.sData,rest);
4150 data.undo=[];
4151 if ~LOG
4152 data.LOG{length(data.LOG)+1}='% Undo the most recent operation.';
4153 data.LOG{length(data.LOG)+1}='preprocess(''undo'',''foo'');';
4154 end
4155 set(gcf,'UserData',data);
4156 set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',index);
4157 set_sD_stats;
4158 sel_sD;
4159 else
4160 msgbox('Can''t do...');
4161 end
4162
4163 %%% Subfunction: write_c_stats %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4164
4165 function write_c_stats(varargin)
4166
4167
4168 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
4169 comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h');
4170 sel_comp_h=getfield(get(pre_h,'UserData'),'sel_comp_h');
4171 sel_chist_h=getfield(get(pre_h,'UserData'),'sel_chist_h');
4172
4173 if nargin==1
4174 val1=varargin(1);
4175 else
4176 val1=get(sel_comp_h,'String');
4177 end
4178
4179 if ~isempty(val1) & iscell(val1)
4180 selected_vects=getfield(get(pre_h,'UserData'),'selected_vects');
4181 sData=getfield(get(pre_h,'UserData'),'sData');
4182 sel_cdata_h=getfield(get(pre_h,'UserData'),'sel_cdata_h');
4183 name=getfield(get(sel_comp_h,'String'),{get(sel_comp_h,'Value')});
4184 name=name{1};
4185 i=2;
4186
4187 while ~isempty(str2num(name(i)))
4188 value(i-1)=name(i);
4189 i=i+1;
4190 end
4191
4192 value=str2num(value);
4193
4194
4195 data=sData.data(selected_vects,value);
4196
4197 string{1} = cat(2,'Min: ',sprintf('%-10.3g',min(data)));
4198 string{2} = cat(2,'Mean: ',sprintf('%-10.3g',mean(data(find(~isnan(data))))));
4199 string{3} = cat(2,'Max: ',sprintf('%-10.3g',max(data)));
4200 string{4} = cat(2,'Std: ',sprintf('%-10.3g',std(data(find(~isnan(data))))));
4201 string{5} = cat(2,'Number of NaNs: ',sprintf('%-10.3g',sum(isnan(data))));
4202 string{6} = cat(2,'NaN (%):',...
4203 sprintf('%-10.3g',100*sum(isnan(data))/length(data)));
4204 string{7} = cat(2,'Number of values: ',sprintf('%-10.3g',...
4205 length(find(~isnan(unique(data))))));
4206 set(sel_cdata_h,'String',string);
4207 set(sel_cdata_h,'HorizontalAlignment','left');
4208 end
4209
4210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4211
4212 %%% Subfunction plot_hist %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4213
4214 function plot_hist
4215
4216 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
4217 sel_chist_h=getfield(get(pre_h,'UserData'),'sel_chist_h');
4218 sData=getfield(get(pre_h,'UserData'),'sData');
4219 selected=getfield(get(pre_h,'UserData'),'selected_vects');
4220
4221 value=get(getfield(get(pre_h,'UserData'),'sel_comp_h'),'Value');
4222 subplot(sel_chist_h);
4223 hold off;
4224 cla;
4225 if all(isnan(sData.data(:,value)));
4226 return;
4227 end
4228 hold on;
4229 lim1=min(sData.data(:,value));
4230 lim2=max(sData.data(:,value));
4231 if lim2 - lim1 >= eps
4232 x=lim1:(lim2-lim1)/(30-1):lim2;
4233 set(sel_chist_h,'XLim',[lim1 lim2]);
4234 elseif lim1 ~= 0
4235 x=(lim1)/2:lim1/(30-1):lim1+(lim1)/2;
4236 set(sel_chist_h,'Xlim',[lim1-abs(lim1/2) lim1+abs(lim1/2)]);
4237 else
4238 x=-1:2/(30-1):1;
4239 set(sel_chist_h,'XLim',[-1 1]);
4240 end
4241
4242 hist(sData.data(selected,value),x);
4243
4244 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4245
4246 %%% Subfunction: select_all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4247
4248 function select_all(varargin)
4249
4250 if nargin == 1
4251 LOG=1;
4252 else
4253 LOG=0;
4254 end
4255
4256 data=get(gcf,'UserData');
4257 data.selected_vects=(1:length(data.sData.data(:,1)));
4258 if ~LOG
4259 data.LOG{length(data.LOG)+1}='% Select all vectors.';
4260 data.LOG{length(data.LOG)+1}='selall(''foo'');';
4261 end
4262 set(gcf,'UserData',data);
4263 tmp=zeros(1,length(data.sData.data(:,1)));
4264 tmp(data.selected_vects)=1;
4265 draw_vectors(tmp,data.vector_h);
4266 cplot_mimema;
4267 vect_means(data.sData,data.vect_mean_h,data.selected_vects);
4268 sel_comp;
4269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4270
4271 %%% Subfunction: plot_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4272
4273 function plot_button
4274
4275 %PLOT_BUTTON A callback function. Plots all the components and marks
4276 % the chosen components.
4277 %
4278 %
4279
4280 sData=getfield(get(gcf,'UserData'),'sData');
4281 selected=getfield(get(gcf,'UserData'),'selected_vects');
4282
4283 indices=get_indices;
4284 if isempty(indices)
4285 return;
4286 end
4287 h=findobj(get(0,'Children'),'Tag','PlotWin');
4288 if isempty(h)
4289 h= figure;
4290 set(h,'Tag','PlotWin');
4291 end
4292
4293 names=sData.comp_names(indices);
4294 data=sData.data(:,indices);
4295
4296 set(0,'CurrentFigure',h);
4297 hold off;
4298 clf;
4299 t=0:1/(getfield(size(data),{1})-1):1;
4300 tmp=setdiff(1:length(data(:,1)),selected);
4301 for i=1:length(names)
4302 subplot(length(names),1,i);
4303 hold on;
4304 if max(data(:,i))- min(data(:,i)) <= eps
4305 set(gca,'YLim',[max(data(:,i))-1 max(data(:,i))+1]);
4306 end
4307 plot(t,data(:,i));
4308 if ~isempty(tmp);
4309 data(tmp,i)=NaN;
4310 end
4311 plot(t,data(:,i),'red');
4312 ylabel(names{i});
4313 set(gca,'XTick',[]);
4314 end
4315 set(gcf,'Name','Plotted Data Components');
4316
4317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4318
4319 %%% Subfunction: plxy_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4320
4321 function plxy_button
4322
4323 %PLXY_BUTTON A callback function. XY-plots the first and the second
4324 % components chosen.
4325 %
4326 %
4327
4328
4329 sData=getfield(get(gcf,'UserData'),'sData');
4330 selected=getfield(get(gcf,'UserData'),'selected_vects');
4331
4332 inds = get_indices;
4333 if length(inds) < 2
4334 errordlg('There must be two components chosen for XY-plot.');
4335 return;
4336 end
4337
4338 inds=inds(1:2);
4339 names=getfield(sData,'comp_names',{inds});
4340
4341 h=findobj(get(0,'Children'),'Tag','PlotWin');
4342
4343 if isempty(h)
4344 h= figure;
4345 set(h,'Tag','PlotWin');
4346 end
4347
4348 set(0,'CurrentFigure',h);
4349 clf;
4350 axes;
4351 if max(sData.data(:,inds(1))) - min(sData.data(:,inds(1))) <= eps
4352 set(gca,'XLim',[max(sData.data(:,inds(1)))-1 max(sData.data(:,inds(1)))+1]);
4353 end
4354 if max(sData.data(:,inds(2))) - min(sData.data(:,inds(2))) <= eps
4355 set(gca,'YLim',[max(sData.data(:,inds(2)))-1 max(sData.data(:,inds(2)))+1]);
4356 end
4357 hold on;
4358 plot(sData.data(:,inds(1)),sData.data(:,inds(2)),'o');
4359 x=sData.data(selected,inds(1));
4360 y=sData.data(selected,inds(2));
4361
4362 plot(x,y,'ored','MarkerSize',4);
4363 xlabel(names(1));
4364 ylabel(names(2));
4365 set(h,'Name','Plotted Data Components');
4366
4367 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4368
4369 %%% Sub_function: bplo_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4370
4371 function bplo_button
4372
4373 %BPLO_BUTTON A callback function. Box-plots the first component chosen.
4374
4375
4376 sData=getfield(get(gcf,'UserData'),'sData');
4377 selected=getfield(get(gcf,'UserData'),'selected_vects');
4378
4379 if length(selected) == 1
4380 errordlg('There are too few vectors chosen for box-plotting.');
4381 else
4382 indices=get_indices;
4383 if isempty(indices)
4384 return;
4385 end
4386 for i=1:length(indices)
4387 if length(unique(sData.data(selected,indices(i))))==1
4388 errordlg('All the values are the same. Operation can''t be evaluated.');
4389 return;
4390 end
4391 end
4392 names=getfield(sData,'comp_names',{indices});
4393 h= findobj(get(0,'Children'),'Tag','PlotWin');
4394 if isempty(h)
4395 h= figure;
4396 set(h,'Tag','PlotWin');
4397 end
4398
4399 data=sData.data(selected,indices);
4400
4401 set(0,'CurrentFigure',h);
4402 hold off;
4403 clf;
4404 hold on;
4405 for i=1:getfield(size(data),{2})
4406 subplot(getfield(size(data),{2}),1,i);
4407 if ~all(isnan(data(:,i)))
4408 boxplot(data(:,i));
4409 end
4410 name=names{i};
4411 tmp=get(get(gca,'YLabel'),'String');
4412 ylabel(cat(2,sprintf('[%s] ',name),tmp));
4413 end
4414 set(h,'Name','Box-plot');
4415 end
4416
4417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4418
4419 %%% Subfunction: hist_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4420
4421 function hist_button
4422
4423 no_of_bins_h=getfield(get(gcf,'UserData'),'no_of_bins_h');
4424 selected=getfield(get(gcf,'UserData'),'selected_vects');
4425 sData=getfield(get(gcf,'UserData'),'sData');
4426 n=str2num(get(no_of_bins_h,'String'));
4427 s1='Invalid number of bins.';
4428 s2=sprintf('\nSet new value to the box under the ''Histogram''-button.');
4429
4430 if isempty(n)
4431 errordlg(cat(2,s1,s2));
4432 else
4433 indices=get_indices;
4434 if isempty(indices)
4435 return;
4436 end
4437 n=round(n);
4438 if n < 1
4439 errordlg('Number of bins must be positive integer.');
4440 else
4441 h= findobj(get(0,'Children'),'Tag','PlotWin');
4442 if isempty(h)
4443 h= figure;
4444 set(h,'Tag','PlotWin');
4445 end
4446
4447 set(0,'CurrentFigure',h);
4448 hold off;
4449 clf;
4450 data=sData.data(selected,indices);
4451 names=sData.comp_names(indices);
4452 for i=1:length(names)
4453 subplot(length(names),1,i);
4454 hold on;
4455 lim1=min(sData.data(:,indices(i)));
4456 lim2=max(sData.data(:,indices(i)));
4457 if n > 1
4458 if lim2 - lim1 >= eps
4459 x=lim1:(lim2-lim1)/(n-1):lim2;
4460 set(gca,'XLim',[lim1 lim2]);
4461 elseif lim1 ~= 0
4462 x=lim1/2:lim1/(n-1):lim1/2+lim1;
4463 if ~all(isnan([lim1 lim2]))
4464 set(gca,'XLim',[lim1-abs(lim1/2) lim1+abs(lim1/2)]);
4465 end
4466 else
4467 x=-1:2/(n-1):1;
4468 set(gca,'XLim',[-1 1]);
4469 end
4470 else
4471 x=1;
4472 if lim2 ~= lim1
4473 set(gca,'XLim',[lim1 lim2]);
4474 else
4475 set(gca,'XLim',[lim1/2 lim1/2+lim1]);
4476 end
4477 end
4478 if ~all(isnan(data(:,i)))
4479 hist(data(:,i),x);
4480 end
4481 name=names{i};
4482 xlabel(name);
4483 end
4484 set(h,'Name','Histogram');
4485 end
4486 end
4487
4488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4489
4490 %%% Subfunction: no_of_values %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4491
4492 function no_of_values(varargin);
4493
4494 %NO_OF_VALUES A callback function. Calculates the number of different
4495 % values of the chosen components.
4496 %
4497 %
4498
4499 if nargin==1;
4500 LOG=1;
4501 else
4502 LOG=0;
4503 end
4504
4505 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
4506 results_h=getfield(get(pre_h,'UserData'),'results_h');
4507 sData=getfield(get(pre_h,'UserData'),'sData');
4508 selected=getfield(get(pre_h,'UserData'),'selected_vects');
4509 str1='There must be one component chosen for ''Number of Values''-operation';
4510
4511
4512 if ~LOG & isempty(get_indices)
4513 errordlg(str1);
4514 else
4515 indices=get_indices;
4516 data=sData.data(selected,indices);
4517
4518 string{1} = 'Number of different values:';
4519
4520 for i=1:getfield(size(data),{2})
4521
4522 tmp=data(:,i);
4523 string{i+1}=cat(2,sprintf('#%d:',indices(i)),...
4524 sprintf('%d',length(find(~isnan(unique(data(:,i)))))));
4525 end
4526
4527 set(results_h,'String',string);
4528 set(results_h,'HorizontalAlignment','left');
4529 if ~LOG
4530 data=get(pre_h,'UserData');
4531 data.LOG{length(data.LOG)+1}='% Number of values';
4532 data.LOG{length(data.LOG)+1}='preprocess(''noof'',''foo'');';
4533 set(pre_h,'UserData',data);
4534 end
4535 end
4536
4537 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4538
4539 %%% Subfunction: correlation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4540
4541 function correlation(varargin)
4542
4543 if nargin == 1
4544 LOG=1;
4545 else
4546 LOG=0;
4547 end
4548
4549 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
4550 results_h=getfield(get(pre_h,'UserData'),'results_h');
4551 selected=getfield(get(pre_h,'UserData'),'selected_vects');
4552 sData=getfield(get(pre_h,'UserData'),'sData');
4553
4554 if length(get_indices) < 2
4555 errordlg('There must be two components chosen for Correlation');
4556 else
4557 indices=getfield(get_indices,{1:2});
4558 data=sData.data(selected,indices);
4559 inds=find(~isnan(data(:,1)) & ~isnan(data(:,2)));
4560 value=getfield(corrcoef(data(inds,1),data(inds,2)),{1,2});
4561 names=sData.comp_names(indices);
4562 string{1}='Correlation between';
4563 string{2}=cat(2,names{1},' and ',names{2},':');
4564 string{3}=sprintf('%-10.3g',value);
4565
4566 set(results_h,'String',string);
4567 set(results_h,'HorizontalAlignment','left');
4568 if ~LOG
4569 data=get(pre_h,'UserData');
4570 data.LOG{length(data.LOG)+1}='% Correlation';
4571 data.LOG{length(data.LOG)+1}='preprocess(''corr'',''foo'');';
4572 set(pre_h,'UserData',data);
4573 end
4574 end
4575
4576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4577
4578 %%% Subfunction: unit_length %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4579
4580 function unit_length(varargin)
4581
4582 %UNIT_LENGTH A callback function Scales all the vectors to the unit
4583 % length.
4584 %
4585 %
4586
4587 if nargin==1
4588 LOG=1;
4589 else
4590 LOG=0;
4591 end
4592
4593 vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h');
4594 sData=getfield(get(gcf,'UserData'),'sData');
4595 sData.MODIFIED=1;
4596 scaled=sData.data;
4597 comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h');
4598
4599 if ~LOG & isempty(get(comp_names_h,'Value'))
4600 errordlg('There must be components chosen for the ''unit length''- operation');
4601 return;
4602 end
4603 inds=get_indices;
4604 for i=1:length(scaled(:,1));
4605 x=find(~isnan(scaled(i,inds)));
4606 scaled(i,inds(x))=(1/sqrt(sum(scaled(i,inds(x)).^2)))*scaled(i,inds(x));
4607 end
4608
4609 data=get(gcf,'UserData');
4610
4611
4612 data.undo.sData = sData;
4613 data.sData.data=scaled;
4614
4615 for i=1:length(inds)
4616 data.sData.comp_norm{inds(i)}=[];
4617 end
4618
4619 if ~LOG
4620 data.LOG{length(data.LOG)+1}='% Unit length';
4621 data.LOG{length(data.LOG)+1}='preprocess(''unit'',''foo'');';
4622 end
4623 set(gcf,'UserData',data);
4624
4625 vects=zeros(1,length(sData.data(:,1)));
4626 vects(data.selected_vects)=1;
4627
4628 draw_vectors(vects,data.vector_h);
4629 vect_means(sData,vect_mean_h,data.selected_vects);
4630 cplot_mimema;
4631 plot_hist;
4632
4633 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4634
4635 %%% Subfunction: one_of_n %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4636
4637 function one_of_n(varargin)
4638
4639 if nargin==1
4640 LOG=1;
4641 else
4642 LOG=0;
4643 end
4644
4645 data=get(gcf,'UserData');
4646 vector_h=getfield(get(gcf,'Userdata'),'vector_h');
4647 comp_names_h=getfield(get(gcf,'Userdata'),'comp_names_h');
4648 vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h');
4649 sData=data.sData;
4650 undo=data.sData;
4651 selected=getfield(get(gcf,'UserData'),'selected_vects');
4652 msg='Creating over 10 new components. Stop operation?';
4653
4654 if ~LOG
4655 if isempty(get(data.comp_names_h,'Value'))
4656 errordlg('There must be one component chosen for ''Add: N binary types'' -operation');
4657 return;
4658 end
4659 end
4660
4661 index=getfield(get_indices,{1});
4662
4663 tmp=unique(sData.data(:,index));
4664 n=length(tmp);
4665
4666 if ~LOG
4667 if n>10
4668 answer=questdlg(msg,'Question','Yes','No','Yes');
4669
4670 if strcmp(answer,'Yes')
4671 msgbox('Operation stopped.');
4672 return;
4673 end
4674
4675 end
4676 end
4677
4678 dim1=getfield(size(sData.data),{1});
4679 dim2=getfield(size(sData.data),{2});
4680 sData.data=cat(2,sData.data,zeros(dim1,n));
4681
4682 dim=dim2+n;
4683 for i=1:n
4684 sData.data(:,dim-(n-i))=(sData.data(:,index) == tmp(i));
4685 end
4686
4687 INDEX=sData.INDEX;
4688 for i=1:n
4689 sData.comp_names{dim2+i}=sprintf('%dNewVar',dim2+i);
4690 end
4691 tmp_norm=cat(1,sData.comp_norm,cell(n,1));
4692 sData=som_data_struct(sData.data,...
4693 'name',sData.name,...
4694 'labels',sData.labels,...
4695 'comp_names',sData.comp_names);
4696
4697 sData.MODIFIED=1;
4698 sData.INDEX=INDEX;
4699 sData.comp_norm=tmp_norm;
4700 data.undo.sData=undo;
4701 data.sData=sData;
4702 data.selected_vects=1:length(sData.data(:,1));
4703 if ~LOG
4704 data.LOG{length(data.LOG)+1}='% Add: N binary types';
4705 data.LOG{length(data.LOG)+1}='preprocess(''oneo'',''foo'');';
4706 end
4707 set(gcf,'UserData',data);
4708 clear_button;
4709 write_sD_stats;
4710 set_compnames(sData,comp_names_h);
4711 tmp=ones(1,length(sData.data(:,1)));
4712 draw_vectors(tmp,vector_h);
4713 vect_means(sData,vect_mean_h,1:length(sData.data(:,1)));
4714 cplot_mimema;
4715 sel_comp;
4716
4717 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4718
4719 %%% Subfunction: add_zeros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4720
4721 function add_zeros(varargin)
4722
4723 if nargin == 1
4724 LOG=1;
4725 else
4726 LOG=0;
4727 end
4728
4729 data=get(gcf,'UserData');
4730 vector_h=getfield(get(gcf,'Userdata'),'vector_h');
4731 comp_names_h=getfield(get(gcf,'Userdata'),'comp_names_h');
4732 vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h');
4733 sData=data.sData;
4734 undo=sData;
4735
4736 dim1=getfield(size(sData.data),{1});
4737 dim2=getfield(size(sData.data),{2});
4738 sData.data=cat(2,sData.data,zeros(dim1,1));
4739
4740 INDEX=sData.INDEX;
4741
4742 sData.comp_names{dim2+1}=sprintf('%dNewVar',dim2+1);
4743 tmp_norm=cat(1,sData.comp_norm,cell(1,1));
4744 sData=som_data_struct(sData.data,...
4745 'name',sData.name,...
4746 'labels',sData.labels,...
4747 'comp_names',sData.comp_names);
4748
4749 sData.MODIFIED=1;
4750 sData.INDEX=INDEX;
4751 sData.comp_norm=tmp_norm;
4752 data.sData=sData;
4753 data.undo.sData=undo;
4754 data.selected_vects=1:length(sData.data(:,1));
4755 if ~LOG
4756 data.LOG{length(data.LOG)+1}='% Add: zeros';
4757 data.LOG{length(data.LOG)+1}='preprocess(''zero'',''foo'');';
4758 end
4759 set(gcf,'UserData',data);
4760 clear_button;
4761 write_sD_stats;
4762 set_compnames(sData,comp_names_h);
4763 tmp=ones(1,length(sData.data(:,1)));
4764 draw_vectors(tmp,vector_h);
4765 vect_means(sData,vect_mean_h,1:length(sData.data(:,1)));
4766 cplot_mimema;
4767 sel_comp;
4768
4769 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4770
4771 %%% Subfunction: move_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4772
4773 function move_component(varargin)
4774
4775 %MOVE_COMPONENT A callback function. Moves one component of vectors to
4776 % the position wanted.
4777 %
4778 %
4779
4780 if nargin == 1
4781 LOG=1;
4782 i=1;
4783 while varargin{1}(i) ~= ' '
4784 value(i)=varargin{1}(i);
4785 i=i+1;
4786 end
4787 value=str2num(value); % the new place
4788 index=str2num(varargin{1}(i:length(varargin{1}))); % index of the chosen
4789 % component
4790 else
4791 LOG=0;
4792 end
4793
4794 data=get(gcf,'UserData');
4795 sData=data.sData;
4796 undo=sData;
4797 prompt='Enter the number of the new component place:';
4798
4799
4800 if isempty(get(data.comp_names_h,'Value'))
4801 errordlg('There must be one component chosen for ''Move Component''-operation');
4802 return;
4803 end
4804
4805 if ~LOG
4806 index=getfield(get_indices,{1});
4807 answer=inputdlg(prompt);
4808
4809 if isempty(answer) | (iscell(answer) & isempty(answer{1}))
4810 msgbox('No components moved');
4811 return;
4812 end
4813
4814 value=str2num(answer{1});
4815
4816
4817 dims=size(value);
4818
4819 if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value)
4820 errordlg('The new component place must be positive integer.')
4821 return;
4822 end
4823
4824 if value <= 0 | round(value) ~= value
4825 errordlg('The new component place must be positive integer.');
4826 return;
4827 end
4828
4829 if value > getfield(size(sData.data),{2})
4830 errordlg('Too big value for the new component place.');
4831 return;
4832 end
4833 end
4834
4835 sData.MODIFIED=1;
4836 if index < value
4837 indices1=setdiff(1:value,index);
4838 indices2=setdiff(value+1:length(sData.data(1,:)),index);
4839 elseif index > value
4840 indices1=setdiff(1:value-1,index);
4841 indices2=setdiff(value:length(sData.data(1,:)),index);
4842 else
4843 data.sData=sData;
4844 data.undo.sData=undo;
4845 set(gcf,'UserData',data);
4846 return;
4847 end
4848
4849 tmp1=sData.data(:,indices1);
4850 tmp2=sData.data(:,indices2);
4851 sData.data=cat(2,tmp1,sData.data(:,index),tmp2);
4852
4853 tmp1=sData.comp_names(indices1);
4854 tmp2=sData.comp_names(indices2);
4855 sData.comp_names=cat(1,tmp1,sData.comp_names(index),tmp2);
4856
4857 tmp1=sData.comp_norm(indices1);
4858 tmp2=sData.comp_norm(indices2);
4859 sData.comp_norm=cat(1,tmp1,sData.comp_norm(index),tmp2);
4860
4861 data.sData=sData;
4862 data.undo.sData=undo;
4863 if ~LOG
4864 data.LOG{length(data.LOG)+1}='% Move component.';
4865 data.LOG{length(data.LOG)+1}=sprintf('preprocess(''move'',''%s %s'');',...
4866 num2str(value),num2str(index));
4867 end
4868 comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h');
4869 vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h');
4870 vector_h=getfield(get(gcf,'UserData'),'vector_h');
4871 data.selected_vects=1:length(sData.data(:,1));
4872 set(gcf,'UserData',data);
4873 clear_button;
4874 set_compnames(sData,comp_names_h);
4875 draw_vectors(ones(1,length(sData.data(:,1))),vector_h);
4876 vect_means(sData,vect_mean_h,data.selected_vects);
4877 cplot_mimema;
4878 sel_comp;
4879 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4880
4881 %%% Subfunction: copy_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4882
4883 function copy_component(varargin)
4884
4885 %COPY_COMPONENT Copies one component of vectors to the position wanted.
4886 %
4887 %
4888
4889 if nargin == 1
4890 LOG=1;
4891 i=1;
4892 while varargin{1}(i) ~= ' '
4893 value(i)=varargin{1}(i);
4894 i=i+1;
4895 end
4896 value=str2num(value); % the new place
4897 index=str2num(varargin{1}(i:length(varargin{1}))); % index of the chosen
4898 % component
4899 else
4900 LOG=0;
4901 end
4902
4903
4904 data=get(gcf,'UserData');
4905 sData=data.sData;
4906 undo=sData;
4907 if ~LOG
4908 prompt='Enter the number of the new component place:';
4909
4910
4911 if isempty(get(data.comp_names_h,'Value'))
4912 errordlg('There must be one component chosen for ''Copy Component''-operation');
4913 return;
4914 end
4915
4916 index=getfield(get_indices,{1});
4917 answer=inputdlg(prompt);
4918
4919 if isempty(answer) | (iscell(answer) & isempty(answer{1}))
4920 msgbox('No components moved');
4921 return
4922 end
4923
4924
4925 value=str2num(answer{1});
4926 dims=size(value);
4927
4928 if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value)
4929 errordlg('The new component place must be positive integer.')
4930 return;
4931 end
4932
4933 if value <= 0 | round(value) ~= value
4934 errordlg('The new component place must be positive integer.');
4935 return;
4936 end
4937
4938 if value > getfield(size(sData.data),{2}) + 1
4939 errordlg('Too big value for the new component place.');
4940 return;
4941 end
4942 end
4943
4944 sData.MODIFIED=1;
4945
4946 indices1=1:value-1;
4947 indices2=value:length(sData.data(1,:));
4948 tmp1=sData.data(:,indices1);
4949 tmp2=sData.data(:,indices2);
4950 sData.data=cat(2,tmp1,sData.data(:,index),tmp2);
4951
4952 tmp1=sData.comp_names(indices1);
4953 tmp2=sData.comp_names(indices2);
4954 name=cell(1,1);
4955 name{1}=cat(2,'Copied',sData.comp_names{index});
4956 sData.comp_names=cat(1,tmp1,name,tmp2);
4957
4958 tmp1=sData.comp_norm(indices1);
4959 tmp2=sData.comp_norm(indices2);
4960 norm=cell(1,1);
4961 norm{1}=sData.comp_norm{index};
4962 sData.comp_norm=cat(1,tmp1,norm,tmp2);
4963
4964 data.sData=sData;
4965 data.undo.sData=undo;
4966 if ~LOG
4967 data.LOG{length(data.LOG)+1}='% Copy component';
4968 data.LOG{length(data.LOG)+1}=sprintf('preprocess(''copy'',''%s %s'');',...
4969 num2str(value),num2str(index));
4970 end
4971
4972
4973 comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h');
4974 vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h');
4975 vector_h=getfield(get(gcf,'UserData'),'vector_h');
4976 data.selected_vects=1:length(sData.data(:,1));
4977 set(gcf,'UserData',data);
4978 clear_button;
4979 write_sD_stats;
4980 set_compnames(sData,comp_names_h);
4981 draw_vectors(ones(1,length(sData.data(:,1))),vector_h);
4982 vect_means(sData,vect_mean_h,data.selected_vects);
4983 cplot_mimema;
4984 sel_comp;
4985
4986 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4987
4988 %%% Subfunction: remove_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4989
4990 function remove_component(varargin)
4991
4992 if nargin == 1
4993 LOG=1;
4994 value=str2num(varargin{1});
4995 else
4996 LOG=0;
4997 end
4998
4999 data=get(gcf,'UserData');
5000 vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h');
5001 vector_h=getfield(get(gcf,'UserData'),'vector_h');
5002 comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h');
5003 sData=data.sData;
5004 undo=sData;
5005 prompt='Enter the number of component to be removed.';
5006 dim=length(sData.data(1,:));
5007
5008 if ~LOG
5009 answer=inputdlg(prompt);
5010
5011 if isempty(answer) | (iscell(answer) & isempty(answer{1}))
5012 msgbox('Components not removed.');
5013 return;
5014 end
5015
5016 value=str2num(answer{1});
5017 dims=size(value);
5018
5019 if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value)
5020 errordlg('Number of the component to be removed must be positive integer.')
5021 return;
5022 end
5023
5024 if value <= 0 | round(value) ~= value
5025 errordlg('Number of the component to be removed must be positive integer.');
5026 return;
5027 end
5028
5029 if value > getfield(size(sData.data),{2})
5030 errordlg('There are less components.');
5031 return;
5032 end
5033 end
5034
5035 sD_set_h=getfield(get(gcf,'UserData'),'sD_set_h');
5036 index=get(sD_set_h,'Value');
5037 if value == 1 & getfield(size(sData.data),{2}) == 1
5038 if length(get(sD_set_h,'String')) == 1
5039 msgbox('No data left. Closing program...')
5040 pro_tools('close');
5041 return;
5042 end
5043
5044 set1=data.sD_set(1:index-1);
5045 set2=data.sD_set(index+1:length(data.sD_set));
5046 data.sD_set=[set1 set2];
5047 set(gcf,'UserData',data);
5048
5049 set_sD_stats;
5050 sel_sD;
5051 data=get(gcf,'UserData');
5052 data.undo.sData=undo;
5053 data.undo.index=index;
5054 set(gcf,'UserData',data);
5055 return;
5056 end
5057 dims=size(sData.data);
5058 tmp_data=cat(2,sData.data(:,1:value-1),sData.data(:,value+1:dims(2)));
5059 tmp_norm=cat(1,sData.comp_norm(1:value-1),sData.comp_norm(value+1:dims(2)));
5060 names=cat(1,sData.comp_names(1:value-1),sData.comp_names(value+1:dims(2)));
5061 INDEX=sData.INDEX;
5062 comp_norm=sData.comp_norm;
5063 sData=som_data_struct(tmp_data,...
5064 'name',sData.name,...
5065 'labels',sData.labels,...
5066 'comp_names',names);
5067 sData.comp_norm=tmp_norm;
5068 sData.MODIFIED=1;
5069 sData.INDEX=INDEX;
5070 data=get(gcf,'UserData');
5071 data.sData=sData;
5072 data.undo.sData=undo;
5073 data.selected_vects=1:length(sData.data(:,1));
5074 if ~LOG
5075 data.LOG{length(data.LOG)+1}='% Remove component';
5076 data.LOG{length(data.LOG)+1}=sprintf('preprocess(''remove'',''%s'');',...
5077 answer{1});
5078 end
5079 set(gcf,'UserData',data);
5080 clear_button;
5081 write_sD_stats;
5082 set_compnames(sData,comp_names_h);
5083 tmp=ones(1,length(sData.data(:,1)));
5084 draw_vectors(tmp,vector_h);
5085 vect_means(sData,vect_mean_h,1:length(sData.data(:,1)));
5086 cplot_mimema;
5087 sel_comp;
5088
5089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5090
5091 %%% Subfunction: remove_vects %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5092
5093 function remove_vects(varargin)
5094
5095 if nargin==1
5096 LOG=1;
5097 tmp_str=varargin{1};
5098 else
5099 LOG=0;
5100 tmp_str='_foo';
5101 end
5102 data=get(gcf,'UserData');
5103 vect_mean_h=data.vect_mean_h;
5104 vector_h=data.vector_h;
5105 sData=data.sData;
5106 undo=sData;
5107
5108 if length(data.selected_vects) == getfield(size(sData.data),{1})
5109 if LOG
5110 answer='Yes';
5111 else
5112 answer=questdlg('Do you want to delete this data set?');
5113 end
5114 if strcmp(answer,'No')
5115 return;
5116 else
5117 index=get(data.sD_set_h,'Value');
5118 if length(get(data.sD_set_h,'String')) == 1
5119 msgbox('No data left. Closing program...')
5120 pro_tools('close');
5121 return;
5122 end
5123
5124 set1=data.sD_set(1:index-1);
5125 set2=data.sD_set(index+1:length(data.sD_set));
5126 data.sD_set=[set1 set2];
5127 set(gcf,'UserData',data);
5128
5129 set(data.sD_set_h,'Value',1);
5130 set_sD_stats;
5131 sel_sD;
5132 data=get(gcf,'UserData');
5133 data.undo.sData=undo;
5134 data.undo.index=index;
5135 if ~LOG
5136 data.LOG{length(data.LOG)+1}='% Remove selected vectors';
5137 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''remove_vects'',''',...
5138 tmp_str,''');');
5139 end
5140 set(gcf,'UserData',data);
5141 return;
5142 end
5143 end
5144
5145 tmp=sData.data(data.selected_vects,:);
5146 if ~LOG
5147 answer=questdlg('Do you want to save removed values to workspace?');
5148 else
5149 if ~strcmp(tmp_str,'_foo')
5150 answer='Yes';
5151 else
5152 answer='No';
5153 end
5154 end
5155 old=gcf;
5156 if strcmp(answer,'Yes')
5157 if ~LOG
5158 answer=inputdlg('Give the name of the output -variable.');
5159 else
5160 answer={tmp_str};
5161 end
5162 if isvalid_var_name(answer)
5163 assignin('base',answer{1},tmp);
5164 disp(sprintf('Removed values are set to workspace as''%s''.',answer{1}));
5165 tmp_str=answer{1};
5166 end
5167 end
5168 set(0,'CurrentFigure',old);
5169 sData.data(data.selected_vects,:)=[];
5170 sData.labels(data.selected_vects,:)=[];
5171 sData.MODIFIED=1;
5172 data.sData=sData;
5173 data.selected=1:length(sData.data(:,1));
5174 data.undo.sData=undo;
5175 if ~LOG
5176 data.LOG{length(data.LOG)}='% Remove selected vectors';
5177 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''remove_vects'',''',...
5178 tmp_str,''');');
5179 end
5180 set(gcf,'UserData',data);
5181
5182
5183 draw_vectors(ones(1,length(data.selected)),data.vector_h);
5184 write_sD_stats;
5185 select_all('foo');
5186
5187
5188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5189
5190
5191
5192
5193 %%% Subfunction: eval1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5194
5195 function eval1(varargin);
5196
5197 if nargin == 1
5198 answer=varargin
5199 LOG=1;
5200 else
5201 LOG=0;
5202 end
5203
5204 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
5205 if isempty(pre_h)
5206 errordlg('''Preprocess''-figure does not exist. Terminating program...');
5207 pro_tools('close');
5208 return;
5209 end
5210
5211 undo=getfield(get(pre_h,'UserData'),'sData');
5212
5213 if ~LOG
5214 prompt={'Enter the expression to be evaluated.',...
5215 'Enter the inverse normalization method (optional).'};
5216 title='Single component eval.';
5217 answer= inputdlg(prompt,title,1);
5218 end
5219
5220 if ~isempty(answer)
5221 tmp=[];
5222 if ~isempty(answer{1})
5223 [tmp,method]=build_expr(answer{1},'single');
5224 if ~isstr(tmp)
5225 sData=getfield(get(gcf,'UserData'),'sData');
5226 tmp='Done.';
5227 %if ~isempty(answer{2})
5228 % sN=som_norm_struct('eval',{method,answer{2}});
5229 %else
5230 % sN=som_norm_struct('eval',{method});
5231 %end
5232 %sN=som_set(sN,'status','done');
5233 params={answer{1};answer{2}};
5234 ind=getfield(get_indices,{1});
5235 x.type='';
5236 x.method='eval';
5237 x.params={answer{1};answer{2}};
5238 x.status='';
5239 sData.comp_norm{ind}=x;
5240 data=get(gcf,'UserData');
5241 data.undo.sData=undo;
5242 data.sData=sData;
5243 if ~LOG
5244 data.LOG{length(data.LOG)+1}='% Eval (1-comp)';
5245 data.LOG{length(data.LOG)+1}=cat(2,'preprocess eval1 ',...
5246 sprintf('{''%s'' ''%s''};',answer{1},answer{2}));
5247 end
5248 set(pre_h,'UserData',data);
5249
5250 end
5251 end
5252 set(getfield(get(pre_h,'UserData'),'results_h'),'String',tmp);
5253 end
5254
5255
5256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5257
5258 %%% Subfunction: eval2
5259
5260 function eval2(varargin)
5261
5262 if nargin == 1
5263 answer=varargin{1};
5264 LOG=1;
5265 else
5266 LOG=0;
5267 end
5268
5269 undo=getfield(get(gcf,'UserData'),'sData');
5270 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
5271
5272 if isempty(pre_h)
5273 errordlg('''Preprocess''-figure does not exist. Terminating program.');
5274 pro_tools('close');
5275 return;
5276 end
5277
5278 if ~LOG
5279 prompt='Enter the expression to be evaluated.';
5280 title ='Eval';
5281 answer=inputdlg(prompt,title,1);
5282 end
5283
5284 if ~isempty(answer) & ~isempty(answer{1})
5285 str=answer{1};
5286 [answer,foo]=build_expr(answer{1},'multiple');
5287 if ~isstr(answer)
5288
5289 answer='Done.';
5290 data=get(gcf,'UserData');
5291 data.undo.sData=undo;
5292 if ~LOG
5293 data.LOG{length(data.LOG)+1}='% Eval';
5294 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''eval2'',',...
5295 sprintf('{''%s''});',str));
5296 end
5297 set(gcf,'UserData',data);
5298 end
5299 end
5300
5301 set(getfield(get(pre_h,'UserData'),'results_h'),'String',answer);
5302
5303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5304
5305 %%% Subfunction: zero2one_scale %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5306
5307 function zero2one_scale(varargin)
5308
5309 if nargin == 1
5310 LOG=1;
5311 else
5312 LOG=0;
5313 end
5314
5315
5316 data=get(gcf,'UserData');
5317 sData=data.sData;
5318 undo=sData;
5319 INDEX=sData.INDEX;
5320 sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]);
5321
5322 if isempty(get(data.comp_names_h,'Value'))
5323 errordlg('There must be components chosen for scaling.');
5324 return;
5325 end
5326
5327 sData=som_normalize(sData,'range',get_indices);
5328 sData.MODIFIED=1;
5329 sData.INDEX=INDEX;
5330
5331 data.sData=sData;
5332 data.undo.sData=undo;
5333 if ~LOG
5334 data.LOG{length(data.LOG)+1}='% Scale [0,1]';
5335 data.LOG{length(data.LOG)+1}='preprocess(''zscale'', ''foo'');';
5336 end
5337 set(gcf,'UserData',data);
5338
5339 vects=zeros(1,length(sData.data(:,1)));
5340 vects(data.selected_vects)=1;
5341
5342 cplot_mimema;
5343 plot_hist;
5344 vect_means(sData,data.vect_mean_h,data.selected_vects);
5345 draw_vectors(vects,data.vector_h);
5346
5347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5348
5349 %%% Subfunction: var_scale %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5350
5351 function var_scale(varargin)
5352
5353 if nargin == 1
5354 LOG=1;
5355 else
5356 LOG=0;
5357 end
5358
5359 data=get(gcf,'UserData');
5360 sData=data.sData;
5361 undo=sData;
5362 INDEX=sData.INDEX;
5363 sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]);
5364
5365 if isempty(get(data.comp_names_h,'Value'))
5366 errordlg('There must be components chosen for scaling.');
5367 return;
5368 end
5369
5370 sData=som_normalize(sData,'var',get_indices);
5371
5372 sData.INDEX=INDEX;
5373 sData.MODIFIED=1;
5374
5375 data.sData=sData;
5376 data.undo.sData=undo;
5377 if ~LOG
5378 data.LOG{length(data.LOG)+1}='% Scale var=1';
5379 data.LOG{length(data.LOG)+1}='preprocess(''vscale'', ''foo'');';
5380 end
5381 set(gcf,'UserData',data);
5382
5383 vects=zeros(1,length(sData.data(:,1)));
5384 vects(data.selected_vects)=1;
5385
5386 cplot_mimema;
5387 plot_hist;
5388 vect_means(sData,data.vect_mean_h,data.selected_vects);
5389 draw_vectors(vects,data.vector_h);
5390
5391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5392
5393 %%% Subfunction: hist_eq %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5394
5395 function hist_eq(varargin)
5396
5397 if nargin == 1
5398 LOG=1;
5399 else
5400 LOG=0;
5401 end
5402
5403 data=get(gcf,'UserData');
5404 sData=data.sData;
5405 undo=sData;
5406 INDEX=sData.INDEX;
5407 sData=rmfield(sData,[{'INDEX'},{'MODIFIED'}]);
5408
5409 if isempty(get(data.comp_names_h,'Value'))
5410 errordlg('There must be components chosen for ''Histogram eq''.');
5411 return;
5412 end
5413
5414 sData=som_normalize(sData,'histD',get_indices);
5415
5416 sData.INDEX=INDEX;
5417 sData.MODIFIED=1;
5418
5419 data.sData=sData;
5420 data.undo.sData=undo;
5421 if ~LOG
5422 data.LOG{length(data.LOG)+1}='% Histogram eq';
5423 data.LOG{length(data.LOG)+1}='preprocess(''histeq'', ''foo'');';
5424 end
5425 set(gcf,'UserData',data);
5426
5427 vects=zeros(1,length(sData.data(:,1)));
5428 vects(data.selected_vects)=1;
5429
5430 cplot_mimema;
5431 plot_hist;
5432 vect_means(sData,data.vect_mean_h,data.selected_vects);
5433 draw_vectors(vects,data.vector_h);
5434
5435 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5436
5437 %%% Subfunction: hist_eq2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5438
5439 function hist_eq2(varargin)
5440
5441 if nargin == 1
5442 LOG=1;
5443 else
5444 LOG=0;
5445 end
5446
5447
5448 data=get(gcf,'UserData');
5449 sData=data.sData;
5450 undo=sData;
5451
5452 INDEX=sData.INDEX;
5453 sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]);
5454
5455 if isempty(get(data.comp_names_h,'Value'))
5456 errordlg('There must be components chosen for ''Histogram eq2''.');
5457 return;
5458 end
5459
5460 inds=get_indices;
5461 %%%[sData,ok]=som_normalize(sData,inds,'histC');
5462 sData=som_normalize(sData,'histC',inds);
5463 sData.INDEX=INDEX;
5464 sData.MODIFIED=1;
5465
5466 data.sData=sData;
5467 data.undo.sData=undo;
5468 if ~LOG
5469 data.LOG{length(data.LOG)+1}='% Histogram eq2';
5470 data.LOG{length(data.LOG)+1}='preprocess(''histeq2'', ''foo'');';
5471 end
5472 set(gcf,'UserData',data);
5473
5474 vects=zeros(1,length(sData.data(:,1)));
5475 vects(data.selected_vects)=1;
5476
5477 cplot_mimema;
5478 plot_hist;
5479 vect_means(sData,data.vect_mean_h,data.selected_vects);
5480 draw_vectors(vects,data.vector_h);
5481
5482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5483
5484 %%% Subfunction: logarithm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5485
5486 function logarithm(varargin)
5487
5488 if nargin == 1
5489 LOG=1;
5490 else
5491 LOG=0;
5492 end
5493
5494 data=get(gcf,'UserData');
5495 sData=data.sData;
5496 undo=sData;
5497
5498 INDEX=sData.INDEX;
5499 sData=rmfield(sData,[{'INDEX'},{'MODIFIED'}]);
5500
5501 if isempty(get(data.comp_names_h,'Value'))
5502 errordlg('There must be components chosen for ''Log''.');
5503 return;
5504 end
5505
5506 Data=som_normalize(sData,'log',get_indices);
5507
5508 sData.INDEX=INDEX;
5509 sData.MODIFIED=1;
5510
5511 data.sData=sData;
5512 data.undo.sData=undo;
5513 if ~LOG
5514 data.LOG{length(data.LOG)+1}='% Log';
5515 data.LOG{length(data.LOG)+1}='preprocess(''log'', ''foo'');';
5516 end
5517 set(gcf,'UserData',data);
5518
5519 vects=zeros(1,length(sData.data(:,1)));
5520 vects(data.selected_vects)=1;
5521
5522 cplot_mimema;
5523 plot_hist;
5524 vect_means(sData,data.vect_mean_h,data.selected_vects);
5525 draw_vectors(vects,data.vector_h);
5526
5527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5528
5529 function [answer,method]=build_expr(string,evaltype)
5530
5531 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
5532
5533 method=[];
5534 if isempty(pre_h)
5535 close_preprocess;
5536 errordlg('''Preprocess'' -figure does not exist. Terminating program...');
5537 return;
5538
5539 end
5540
5541 if isempty(string)
5542 str = '[]';
5543 return;
5544 end
5545
5546 tmp=[];
5547 [name,assign,skip]=check_assign(string,evaltype);
5548
5549 if ~strcmp(assign,'NOTASSIGN') & ~strcmp(assign,'error')
5550 string=string(skip:length(string));
5551 end
5552
5553 if ~strcmp(assign,'error')
5554 if isempty(string)
5555 answer='Illegal expression.';
5556 return;
5557 end
5558 [str,skip]=check_token(string,evaltype);
5559 method=string;
5560 while ~strcmp(str,'error') & ~strcmp(tmp,'error') & skip < length(string)
5561 if ~strcmp(tmp,')')
5562 str=cat(2,str,tmp);
5563 end
5564 [tmp,skip2]=check_token(string(skip+1:length(string)),evaltype);
5565 skip=skip+skip2;
5566
5567 end
5568 if ~strcmp(tmp,')') & ~strcmp(tmp,'error')
5569 str=cat(2,str,tmp);
5570 elseif strcmp(tmp,'error')
5571 str='error';
5572 end
5573 end
5574
5575 if ~strcmp(assign,'error') & ~strcmp(str,'error');
5576 answer=evalin('caller',str,'lasterr');
5577 else
5578 answer='??? Illegal expression.';
5579 end
5580
5581
5582 data=get(pre_h,'UserData');
5583 sData=data.sData;
5584 if strcmp(assign,'NOTASSIGN') & strcmp(evaltype,'single') & ~isstr(answer)
5585 if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value'))
5586 errordlg('There are not components chosen.');
5587 answer='??? Illegal expression.';
5588 return;
5589 end
5590 index=getfield(get_indices,{1});
5591 if strcmp(assign,'NOTASSIGN')
5592 if length(sData.data(:,index)) ~=length(answer) & ~isscalar(answer)
5593 answer='??? Illegal assignment.';
5594 else
5595 sData.data(:,index)=answer;
5596 sData.MODIFIED=1;
5597 data.sData=sData;
5598 set(pre_h,'UserData',data);
5599 end
5600 else
5601 if length(sData.data(str2num(assign),index)) ~=length(answer) & ~isscalar(answer)
5602 answer='??? Illegal assignment.';
5603 else
5604 sData.data(str2num(assign),index)=answer;
5605 sData.MODIFIED=1;
5606 data.sData=sData;
5607 set(pre_h,'UserData',data);
5608 end
5609 end
5610 elseif ~strcmp(assign,'error') & ~isstr(answer) & ~strcmp(assign,'NOTASSIGN')
5611 switch name
5612 case 'x'
5613 if isempty(get(data.comp_names_h,'Value'))
5614 return;
5615 end
5616 index = getfield(get_indices,{1});
5617 if isempty(assign)
5618 if length(sData.data(:,index)) ~= length(answer) & ~isscalar(answer)
5619 answer='??? Illegal assignment.';
5620 else
5621 sData.data(:,index)=answer;
5622 sData.MODIFIED=1;
5623 data.sData=sData;
5624 if strcmp(evaltype,'multiple')
5625 data.sData.comp_norm(index)={[]};
5626 end
5627 set(pre_h,'UserData',data);
5628 end
5629 else
5630 args=create_args(assign,'x');
5631 if length(args) == 1
5632 len=max(str2num(args{1}));
5633 if ~isscalar(len)
5634 answer='??? Illegal assignment.';
5635 return;
5636 elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1
5637 answer='??? Illegal assignment.';
5638 return;
5639 elseif ~all(size(sData.data(str2num(args{1}),index))) == size(answer) & ~isscalar(answer)
5640 answer='??? Illegal assignment.';
5641 return;
5642 else
5643 sData.data(str2num(args{1}),index)=answer;
5644 sData.MODIFIED=1;
5645 data.sData=sData;
5646 if strcmp(evaltype,'multiple')
5647 data.sData.comp_norm(index)={[]};
5648 end
5649 set(pre_h,'UserData',data);
5650 end
5651 else
5652 len=max(str2num(args{1}));
5653 dim=max(str2num(args{2}));
5654 asize=size(answer);
5655 msize=size(sData.data);
5656 if ~isscalar(len) | ~isscalar(dim)
5657 answer='??? Illegal assignment.';
5658 return;
5659 elseif len > length(sData.data(:,1)) | len < 1
5660 answer='??? Illegal assignment.';
5661 return;
5662 elseif dim > 1 | dim > msize(2) | min(str2num(args{2})) < 1
5663 answer='??? Illegal assignment.';
5664 return;
5665 end
5666 len=length(str2num(args{1}));
5667 dim=length(str2num(args{1}));
5668 if ~all([len dim] == asize) & ~isscalar(answer)
5669 answer='??? Illegal assignment.';
5670 return;
5671 else
5672 tmp=sData.data(:,index);
5673 tmp([str2num(args{1})],[str2num(args{2})])=answer;
5674 sData.data(:,index)=tmp;
5675 sData.MODIFIED=1;
5676 data.sData=sData;
5677 if strcmp(evaltype,'multiple')
5678 data.sData.comp_norm(index)={[]};
5679 end
5680 set(pre_h,'UserData',data);
5681 end
5682 end
5683 end
5684
5685 case 'xs'
5686 if isempty(get(data.comp_names_h,'Value'))
5687 return;
5688 end
5689 indices=get_indices;
5690 if isempty(assign)
5691 if ~all(size(answer) == size(sData.data(:,indices))) & ~isscalar(answer)
5692 answer='??? Illegal assignment.';
5693 else
5694 sData.data(:,indices) = answer;
5695 sData.MODIFIED=1;
5696 data.sData=sData;
5697 data.sData.comp_norm(indices)={[]};
5698 set(pre_h,'UserData',data);
5699 end
5700 else
5701 args=create_args(assign,'xs');
5702 if length(args) == 1
5703 len=max(str2num(args{1}));
5704 if ~isscalar(len)
5705 answer='??? Illegal assignment.';
5706 return;
5707 elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1
5708 answer='??? Illegal assignment.';
5709 return;
5710 end
5711 if ~all(size(answer) == size(sData.data(str2num(args{1})))) &...
5712 ~isscalar(answer)
5713 answer='??? Illegal assignment.';
5714 return;
5715 else
5716 tmp=sData.data(:,indices);
5717 tmp(str2num(args{1}))=answer;
5718 sData.data(:,indices)=tmp;
5719 sData.MODIFIED=1;
5720 sData.comp_norm{indices}={[]};
5721 data.sData=sData;
5722 set(pre_h,'UserData',data);
5723 end
5724 else
5725 len=max(str2num(args{1}));
5726 dim=max(str2num(args{2}));
5727 asize=size(answer);
5728 msize=size(sData.data(:,indices));
5729 if ~isscalar(len) | ~isscalar(dim)
5730 answer='??? Illegal assignment.';
5731 return;
5732 elseif len > msize(1) | min(str2num(args{1})) < 1
5733 answer='??? Illegal assignment.';
5734 return;
5735 elseif dim > msize(2) | min(str2num(args{2})) < 1
5736 answer='??? Illegal assignment.';
5737 return;
5738 end
5739 len=length(str2num(args{1}));
5740 dim=length(str2num(args{2}));
5741 if ~all([len dim] == asize) & ~isscalar(answer)
5742 answer='??? Illegal assignment';
5743 return;
5744 else
5745 tmp=sData.data(:,indices);
5746 tmp([str2num(args{1})],[str2num(args{2})])=answer;
5747 sData.MODIFIED=1;
5748 sData.data(:,indices)=tmp;
5749 data.sData=sData;
5750 data.sData.comp_norm(indices)={[]};
5751 set(pre_h,'UserData',data);
5752 end
5753
5754 end
5755 end
5756
5757 case 'D'
5758 if isempty(assign)
5759 if ~all(size(answer) == size(sData.data)) & ~isscalar(answer)
5760 answer='??? Illegal assignment.';
5761 else
5762 if isscalar(answer)
5763 sData.data(:,:)=answer;
5764 else
5765 sData.data=answer;
5766 end
5767 sData.MODIFIED=1;
5768 data.sData=sData;
5769 data.sData.comp_norm(1:length(sData.data(1,:)))={[]};
5770 set(pre_h,'UserData',data);
5771 end
5772 else
5773 args=create_args(assign,'D');
5774 if length(args) == 1
5775 len=max(str2num(args{1}));
5776 if ~isscalar(len)
5777 answer='??? Illegal assignment.';
5778 return;
5779 elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1
5780 answer='??? Illegal assignment.';
5781 return;
5782 end
5783 if ~all(size(answer) == size(sData.data(str2num(args{1})))) &...
5784 ~isscalar(answer)
5785 answer='??? Illegal assignment.';
5786 else
5787 sData.data(str2num(args{1}))=answer;
5788 sData.MODIFIED=1;
5789 data.sData=sData;
5790 [i,j]=ind2sub(size(sData.data),str2num(args{1}));
5791 data.sData.comp_norm(j)={[]};
5792 set(pre_h,'UserData',data);
5793 end
5794 else
5795 len=max(str2num(args{1}));
5796 dim=max(str2num(args{2}));
5797 asize=size(answer);
5798 msize=size(sData.data);
5799 if ~isscalar(len) | ~isscalar(dim)
5800 answer='??? Illegal assignment.';
5801 return;
5802 elseif len > msize(1) | min(str2num(args{1})) < 1
5803 answer='??? Illegal assignment.';
5804 return;
5805 elseif dim > msize(2) | min(str2num(args{2})) < 1
5806 answer= '??? Illegal assignment.';
5807 return;
5808 end
5809 len = length(str2num(args{1}));
5810 dim = length(str2num(args{2}));
5811 if ~all([len dim] == asize) & ~isscalar(answer)
5812 answer='??? Illegal assignment.';
5813 return;
5814 else
5815 sData.data([str2num(args{1})],[str2num(args{2})])=answer;
5816 sData.MODIFIED=1;
5817 data.sData=sData;
5818 data.sData.comp_norm(str2num(args{2}))={[]};
5819 set(pre_h,'UserData',data);
5820 end
5821 end
5822 end
5823 end
5824 end
5825 if sData.MODIFIED
5826 selected=getfield(get(pre_h,'UserData'),'selected_vects');
5827 vector_h=getfield(get(pre_h,'UserData'),'vector_h');
5828 vect_mean_h=getfield(get(pre_h,'UserData'),'vect_mean_h');
5829 vects=zeros(length(sData.data(:,1)));
5830 vects(selected)=1;
5831 draw_vectors(vects,vector_h);
5832 vect_means(sData,vect_mean_h,selected);
5833 pro_tools('plot_hist');
5834 pro_tools('c_stat');
5835 cplot_mimema;
5836 end
5837
5838
5839 %%% Subfunction: check_assign %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5840
5841 function [name,string,skip]=check_assign(string,evaltype)
5842
5843
5844 reswords=[{'D'};{'x'};{'xs'}];
5845 flag=0;
5846 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
5847
5848 if isempty(pre_h)
5849 man_h=findobj(get(0,'Children'),'Tag','Management');
5850 clip_h=findobj(get(0,'Children'),'Tag','Clipping');
5851 errordlg('''Preprocess'' -window does not exist. Terminating program.');
5852 if ~isempty(man_h)
5853 close man_h;
5854 end
5855 if ~isempty(clip_h)
5856 close clip_h;
5857 end
5858 return;
5859 end
5860
5861 EMPTY=isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value'));
5862
5863 [name,s]=give_token(string,evaltype);
5864 skip=length(s);
5865
5866 if strcmp(evaltype,'single') & ~strcmp(name,'x')
5867 string='NOTASSIGN';
5868 return;
5869 end
5870
5871 if strcmp(name,'other') & ~strcmp(s,'x')
5872 string = 'error';
5873 return;
5874 end
5875
5876 if strcmp(name,[{'x'};{'xs'}])
5877 comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h');
5878 if isempty(get(comp_names_h,'Value'))
5879 errordlg('There are not components chosen.');
5880 string='error';
5881 return;
5882 end
5883 end
5884
5885
5886 if skip == length(string) | ~strcmp(name,reswords)
5887 string = 'NOTASSIGN';
5888 return;
5889 end
5890
5891 if (strcmp(name,'x') | strcmp(name,'xs')) & EMPTY
5892 errordlg('There are not components chosen.');
5893 string = 'error';
5894 return;
5895 end
5896
5897 [t,s]=give_token(string(length(name)+1),evaltype);
5898
5899 if strcmp(t,'(')
5900 flag=1;
5901 end
5902
5903 [foo,skip]=check_token(string,evaltype);
5904 if length(name) ~= skip-1
5905 skip=skip-1;
5906 tmp=string(length(name)+1:skip);
5907 else
5908 tmp = [];
5909 end
5910
5911 if flag & tmp(length(tmp)) ~= ')'
5912 tmp(length(tmp)+1)=')';
5913 end
5914
5915 if skip==length(string)
5916 return;
5917 end
5918
5919 skip=skip+1;
5920 if length(string) ~= skip
5921 [t,s]=give_token(string(skip+1:length(string)),evaltype);
5922 else
5923 string='NOTASSIGN';
5924 return;
5925 end
5926
5927 if ~strcmp(t,'=')
5928 string = 'NOTASSIGN';
5929 return;
5930 end
5931 string=tmp;
5932 skip = skip+2;
5933
5934 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5935
5936 %%% Subfunction: isscalar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5937
5938 function bool = isscalar(x)
5939
5940 m= size(x);
5941
5942 bool = m(1) == 1 & m(2) == 1;
5943
5944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5945
5946 %%% Subfunction: create_args %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5947
5948 function args=create_args(string,type)
5949
5950 arg2='';
5951 i=2;
5952 j=1;
5953 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
5954 msize=size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data'));
5955
5956
5957 if string(i) == ':'
5958 arg1=num2str(cat(2,'1:',num2str(msize(1))));
5959 i=i+1;
5960 j=j+length(arg1);
5961 end
5962
5963 while string(i) ~=',' & string(i) ~=')'
5964 arg1(j)=string(i);
5965 i=i+1;
5966 j=j+1;
5967 end
5968
5969
5970
5971 if string(i) ==','
5972 j=1;
5973 i=i+1;
5974 if string(i)==':'
5975 switch type
5976 case 'x'
5977 arg2='1';
5978 case 'cs'
5979 arg2=num2str(get_indices);
5980 case 'D'
5981 arg2=num2str(cat(2,'1:',num2str(msize(2))));
5982 end
5983 i=i+1;
5984 j=j+length(arg2);
5985 end
5986
5987 while string(i) ~= ')'
5988 arg2(j)=string(i);
5989 j=j+1;
5990 i=i+1;
5991 end
5992 end
5993
5994
5995 args{1}=arg1;
5996 if ~isempty(arg2)
5997 args{2} = arg2;
5998 end
5999
6000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6001
6002 function [str,skip] = check_token(string,evaltype)
6003
6004 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
6005
6006 tmp_string=string;
6007 [t,s]=give_token(tmp_string,evaltype);
6008 skip=length(s);
6009
6010 if strcmp(t,'c')
6011 if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value'))
6012 errordlg('There are no components chosen.');
6013 str='error';
6014 return;
6015 end
6016 index=getfield(get_indices,{1});
6017 str=cat(2,'[',num2str(index),']');
6018 if skip == length(tmp_string)
6019 return;
6020 end
6021 tmp_string=tmp_string(skip+1:length(tmp_string));
6022 [t,s] = give_token(tmp_string,evaltype);
6023 if ~strcmp(t,'(')
6024 return;
6025 end
6026 [args,skip2] = get_args(tmp_string(length(s)+1:length(tmp_string)),'c',...
6027 evaltype);
6028 skip=skip+skip2+2;
6029 if strcmp(args,'error')
6030 str = 'error'
6031 return;
6032 elseif ~strcmp(args,'all')
6033 str=cat(2,'getfield(',str,',',args,')');
6034 else
6035 str=cat(2,'getfield(',str,',{[1]})');
6036 end
6037 elseif strcmp(t,'cs')
6038 if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value'))
6039 errordlg('There are no components chosen.');
6040 str='error';
6041 return;
6042 end
6043 str =cat(2,'[',num2str(get_indices),']');
6044 if length(s) == length(string)
6045 return;
6046 end
6047 tmp_string=tmp_string(1+length(s):length(string));
6048 [t,s]=give_token(tmp_string,evaltype);
6049 if ~strcmp(t,'(')
6050 return;
6051 else
6052 [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'cs',...
6053 evaltype);
6054 skip=2+skip+skip2;
6055 if strcmp(args,'error')
6056 str='error';
6057 return;
6058 elseif ~strcmp(args,'all')
6059 str = cat(2,'getfield(',str,',',args,')');
6060 else
6061 tmp_str=str;
6062 str=cat(2,'[getfield(',str,',','{1})');
6063 for i=2:length(get_indices)
6064 str=cat(2,str,';getfield(',tmp_str,',',sprintf('{%d})',i));
6065 end
6066 str=cat(2,str,']');
6067 end
6068 end
6069 elseif strcmp(t,'dim')
6070 ind1=getfield(size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')),{2});
6071 str=cat(2,'[',num2str(ind1),']');
6072 if length(s)==length(string)
6073 return;
6074 end
6075 tmp_string=string(1+length(s):length(string));
6076 [t,s]=give_token(tmp_string,evaltype);
6077 if ~strcmp(t,'(')
6078 return;
6079 end
6080 skip=1+skip+length(s);
6081 [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'dim',...
6082 evaltype);
6083 if strcmp(args,'error')
6084 str = 'error';
6085 return;
6086 else
6087 skip=skip+skip2;
6088 if ~strcmp(args,'all')
6089 str=cat(2,'getfield(',str,',',args,')');
6090 end
6091 end
6092
6093 elseif strcmp(t,'dlen')
6094 ind1=getfield(size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')),{1});
6095 str=cat(2,'[',num2str(ind1),']');
6096 if length(s)==length(string)
6097 return;
6098 end
6099 tmp_string=string(1+length(s):length(string));
6100 [t,s]=give_token(tmp_string,evaltype);
6101 if ~strcmp(t,'(')
6102 return;
6103 end
6104 skip=skip+length(s);
6105 [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'dlen',...
6106 evaltype);
6107 if strcmp(args,'error')
6108 str='error';
6109 return;
6110 else
6111 skip=1+skip+skip2;
6112 if ~strcmp(args,'all')
6113 str=cat(2,'getfield(',str,',',args,')');
6114 end
6115 end
6116
6117 elseif strcmp(t,'x')
6118 if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value'))
6119 errordlg('There are not components chosen.');
6120 str='error';
6121 return;
6122 end
6123 len=getfield(size(getfield(getfield(get(pre_h,'UserData'),...
6124 'sData'),'data')),{1});
6125 index=num2str(getfield(get_indices,{1}));
6126 h_str='findobj(get(0,''Children''),''Tag'',''Preprocess'')';
6127 get_str=cat(2,'getfield(get(',h_str,',''UserData''),''sData'')');
6128 get_str=cat(2,'getfield(',get_str,',''data'')');
6129 str=cat(2,'getfield(',get_str,',{[1:',num2str(len),'],',index,'})');
6130 if length(s) == length(string)
6131 return;
6132 end
6133 tmp_string=string(1+length(s):length(string));
6134 [t,s]=give_token(tmp_string,evaltype);
6135 if ~strcmp(t,'(');
6136 return;
6137 end
6138 skip=skip+length(s);
6139 [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'x',...
6140 evaltype);
6141 if strcmp(args,'error')
6142 str = 'error';
6143 return;
6144 else
6145 skip=1+skip+skip2;
6146 if ~strcmp(args,'all')
6147 str=cat(2,'getfield(',str,',',args,')');
6148 end
6149 end
6150
6151 elseif strcmp(t,'xs')
6152 if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value'))
6153 errordlg('There are not components chosen.');
6154 str='error';
6155 return;
6156 end
6157 len=getfield(size(getfield(getfield(get(pre_h,'UserData'),...
6158 'sData'),'data')),{1});
6159 index=get_indices;
6160 index=cat(2,'[',num2str(index),']');
6161 h_str='findobj(get(0,''Children''),''Tag'',''Preprocess'')';
6162 get_str=cat(2,'getfield(get(',h_str,',''UserData''),''sData'')');
6163 get_str=cat(2,'getfield(',get_str,',''data'')');
6164 str=cat(2,'getfield(',get_str,',{[1:',num2str(len),'],',index,'})');
6165 if length(s) == length(string)
6166 return;
6167 end
6168 tmp_string=string(1+length(s):length(string));
6169 [t,s]=give_token(tmp_string,evaltype);
6170 if ~strcmp(t,'(')
6171 return;
6172 end
6173 skip=1+skip+length(s);
6174
6175 [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'xs',...
6176 evaltype);
6177 if strcmp(args,'error')
6178 str = 'error';
6179 return;
6180 elseif ~strcmp(args,'all')
6181 str=cat(2,'getfield(',str,',',args,')');
6182 skip=skip+skip2;
6183 else
6184 skip=skip+skip2;
6185 [dlen,dim]=size(eval(str));
6186 tmp_str=str;
6187 str=cat(2,'[','getfield(',tmp_str,sprintf(',{1:%d,1})',dlen));
6188 for i=2:dim
6189 tmp=sprintf(',{1:%d,%d})',dlen,dim);
6190 str=cat(2,str,';','getfield(',tmp_str,tmp);
6191 end
6192 str=cat(2,str,']');
6193 end
6194 elseif strcmp(t,'D')
6195 get_h='findobj(get(0,''Children''),''Tag'',''Preprocess'')';
6196 str=cat(2,'getfield(getfield(get(',get_h,',''UserData''),''sData''),''data'')');
6197
6198 if length(s) >= length(tmp_string)
6199 return;
6200 end
6201
6202 tmp_string=tmp_string(1+length(s):length(tmp_string));
6203 [t,s]=give_token(tmp_string,evaltype);
6204 if ~strcmp(t,'(')
6205 return;
6206 else
6207 tmp_string=tmp_string(1+length(s):length(tmp_string));
6208 skip = skip+length(s);
6209 [args, skip2]=get_args(tmp_string,'D',evaltype);
6210 if strcmp(args,'error')
6211 str='error';
6212 return;
6213 elseif ~strcmp(args,'all')
6214 str=cat(2,'getfield(',str,',',args,')');
6215 skip=1+skip+skip2;
6216 else
6217 skip=1+skip+skip2;
6218 [dlen,dim]=size(eval(str));
6219 tmp_str=str;
6220 str=cat(2,'[getfield(',str,sprintf(',{1:%d,1})',dlen));
6221 for i=2:dim
6222 tmp=sprintf(',{1:%d,%d}',dlen,i);
6223 str=cat(2,str,';getfield(',tmp_str,tmp,')');
6224 end
6225 str=cat(2,str,']');
6226 end
6227 end
6228 else
6229 if strcmp(t,'(')
6230 str = t;
6231 str2='';
6232 tmp_string=tmp_string(1+length(s):length(tmp_string));
6233 while ~strcmp(str2,')') & ~isempty(tmp_string)
6234 [str2,skip2]=check_token(tmp_string,evaltype);
6235 if strcmp(str2,'error')
6236 str='error';
6237 return;
6238 end
6239 skip=skip+skip2;
6240 tmp_string=tmp_string(skip2+1:length(tmp_string));
6241 str=cat(2,str,str2);
6242 end
6243 if ~strcmp(str2,')')
6244 str = 'error';
6245 end
6246 else
6247 str = s;
6248 end
6249 end
6250
6251 %%% Subfunction: get_args %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6252
6253 function [str,skip] = get_args(string,flag,evaltype)
6254
6255 res_words=[{'D'};{'c'};{'cs'};{'dim'};{'dlen'};{'x'};{'xs'}];
6256 NOTALL=1;
6257 if isempty(string)
6258 str='error'
6259 skip=[];
6260 return;
6261 end
6262 [t,s] = give_token(string,evaltype);
6263
6264
6265 skip=length(s);
6266 if any(strcmp(t,res_words));
6267 [str,skip2] = check_token(string,evaltype);
6268 string=string(1+length(s):length(string));
6269 str=cat(2,'{[',str);
6270 [t,s]=give_token(string,evaltype);
6271 elseif t==')' | t==','
6272 str = 'error';
6273 return;
6274 elseif strcmp(t,':');
6275 if length(s) == length(string)
6276 str='error';
6277 return;
6278 end
6279 [t,s]=give_token(string(1+length(s):length(string)),evaltype);
6280 if t == ')'
6281 str = 'all';
6282 return;
6283 end
6284 switch flag
6285 case {'c','cs','dim','dlen'}
6286 str= '{[1';
6287 otherwise
6288 str=cat(2,'{[',get_all('vect'));
6289 end
6290 NOTALL=0;
6291 string=string(1+length(s):length(string));
6292 [t,s]=give_token(string,evaltype);
6293 skip=skip+1;
6294 else
6295 str = cat(2,'{[',s);
6296 end
6297 str2 =[];
6298
6299
6300 if ~strcmp(t,',') & ~strcmp(t,')')
6301 skip=skip-length(s);
6302 end
6303
6304
6305
6306 while ~strcmp(t,',') & ~strcmp(t,')') & NOTALL;
6307 str=cat(2,str,str2);
6308 [t,s] = give_token(string,evaltype);
6309 if length(s) == length(string)
6310 str = 'error';
6311 return;
6312 end
6313 string=string(1+length(s):length(string));
6314 skip=skip+length(s);
6315 [t,s]=give_token(string,evaltype);
6316 if length(s) == length(string) & ~strcmp(t,')')
6317 str = 'error';
6318 return;
6319 end
6320
6321 [str2,foo]=check_token(string,evaltype);
6322 end
6323
6324 if NOTALL & ~strcmp(t,')')
6325 skip=skip+1;
6326 end
6327
6328 if strcmp(t,')')
6329 str=cat(2,str,']}');
6330 return
6331 end
6332
6333 str=cat(2,str,']',',','[');
6334 str2 = [];
6335
6336
6337 [t,s] = give_token(string,evaltype);
6338 if strcmp(t,')')
6339 str = 'error'
6340 return;
6341 end
6342 NOTALL=1;
6343 string=string(1+length(s):length(string));
6344 [t,s]=give_token(string,evaltype);
6345 if strcmp(t,':');
6346 switch flag
6347 case {'c','dim','dlen','x'}
6348 str=cat(2,str,'1');
6349 case 'D'
6350 str=cat(2,str,get_all('comp'));
6351 case {'cs','xs'}
6352 str=cat(2,str,'1:',num2str(length(get_indices)));
6353 end
6354 NOTALL=0;
6355 if length(s) == length(string)
6356 str='error';
6357 return;
6358 end
6359 string=string(1+length(s):length(string));
6360 [t,s]=give_token(string,evaltype);
6361 end
6362
6363 if ~strcmp(t,')') & NOTALL
6364 skip=skip-1;
6365 end
6366
6367 while ~strcmp(t,')') & NOTALL
6368 str=cat(2,str,str2);
6369 skip=skip+length(s);
6370 if length(s) == length(string) & ~strcmp(t,')')
6371 str='error';
6372 return;
6373 end
6374 [str2,foo]=check_token(string,evaltype);
6375 string=string(1+length(s):length(string));
6376 [t,s]=give_token(string,evaltype);
6377 end
6378 if ~strcmp(t,')')
6379 str='error';
6380 return;
6381 end
6382
6383
6384 str=cat(2,str,str2,']}');
6385 skip=skip+length(s);
6386
6387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6388
6389 %%% Subfunction: get_all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6390
6391 function str=get_all(vect_or_comp)
6392
6393 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
6394
6395 switch vect_or_comp
6396 case 'vect'
6397 dim=getfield(size(getfield(getfield(get(pre_h,'UserData'),...
6398 'sData'),'data')),{1});
6399 str=cat(2,'1:',num2str(dim));
6400 case 'comp'
6401 dim=getfield(size(getfield(getfield(get(pre_h,'UserData'),...
6402 'sData'),'data')),{2});
6403 str=cat(2,'1:',num2str(dim));
6404 end
6405
6406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6407
6408 function [token,str]=give_token(string,evaltype)
6409
6410 n=length(string);
6411 i=1;
6412 char=string(i);
6413
6414 switch analyze_char(string(i));
6415 case 'num'
6416 token='num';
6417 while i <= n & strcmp('num',analyze_char(string(i)))
6418 str(i)=string(i);
6419 i=i+1;
6420 end
6421 case 'other'
6422 switch string(i)
6423 case ':'
6424 token = ':';
6425 case ','
6426 token = ',';
6427 case '('
6428 token = '(';
6429 case ')'
6430 token = ')';
6431 case '='
6432 token = '=';
6433 otherwise
6434 token='other';
6435 end
6436 str=string(i);
6437 case 'alpha'
6438 while i <= n & strcmp('alpha',analyze_char(string(i)))
6439 str(i)=string(i);
6440 i=i+1;
6441 end
6442 token = find_res_word(str,evaltype);
6443 end
6444
6445 %%% Subfunction: analyze_char %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6446
6447 function type=analyze_char(char)
6448
6449
6450 if ((char-0) >= ('0'-0) & (char-0) <= ('9'-0))
6451 type='num';
6452 elseif ((char-0) >= ('a'-0) & (char-0) <= ('z'-0)) ...
6453 | ((char-0) >= ('A'-0) & (char-0) <= ('Z'-0))
6454 type='alpha';
6455 else
6456 type='other';
6457 end
6458
6459
6460 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6461
6462 %%% Subfunction: find_res_word %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6463
6464 function token = find_res_word(string,evaltype)
6465
6466 reswords=[{'D'};{'c'};{'cs'};{'dim'};{'dlen'};{'x'};{'xs'};{'other'}];
6467
6468 for i=1:length(reswords);
6469 token=reswords{i};
6470 if strcmp(string,reswords{i})
6471 if strcmp(evaltype,'single') & ~strcmp(string,'x')
6472 token = 'other';
6473 end
6474 return;
6475 end
6476 end
6477
6478 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6479
6480 function close_func(varargin)
6481
6482 switch varargin{1}
6483 case 'close_c'
6484 str='% Closing the ''Clipping'' -window...';
6485 clip_h=findobj(get(0,'Children'),'Tag','Clipping');
6486 close(clip_h);
6487 case 'close_sD'
6488 str='% Closing the ''Data Set Management'' -window...';
6489 sD_h=findobj(get(0,'Children'),'Tag','Management');
6490 close(sD_h);
6491 case 'close_w'
6492 str='% Closing the ''Windowed'' -window...';
6493 win_h=findobj(get(0,'Children'),'Tag','Window');
6494 close(win_h);
6495 case 'close_s'
6496 str='% Closing the ''Select'' -window...';
6497 sel_h=findobj(get(0,'Children'),'Tag','Select');
6498 close(sel_h);
6499 case 'close_d'
6500 str='% Closing the ''Delay'' -window...';
6501 del_h=findobj(get(0,'Children'),'Tag','Delay');
6502 close(del_h);
6503 end
6504
6505 if nargin ~= 2
6506 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
6507 preh_udata=get(pre_h,'UserData');
6508 str2=cat(2,'preprocess(''',varargin{1},''',''foo'');');
6509 preh_udata.LOG{length(preh_udata.LOG)+1}=str;
6510 preh_udata.LOG{length(preh_udata.LOG)+1}=str2;
6511 set(pre_h,'UserData',preh_udata);
6512 end
6513
6514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6515
6516 function log_file
6517
6518 answer=inputdlg('Give the name of the outputfile:','LOG function',1,...
6519 {'log_function'});
6520
6521 if isempty(answer)
6522 return;
6523 end
6524
6525
6526 tmp=clock;
6527 str =cat(2,'% Created: ',...
6528 date,...
6529 ' ',sprintf('%d:%d\n%\n\n',tmp(4),tmp(5)));
6530 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
6531 LOG=getfield(get(pre_h,'UserData'),'LOG');
6532 file=cat(2,pwd,'/',answer{1},'.m');
6533 fid =fopen(file,'w');
6534
6535 arg=LOG{2}(12:length(LOG{2})-2);
6536 fprintf(fid,'%s\n \n',cat(2,'function ',answer{1},'(',arg,')'));
6537 fprintf(fid,'%s\n',str);
6538 for i=1:length(LOG)
6539 fprintf(fid,'%s\n',LOG{i});
6540 end
6541 fclose(fid);
6542 disp(sprintf('LOG-file ''%s'' is done.',file));
6543
6544 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6545
6546 function get_selected_inds(varargin)
6547
6548 if nargin == 1
6549 LOG=1;
6550 answer = {varargin{1}};
6551 else
6552 LOG=0;
6553 end
6554
6555 selected=getfield(get(gcf,'UserData'),'selected_vects');
6556 if ~LOG
6557 answer=inputdlg('Give the name of the output variable:',...
6558 '',1,{'indices'});
6559 end
6560
6561 if isempty(answer) | isempty(answer{1})
6562 return;
6563 else
6564 assignin('base',answer{1},selected);
6565 disp(cat(2,'Indices of the selected vectors are set to the workspace ',...
6566 sprintf(' as ''%s''.',answer{1})));
6567 if ~LOG
6568 data=get(gcf,'UserData');
6569 data.LOG{length(data.LOG)+1}=...
6570 '% Saving indices of the selected vectors to the workspace.';
6571 data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''get_inds'',',...
6572 '''',answer{1},''');');
6573 set(gcf,'UserData',data);
6574 end
6575 end
6576
6577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6578
6579 function no_of_selected(varargin)
6580
6581 if nargin == 1
6582 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
6583 set(0,'CurrentFigure',pre_h);
6584 LOG = 1;
6585 else
6586 LOG = 0;
6587 end
6588
6589 results_h=getfield(get(gcf,'UserData'),'results_h');
6590 no=length(getfield(get(gcf,'UserData'),'selected_vects'));
6591 str={sprintf('Number of selected vectors: %d\n', no)};
6592 set(results_h,'String',str,'HorizontalAlignment','left');
6593
6594 if ~LOG
6595 data=get(gcf,'UserData');
6596 data.LOG{length(data.LOG)+1}='% Number of selected vectors';
6597 data.LOG{length(data.LOG)+1}='preprocess(''no_of_sel'',''foo'');';
6598 set(gcf,'UserData',data);
6599 end
6600
6601 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6602
6603 function select_all_comps(varargin)
6604
6605 if nargin == 1
6606 pre_h=findobj(get(0,'Children'),'Tag','Preprocess');
6607 set(0,'CurrentFigure',pre_h);
6608 LOG=1;
6609 else
6610 LOG=0;
6611 end
6612
6613 comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h');
6614
6615 set(comp_names_h,'Value',[1:length(get(comp_names_h,'String'))]);
6616 sel_comp;
6617
6618 if ~LOG
6619 data=get(gcf,'UserData');
6620 data.LOG{length(data.LOG)+1}='% Select all components';
6621 data.LOG{length(data.LOG)+1}='preprocess(''sel_all_comps'',''foo'');';
6622 set(gcf,'UserData',data);
6623 end
6624
6625 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6626
6627 function code=write_log_code(indices,arg1,arg2,arg3,arg4,arg5,arg6);
6628
6629 str=textwrap({num2str(indices)},500);
6630
6631 code{1}=sprintf('inds=[];');
6632 for i=1:length(str);
6633 code{i+1}=sprintf(' inds=cat(2,inds,[%s]);',str{i});
6634 end
6635 str=cat(2,'preprocess(''''clip_data'''',''''',arg1,' ',num2str(arg2),' ',...
6636 num2str(arg3),' ',num2str(arg4),...
6637 ' ',num2str(arg5),' ',num2str(arg6),' ');
6638 code{length(code)+1}=cat(2,'eval(cat(2,',...
6639 '''',str,'''',...
6640 ',num2str(inds),'''''');''));');
6641
6642 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%