function fig = som_show_gui(input,varargin) %SOM_SHOW_GUI A GUI for using SOM_SHOW and associated functions. % % h = som_show_gui(sM); % % Input and output arguments: % sM (struct) a map struct: the SOM to visualize % h (scalar) a handle to the GUI figure % % This is a graphical user interface to make the usage of SOM_SHOW and % associated functions somewhat easier for beginning users of the SOM % Toolbox. % % How to use the GUI: % 1. Start the GUI by giving command som_show_gui(sM); % 2. Build a list of visualization planes using the buttons % ('Add components', etc.) on the right % - the options associated with each of the planes can be % modified by selecting a plane from the list, and pressing % the 'Plane options' button % - the controls below the list apply to all planes % - the subplot grid size can be controlled using the 'subplots' % field on top right corner, e.g. '4 3' to get 4 times 3 grid % 3. To visualize the planes, press the 'Visualize' button on the bottom. % 4. To add hits, labels, trajectories (or comets) to the % visualization, or clear them, or reset the colorbars, % see the tools available from the 'Tools' menu. % - the arguments to those tools are either given in the tool, % or read from the workspace ('Select variable' buttons) % - the tools always apply to the latest figure created % by the GUI % 5. To quit, press the 'Close' button on the bottom. % % Known bugs: % - Especially when using the adding tools, you can easily % give arguments which do not fit each other, and this % results in a lengthy (and often cryptic) error message. % In such a case, check the arguments you are giving to see % if there's something wrong with them. See function % SOM_SHOW_ADD for more information on how the options % can be set. % - The default values in the adding tools may not be % very reasonable: you may have to try out different % values for e.g. markersize before getting the kind of % result you want. % % SOM_SHOW_GUI has two subfunctions: VIS_SHOW_GUI_COMP and % VIS_SHOW_GUI_TOOL. These are for internal use of SOM_SHOW_GUI. % % See also SOM_SHOW, SOM_SHOW_ADD, SOM_SHOW_CLEAR, SOM_RECOLORBAR. % Copyright (c) 2000 by Roman Feldman and Juha Vesanto % Contributed to SOM Toolbox on August 22nd, 2000 % http://www.cis.hut.fi/projects/somtoolbox/ % Version 2.0beta roman 160800 juuso 220800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % MAIN % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% warning off; if (nargin < 1) errordlg({'Make sure you have SOM as input argument'; ''; ... 'example: som_show_gui(sMap)'},'Error in SOM_VIS: input arguments'); return end if isstruct(input) fig_h = create_main_gui(input); if (nargout > 0) fig = fig_h; end return; elseif ischar(input) action = lower(input); % udata = get(varargin{1},'UserData'); plot_array = udata.plot_array; l = length(plot_array); list1_h = udata.h(1); if (strcmp(action,'')) errordlg('','Error in SOM_VIS: input arguments'); return; %%%%%%%%%%%%%%%%%%%% % add_selected_comp % elseif (strcmp(action,'add_selected_comp')) if isempty(plot_array(1).string), tmp = 1; else tmp = l+1; end [sel,ok] = listdlg('ListString',udata.sM.comp_names,... 'Name','Component selection',... 'PromptString','Select components to add'); if ok & ~isempty(sel), for i=1:length(sel), plot_array(tmp+i-1).string = udata.sM.comp_names{sel(i)}; plot_array(tmp+i-1).args = {'comp' sel(i)}; udata.property{tmp+i-1} = {0}; end set(list1_h,'Value',tmp+i-1, ... 'String',{plot_array(:).string}); end udata.plot_array = plot_array; set(varargin{1},'UserData',udata); %%%%%%%%%%%%%%%%%%%% % add_all_comps % elseif (strcmp(action,'add_all_comps')) if (strcmp(plot_array(1).string,'')) tmp = 1; else tmp = l+1; end indx = length(udata.sM.comp_names); for (i=1:indx) plot_array(tmp+i-1).string = udata.sM.comp_names{i}; plot_array(tmp+i-1).args = {'comp' i}; udata.property{tmp+i-1} = {0}; end % update list set(list1_h,'Value',tmp+indx-1, ... 'String',{plot_array(:).string}); udata.plot_array = plot_array; set(varargin{1},'UserData',udata); %%%%%%%%%%%%%%%%%%%% % add_u_matrix % elseif (strcmp(action,'add_u_matrix')) if (strcmp(plot_array(1).string,'')) tmp = 1; else tmp = l+1; end plot_array(tmp).string = 'U-matrix'; plot_array(tmp).args = {'umat' 'all'}; udata.property{tmp} = {0 'U-matrix' 1:length(udata.sM.comp_names)}; % update list set(list1_h,'Value',tmp, ... 'String',{plot_array(:).string}); udata.plot_array = plot_array; set(varargin{1},'UserData',udata); %%%%%%%%%%%%%%%%%%%% % add_colorplane % elseif (strcmp(action,'add_colorplane')) if (strcmp(plot_array(1).string,'')) tmp = 1; else tmp = l+1; end plot_array(tmp).string = 'color plane'; c = som_colorcode(udata.sM); plot_array(tmp).args = {'color' c}; udata.property{tmp} = {0 'Color code' {'rgb1' 'rgb2' 'rgb3' 'rgb4' 'hsv' '-variable-'} 1}; % update list set(list1_h,'Value',tmp, ... 'String',{plot_array(:).string}); udata.plot_array = plot_array; set(varargin{1},'UserData',udata); %%%%%%%%%%%%%%%%%%%% % add_empty % elseif (strcmp(action,'add_empty')) if (strcmp(plot_array(1).string,'')) tmp = 1; else tmp = l+1; end plot_array(tmp).string = 'empty plane'; plot_array(tmp).args = {'empty' ''}; udata.property{tmp} = {''}; % update list set(list1_h,'Value',tmp, ... 'String',{plot_array(:).string}); udata.plot_array = plot_array; set(varargin{1},'UserData',udata); %%%%%%%%%%%%%%%%%%%% % remove % elseif (strcmp(action,'remove')) rm_indx = get(list1_h,'Value'); rm_l = length(rm_indx); % rebuild array incl_inds = setdiff(1:length(plot_array),rm_indx); if isempty(incl_inds), clear plot_array; plot_array(1).args = {}; plot_array(1).string = ''; udata.property = {}; udata.property{1} = {}; else plot_array = plot_array(incl_inds); udata.property = udata.property(incl_inds); end set(list1_h,'Value',length(plot_array), ... 'String',{plot_array(:).string}); udata.plot_array = plot_array; set(varargin{1},'UserData',udata); %%%%%%%%%%%%%%%%%%%% % remove_all % elseif (strcmp(action,'remove_all')) plot_array = []; plot_array(1).args = {}; plot_array(1).string = ''; udata.property = {}; set(list1_h,'Value',1, ... 'String',{plot_array(:).string}); udata.plot_array = plot_array; set(varargin{1},'UserData',udata); %%%%%%%%%%%%%%%%%%%% % more_options % elseif (strcmp(action,'more_options')) vis_show_gui_comp(varargin{1},get(list1_h,'Value'),'init'); %%%%%%%%%%%%%%%%%%%% % close % elseif (strcmp(action,'close')) close(varargin{1}); %%%%%%%%%%%%%%%%%%%% % visualize % elseif (strcmp(action,'visualize')) %% s = {k k.^2}; plot(s{:}); current_fig = varargin{1}; figure; args = [{udata.sM} plot_array(:).args]; % edge tmp = get(udata.h(2),'UserData'); i = get(udata.h(2),'Value'); args = [args {'edge' tmp{i}}]; % bar tmp = get(udata.h(3),'UserData'); i = get(udata.h(3),'Value'); args = [args {'bar' tmp{i}}]; % norm tmp = get(udata.h(4),'UserData'); i = get(udata.h(4),'Value'); args = [args {'norm' tmp{i}}]; % size tmp = get(udata.h(5),'String'); args = [args {'size' eval(tmp)}]; % colormap tmp = get(udata.h(6),'String'); if ~isempty(tmp) args = [args {'colormap' eval(tmp)}]; end % footnote tmp = get(udata.h(7),'String'); args = [args {'footnote' tmp}]; % subplots tmp = get(udata.h(8),'String'); if ~(strcmp(tmp,'default') | isempty(tmp)) tmp2 = sscanf(tmp,'%i %i'); if length(tmp2)<2, tmp2 = sscanf(tmp,'%ix%i'); end if length(tmp2)<2, tmp = eval(tmp); else tmp = tmp2'; end if length(tmp)<2, tmp(2) = 1; end if tmp(1)*tmp(2)