wolffd@0: function varargout=sompak_rb_control(str) wolffd@0: wolffd@0: %SOMPAK_RB_CONTROL An auxiliary function for SOMPAK_*_GUI functions. wolffd@0: % wolffd@0: % This is an auxiliary function for SOMPAK_GUI, SOMPAK_INIT_GUI, wolffd@0: % SOMPAK_SAMMON_GUI and SOMPAK_TRAIN_GUI functions. It controls the wolffd@0: % radio buttons in the GUIs. wolffd@0: % wolffd@0: % See also SOMPAK_GUI, SOMPAK_INIT_GUI, SOMPAK_SAMMON_GUI, SOMPAK_TRAIN_GUI. wolffd@0: wolffd@0: % Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Parhankangas wolffd@0: % Copyright (c) by Juha Parhankangas wolffd@0: % http://www.cis.hut.fi/projects/somtoolbox/ wolffd@0: wolffd@0: % Juha Parhankangas 050100 wolffd@0: wolffd@0: data=get(gcf,'UserData'); wolffd@0: switch str wolffd@0: case {'rand','linear'} wolffd@0: h=cat(2,findobj(get(gcf,'Children'),'Tag','RANDOM'),... wolffd@0: findobj(get(gcf,'Children'),'Tag','LINEAR')); wolffd@0: set(h,'Value',0); wolffd@0: set(gcbo,'Value',1); wolffd@0: data.inittype=str; wolffd@0: case {'bubble','gaussian'} wolffd@0: h=cat(2,findobj(get(gcf,'Children'),'Tag','BUBBLE'),... wolffd@0: findobj(get(gcf,'Children'),'Tag','GAUSSIAN')); wolffd@0: set(h,'Value',0); wolffd@0: set(gcbo,'Value',1); wolffd@0: data.neigh=str; wolffd@0: case {'hexa','rect'} wolffd@0: h=cat(2,findobj(get(gcf,'Children'),'Tag','HEXA'),... wolffd@0: findobj(get(gcf,'Children'),'Tag','RECT')); wolffd@0: set(h,'Value',0); wolffd@0: set(gcbo,'Value',1); wolffd@0: data.topol=str; wolffd@0: case {'out_ft'} wolffd@0: value=get(gcbo,'Value'); wolffd@0: switch value wolffd@0: case 1 wolffd@0: h=findobj(get(gcf,'Children'),'Tag','OUT_FILE'); wolffd@0: data.out_file_type=''; wolffd@0: set(h,'String',''); wolffd@0: case 2 wolffd@0: data.out_file_type='box'; wolffd@0: case 3 wolffd@0: data.out_file_type='pak'; wolffd@0: end wolffd@0: case {'input_ft'} wolffd@0: value=get(gcbo,'Value'); wolffd@0: switch value wolffd@0: case 1 wolffd@0: data.input_file_type=''; wolffd@0: case 2 wolffd@0: data.input_file_type='box'; wolffd@0: case 3 wolffd@0: data.input_file_type='pak'; wolffd@0: end wolffd@0: case {'map_ft'} wolffd@0: value=get(gcbo,'Value'); wolffd@0: switch value wolffd@0: case 1 wolffd@0: data.map_type=''; wolffd@0: case 2 wolffd@0: data.map_type='box'; wolffd@0: case 3 wolffd@0: data.map_type='pak'; wolffd@0: end wolffd@0: case {'out_file'} wolffd@0: if isempty(data.out_file_type) wolffd@0: data.out_file=''; wolffd@0: h=findobj(get(gcf,'Children'),'Tag','OUT_FILE'); wolffd@0: set(h,'String',''); wolffd@0: else wolffd@0: data.out_file=get(findobj(get(gcf,'Children'),'Tag','OUT_FILE'),'String'); wolffd@0: if isempty(data.out_file) wolffd@0: h=findobj(get(gcf,'Children'),'Tag','OUT_FILE_TYPE'); wolffd@0: set(h,'Value',1); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: case {'out_var'} wolffd@0: h=findobj(get(gcf,'Children'),'Tag','OUT_VAR'); wolffd@0: if ~isempty(get(h,'String')) wolffd@0: data.out_var=get(h,'String'); wolffd@0: else wolffd@0: data.out_var=[]; wolffd@0: set(h,'String','''ans'''); wolffd@0: end wolffd@0: case {'xdim'} wolffd@0: h=findobj(get(gcf,'Children'),'Tag','XDIM'); wolffd@0: data.xdim=str2num(get(h,'String')); wolffd@0: case {'ydim'} wolffd@0: h=findobj(get(gcf,'Children'),'Tag','YDIM'); wolffd@0: data.ydim=str2num(get(h,'String')); wolffd@0: case {'radius'} wolffd@0: h=findobj(get(gcf,'Children'),'Tag','RADIUS'); wolffd@0: data.radius=str2num(get(h,'String')); wolffd@0: case {'data'} wolffd@0: h=findobj(get(gcf,'Children'),'Tag','DATA'); wolffd@0: data.data=get(h,'String'); wolffd@0: case {'rlen'} wolffd@0: h=findobj(get(gcf,'Children'),'Tag','RLEN'); wolffd@0: data.rlen=str2num(get(h,'String')); wolffd@0: case {'alpha'} wolffd@0: h=findobj(get(gcf,'Children'),'Tag','ALPHA'); wolffd@0: data.alpha=str2num(get(h,'String')); wolffd@0: case {'map'} wolffd@0: h=findobj(get(gcf,'Children'),'Tag','MAP'); wolffd@0: data.map=get(h,'String'); wolffd@0: case 'init_ok' wolffd@0: if isempty(data.xdim) | ~is_positive_integer(data.xdim) wolffd@0: errordlg('Argument ''xdim'' must be positive integer.'); wolffd@0: return; wolffd@0: end wolffd@0: if isempty(data.ydim) | ~is_positive_integer(data.ydim) wolffd@0: errordlg('Argument ''ydim'' must be positive integer.'); wolffd@0: return; wolffd@0: end wolffd@0: if isempty(data.data) wolffd@0: errordlg('Argument ''Workspace data'' must be a string.'); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: if isempty(data.input_file_type) wolffd@0: sData=evalin('base',data.data); wolffd@0: else wolffd@0: sData=data.data; wolffd@0: end wolffd@0: if isempty(data.out_file) wolffd@0: if ~isempty(data.out_file_type) wolffd@0: errordlg('Argument ''Output file'' is not defined.'); wolffd@0: return; wolffd@0: end wolffd@0: data.out_file=[]; wolffd@0: end wolffd@0: answer=sompak_init(sData,... wolffd@0: data.input_file_type,... wolffd@0: data.inittype,... wolffd@0: data.out_file,... wolffd@0: data.out_file_type,... wolffd@0: data.xdim,... wolffd@0: data.ydim,... wolffd@0: data.topol,... wolffd@0: data.neigh); wolffd@0: if any(strcmp(data.out_var,{'ans','''ans'''})) | isstr(answer) wolffd@0: varargout{1}=answer; wolffd@0: else wolffd@0: assignin('base',data.out_var,answer); wolffd@0: disp(sprintf('Map is set to workspace as ''%s''.',data.out_var)); wolffd@0: end wolffd@0: close(findobj(get(0,'Children'),'Tag','InitGUI')); wolffd@0: return; wolffd@0: case 'train_ok' wolffd@0: if isempty(data.rlen) | ~is_positive_integer(data.rlen) wolffd@0: errordlg('Argument ''Running Length'' must be positive integer.'); wolffd@0: return; wolffd@0: end wolffd@0: if isempty(data.alpha) | data.alpha <= 0 wolffd@0: errordlg('Argument ''Initial Alpha Value'' must be a positive float.'); wolffd@0: return; wolffd@0: end wolffd@0: if isempty(data.radius) | data.radius <= 0 wolffd@0: errordlg('Argument ''Neighborhood Radius'' must be a positive float.'); wolffd@0: return; wolffd@0: end wolffd@0: if isempty(data.data) wolffd@0: errordlg('Argument ''Teaching Data'' must be a string.'); wolffd@0: return; wolffd@0: end wolffd@0: if isempty(data.input_file_type) wolffd@0: sData=evalin('base',data.data); wolffd@0: else wolffd@0: sData=data.data; wolffd@0: end wolffd@0: if isempty(data.out_file); wolffd@0: data.outfile = []; wolffd@0: end wolffd@0: if isempty(data.map) wolffd@0: errordlg('Argument ''Workspace Map'' must be a string.'); wolffd@0: return; wolffd@0: end wolffd@0: if isempty(data.map_type) wolffd@0: sMap=evalin('base',data.map); wolffd@0: else wolffd@0: sMap=data.map; wolffd@0: end wolffd@0: wolffd@0: answer=sompak_train(sMap,... wolffd@0: data.map_type,... wolffd@0: data.out_file,... wolffd@0: data.out_file_type,... wolffd@0: data.data,... wolffd@0: data.input_file_type,... wolffd@0: data.rlen,... wolffd@0: data.alpha,... wolffd@0: data.radius); wolffd@0: if any(strcmp(data.out_var,{'''ans''','ans'})) | isstr(answer) wolffd@0: varargout{1}=answer; wolffd@0: else wolffd@0: assignin('base',data.out_var,answer); wolffd@0: disp(sprintf('Map is set to workspace as ''%s''.',data.out_var)); wolffd@0: end wolffd@0: close(findobj(get(0,'Children'),'Tag','TrainGUI')); wolffd@0: return; wolffd@0: case 'sammon_ok' wolffd@0: if isempty(data.map) wolffd@0: errordlg('Argument ''Workspace Map'' must be a string.'); wolffd@0: return; wolffd@0: end wolffd@0: if isempty(data.map_type) wolffd@0: sMap=evalin('base',data.map); wolffd@0: else wolffd@0: sMap=data.map; wolffd@0: end wolffd@0: if isempty(data.out_file); wolffd@0: data.outfile = []; wolffd@0: end wolffd@0: answer=sompak_sammon(sMap,... wolffd@0: data.map_type,... wolffd@0: data.out_file,... wolffd@0: data.out_file_type,... wolffd@0: data.rlen); wolffd@0: if strcmp(data.out_var,'''ans''')|strcmp(data.out_var,'ans')|isstr(answer) wolffd@0: varargout{1}=answer; wolffd@0: else wolffd@0: assignin('base',data.out_var,answer); wolffd@0: disp(sprintf('Codebook is set to workspace as ''%s''.',data.out_var)); wolffd@0: end wolffd@0: close(findobj(get(0,'Children'),'Tag','SammonGUI')); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: set(gcf,'UserData',data); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function bool = is_positive_integer(x) wolffd@0: wolffd@0: bool = ~isempty(x) & isreal(x) & all(size(x) == 1) & x > 0; wolffd@0: if ~isempty(bool) wolffd@0: if bool & x~=round(x) wolffd@0: bool = 0; wolffd@0: end wolffd@0: else wolffd@0: bool = 0; wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: wolffd@0: