wolffd@0: function [handles,msg,lattice,msize,dim,normalization,comps]=vis_som_show_data(p,f) wolffd@0: wolffd@0: % VIS_SOM_SHOW_DATA Checks and returns UserData and subplot handles stored by SOM_SHOW wolffd@0: % wolffd@0: % [handles,msg,lattice,msize,dim,normalization,comps] = vis_som_show_data(p, f) wolffd@0: % wolffd@0: % Input and output arguments ([]'s are optional): wolffd@0: % [p] (vector) subplot numbers wolffd@0: % (string) 'all' to process all subplots, this is default wolffd@0: % 'comp' to process only subplots which have wolffd@0: % component planes wolffd@0: % [f] (double) figure handle, default is current figure wolffd@0: % wolffd@0: % handles (vector) handles of requested subplots wolffd@0: % msg (string) error message or empty string (no error) wolffd@0: % lattice (string) map lattice: 'hexa' or 'rect' wolffd@0: % msize (vector) map grid size in figure wolffd@0: % dim (scalar) map data dimension in figure wolffd@0: % normalization (struct) normalization struct used in the map in figure wolffd@0: % comps (vector) the component indexes in figure wolffd@0: % wolffd@0: % This function gets the handles of component planes and u-matrices in wolffd@0: % subplots p from figure f. SOM_SHOW writes the handles into the wolffd@0: % UserData field of the figure where their order won't be mixed wolffd@0: % up. This function reads the data according to the vector p. If the wolffd@0: % figure has been manipulated (original planes are missing) the function wolffd@0: % warns user or returns error string. wolffd@0: % wolffd@0: % The main purpose for this is to be a subfuncion for SOM_SHOW_ADD, wolffd@0: % SOM_SHOW_CLEAR and SOM_RECOLORBAR functions, but it may be used on wolffd@0: % command line in the followong manner: wolffd@0: % wolffd@0: % % plots text on the fifth plane wolffd@0: % axes(vis_som_show_data(5)); hold on; text(1,3,'I am here'); wolffd@0: % wolffd@0: % See also SOM_SHOW, SOM_SHOW_ADD. wolffd@0: wolffd@0: % Copyright (c) 1997-2000 by the SOM toolbox programming team. wolffd@0: % http://www.cis.hut.fi/projects/somtoolbox/ wolffd@0: wolffd@0: % Version 2.0beta Johan 201099 juuso 160600 wolffd@0: wolffd@0: %% Check input args %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: error(nargchk(0, 2, nargin)) % check no. of input args wolffd@0: wolffd@0: %% Init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: handles=[]; % initialize output wolffd@0: normalize=[]; wolffd@0: comps=[]; wolffd@0: dim=[]; wolffd@0: msize=[]; wolffd@0: lattice=[]; wolffd@0: msg=[]; wolffd@0: wolffd@0: cr=sprintf('\n'); % carriage return wolffd@0: wolffd@0: if nargin < 2 | isempty(f) wolffd@0: f=gcf; % default figure wolffd@0: end wolffd@0: wolffd@0: if nargin < 1 | isempty(p) % default p wolffd@0: p= 'all'; wolffd@0: end wolffd@0: wolffd@0: % Find component planes and u-matrices from the figure and get the wolffd@0: % UserData field where the handles for the components are wolffd@0: % in the original order. wolffd@0: % If the fields are corrupted, return an error message. wolffd@0: wolffd@0: h_real = [findobj(f, 'Tag', 'Cplane'); ... wolffd@0: findobj(f, 'Tag', 'Uplane'); ... wolffd@0: findobj(f,'Tag','CplaneI'); ... wolffd@0: findobj(f,'Tag','UplaneI')]; wolffd@0: eval( 'h_stored=getfield(get(f,''UserData''),''subplotorder'');' , ... wolffd@0: 'msg=[ msg cr '' Missing SOM_SHOW.subplotorder''];'); wolffd@0: eval( 'normalization=getfield(get(f,''UserData''),''comp_norm'');' , ... wolffd@0: 'msg=[msg cr '' Missing SOM_SHOW.comp_norm''];'); wolffd@0: eval( 'comps=getfield(get(f,''UserData''),''comps'');' , ... wolffd@0: 'msg=[msg cr '' Missing SOM_SHOW.comps''];'); wolffd@0: eval( 'msize=getfield(get(f,''UserData''),''msize'');' , ... wolffd@0: 'msg=[msg cr '' Missing SOM_SHOW.msize''];'); wolffd@0: eval( 'dim=getfield(get(f,''UserData''),''dim'');' , ... wolffd@0: 'msg=[msg cr '' Missing SOM_SHOW.dim''];'); wolffd@0: eval( 'lattice=getfield(get(f,''UserData''),''lattice'');' , ... wolffd@0: 'msg=[msg cr '' Missing SOM_SHOW.lattice''];'); wolffd@0: if ~isempty(msg), wolffd@0: msg=['The figure does not contain SOM_SHOW visualization or is corrupted.'... wolffd@0: cr msg cr cr ... wolffd@0: 'This command may be applied only to a SOM_SHOW visualization.']; wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: %% Check arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: index=ismember(h_stored, h_real); % the original order for plot axes wolffd@0: wolffd@0: if ~prod(double(index)) % missing planes?! wolffd@0: % double added by kr 1.10.02 wolffd@0: l1= 'Some of the original planes seems to be missing.'; wolffd@0: l2= 'Subplot numbers now refer to the existing ones.'; wolffd@0: warning([l1 cr l2]); wolffd@0: end wolffd@0: wolffd@0: if ~prod(double(ismember(h_real, h_stored))) % extra planes?! wolffd@0: % double added by kr 5.9.02 wolffd@0: warning('There seems to be new planes. Subplot numbers refer to the old ones.'); wolffd@0: end wolffd@0: wolffd@0: h_stored=h_stored(index); % existing original plots in original order wolffd@0: wolffd@0: if ischar(p) % check if p is 'all' wolffd@0: switch(p) wolffd@0: case 'all' wolffd@0: p=1:size(h_stored,1); % all original subplots wolffd@0: case 'comp' wolffd@0: p=find(comps>0); wolffd@0: otherwise wolffd@0: msg= 'String value for subplot number vector has to be ''all''!'; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~vis_valuetype(p,{ '1xn','nx1'}) % check the size wolffd@0: msg= 'Subplot numbers (argument p in help text) have to be in a vector!'; wolffd@0: return wolffd@0: end wolffd@0: wolffd@0: if min(p) < 1 % check for invalid values wolffd@0: msg= 'Subplot numbers (argument p in help text) must be at least 1!'; wolffd@0: return wolffd@0: end wolffd@0: wolffd@0: %% p is too large wolffd@0: wolffd@0: if max(p) > size(h_stored,1) wolffd@0: l1= 'There are not so many existing subplots created by SOM_SHOW in the'; wolffd@0: l2= 'figure as you are trying to refer with subplot numbers.'; wolffd@0: l3= 'This is probably caused by having a too large subplot number.'; wolffd@0: l4= 'However, the reason may be invalid manipulation of'; wolffd@0: l5= 'this figure object or a program failure, too.'; wolffd@0: msg=([l1 cr l2 cr l3 cr cr l4 cr l5]); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: %% Action and building output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: handles=h_stored(p); wolffd@0: comps=comps(p); wolffd@0: