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