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