Browse code

starting som prediction fine-tuned class-performance visualisation

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@112 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on21/01/2009 16:34:25
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,6642 @@
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_s