comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/som_show.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 h=som_show(sMap, varargin)
2
3 % SOM_SHOW Basic SOM visualizations: component planes, u-matrix etc.
4 %
5 % h = som_show(sMap, ['argID', value, ...])
6 %
7 % som_show(sMap);
8 % som_show(sMap,'bar','none');
9 % som_show(sMap,'comp',[1:3],'umat','all');
10 % som_show(sMap,'comp',[1 2],'umat',{[1 2],'1,2 only'},'comp',[3:6]);
11 % som_show(sMap,'size',m,'bar','vert','edge','off');
12 %
13 % Input and output arguments ([]'s are optional):
14 % sMap (struct) map struct
15 % [argID, (string) Additional parameters are given as argID, value
16 % value] (varies) pairs. See below for list of valid IDs and values.
17 %
18 % h (struct) struct with the following fields:
19 % .plane (vector) handles to the axes objecets (subplots)
20 % .colorbar (vector) handles to the colorbars. Colorbars for empty
21 % grids & RGB color planes do not exist: the
22 % value for them in the vector is -1.
23 % .label (vector) handles to the axis labels
24 %
25 % Here are the valid argument IDs and corresponding values. M is
26 % the number of map units
27 % 'comp' Which component planes to draw, title is
28 % the name of the component (from sMap.comp_names)
29 % (vector) a vector of component indices
30 % (string) 'all' (or '' or []) for all components
31 % 'compi' as 'comp' but uses interpolated shading
32 % 'umat' Show u-matrix calculated using specified
33 % components
34 % (vector) a vector of component indeces
35 % (string) 'all' (or '' or []) to use all components
36 % (cell) of form {v, str} uses v as the vector, and put
37 % str as title instead of the default 'U-matrix'
38 % 'umati' as 'umat' but uses interpolated shading of colors
39 % 'empty' (string) Make an empty plane using given string as title
40 % 'color' Set arbitrary unit colors explicitly
41 % (matrix) size Mx1 or Mx3, Mx1 matrix uses indexed
42 % coloring; Mx3 matrix (RGB triples as rows)
43 % defines fixed unit colors
44 % (cell) of from {color, str}. 'color' is the Mx1
45 % or Mx3 RGB triple matrix and 'str' is title
46 % string
47 % 'colori' as 'color' but uses interpolated shading of colors
48 % 'norm' (string) 'n' or 'd': Whether to show normalized 'n' or
49 % denormalized 'd' data values on the
50 % colorbar. By default denormalized values are used.
51 % 'bar' (string) Colorbar direction: 'horiz', 'vert' (default)
52 % or 'none'
53 % 'size' size of the units
54 % (scalar) same size for each unit, default is 1
55 % (vector) size Mx1, individual size for each unit
56 % 'edge' (string) Unit edges on component planes 'on'
57 % (default) or 'off'
58 % 'footnote' (string) Footnote string, sMap.name by default
59 % 'colormap' (matrix) user defined colormap
60 % 'subplots' (vector) size 1 x 2, the number of subplots in y- and
61 % and x-directions (as in SUBPLOT command)
62 %
63 % If identifiers 'comp', 'compi', 'umat', 'umati', 'color', 'colori'
64 % or 'empty' are not specified at all, e.g. som_show(sMap) or
65 % som_show(sMap,'bar','none'), the U-matrix and all component planes
66 % are shown.
67 %
68 % For more help, try 'type som_show' or check out online documentation.
69 % See also SOM_SHOW_ADD, SOM_SHOW_CLEAR, SOM_UMAT, SOM_CPLANE, SOM_GRID.
70
71 %%%%%%%%%%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 %
73 % som_show
74 %
75 % PURPOSE
76 %
77 % Shows basic visualizations of SOM: component planes, unified distance
78 % matrices as well as empty planes and fixed color planes.
79 %
80 % SYNTAX
81 %
82 % h = som_show(sMap)
83 % h = som_show(sMap, 'argID', value, ...)
84 %
85 % DESCRIPTION
86 %
87 % This function is used for basic visualization of the SOM. Four
88 % kinds of SOM planes can be shown:
89 %
90 % 1. U-matrix (see SOM_UMAT) which shows clustering structure of
91 % the SOM. Either all or just part of the components can
92 % be used in calculating the U-matrix.
93 % 2. component planes: each component plane shows the values of
94 % one variable in each map unit
95 % 3. an empty plane which may be used as a base for, e.g., hit
96 % histogram visualization or labeling (see SOM_SHOW_ADD)
97 % 4. a fixed or indexed color representation for showing color coding or
98 % clustering
99 %
100 % The component planes and u-matrices may have colorbars showing the
101 % scale for the variable. The scale shows by default the values that
102 % variables have in the map struct. It may be changed to show the
103 % original data values (estimated by SOM_DENORMALIZE). In this case a
104 % small 'd' appears below the colorbar. The orientation of these
105 % colorbars may be changed, or they can be removed.
106 %
107 % By default the u-matrix - calculated using all variables - and all
108 % component planes are shown. This is achieved by giving command
109 % som_show(sMap) without any further arguments
110 %
111 % REQUIRED INPUT ARGUMENTS
112 %
113 % sMap (struct) Map to be shown. If only this argument is
114 % specified, the function draws first the u-matrix
115 % calculated using all the variables followed by all
116 % the component planes.
117 %
118 % OPTIONAL INPUT ARGUMENTS
119 %
120 % (M is the number of map units)
121 %
122 % Optional arguments must be given as 'argID',value -pairs
123 %
124 % 'comp' Defines the variabels to be shown as component planes.
125 % (vector) 1xN or Nx1 vector with integer positive numbers ranging
126 % from 1 to the number of variables in the map codebook
127 % (dim). This vector determines the variables to be show
128 % as component planes and their order. Note that the same
129 % component plane (the same variable index) is allowed to
130 % occur several times.
131 % (string) 'all' or '' or []. This uses all variables, that is, it's
132 % the same that using value [1:dim] where dim is the
133 % number of variables in the codebook.
134 %
135 % 'compi' Same as 'comp' but uses a Gouraud shaded color plane
136 % (made using SOM_GRID function) instead of the cell-like
137 % visualization of 'comp' (made using SOM_CPLANE). Note
138 % that the color interpolation doesn't work strictly
139 % correctly on 'hexa' grid, as it uses rectangular grid
140 % (see SURF).
141 %
142 % 'umat' Show U-matrix: value defines the variables to be used
143 % for calculating a u-matrix.
144 % (vector) as in 'comps'. However, multiple occurences of the
145 % same variable (same variable index) are ignored.
146 % (string) 'all' or '' or []. This uses all variables, that is,
147 % is the same as using value [1:dim] where dim is the
148 % number of variables in the codebook.
149 % (cell) of form {v, str} where v is a valid index vector for 'umat'
150 % (see above) and str is a string that is used as a title
151 % for the u-matrix instead of the default title
152 % 'U-matrix'. This may be useful if several u-matrices
153 % are shown in the same figure.
154 %
155 % 'umati' Same as 'umat' but uses shaded color plane (see 'compi').
156 %
157 % 'empty' Show an empty plane (patch edges only)
158 % (string) value is used as title
159 %
160 % 'color' Define fixed RGB colors for the map units
161 % (matrix) a Mx3 matrix of RGB triples as rows
162 % (vector) a Mx1 vector of any values: sets indexed coloring using
163 % the current colormap (as SURF does)
164 % (matrix) a Mx3xN matrix of RGB triples as rows. This gives N
165 % color planes.
166 % (matrix) a Mx1xN matrix of any values: sets indexed coloring using
167 % the current colormap (as SURF does). This gives N
168 % color planes.
169 % (cell) of form {rgb, str} where rgb is a Mx3 (xN) matrix of RGB
170 % triples as rows and str is a string that is used as
171 % title(s).
172 % (cell) of form {v, str} where v is a Mx1(xN) matrix of values
173 % and str is a string that is used as title(s).
174 %
175 % 'colori' Same as 'color' but uses shaded color plane (see 'compi').
176 %
177 % 'norm' Defines whether to use normalized or denormalized
178 % values in the colorbar. If denormalized values are
179 % used, they are acquired from SOM_DENORMALIZE function
180 % using sMap.comp_norm field.
181 % (string) 'd' (default) for denormalized values and 'n' for
182 % normalized values. The corresponding letter appears
183 % below the colorbar.
184 %
185 % 'bar' Define the direction of the colorbars for component planes
186 % and U-matrices or turn them completely off.
187 % (string) 'vert' (default), 'horiz' or 'none'. 'vert' gives
188 % vertical and 'horiz' horizontal colorbars. 'none'
189 % shows no colorbars at all.
190 %
191 % 'size' Define sizes of the units.
192 % (scalar) all units have the same size (1 by default)
193 % (vector) size Mx1, each unit gets individual size scaling
194 % (as in SOM_CPLANE)
195 %
196 % 'edge' Unit edges on component plane visualizations.
197 % (string) 'on' or 'off' determines whether the unit edges on component
198 % planes ('comp') are shown or not. Default is 'off'. Note that
199 % U-matrix and color planes are _always_ drawn without edges.
200 %
201 % 'footnote' Text on the figure
202 % (string) is printed as a movable text object on the figure
203 % where it may be moved using mouse. Default value is the
204 % string in the sMap.name field. Note: value [] gives the
205 % string, but input value '' gives no footnote a all.
206 % See VIS_FOOTNOTE for more information on the text object
207 % and ways to change its font size.
208 %
209 % 'colormap' som_show ghages the colormap by default to a gray-level map
210 % (matrix) This argument is used to set some other colormap.
211 %
212 % 'subplots' the number of subplots in y- and x-directions, as in
213 % (vector) command SUBPLOT
214 %
215 % OUTPUT ARGUMENTS
216 %
217 % h (struct)
218 % .plane (vector) handles to the axes objects (subplots)
219 % .colorbar (vector) handles to the colorbars. Colorbars of empty
220 % & color planes do not exist: the corresponding
221 % value in the vector is -1
222 % .label (vector) handles to the axis labels
223 %
224 % OBJECT TAGS
225 %
226 % The property field 'Tag' of the axis objects created by this function
227 % are set to contain string 'Cplane' if the axis contains component plane
228 % ('comp'), color plane ('color') or empty plane ('empty') and string
229 % 'Uplane' if it contains a u-matrix ('umat'). The tag is set to
230 % 'CplaneI' for planes created using 'compi' and 'colori', and
231 % 'UplaneI' for 'umati'.
232 %
233 % FEATURES
234 %
235 % Note that when interpolated shading is used in coloring ('compi' and
236 % 'colori') the standard built-in bilinear Gouraud interpolation for a
237 % SURF object is used. If the lattice is hexagonal - or anything else than
238 % rectangular in general - the result is not strictly what is looked
239 % for, especially if the map is small.
240 %
241 % EXAMPLES
242 %
243 %% Make random data, normalize it, and give component names
244 %% Make a map
245 %
246 % data=som_data_struct(rand(1000,3),'comp_names',{'One','Two','Three'});
247 % data=som_normalize(data,'var');
248 % map=som_make(data);
249 %
250 %% Do the basic visualization with som_show: u-matrix and all
251 %% component planes
252 %
253 % som_show(map);
254 %
255 %% The values shown in the colorbar are denormalized codebook values
256 %% (if denormalization is possible). To view the actual values, use
257 %% the ..., 'norm', 'n' argument pair.
258 %
259 % som_show(map,'norm','n')
260 %
261 %% Something more complex:
262 %% Show 1-2. Component planes 1 and 2 (variables 'One' and 'Two')
263 %% 3. U-matrix that is calculated only using variables
264 %% 'One' and 'Two'
265 %% with title '1,2 only'
266 %% 4. U-matrix that is calculated using all variables with the
267 %% deafult title 'U-matrix'
268 %% 5. The color code (in c) with title 'Color code'
269 %% 6. Component plane 3 (variable 'Three')
270 %% and use vertical colorbars and and the values
271 %% But first: make a continuous color code (see som_colorcode)
272 %
273 % c=som_colorcode(map,'rgb1');
274 %
275 % som_show(map,'comp',[1 2],'umat',{1:2,'1,2 only'},'umat','all', ...
276 % 'color',{c,'Color code'},'bar','vert','norm','n','comp',3)
277 %
278 % SEE ALSO
279 %
280 % som_show_add Show hits, labels and trajectories on SOM_SHOW visualization.
281 % som_show_clear Clear hit marks, labels or trajectories from current figure.
282 % som_umat Compute unified distance matrix of self-organizing map.
283 % som_grid Visualization of a SOM grid.
284 % som_cplane Visualization of component, u-matrix and color planes.
285
286 % Copyright (c) 1997-2000 by the SOM toolbox programming team.
287 % http://www.cis.hut.fi/projects/somtoolbox/
288
289 % Version 1.0beta johan 100298
290 % Version 2.0beta johan 201099 juuso 181199 johan 011299-100200
291 % juuso 130300 190600
292
293 %% Check arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294
295 error(nargchk(1,Inf,nargin)) % check no. of input args
296
297 if isstruct(sMap), % check map
298 [tmp,ok,tmp]=som_set(sMap);
299 if all(ok) & strcmp(sMap.type,'som_map')
300 ;
301 else
302 error('Map struct is invalid!');
303 end
304 else
305 error('Requires a map struct!')
306 end
307
308 munits=size(sMap.codebook,1); % numb. of map units
309 d=size(sMap.codebook,2); % numb. of components
310 msize=sMap.topol.msize; % size of the map
311 lattice=sMap.topol.lattice; % lattice
312
313 if length(msize)>2
314 error('This visualizes only 2D maps!')
315 end
316
317 if rem(length(varargin),2)
318 error('Mismatch in identifier-value pairs.');
319 end
320
321 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
322 % read in optional arguments
323
324 if isempty(varargin),
325 varargin = { 'umat','all','comp','all'};
326 end
327
328 %% check the varargin and build visualization infostrcuts
329 % Vis: what kind of planes, in which order, what are the values in
330 % the units
331 % Vis_param: general properties
332 % see subfunction
333
334 % The try-catch construction is here just for avoiding the
335 % possible termination to happen in subfunction because an error
336 % message containing subfunction line numbers etc. might be confusing, as
337 % there probably is nothing wrong with the subfunction but with the
338 % input. Ok, this isn't proper programming sytle...
339
340 try
341 [Plane, General]= check_varargin(varargin, munits, d, sMap.name);
342 catch
343 error(lasterr);
344 end
345
346 % Set default values for missing ones
347
348 % No planes at all (only general properties given in varargin):
349 % set default visualization
350
351 if isempty(Plane)
352 varargin = [varargin, { 'umat','all','comp','all'}];
353 % and again we go...
354 try
355 [Plane, General]= check_varargin(varargin, munits, d, sMap.name);
356 catch
357 error(lasterr);
358 end
359 end
360
361 % set defaults for general properties
362
363 if isempty(General.colorbardir)
364 General.colorbardir='vert';
365 end
366
367 if isempty(General.scale)
368 General.scale='denormalized';
369 end
370
371 if isempty(General.size)
372 General.size=1;
373 end
374
375 if isempty(General.edgecolor)
376 General.edgecolor='none';
377 end
378
379 %% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380
381 % get rid of an annoying warning: "RGB color data not yet supported in
382 % Painter's mode."
383 %set(gcf, 'renderer','zbuffer');
384 %% -> a much more annoying thing results: the output to PostScript is
385 %% as bitmap, making the files over 6MB in size...
386
387 n=length(Plane); % the number of subfigures
388
389 % get the unique component indices
390 c=General.comp(General.comp>0);
391 c=setdiff(unique(c),[0 -1]);
392 c=c(~isnan(c));
393
394 % estimate the suitable dimension for
395 if isempty(General.subplots),
396 y=ceil(sqrt(n)); % subplots
397 x=ceil(n/y);
398 else
399 y = General.subplots(2);
400 x = General.subplots(1);
401 if y*x<n,
402 error(['Given subplots grid size is too small: should be >=' num2str(n)]);
403 end
404 end
405
406 clf; % clear figure
407
408 for i=1:n, % main loop
409 h_axes(i,1)=subplot(x,y,i); % open a new subplot
410
411 % Main switch: select function according to the flags set in comps
412
413 switch Plane{i}.mode
414
415 case 'comp'
416 %%% Component plane
417
418 tmp_h=som_cplane(lattice,msize, sMap.codebook(:,General.comp(i)), ...
419 General.size);
420 set(tmp_h,'EdgeColor', General.edgecolor);
421 set(h_axes(i),'Tag','Cplane');
422 h_label(i,1)=xlabel(sMap.comp_names{General.comp(i)});
423
424
425 case 'compi'
426 %%% Component plane (interpolated shading)
427
428 tmp_h=som_grid(lattice, msize, 'surf', sMap.codebook(:,Plane{i}.value), ...
429 'Marker', 'none', 'Line', 'none');
430 set(h_axes(i),'Tag','CplaneI');
431 h_label(i,1)=xlabel(sMap.comp_names(Plane{i}.value));
432 vis_PlaneAxisProperties(gca,lattice,msize,NaN);
433
434 case 'color'
435 %%% Color plane
436
437 tmp_h=som_cplane(lattice,msize,Plane{i}.value,General.size);
438 set(tmp_h,'EdgeColor','none');
439 set(h_axes(i),'Tag','Cplane');
440 h_label(i,1)=xlabel(Plane{i}.name);
441
442
443 case 'colori'
444 %%% Color plane (interpolated shading)
445
446 tmp_h=som_grid(lattice, msize, 'surf', Plane{i}.value, 'Marker', 'none', ...
447 'Line', 'none');
448 set(h_axes(i),'Tag','CplaneI');
449 h_label(i,1)=xlabel(Plane{i}.name);
450 vis_PlaneAxisProperties(gca,lattice,msize,NaN);
451
452 case 'empty'
453 %%% Empty plane
454
455 tmp_h=som_cplane(lattice,msize,'none');
456 h_label(i,1)=xlabel(Plane{i}.name);
457 set(h_axes(i),'Tag','Cplane');
458
459 case 'umat'
460 %%% Umatrix
461
462 u=som_umat(sMap.codebook(:,Plane{i}.value),sMap.topol,'median',...
463 'mask',sMap.mask(Plane{i}.value)); u=u(:);
464 tmp_h=som_cplane([lattice 'U'],msize,u);
465 set(tmp_h,'EdgeColor','none');
466 set(h_axes(i),'Tag','Uplane');
467 h_label(i,1)=xlabel(Plane{i}.name);
468
469 case 'umati'
470 %%% Umatrix (interpolated shading)
471
472 u=som_umat(sMap.codebook(:,Plane{i}.value),sMap.topol,'mean',...
473 'mask',sMap.mask(Plane{i}.value)); u=u(1:2:end,1:2:end);
474 u=u(:);
475 tmp_h=som_grid('rect', msize, 'surf', u, ...
476 'Marker', 'none', 'Line', 'none', ...
477 'coord', som_vis_coords(lattice,msize));
478 set(h_axes(i),'Tag','UplaneI');
479 h_label(i,1)=xlabel(Plane{i}.name);
480 vis_PlaneAxisProperties(gca,lattice,msize,NaN);
481
482 otherwise
483 error('INTERNAL ERROR: unknown visualization mode.');
484 end
485
486 %%% Adjust axis ratios to optimal (only 2D!) and put the
487 %%% title as close to axis as possible
488
489 set(h_label,'Visible','on','verticalalignment','top');
490 set(gca,'plotboxaspectratio',[msize(2) msize(1) msize(1)]);
491
492 %%% Draw colorbars if they are turned on and the plane is umat or c-plane
493
494 if General.comp(i)> -1 & ~strcmp(General.colorbardir,'none'),
495 h_colorbar(i,1)=colorbar(General.colorbardir); % colorbars
496 else
497 h_colorbar(i,1)=-1;
498 General.comp(i)=-1;
499 end
500 end %% main loop ends
501
502 % Set window name
503
504 set(gcf,'Name',[ 'Map name: ' sMap.name]);
505
506 %% Set axes handles to the UserData field (for som_addxxx functions
507 %% and som_recolorbar)
508 %% set component indexes and normalization struct for som_recolorbar
509
510 SOM_SHOW.subplotorder=h_axes;
511 SOM_SHOW.msize=msize;
512 SOM_SHOW.lattice=lattice;
513 SOM_SHOW.dim=d;
514 SOM_SHOW.comps=General.comp;
515 SOM_SHOW.comp_norm=sMap.comp_norm; %(General.comp(find(General.comp>0)));
516
517 set(gcf,'UserData', SOM_SHOW);
518
519 % Set text property 'interp' to 'none' in title texts
520
521 set(h_label,'interpreter','none');
522
523 h_colorbar=som_recolorbar('all', 3, General.scale); %refresh colorbars
524
525 % Set a movable text to lower corner pointsize 12.
526
527 vis_footnote(General.footnote); vis_footnote(12);
528
529 % set colormap
530 colormap(General.colormap);
531
532 %% Build output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533
534 if nargout > 0
535 h.plane=h_axes; h.colorbar=h_colorbar; h.label=h_label;
536 end
537
538
539 %%%%%% SUBFUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
540
541 function [Plane, General]=check_varargin(args, munits, dim, name)
542
543 % args: varargin of the main function
544 % munits: number of map units
545 % dim: map codebook dimension
546 % name: map name
547 % Define some variables (they must exist later)
548
549 Plane={}; % stores the visualization data for each subplot
550 General.comp=[]; % information stored on SOM_SHOW figure (which component)
551 General.size=[]; % unit size
552 General.scale=[]; % normalization
553 General.colorbardir=[]; % colorbar direction
554 General.edgecolor=[]; % edge colors
555 General.footnote=name; % footnote text
556 General.colormap=colormap; % default colormap (used to be gray(64).^.5;)
557 General.subplots=[]; % number of subplots in y- and x-directions
558
559 for i=1:2:length(args),
560 %% Check that all argument types are strings
561
562 if ~ischar(args{i}),
563 error('Invalid input identifier names or input argument order.');
564 end
565
566 %% Lower/uppercase in identifier types doesn't matter:
567
568 identifier=lower(args{i}); % identifier (lowercase)
569 value=args{i+1};
570
571 %%% Check first the identifiers that define planes and get values
572 %%% to the visualization data struct array Plane.
573 %%% (comps,compi,umat,color,empty) Note that name, value and comp_
574 %%% must be specified in these cases
575 %%% comp_ are collected to comp in order. This is stored to the
576 %%% SOM_SHOW user property field to give information for SOM_RECOLROBAR
577 %%% how to operate, i.e., which component is in which subplot:
578 %%% comp(i)=0: draw colorbar, but no normalization (umat)
579 %%% comp(i)=1...N: a component plane of variable comp(i)
580 %%% comp(i)=-1: no colorbar (color or empty plane)
581
582 switch identifier
583 case {'comp','compi'}
584 %%% Component planes: check values & set defaults
585
586 if ~vis_valuetype(value,{'nx1','1xn','string'}) & ~isempty(value),
587 error([ 'A vector argument or string ''all'' expected for ''' ...
588 identifier '''.'])
589 end
590 if isempty(value)
591 value=1:dim;
592 elseif ischar(value),
593 if ~strcmp(value,'all')
594 error([ 'Only string value ''all'' is valid for ''' ...
595 identifier '''.']);
596 else
597 value=1:dim;
598 end
599 else
600 value=round(value);
601 if min(value)<1 | max(value)>dim,
602 error([ 'Component indices out of range in ''' identifier '''.'])
603 end
604 end
605 if size(value,1)==1, value=value';end
606 comp_=value;
607 name=[]; % name is taken form sMap by index in main loop
608
609 case {'umat','umati'}
610 %%% Check first the possible cell input
611
612 if iscell(value),
613 if ndims(value) ~= 2 | any(size(value) ~= [1 2]) | ...
614 ~vis_valuetype(value{2},{'string'}),
615 error('Cell input for ''umat'' has to be of form {vector, string}.');
616 else
617 name=value{2}; value=value{1};
618 end
619 else
620 name='U-matrix'; % no cell: default title is set
621 end
622 if ~vis_valuetype(value,{'nx1','1xn','string'}) & ~isempty(value),
623 error('Vector, string ''all'', or cell {vector, string} expected for ''umat''.')
624 end
625 if isempty(value)
626 value=1:dim;
627 elseif ischar(value),
628 if ~strcmp(value,'all')
629 error('Only string value ''all'' is valid for ''umat''.')
630 else
631 value=1:dim;
632 end
633 else
634 value=unique(round(value));
635 end
636 if min(value)<1 | max(value)>dim,
637 error('Component indices out of range in ''umat''.')
638 end
639
640 if size(value,1)==1, value=value';end
641 comp_=0;
642
643 case 'empty'
644 %%% Empty plane: check values & set defaults
645
646 if ~vis_valuetype(value,{'string'}),
647 error('A string value for title name expected for ''empty''.');
648 end
649 name=value;
650 comp_=-1;
651
652 case { 'color','colori'}
653 %%% Color plane: check values & set defaults
654
655 % Check first the possible cell input
656 if iscell(value),
657 if ndims(value)~=2 | any(size(value) ~= [1 2]) | ...
658 ~vis_valuetype(value{2},{'string'}),
659 error([ 'Cell input for ''' identifier ...
660 ''' has to be of form {M, string}.']);
661 else
662 name=value{2}; value=value{1};
663 end
664 else
665 name='Color code'; % no cell: default title is set
666 end
667 if size(value,1)~=munits | ...
668 (~vis_valuetype(value,{'nx3rgb'}) & ...
669 ~vis_valuetype(value,{'nx1'}) & ...
670 ~vis_valuetype(value,{'nx1xm'}) & ...
671 ~vis_valuetype(value,{'nx3xdimrgb'})),
672 error(['Mx3 or Mx3xN RGBmatrix, Mx1 or Mx1xN matrix, cell '...
673 '{RGBmatrix, string},' ...
674 ' or {matrix, string} expected for ''' identifier '''.']);
675 end
676
677 % if colormap is fixed, we don't draw colorbar (comp_ flag is -1)
678 % if colormap is indexed, we draw colorbar as in umat (comp_=0)
679
680 if size(value,2)==3
681 comp_=-1;
682 else
683 comp_=0;
684 end
685
686 %%%% The next things are general properties of the visualization---
687 %%%%
688 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
689
690 case 'size'
691 %%% Unit size: check & set
692
693 if ~vis_valuetype(value,{'1x1',[munits 1]})
694 error('A munits x 1 vector or a scalar expected for ''size''.')
695 end
696 if isempty(value),
697 General.size=1;
698 else
699 General.size=value;
700 end
701
702 case 'bar'
703 %%% Colorbar existence & direction: check & set
704
705 if ~vis_valuetype(value,{'string'})
706 error('String value expected for ''bar''.')
707 elseif isempty(value)
708 value='vert';
709 end
710 if any(strcmp(value,{'vert','horiz','none'})),
711 General.colorbardir=value;
712 else
713 error('String ''vert'', ''horiz'' or ''none'' expected for ''bar''.');
714 end
715
716 case 'norm'
717 %%% Value normalization: check & set
718
719 if ~vis_valuetype(value,{'string'})
720 error('String ''n'' or ''d'' expected for ''norm''.');
721 elseif isempty(value)
722 value='n';
723 end
724 if strcmp(value(1),'n'),
725 General.scale='normalized';
726 elseif strcmp(value(1),'d'),
727 General.scale='denormalized';
728 else
729 error('String ''n(ormalized)'' or ''d(enormalized)'' expected for ''norm''.');
730 end
731
732 case 'edge'
733 %%% Edge on or off : check % set
734
735 if ~vis_valuetype(value,{'string'}) & ~isempty(value),
736 error('String value expected for ''edge''.')
737 elseif ~isempty(value),
738 switch value
739 case 'on'
740 General.edgecolor='k';
741 case 'off'
742 General.edgecolor='none';
743 otherwise
744 error('String value ''on'' or ''off'' expected for ''edge''.')
745 end
746 end
747
748 case 'footnote'
749 %%% Set the movable footnote text
750
751 if ~vis_valuetype(value,{'string'})
752 if ~isempty(value),
753 error('String value expected for ''footnote''.');
754 else
755 General.footnote=sMap.name;
756 end
757 else
758 General.footnote=value;
759 end
760
761 case 'colormap'
762 %%% Set the colormap
763 if isempty(value)
764 General.colormap=gray(64).^2;
765 elseif ~vis_valuetype(value,{'nx3rgb'})
766 error('Colormap is invalid!');
767 else
768 General.colormap=value;
769 end
770
771 case 'subplots'
772 %%% set the number of subplots
773 if ~vis_valuetype(value,{'1x2'}) & ~vis_valuetype(value,{'2x1'})
774 error('Subplots grid size is invalid!');
775 else
776 General.subplots=value;
777 end
778
779 otherwise
780 %%% Unknown identifier
781
782 error(['Invalid argument identifier ''' identifier '''!']);
783 end
784
785 %%% Set new entry to the Plane array if the indentifier means
786 %%% making a new plane/planes
787
788 tail=length(Plane);
789 switch identifier
790 case {'comp','compi'}
791 for i=1:length(value)
792 Plane{tail+i}.mode=identifier;
793 Plane{tail+i}.value=value(i);
794 Plane{tail+i}.name=name; % not used actually
795 end
796 General.comp = [General.comp; comp_];
797 case {'umat','umati','empty'}
798 Plane{tail+1}.mode=identifier;
799 Plane{tail+1}.value=value;
800 Plane{tail+1}.name=name;
801 General.comp = [General.comp; comp_];
802 case {'color','colori'},
803 for i=1:size(value,3),
804 Plane{tail+i}.mode=identifier;
805 Plane{tail+i}.name=[name '_' num2str(i)];
806 Plane{tail+i}.value=value(:,:,i);
807 General.comp = [General.comp; comp_];
808 end
809 if size(value,3)==1,
810 Plane{tail+1}.name=name;
811 end
812 otherwise
813 ; % do nothing
814 end
815 end