annotate toolboxes/MIRtoolbox1.3.2/somtoolbox/vis_som_show_data.m @ 0:cc4b1211e677 tip

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