comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/som_bmucolor.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 bmu_colors=som_bmucolor(bmus, m, colors);
2
3 % SOM_BMUCOLOR Returns the colors of the bmus according to a map colorcode
4 %
5 % bmu_colors=som_bmucolor(bmus, msize, colors);
6 %
7 % INPUT ARGUMENTS ([]'s are optional)
8 %
9 % bmus (matrix) Nx1 vector of BMU indexes
10 % msize (map struct, topol struct or 1x2 vector)
11 % gives the map grid size
12 % colors (matrix) colormap(s): munits x 3 x d matrix of RGB vectors
13 %
14 % OUTPUT ARGUMENTS
15 %
16 % bmu_colors (Nx3xd matrix) color of the data point according to its BMU's
17 % color(s).
18 %
19 % Idea is to get a color for each data point that links it to its BMU.
20 %
21 % EXAMPLE
22 %
23 % We want to show how an time series is projected to a map. Instead of
24 % a trajectory, we use 'color linking'
25 %
26 % map=som_make(multi_dim_signal);
27 % bmus=som_bmu(map,multi_dim_signal);
28 % Colors=som_bmucolor(bmus, map, som_colorcode(map,'rgb1'));
29 % colorsignal(Colors, multi_dim_signal);
30 %
31 % See also SOM_COLORCODE.
32
33 % Copyright (c) 1999-2000 by the SOM toolbox programming team.
34 % http://www.cis.hut.fi/projects/somtoolbox/
35
36 % Version 2.0alpha Johan 170699
37
38 %% Check arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39
40 error(nargchk(3, 3, nargin)) % check no. of input args is correct
41
42 % Check map grid size
43
44 if vis_valuetype(m,{'1x2'}),
45 msize=m;
46 else
47 [tmp,ok,tmp]=som_set(m);
48 if isstruct(m) & all(ok) % check m type
49 switch m.type
50 case 'som_topol'
51 msize=m.msize;
52 lattice=m.lattice;
53 case 'som_map'
54 msize=m.topol.msize;
55 lattice=m.topol.lattice;
56 otherwise
57 error('Invalid map or topol struct.');
58 end
59 end
60 end
61
62 if length(msize)>2
63 error('Only 2D maps allowed!');
64 end
65
66 n=prod(msize)
67
68 % Check colorcode size
69
70 if ~vis_valuetype(colors,{'nx3xdimrgb','nx3rgb'})
71 error('Colorcode matrix not valid!');
72 end
73
74 % Check bmu vector
75
76 if ~vis_valuetype(bmus,{'nx1'}),
77 error('Need a column vector of BMU indexes!');
78 else
79 bmus=round(bmus);
80 if max(bmus) > n | min(bmus) < 1
81 error('BMU indexes exeed the map size!')
82 end
83 end
84
85 %% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86
87 bmu_c=colors(bmus,:,:);
88
89 %% Build output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90
91
92 bmu_colors=squeeze(bmu_c);
93