comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/vis_som_show_data.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 [handles,msg,lattice,msize,dim,normalization,comps]=vis_som_show_data(p,f)
2
3 % VIS_SOM_SHOW_DATA Checks and returns UserData and subplot handles stored by SOM_SHOW
4 %
5 % [handles,msg,lattice,msize,dim,normalization,comps] = vis_som_show_data(p, f)
6 %
7 % Input and output arguments ([]'s are optional):
8 % [p] (vector) subplot numbers
9 % (string) 'all' to process all subplots, this is default
10 % 'comp' to process only subplots which have
11 % component planes
12 % [f] (double) figure handle, default is current figure
13 %
14 % handles (vector) handles of requested subplots
15 % msg (string) error message or empty string (no error)
16 % lattice (string) map lattice: 'hexa' or 'rect'
17 % msize (vector) map grid size in figure
18 % dim (scalar) map data dimension in figure
19 % normalization (struct) normalization struct used in the map in figure
20 % comps (vector) the component indexes in figure
21 %
22 % This function gets the handles of component planes and u-matrices in
23 % subplots p from figure f. SOM_SHOW writes the handles into the
24 % UserData field of the figure where their order won't be mixed
25 % up. This function reads the data according to the vector p. If the
26 % figure has been manipulated (original planes are missing) the function
27 % warns user or returns error string.
28 %
29 % The main purpose for this is to be a subfuncion for SOM_SHOW_ADD,
30 % SOM_SHOW_CLEAR and SOM_RECOLORBAR functions, but it may be used on
31 % command line in the followong manner:
32 %
33 % % plots text on the fifth plane
34 % axes(vis_som_show_data(5)); hold on; text(1,3,'I am here');
35 %
36 % See also SOM_SHOW, SOM_SHOW_ADD.
37
38 % Copyright (c) 1997-2000 by the SOM toolbox programming team.
39 % http://www.cis.hut.fi/projects/somtoolbox/
40
41 % Version 2.0beta Johan 201099 juuso 160600
42
43 %% Check input args %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
45 error(nargchk(0, 2, nargin)) % check no. of input args
46
47 %% Init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48
49 handles=[]; % initialize output
50 normalize=[];
51 comps=[];
52 dim=[];
53 msize=[];
54 lattice=[];
55 msg=[];
56
57 cr=sprintf('\n'); % carriage return
58
59 if nargin < 2 | isempty(f)
60 f=gcf; % default figure
61 end
62
63 if nargin < 1 | isempty(p) % default p
64 p= 'all';
65 end
66
67 % Find component planes and u-matrices from the figure and get the
68 % UserData field where the handles for the components are
69 % in the original order.
70 % If the fields are corrupted, return an error message.
71
72 h_real = [findobj(f, 'Tag', 'Cplane'); ...
73 findobj(f, 'Tag', 'Uplane'); ...
74 findobj(f,'Tag','CplaneI'); ...
75 findobj(f,'Tag','UplaneI')];
76 eval( 'h_stored=getfield(get(f,''UserData''),''subplotorder'');' , ...
77 'msg=[ msg cr '' Missing SOM_SHOW.subplotorder''];');
78 eval( 'normalization=getfield(get(f,''UserData''),''comp_norm'');' , ...
79 'msg=[msg cr '' Missing SOM_SHOW.comp_norm''];');
80 eval( 'comps=getfield(get(f,''UserData''),''comps'');' , ...
81 'msg=[msg cr '' Missing SOM_SHOW.comps''];');
82 eval( 'msize=getfield(get(f,''UserData''),''msize'');' , ...
83 'msg=[msg cr '' Missing SOM_SHOW.msize''];');
84 eval( 'dim=getfield(get(f,''UserData''),''dim'');' , ...
85 'msg=[msg cr '' Missing SOM_SHOW.dim''];');
86 eval( 'lattice=getfield(get(f,''UserData''),''lattice'');' , ...
87 'msg=[msg cr '' Missing SOM_SHOW.lattice''];');
88 if ~isempty(msg),
89 msg=['The figure does not contain SOM_SHOW visualization or is corrupted.'...
90 cr msg cr cr ...
91 'This command may be applied only to a SOM_SHOW visualization.'];
92 return;
93 end
94
95 %% Check arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96
97 index=ismember(h_stored, h_real); % the original order for plot axes
98
99 if ~prod(double(index)) % missing planes?!
100 % double added by kr 1.10.02
101 l1= 'Some of the original planes seems to be missing.';
102 l2= 'Subplot numbers now refer to the existing ones.';
103 warning([l1 cr l2]);
104 end
105
106 if ~prod(double(ismember(h_real, h_stored))) % extra planes?!
107 % double added by kr 5.9.02
108 warning('There seems to be new planes. Subplot numbers refer to the old ones.');
109 end
110
111 h_stored=h_stored(index); % existing original plots in original order
112
113 if ischar(p) % check if p is 'all'
114 switch(p)
115 case 'all'
116 p=1:size(h_stored,1); % all original subplots
117 case 'comp'
118 p=find(comps>0);
119 otherwise
120 msg= 'String value for subplot number vector has to be ''all''!';
121 return;
122 end
123 end
124
125 if ~vis_valuetype(p,{ '1xn','nx1'}) % check the size
126 msg= 'Subplot numbers (argument p in help text) have to be in a vector!';
127 return
128 end
129
130 if min(p) < 1 % check for invalid values
131 msg= 'Subplot numbers (argument p in help text) must be at least 1!';
132 return
133 end
134
135 %% p is too large
136
137 if max(p) > size(h_stored,1)
138 l1= 'There are not so many existing subplots created by SOM_SHOW in the';
139 l2= 'figure as you are trying to refer with subplot numbers.';
140 l3= 'This is probably caused by having a too large subplot number.';
141 l4= 'However, the reason may be invalid manipulation of';
142 l5= 'this figure object or a program failure, too.';
143 msg=([l1 cr l2 cr l3 cr cr l4 cr l5]);
144 return;
145 end
146
147 %% Action and building output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148
149 handles=h_stored(p);
150 comps=comps(p);
151