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