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