Daniel@0: function preprocess(sData,arg2) Daniel@0: Daniel@0: %PREPROCESS A GUI for data preprocessing. Daniel@0: % Daniel@0: % preprocess(sData) Daniel@0: % Daniel@0: % preprocess(sData) Daniel@0: % Daniel@0: % Launches a preprocessing GUI. The optional input argument can be Daniel@0: % either a data struct or a struct array of such. However, primarily Daniel@0: % the processed data sets are loaded to the application using the Daniel@0: % tools in the GUI. Also, the only way to get the preprocessed data Daniel@0: % sets back into the workspace is to use the tools in the GUI (press Daniel@0: % the button DATA SET MANAGEMENT). Daniel@0: % Daniel@0: % For a more throughout description, see online documentation. Daniel@0: % See also SOM_GUI. Daniel@0: Daniel@0: %%%%%%%%%%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: % Daniel@0: % IN FILES: preprocess.html,preproc.jpg,sDman.jpg,clip.jpg,delay.jpg,window.jpg,selVect.jpg Daniel@0: Daniel@0: % Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Parhankangas Daniel@0: % Copyright (c) by Juha Parhankangas and the SOM Toolbox team Daniel@0: Daniel@0: % http://www.cis.hut.fi/projects/somtoolbox/ Daniel@0: Daniel@0: % Juha Parhankangas 050100 Daniel@0: Daniel@0: global no_of_sc % every Nth component in 'relative values' is drawn stronger. Daniel@0: no_of_sc=5; Daniel@0: Daniel@0: if nargin < 1 | nargin > 2 Daniel@0: error('Invalid number of input arguments'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if nargin == 1, arg2=[]; end Daniel@0: Daniel@0: if ~isstr(sData) %%% Preprocess is started... Daniel@0: data.LOG{1}='% Starting the ''Preprocess'' -window...'; Daniel@0: data.LOG{2}=cat(2,'preprocess(',... Daniel@0: sprintf('%s);',inputname(1))); Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: if ~isempty(pre_h) Daniel@0: figure(pre_h); Daniel@0: msgbox('''Preprocess''-figure already exists.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: h0 = figure('Color',[0.8 0.8 0.8], ... Daniel@0: 'PaperPosition',[18 180 576 432], ... Daniel@0: 'PaperUnits','points', ... Daniel@0: 'Position',[595 216 600 775], ... Daniel@0: 'Tag','Preprocess'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.015 0.06064516129032258 0.9550000000000001 0.1458064516129032], ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText1'); Daniel@0: Daniel@0: data.results_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess close', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.8067 0.0142 0.1667 0.0348],... Daniel@0: 'String','CLOSE', ... Daniel@0: 'Tag','Pushbutton1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.01833333333333333 0.2141935483870968 0.07000000000000001 0.01806451612903226], ... Daniel@0: 'String','LOG', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText2'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess sel_comp',... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.7983333333333333 0.2090322580645161 0.1666666666666667 0.03483870967741935], ... Daniel@0: 'String',' ', ... Daniel@0: 'Style','popupmenu', ... Daniel@0: 'Tag','sel_comp_h', ... Daniel@0: 'Value',1); Daniel@0: Daniel@0: data.sel_comp_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.0183 0.2568 0.2133 0.1290], ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText3'); Daniel@0: Daniel@0: data.sel_cdata_h=h1; Daniel@0: Daniel@0: h1 = axes('Parent',h0, ... Daniel@0: 'CameraUpVector',[0 1 0], ... Daniel@0: 'CameraUpVectorMode','manual', ... Daniel@0: 'Color',[1 1 1], ... Daniel@0: 'Position',[0.2583 0.2568 0.2133 0.1290], ... Daniel@0: 'Tag','Axes1', ... Daniel@0: 'XColor',[0 0 0], ... Daniel@0: 'XTickLabel',['0 ';'0.5';'1 '], ... Daniel@0: 'XTickLabelMode','manual', ... Daniel@0: 'XTickMode','manual', ... Daniel@0: 'YColor',[0 0 0], ... Daniel@0: 'YTickMode','manual', ... Daniel@0: 'ZColor',[0 0 0]); Daniel@0: Daniel@0: data.sel_chist_h=h1; Daniel@0: Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[0.4960629921259843 -0.08080808080808044 9.160254037844386], ... Daniel@0: 'Tag','Axes1Text4', ... Daniel@0: 'VerticalAlignment','cap'); Daniel@0: set(get(h2,'Parent'),'XLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[-0.0551181102362206 0.4848484848484853 9.160254037844386], ... Daniel@0: 'Rotation',90, ... Daniel@0: 'Tag','Axes1Text3', ... Daniel@0: 'VerticalAlignment','baseline'); Daniel@0: set(get(h2,'Parent'),'YLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','right', ... Daniel@0: 'Position',[-1.2283 5.7980 9.1603], ... Daniel@0: 'Tag','Axes1Text2', ... Daniel@0: 'Visible','off'); Daniel@0: set(get(h2,'Parent'),'ZLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[0.4960629921259843 1.070707070707071 9.160254037844386], ... Daniel@0: 'Tag','Axes1Text1', ... Daniel@0: 'VerticalAlignment','bottom'); Daniel@0: set(get(h2,'Parent'),'Title',h2); Daniel@0: Daniel@0: h1 = axes('Parent',h0, ... Daniel@0: 'CameraUpVector',[0 1 0], ... Daniel@0: 'CameraUpVectorMode','manual', ... Daniel@0: 'Color',[0.7529 0.7529 0.7529], ... Daniel@0: 'Position',[0.4950000000000001 0.2567741935483871 0.4766666666666667 0.1290322580645161], ... Daniel@0: 'Tag','Axes2', ... Daniel@0: 'XColor',[0 0 0], ... Daniel@0: 'XTickMode','manual', ... Daniel@0: 'YColor',[0 0 0], ... Daniel@0: 'YTick',[0 0.5 1], ... Daniel@0: 'YTickMode','manual', ... Daniel@0: 'ZColor',[0 0 0]); Daniel@0: Daniel@0: data.vector_h=h1; Daniel@0: Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[0.4982456140350879 -0.08080808080808044 9.160254037844386], ... Daniel@0: 'Tag','Axes2Text4', ... Daniel@0: 'VerticalAlignment','cap'); Daniel@0: set(get(h2,'Parent'),'XLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[-0.1018 0.4848 9.1603], ... Daniel@0: 'Rotation',90, ... Daniel@0: 'Tag','Axes2Text3', ... Daniel@0: 'VerticalAlignment','baseline'); Daniel@0: set(get(h2,'Parent'),'YLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','right', ... Daniel@0: 'Position',[-1.045614035087719 5.797979797979799 9.160254037844386], ... Daniel@0: 'Tag','Axes2Text2', ... Daniel@0: 'Visible','off'); Daniel@0: set(get(h2,'Parent'),'ZLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[0.4982456140350879 1.070707070707071 9.160254037844386], ... Daniel@0: 'Tag','Axes2Text1', ... Daniel@0: 'VerticalAlignment','bottom'); Daniel@0: set(get(h2,'Parent'),'Title',h2); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.01833333333333333 0.3922580645161291 0.17 0.01806451612903226], ... Daniel@0: 'String','STATISTICS', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText4'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.2583333333333334 0.3922580645161291 0.1633333333333333 0.01806451612903226], ... Daniel@0: 'String','HISTOGRAM', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText5'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi',... Daniel@0: 'FontSize',6,... Daniel@0: 'HorizontalAlignment','left',... Daniel@0: 'String',{'LEFT: NEW SELECTION';'RIGHT: ADD TO SELECTION'}, ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5016666666666667 0.38 0.235 0.03741935483870968], ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText6', ... Daniel@0: 'UserData','[ ]'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess selall', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.8066666666666668 0.3922580645161291 0.1666666666666667 0.03483870967741935], ... Daniel@0: 'String','SELECT ALL', ... Daniel@0: 'Tag','Pushbutton2', ... Daniel@0: 'UserData','[ ]'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.7529 0.7529 0.7529], ... Daniel@0: 'Position',[0.01833333333333333 0.4503225806451613 0.23 0.3225806451612903], ... Daniel@0: 'String',' ', ... Daniel@0: 'Style','listbox', ... Daniel@0: 'Tag','Listbox1', ... Daniel@0: 'Value',1); Daniel@0: Daniel@0: data.comp_names_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'Position',[0.4950000000000001 0.4503225806451613 0.2333333333333333 0.3225806451612903], ... Daniel@0: 'String',' ', ... Daniel@0: 'Style','listbox', ... Daniel@0: 'Tag','Listbox2', ... Daniel@0: 'Value',1); Daniel@0: Daniel@0: data.vect_mean_h = h1; Daniel@0: Daniel@0: h1 = axes('Parent',h0, ... Daniel@0: 'CameraUpVector',[0 1 0], ... Daniel@0: 'CameraUpVectorMode','manual', ... Daniel@0: 'Color',[1 1 1], ... Daniel@0: 'Position',[0.7383333333333334 0.4503225806451613 0.2333333333333333 0.3225806451612903], ... Daniel@0: 'Tag','Axes3', ... Daniel@0: 'XColor',[0 0 0], ... Daniel@0: 'XTickMode','manual', ... Daniel@0: 'YColor',[0 0 0], ... Daniel@0: 'YTickMode','manual', ... Daniel@0: 'ZColor',[0 0 0]); Daniel@0: Daniel@0: data.sel_cplot_h = h1; Daniel@0: Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[0.4964028776978418 -0.03212851405622486 9.160254037844386], ... Daniel@0: 'Tag','Axes3Text4', ... Daniel@0: 'VerticalAlignment','cap'); Daniel@0: set(get(h2,'Parent'),'XLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[-0.05035971223021596 0.493975903614458 9.160254037844386], ... Daniel@0: 'Rotation',90, ... Daniel@0: 'Tag','Axes3Text3', ... Daniel@0: 'VerticalAlignment','baseline'); Daniel@0: set(get(h2,'Parent'),'YLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','right', ... Daniel@0: 'Position',[-3.1942 1.7028 9.1603], ... Daniel@0: 'Tag','Axes3Text2', ... Daniel@0: 'Visible','off'); Daniel@0: set(get(h2,'Parent'),'ZLabel',h2); Daniel@0: h2 = text('Parent',h1, ... Daniel@0: 'Color',[0 0 0], ... Daniel@0: 'HandleVisibility','off', ... Daniel@0: 'HorizontalAlignment','center', ... Daniel@0: 'Position',[0.4964028776978418 1.028112449799197 9.160254037844386], ... Daniel@0: 'Tag','Axes3Text1', ... Daniel@0: 'VerticalAlignment','bottom'); Daniel@0: set(get(h2,'Parent'),'Title',h2); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess plxy', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.265 0.4683870967741936 0.125 0.03483870967741935], ... Daniel@0: 'String','XY-PLOT', ... Daniel@0: 'Tag','Pushbutton3'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess hist', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.265 0.5303225806451613 0.125 0.03483870967741935], ... Daniel@0: 'String','HISTOGRAM', ... Daniel@0: 'Tag','Pushbutton4'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess bplo', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.265 0.5922580645161291 0.125 0.03483870967741935], ... Daniel@0: 'String','BOX PLOT', ... Daniel@0: 'Tag','Pushbutton5'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess plot', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.265 0.654195483870968 0.125 0.03483870967741935], ... Daniel@0: 'String','PLOT', ... Daniel@0: 'Tag','Pushbutton6'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.4088888888888889 0.5333333333333333 0.06 0.03268817204301075], ... Daniel@0: 'String','30', ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText1'); Daniel@0: Daniel@0: data.no_of_bins_h = h1; Daniel@0: Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.01833333333333333 0.775483870967742 0.2016666666666667 0.01806451612903226], ... Daniel@0: 'String','COMPONENT LIST', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText7'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.4950000000000001 0.775483870967742 0.1966666666666667 0.01806451612903226], ... Daniel@0: 'String','AVERAGE', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText8'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.7383333333333334 0.775483870967742 0.225 0.01806451612903226], ... Daniel@0: 'String','RELATIVE VALUES', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText9'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',10, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.01833333333333333 0.8154838709677419 0.2033333333333333 0.0232258064516129], ... Daniel@0: 'String','COMPONENTS', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText10'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',10, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.4950000000000001 0.8154838709677419 0.2 0.0232258064516129], ... Daniel@0: 'String','VECTORS', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText11'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess sD_management', ... Daniel@0: 'FontSize',5, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.01833333333333333 0.8503225806451613 0.1666666666666667 0.03483870967741935], ... Daniel@0: 'String','DATA SET MANAGEMENT', ... Daniel@0: 'Tag','Pushbutton7'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','preprocess sel_sD', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.01833333333333333 0.8890322580645161 0.1666666666666667 0.03483870967741935], ... Daniel@0: 'String',' ', ... Daniel@0: 'Style','popupmenu', ... Daniel@0: 'Tag','PopupMenu2', ... Daniel@0: 'Value',1); Daniel@0: Daniel@0: data.sD_set_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.2516666666666667 0.8503225806451613 0.7216666666666667 0.07354838709677419], ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText12'); Daniel@0: Daniel@0: data.sD_name_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',10, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.01833333333333333 0.9341935483870968 0.1616666666666667 0.02064516129032258], ... Daniel@0: 'String','DATA SETS', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText13'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',10, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.2516666666666667 0.9341935483870968 0.2833333333333333 0.02064516129032258], ... Daniel@0: 'String','SELECTED DATA SET', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText14'); Daniel@0: Daniel@0: if ~isstruct(sData), Daniel@0: sData=som_data_struct(sData); Daniel@0: end Daniel@0: Daniel@0: ui_h=uimenu('Label','&Normalization'); Daniel@0: uimenu(ui_h,'Label','Scale [0,1]','Callback','preprocess zscale'); Daniel@0: uimenu(ui_h,'Label','Scale var=1','Callback','preprocess vscale'); Daniel@0: uimenu(ui_h,'Label','HistD','Callback','preprocess histeq'); Daniel@0: uimenu(ui_h,'Label','HistC','Callback','preprocess histeq2'); Daniel@0: uimenu(ui_h,'Label','Log','Callback','preprocess log'); Daniel@0: uimenu(ui_h,'Label','Eval (1-comp)','Callback','preprocess eval1'); Daniel@0: Daniel@0: ui_h=uimenu('Label','&Components'); Daniel@0: uimenu(ui_h,'Label','Move component','Callback','preprocess move'); Daniel@0: uimenu(ui_h,'Label','Copy component','Callback','preprocess copy'); Daniel@0: uimenu(ui_h,'Label','Add: N binary types','Callback','preprocess oneo'); Daniel@0: uimenu(ui_h,'Label','Add: zeros','Callback','preprocess zero'); Daniel@0: uimenu(ui_h,'Label','Remove component','Callback','preprocess remove'); Daniel@0: uimenu(ui_h,'Label','Remove selected vectors',... Daniel@0: 'Callback','preprocess remove_vects'); Daniel@0: uimenu(ui_h,'Label','Select all components',... Daniel@0: 'Callback','preprocess sel_all_comps'); Daniel@0: Daniel@0: ui_h=uimenu('Label','&Misc'); Daniel@0: ui_h1=uimenu(ui_h,'Label','Calculate'); Daniel@0: ui_h2=uimenu(ui_h,'Label','Process'); Daniel@0: Daniel@0: uimenu(ui_h,'Label','Get LOG-file','Callback','preprocess LOG'); Daniel@0: uimenu(ui_h,'Label','Indices of the selected vectors',... Daniel@0: 'Callback','preprocess get_inds'); Daniel@0: uimenu(ui_h,'Label','Undo','Callback','preprocess undo'); Daniel@0: uimenu(ui_h1,'Label','Number of values','Callback','preprocess noof'); Daniel@0: uimenu(ui_h1,'Label','Number of selected vectors',... Daniel@0: 'Callback','preprocess no_of_sel'); Daniel@0: uimenu(ui_h1,'Label','Correlation','Callback','preprocess corr'); Daniel@0: uimenu(ui_h2,'Label','Unit length','Callback','preprocess unit'); Daniel@0: uimenu(ui_h2,'Label','Eval','Callback','preprocess eval2'); Daniel@0: uimenu(ui_h2,'Label','Clipping','Callback','preprocess clipping'); Daniel@0: uimenu(ui_h2,'Label','Delay','Callback','preprocess delay'); Daniel@0: uimenu(ui_h2,'Label','Windowed','Callback','preprocess window'); Daniel@0: uimenu(ui_h2,'Label','Select vectors','Callback','preprocess select'); Daniel@0: Daniel@0: len=getfield(size(sData(1).data),{1}); Daniel@0: data.selected_vects=find(ones(1,len)); Daniel@0: data.sD_set=sData; Daniel@0: set(data.vector_h,'ButtonDownFcn','preprocess(''vector_bdf'',''down'')'); Daniel@0: set(gcf,'UserData',data); Daniel@0: if ~set_sD_stats; Daniel@0: return; Daniel@0: end Daniel@0: sel_sD; Daniel@0: return; %%% Preprocess-window is ready. Daniel@0: Daniel@0: else Daniel@0: arg=sData; Daniel@0: if strcmp(arg,'rename') Daniel@0: rename(arg2); Daniel@0: elseif strcmp(arg,'sel_sD') Daniel@0: if isempty(arg2) Daniel@0: sel_sD; Daniel@0: else Daniel@0: sel_sD(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'zscale') Daniel@0: if isempty(arg2) Daniel@0: zero2one_scale; Daniel@0: else Daniel@0: zero2one_scale(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'vscale'); Daniel@0: if isempty(arg2) Daniel@0: var_scale; Daniel@0: else Daniel@0: var_scale(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'histeq2') Daniel@0: if isempty(arg2) Daniel@0: hist_eq2; Daniel@0: else Daniel@0: hist_eq2(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'log') Daniel@0: if isempty(arg2) Daniel@0: logarithm; Daniel@0: else Daniel@0: logarithm(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'eval1') Daniel@0: if isempty(arg2) Daniel@0: eval1; Daniel@0: else Daniel@0: eval1(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'eval2') Daniel@0: if isempty(arg2) Daniel@0: eval2; Daniel@0: else Daniel@0: eval2(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'histeq'); Daniel@0: if isempty(arg2) Daniel@0: hist_eq; Daniel@0: else Daniel@0: hist_eq(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'selall') Daniel@0: if isempty(arg2) Daniel@0: select_all; Daniel@0: else Daniel@0: select_all(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'sel_button'); Daniel@0: if isempty(arg2) Daniel@0: sel_button; Daniel@0: else Daniel@0: sel_button(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'clear_button') Daniel@0: if isempty(arg2) Daniel@0: clear_button; Daniel@0: else Daniel@0: clear_button(arg2) Daniel@0: end Daniel@0: elseif(strcmp(arg,'move')) Daniel@0: if isempty(arg2) Daniel@0: move_component; Daniel@0: else Daniel@0: move_component(arg2); Daniel@0: end Daniel@0: elseif(strcmp(arg,'copy')) Daniel@0: if isempty(arg2) Daniel@0: copy_component; Daniel@0: else Daniel@0: copy_component(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'oneo') Daniel@0: if isempty(arg2) Daniel@0: one_of_n; Daniel@0: else Daniel@0: one_of_n(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'zero') Daniel@0: if isempty(arg2) Daniel@0: add_zeros; Daniel@0: else Daniel@0: add_zeros(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'remove') Daniel@0: if isempty(arg2) Daniel@0: remove_component; Daniel@0: else Daniel@0: remove_component(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'remove_vects') Daniel@0: if isempty(arg2) Daniel@0: remove_vects; Daniel@0: else Daniel@0: remove_vects(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'noof') Daniel@0: if isempty(arg2) Daniel@0: no_of_values; Daniel@0: else Daniel@0: no_of_values(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'corr'); Daniel@0: if isempty(arg2) Daniel@0: correlation; Daniel@0: else Daniel@0: correlation(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'unit') Daniel@0: if isempty(arg2) Daniel@0: unit_length; Daniel@0: else Daniel@0: unit_length(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'clip_data') Daniel@0: clip_data(arg2); Daniel@0: elseif strcmp(arg,'copy_delete') Daniel@0: copy_delete(arg2); Daniel@0: elseif strcmp(arg,'and_or_cb') Daniel@0: and_or_cb(arg2); Daniel@0: elseif strcmp(arg,'all_sel_cb') Daniel@0: all_sel_cb(arg2); Daniel@0: elseif strcmp(arg,'clip_exp_cb') Daniel@0: clip_exp_cb(arg2); Daniel@0: elseif strcmp(arg,'window_cb') Daniel@0: window_cb(arg2); Daniel@0: elseif strcmp(arg,'set_state_vals') Daniel@0: set_state_vals(arg2); Daniel@0: elseif strcmp(arg,'vector_bdf') Daniel@0: vector_bdf(arg2); Daniel@0: elseif strcmp(arg,'sD_management'); Daniel@0: if isempty(arg2) Daniel@0: sD_management; Daniel@0: else Daniel@0: sD_management(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'clipping') Daniel@0: if isempty(arg2) Daniel@0: clipping; Daniel@0: else Daniel@0: clipping(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'delay') Daniel@0: if isempty(arg2) Daniel@0: delay; Daniel@0: else Daniel@0: delay(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'window'); Daniel@0: if isempty(arg2) Daniel@0: window; Daniel@0: else Daniel@0: window(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'select'); Daniel@0: if isempty(arg2) Daniel@0: select; Daniel@0: else Daniel@0: select(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'import') Daniel@0: if isempty(arg2) Daniel@0: import; Daniel@0: else Daniel@0: import(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'export') Daniel@0: if isempty(arg2) Daniel@0: export; Daniel@0: else Daniel@0: export(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'undo'); Daniel@0: if isempty(arg2) Daniel@0: undo; Daniel@0: else Daniel@0: undo(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'delay_data') Daniel@0: if isempty(arg2) Daniel@0: delay_data; Daniel@0: else Daniel@0: delay_data(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'eval_windowed') Daniel@0: if isempty(arg2) Daniel@0: eval_windowed; Daniel@0: else Daniel@0: eval_windowed(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'get_inds') Daniel@0: if isempty(arg2) Daniel@0: get_selected_inds; Daniel@0: else Daniel@0: get_selected_inds(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'no_of_sel') Daniel@0: if isempty(arg2) Daniel@0: no_of_selected; Daniel@0: else Daniel@0: no_of_selected(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'sel_comp'); Daniel@0: if isempty(arg2) Daniel@0: sel_comp; Daniel@0: else Daniel@0: sel_comp(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'sel_all_comps') Daniel@0: if isempty(arg2) Daniel@0: select_all_comps; Daniel@0: else Daniel@0: select_all_comps(arg2); Daniel@0: end Daniel@0: elseif strcmp(arg,'refresh') Daniel@0: set_var_names; Daniel@0: elseif any(strcmp(arg,{'close_c','close_d','close_s','close_w','close_sD'})) Daniel@0: if isempty(arg2) Daniel@0: close_func(arg) Daniel@0: else Daniel@0: close_func(arg,arg2); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: Daniel@0: switch arg Daniel@0: case 'sD_stats' Daniel@0: sD_stats; Daniel@0: case 'LOG' Daniel@0: log_file; Daniel@0: otherwise Daniel@0: pro_tools(arg); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function set_compnames(sData,h) Daniel@0: Daniel@0: %SET_COMPNAMES Daniel@0: % Daniel@0: % set_compnames(sData,h) Daniel@0: % Daniel@0: % ARGUMENTS Daniel@0: % Daniel@0: % sData (struct) som_data_struct Daniel@0: % h (scalar) handle to a list box object Daniel@0: % Daniel@0: % Daniel@0: % This function sets the component names of sData to the list box Daniel@0: % indicated by 'h'. Daniel@0: % Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: error('Figure ''Preprocess'' does not exist. Closing program...'); Daniel@0: close_preprocess; Daniel@0: end Daniel@0: Daniel@0: udata=get(pre_h,'UserData'); Daniel@0: Daniel@0: set(h,'Value',[]); Daniel@0: for i=1:length(sData.comp_names) Daniel@0: tmp=sprintf('#%d: ',i); Daniel@0: names{i,1}=cat(2,tmp, sData.comp_names{i}); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: set(h,'String',names,'Max',2); Daniel@0: set(udata.sel_comp_h,'String',names); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function draw_vectors(vectors,h) Daniel@0: Daniel@0: %DRAW_VECTORS Daniel@0: % Daniel@0: % draw_vectors(vectors,h) Daniel@0: % Daniel@0: % ARGUMENTS Daniel@0: % Daniel@0: % vectors (vector) vector of 0's and 1's Daniel@0: % h (scalar) handle to an axis object Daniel@0: % Daniel@0: % Daniel@0: % This function draws an horizontal bar of 'vectors' in the axis Daniel@0: % indicated by 'h'. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: subplot(h); Daniel@0: hold off; Daniel@0: cla; Daniel@0: Daniel@0: set(h,'YLim',[0 1]); Daniel@0: set(h,'YTick',[]); Daniel@0: set(h,'XLim',[0 length(vectors)+1]); Daniel@0: hold on; Daniel@0: Daniel@0: comp_no=get(getfield(get(pre_h,'UserData'),'sel_comp_h'),'Value'); Daniel@0: comp=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: comp=comp.data(:,comp_no); Daniel@0: Max = max(comp); Daniel@0: Min = min(comp); Daniel@0: lims=get(gca,'YLim'); Daniel@0: lims(1)=Min; Daniel@0: h=abs(0.1*Max); Daniel@0: lims(2)=Max; Daniel@0: if Max - Min <= eps Daniel@0: tmp=Max; Daniel@0: lims(1)=tmp-1; Daniel@0: lims(2)=tmp+1; Daniel@0: end Daniel@0: lims(2)=lims(2)+h; Daniel@0: if ~all(isnan(lims)) Daniel@0: set(gca,'YLim',lims); Daniel@0: end Daniel@0: h=(lims(2)-lims(1))/4; Daniel@0: set(gca,'YTickMode','auto'); Daniel@0: t=1:length(vectors); Daniel@0: h=plot(t,comp); Daniel@0: set(h,'ButtonDownFcn','preprocess(''vector_bdf'',''down'')'); Daniel@0: indices =find(vectors); Daniel@0: vectors(indices)=0.1*(getfield(get(gca,'YLim'),... Daniel@0: {2})-getfield(get(gca,'YLim'),{1})); Daniel@0: plot(indices,vectors(indices)+getfield(get(gca,'YLim'),{1}),... Daniel@0: 'ored','MarkerSize',4); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function vect_means(sData,handle,indices) Daniel@0: Daniel@0: %VECT_MEANS Daniel@0: % Daniel@0: % vect_means(sData,handle,indices) Daniel@0: % Daniel@0: % ARGUMENTS Daniel@0: % Daniel@0: % sData (struct) som_data_struct Daniel@0: % handle (scalar) handle to the static text box object Daniel@0: % indices (vector) indices of selected vectors Daniel@0: % Daniel@0: % Daniel@0: % This function calculates means of selected vectors' components Daniel@0: % and writes them in the static text box indicated by 'handle'. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: sData= sData.data(indices,:); Daniel@0: Daniel@0: for i=1:length(sData(1,:)) Daniel@0: names{i}=sprintf('#%d: ',i); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: for i=1:length(sData(1,:)) Daniel@0: tmp=sData(:,i); Daniel@0: tmp=cat(2,names{i},sprintf('%-10.3g',mean(tmp(find(~isnan(tmp)))))); Daniel@0: string{i}=tmp; Daniel@0: end Daniel@0: Daniel@0: set(handle,'String',string); Daniel@0: set(handle,'HorizontalAlignment','left'); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function vector_bdf(arg) Daniel@0: Daniel@0: %VECTOR_BDF A button down function. Daniel@0: % Daniel@0: % vector_bdf(arg) Daniel@0: % Daniel@0: % ARGUMENTS Daniel@0: % Daniel@0: % arg (string) 'down' or 'up', tells the mouse button's state. Daniel@0: % Daniel@0: % Daniel@0: % This function selects vectors in the vector-window and plots maxima, Daniel@0: % minima and means of the selected vectors. It also writes means of the Daniel@0: % selected vectors' components in a static text box and takes care of Daniel@0: % changes of the chosen component's data. Daniel@0: % Daniel@0: % See also VECTOR_MEANS, SEL_COMP Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: Daniel@0: arg2=arg(6:length(arg)); Daniel@0: if ~isempty(arg2) Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: arg=arg(1:4); Daniel@0: Daniel@0: %%% arg's first "word" is 4 letters long and it can be: Daniel@0: %%% Daniel@0: %%% 'key ' Daniel@0: %%% 'down' Daniel@0: %%% 'drag' Daniel@0: %%% 'up ' Daniel@0: Daniel@0: if strcmp(arg,'key ') %string is 'key' + 1 space!!! Daniel@0: if ~LOG Daniel@0: key=get(gcf,'CurrentCharacter'); Daniel@0: else Daniel@0: key=arg2 Daniel@0: end Daniel@0: if ~strcmp(key,'<') & ~strcmp(key,'>') Daniel@0: return; Daniel@0: end Daniel@0: data=get(gcf,'UserData'); Daniel@0: sel=data.selected_vects; Daniel@0: if length(sel) == 1 Daniel@0: if strcmp(key,'<') & sel ~= 1 Daniel@0: data.selected_vects=sel-1; Daniel@0: set(gcf,'UserData',data); Daniel@0: elseif strcmp(key,'>') & sel ~= length(data.sData.data(:,1)) Daniel@0: data.selected_vects = sel + 1; Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: else Daniel@0: if strcmp(key,'<') & sel(1) ~= 1 Daniel@0: data.selected_vects=cat(2,sel(1)-1,sel); Daniel@0: set(gcf,'UserData',data); Daniel@0: elseif strcmp(key,'>') & sel(length(sel)) ~= length(sel) Daniel@0: data.selected_vects=cat(2,sel,sel(length(sel))+1); Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: end Daniel@0: cplot_mimema; Daniel@0: pro_tools('plot_hist'); Daniel@0: pro_tools('c_stat'); Daniel@0: vects=zeros(1,length(data.sData.data(:,1))); Daniel@0: vects(data.selected_vects)=1; Daniel@0: draw_vectors(vects,data.vector_h); Daniel@0: Daniel@0: if ~LOG Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}=... Daniel@0: sprintf('preprocess(''vector_bdf'',''key %s'');',key); Daniel@0: %string is 'key'+2spaces+%s Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: switch arg Daniel@0: case 'down' Daniel@0: set(gcf,'WindowButtonUpFcn','preprocess(''vector_bdf'',''up '')'); Daniel@0: set(gcf,'WindowButtonMotionFcn','preprocess(''vector_bdf'',''drag'')'); Daniel@0: switch get(gcf,'SelectionType') Daniel@0: case 'normal' Daniel@0: data.lims1=round(getfield(get(gca,'CurrentPoint'),{1,1})); Daniel@0: data.lims2=[]; Daniel@0: case 'alt' Daniel@0: tmp=round(getfield(get(gca,'CurrentPoint'),{1,1})); Daniel@0: if isempty(get(gca,'UserData')) Daniel@0: data.lims1=tmp; Daniel@0: data.lims2=[]; Daniel@0: else Daniel@0: data.lims1=cat(2,getfield(get(gca,'UserData'),'lims1'),tmp); Daniel@0: data.lims2=getfield(get(gca,'UserData'),'lims2'); Daniel@0: end Daniel@0: end Daniel@0: coords=get(gca,'CurrentPoint'); Daniel@0: h=line([coords(1),coords(1)],get(gca,'YLim'),'EraseMode','xor'); Daniel@0: set(h,'Color','red'); Daniel@0: h2=line([coords(1),coords(1)],get(gca,'YLim'),'EraseMode','xor'); Daniel@0: set(h2,'Color','red'); Daniel@0: data.h=h; Daniel@0: data.h2=h2; Daniel@0: set(gca,'UserData',data); Daniel@0: Daniel@0: case 'drag' Daniel@0: coords=get(gca,'CurrentPoint'); Daniel@0: lim=get(gca,'XLim'); Daniel@0: h2=getfield(get(gca,'UserData'),'h2'); Daniel@0: if lim(1) >= coords(1) Daniel@0: set(h2,'XData',[lim(1) lim(1)]); Daniel@0: elseif lim(2) <= coords(2) Daniel@0: set(h2,'XData',[lim(2) lim(2)]); Daniel@0: else Daniel@0: set(h2,'XData',[coords(1) coords(1)]); Daniel@0: end Daniel@0: case 'up ' % string is 'up' + 2 spaces!!! Daniel@0: set(gcf,'WindowButtonUpFcn',''); Daniel@0: set(gcf,'WindowButtonMotionFcn',''); Daniel@0: if ~LOG Daniel@0: data=get(gca,'UserData'); Daniel@0: delete(data.h); Daniel@0: delete(data.h2); Daniel@0: tmp=round(getfield(get(gca,'CurrentPoint'),{1,1})); Daniel@0: data.lims2=cat(2,data.lims2,tmp); Daniel@0: tmp_data=sort(cat(1,data.lims1,data.lims2)); Daniel@0: high=getfield(get(gca,'XLim'),{2})-1; Daniel@0: vectors=zeros(1,high); Daniel@0: tmp_data(find(tmp_data<1))=1; Daniel@0: tmp_data(find(tmp_data>high))=high; Daniel@0: Daniel@0: for i=1:getfield(size(tmp_data),{2}) Daniel@0: vectors(tmp_data(1,i):tmp_data(2,i))=1; Daniel@0: end Daniel@0: selected_vects=find(vectors); Daniel@0: else Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: len=size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')); Daniel@0: vectors=zeros(1,len(1)); Daniel@0: i=1; Daniel@0: while i <= length(arg2) & (isspace(arg2(i)) | ~isletter(arg2(i))) Daniel@0: i=i+1; Daniel@0: end Daniel@0: arg3=arg2(i:length(arg2)); Daniel@0: selected_vects=str2num(arg2(1:i-1)); Daniel@0: if ~isempty(arg3) & ~all(isspace(arg3)) Daniel@0: selected_vects=unique(cat(2,selected_vects,... Daniel@0: getfield(get(pre_h,'UserData'),'selected_vects'))); Daniel@0: end Daniel@0: vectors(selected_vects)=1; Daniel@0: set(pre_h,'CurrentAxes',getfield(get(pre_h,'UserData'),'vector_h')); Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: end Daniel@0: draw_vectors(vectors,gca); Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: vect_means(sData,h,selected_vects); Daniel@0: if ~LOG Daniel@0: set(gca,'UserData',data); Daniel@0: end Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.undo.sData=data.sData; Daniel@0: data.undo.selected=data.selected_vects; Daniel@0: data.selected_vects=selected_vects; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Vector selection by using the mouse...'; Daniel@0: tmp=sprintf('preprocess(''vector_bdf'',''up %s'');',... Daniel@0: num2str(data.selected_vects)); Daniel@0: if length(tmp) > 500 Daniel@0: tmp=textwrap({tmp},500); Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,tmp{1},''');'); Daniel@0: for i=2:length(tmp)-1 Daniel@0: data.LOG{length(data.LOG)+1}=... Daniel@0: cat(2,sprintf('preprocess(''vector_bdf'',''up %s',... Daniel@0: tmp{i}),'add'');'); Daniel@0: end Daniel@0: data.LOG{length(data.LOG)+1}=... Daniel@0: cat(2,sprintf('preprocess(''vector_bdf'',''up %s',... Daniel@0: tmp{length(tmp)}(1:length(tmp{length(tmp)})-3)),' add'');'); Daniel@0: else Daniel@0: data.LOG{length(data.LOG)+1}=tmp; Daniel@0: end Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: cplot_mimema; Daniel@0: sel_comp; Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function sel_button(varargin) Daniel@0: Daniel@0: %SEL_BUTTON A Callback function. It performs the operations needed Daniel@0: % when vector components are selected. Daniel@0: % Daniel@0: % See also SEL_COMP Daniel@0: % Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: string=getfield(get(pre_h,'UserData'),'comp_names_h'); Daniel@0: string=getfield(get(string,'String'),{str2num(varargin{1})}); Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: else Daniel@0: LOG=0; Daniel@0: val=get(getfield(get(gcf,'UserData'),'comp_names_h'),'Value'); Daniel@0: end Daniel@0: Daniel@0: sel_button_h=getfield(get(gcf,'UserData'),'sel_button_h'); Daniel@0: sel_comps_h=getfield(get(gcf,'UserData'),'sel_comps_h'); Daniel@0: comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); Daniel@0: if ~LOG Daniel@0: string=getfield(get(comp_names_h,'String'),{get(comp_names_h,'Value')}); Daniel@0: end Daniel@0: tmp_string=get(sel_comps_h,'String'); Daniel@0: Daniel@0: if iscell(tmp_string) Daniel@0: Daniel@0: for i=1:length(string) Daniel@0: if ~any(strcmp(string{i},tmp_string)) Daniel@0: tmp_string=cat(1,tmp_string,string(i)); Daniel@0: end Daniel@0: end Daniel@0: string=tmp_string; Daniel@0: end Daniel@0: Daniel@0: set(sel_comps_h,'String',string); Daniel@0: set(comp_names_h,'Value',[]); Daniel@0: sel_comp; Daniel@0: if ~LOG Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Select components'; Daniel@0: data.LOG{length(data.LOG)+1}=sprintf('preprocess(''sel_button'',''%s'');',... Daniel@0: num2str(val)); Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function clear_button(varargin) Daniel@0: Daniel@0: %CLEAR_BUTTON Function callback evaluated when a 'Clear'-button is Daniel@0: % pressed. It removes texts from the 'selected components' Daniel@0: % -window and the 'selected component data' -window and Daniel@0: % clears the 'histogram' -axis. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: if nargin==1 Daniel@0: LOG=1; Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: sel_comp_h=getfield(get(gcf,'UserData'),'sel_comp_h'); Daniel@0: sel_cdata_h=getfield(get(gcf,'UserData'),'sel_cdata_h'); Daniel@0: sel_cplot_h=getfield(get(gcf,'UserData'),'sel_cplot_h'); Daniel@0: sel_chist_h=getfield(get(gcf,'UserData'),'sel_chist_h'); Daniel@0: vector_h=getfield(get(gcf,'UserData'),'vector_h'); Daniel@0: Daniel@0: set(sel_comp_h,'Value',1); Daniel@0: set(sel_cdata_h,'String',' '); Daniel@0: subplot(sel_chist_h); Daniel@0: hold off; Daniel@0: cla; Daniel@0: Daniel@0: selected=getfield(get(gcf,'UserData'),'selected_vects'); Daniel@0: dims=size(getfield(getfield(get(gcf,'UserData'),'sData'),'data')); Daniel@0: vectors=zeros(1,dims(1)); Daniel@0: vectors(selected)=1; Daniel@0: subplot(vector_h); Daniel@0: draw_vectors(vectors,vector_h); Daniel@0: if ~LOG Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Remove components from the selected list.'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''clear_button'',''foo'');'; Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function sel_comp(varargin) Daniel@0: Daniel@0: %SEL_COMP performs the operations needed when vector components are Daniel@0: % chosen. It writes maxima, minima, mean and standard deviation Daniel@0: % of the chosen component to a text box window and draws a Daniel@0: % histogram of the chosen component of selected vectors' Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: sel_comp_h=getfield(get(pre_h,'UserData'),'sel_comp_h'); Daniel@0: Daniel@0: if nargin == 1 Daniel@0: set(sel_comp_h,'Value',str2num(varargin{1})); Daniel@0: elseif ~isempty(gcbo) Daniel@0: no=get(sel_comp_h,'Value'); Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Select one component'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''sel_comp'',''',... Daniel@0: num2str(no),''');'); Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: Daniel@0: pro_tools('c_stat'); Daniel@0: pro_tools('plot_hist'); Daniel@0: data=get(gcf,'UserData'); Daniel@0: sData=data.sData; Daniel@0: vector_h=data.vector_h; Daniel@0: len=length(sData.data(:,1)); Daniel@0: vects=zeros(1,len); Daniel@0: vects(data.selected_vects)=1; Daniel@0: draw_vectors(vects,vector_h); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function cplot_mimema Daniel@0: Daniel@0: global no_of_sc Daniel@0: Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: sel_cplot_h=getfield(get(gcf,'UserData'),'sel_cplot_h'); Daniel@0: selected=getfield(get(gcf,'UserData'),'selected_vects'); Daniel@0: Daniel@0: set(sel_cplot_h,'YLim',[0 length(sData.data(1,:))+1]); Daniel@0: Daniel@0: subplot(sel_cplot_h); Daniel@0: hold off; Daniel@0: cla; Daniel@0: hold on; Daniel@0: Daniel@0: for i=1:length(sData.data(1,:)) Daniel@0: Max=max(sData.data(:,i)); Daniel@0: Min=min(sData.data(:,i)); Daniel@0: tmp=sData.data(selected,i); Daniel@0: Daniel@0: selMax=max(tmp); Daniel@0: selMin=min(tmp); Daniel@0: Mean=abs(mean(tmp(find(~isnan(tmp))))); Daniel@0: Median=abs(median(tmp(find(~isnan(tmp))))); Daniel@0: Daniel@0: if Max ~= Min & ~all(isnan(sData.data(:,i))) Daniel@0: Daniel@0: if rem(i,no_of_sc) % no_of_sc is defined in the beginning of this file... Daniel@0: Daniel@0: line([abs(selMin-Min)/(Max-Min) (selMax-Min)/(Max-Min)],... Daniel@0: [i i],'Color','black'); Daniel@0: plot(abs(Mean-Min)/(Max-Min),i,'oblack'); Daniel@0: plot(abs(Median-Min)/(Max-Min),i,'xblack'); Daniel@0: else Daniel@0: line([abs(selMin-Min)/(Max-Min) (selMax-Min)/(Max-Min)],... Daniel@0: [i i],'Color','black','LineWidth',2); Daniel@0: plot(abs(Mean-Min)/(Max-Min),i,'oblack','LineWidth',2); Daniel@0: plot(abs(Median-Min)/(Max-Min),i,'xblack','LineWidth',2); Daniel@0: end Daniel@0: else Daniel@0: Daniel@0: if rem(i,no_of_sc) % N is defined in the beginning of this file. Daniel@0: Daniel@0: plot(mean(get(gca,'XLim')),i,'oblack'); Daniel@0: plot(mean(get(gca,'XLim')),i,'xblack'); Daniel@0: else Daniel@0: plot(mean(get(gca,'XLim')),i,'oblack','LineWidth',2); Daniel@0: plot(mean(get(gca,'XLim')),i,'xblack','LineWidth',2); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: Daniel@0: function bool=set_sD_stats Daniel@0: Daniel@0: %SET_SD_STATS Writes the data set names to popup menu. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: bool=1; Daniel@0: data=get(gcf,'UserData'); Daniel@0: Daniel@0: for i=1:length(data.sD_set) Daniel@0: % if ~isvalid_var_name({data.sD_set(i).name}) Daniel@0: % close_preprocess; Daniel@0: % bool=0; Daniel@0: % return; Daniel@0: % end Daniel@0: string{i}=cat(2,sprintf('#%d: ',i),data.sD_set(i).name); Daniel@0: end Daniel@0: Daniel@0: set(data.sD_set_h,'String',string); Daniel@0: data.sData=data.sD_set(get(data.sD_set_h,'Value')); Daniel@0: data.sData.MODIFIED=0; Daniel@0: data.sData.INDEX=1; Daniel@0: set(gcf,'UserData',data); Daniel@0: write_sD_stats; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function write_sD_stats Daniel@0: Daniel@0: %WRITE_SD_STATS writes data's name, length and dimension to text box. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: Daniel@0: sD_name_h=getfield(get(pre_h,'UserData'),'sD_name_h'); Daniel@0: sData=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: dims=size(sData.data); Daniel@0: string{1}=cat(2,'Name: ',sData.name); Daniel@0: string{2}=cat(2,'Length: ',sprintf('%d',dims(1))); Daniel@0: string{3}=cat(2,'Dim: ',sprintf('%d',dims(2))); Daniel@0: Daniel@0: set(sD_name_h,'String',string); Daniel@0: set(sD_name_h,'HorizontalAlignment','left'); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function sel_sD(varargin) Daniel@0: Daniel@0: %SEL_SD sets new data to UserData's 'sData'. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: if nargin==1 Daniel@0: LOG=1; Daniel@0: index=str2num(varargin{1}); Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: sD_set_h=getfield(get(gcf,'UserData'),'sD_set_h'); Daniel@0: comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); Daniel@0: vector_h=getfield(get(gcf,'UserData'),'vector_h'); Daniel@0: vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: Daniel@0: if ~LOG Daniel@0: index=get(sD_set_h,'Value'); Daniel@0: end Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.undo = []; Daniel@0: INDEX=data.sData.INDEX; Daniel@0: data.sData=rmfield(data.sData,'MODIFIED'); Daniel@0: data.sData=rmfield(data.sData,'INDEX'); Daniel@0: Daniel@0: tmp=data.sD_set(index); Daniel@0: tmp.MODIFIED=0; Daniel@0: tmp.INDEX=index; Daniel@0: data.sD_set(INDEX)=data.sData; Daniel@0: data.sData=tmp; Daniel@0: Daniel@0: len=getfield(size(tmp.data),{1}); Daniel@0: Daniel@0: data.selected_vects=find(ones(1,len)); Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Select a new data set.'; Daniel@0: data.LOG{length(data.LOG)+1}=sprintf('preprocess(''sel_sD'',''%s'');',... Daniel@0: num2str(index)); Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: write_sD_stats; Daniel@0: set_compnames(tmp,comp_names_h); Daniel@0: draw_vectors(ones(1,len),vector_h); Daniel@0: vect_means(tmp,vect_mean_h,data.selected_vects); Daniel@0: clear_button; Daniel@0: sel_comp; Daniel@0: cplot_mimema; Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function indices=get_indices Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); Daniel@0: indices = get(comp_names_h,'Value'); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function sD_management(varargin) Daniel@0: Daniel@0: if nargin ~= 1 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: preh_udata=get(pre_h,'UserData'); Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}=... Daniel@0: '% Starting the ''Data Set Management'' -window...'; Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}=... Daniel@0: 'preprocess(''sD_management'',''foo'');'; Daniel@0: set(pre_h,'UserData',preh_udata); Daniel@0: end Daniel@0: Daniel@0: man_h=findobj(get(0,'Children'),'Tag','Management'); Daniel@0: if ~isempty(man_h) Daniel@0: figure(man_h); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: h0 = figure('BackingStore','off', ... Daniel@0: 'Color',[0.8 0.8 0.8], ... Daniel@0: 'Name','Data Set Management', ... Daniel@0: 'PaperPosition',[18 180 576 432], ... Daniel@0: 'PaperUnits','points', ... Daniel@0: 'Position',[753 523 324 470], ... Daniel@0: 'RendererMode','manual', ... Daniel@0: 'Tag','Management'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Max',2, ... Daniel@0: 'Position',[0.02777777777777778 0.0723404255319149 0.7716049382716049 0.1914893617021277], ... Daniel@0: 'String',' ', ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText1'); Daniel@0: Daniel@0: data.new_c_name_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Callback','preprocess rename comp',... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.8240740740740741 0.2106382978723404 0.154320987654321 0.05319148936170213], ... Daniel@0: 'String','RENAME', ... Daniel@0: 'Tag','Pushbutton1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Callback','preprocess close_sD',... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.8240740740740741 0.01914893617021277 0.154320987654321 0.05319148936170213], ... Daniel@0: 'String','CLOSE', ... Daniel@0: 'Tag','Pushbutton2'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.02777777777777778 0.2680851063829787 0.345679012345679 0.02978723404255319], ... Daniel@0: 'String','COMPONENTS:', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText1'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.02777777777777778 0.3170212765957447 0.3549382716049382 0.5319148936170213], ... Daniel@0: 'String',' ', ... Daniel@0: 'Style','listbox', ... Daniel@0: 'Tag','Listbox1', ... Daniel@0: 'Value',1); Daniel@0: Daniel@0: data.sets_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.6234567901234568 0.3170212765957447 0.3549382716049382 0.5319148936170213], ... Daniel@0: 'String',' ', ... Daniel@0: 'Style','listbox', ... Daniel@0: 'Tag','Listbox2', ... Daniel@0: 'Value',1); Daniel@0: Daniel@0: Daniel@0: data.variables_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Callback','preprocess export',... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.4259259259259259 0.551063829787234 0.154320987654321 0.0425531914893617], ... Daniel@0: 'String','->', ... Daniel@0: 'Tag','Pushbutton4'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Callback','preprocess import',... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.4259259259259259 0.625531914893617 0.154320987654321 0.0425531914893617], ... Daniel@0: 'String','<-', ... Daniel@0: 'Tag','Pushbutton3'); Daniel@0: Daniel@0: Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.02777777777777778 0.8531914893617022 0.2993827160493827 0.02978723404255319], ... Daniel@0: 'String','DATA SETS', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText2'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.6234567901234568 0.8531914893617022 0.2561728395061728 0.02978723404255319], ... Daniel@0: 'String','WORKSPACE', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText3'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Callback','preprocess rename set',... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1820987654320987 0.9127659574468086 0.7808641975308641 0.0425531914893617], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText2'); Daniel@0: Daniel@0: data.new_name_h = h1; Daniel@0: Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.02777777777777778 0.9127659574468086 0.1388888888888889 0.02978723404255319], ... Daniel@0: 'String','NAME:', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText4'); Daniel@0: Daniel@0: Daniel@0: ui_h=uimenu('Label','&Tools'); Daniel@0: uimenu(ui_h,'Label','Copy','Callback','preprocess copy_delete copy'); Daniel@0: uimenu(ui_h,'Label','Delete','Callback','preprocess copy_delete delete'); Daniel@0: uimenu(ui_h,'Label','Refresh','Callback','preprocess refresh'); Daniel@0: Daniel@0: set(gcf,'UserData',data); Daniel@0: set_var_names; Daniel@0: sD_names; Daniel@0: sD_stats; Daniel@0: Daniel@0: Daniel@0: Daniel@0: %%% Subfunction: set_var_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function set_var_names Daniel@0: Daniel@0: Daniel@0: variables_h=getfield(get(gcf,'UserData'),'variables_h'); Daniel@0: value=get(variables_h,'Value'); Daniel@0: len=evalin('base','length(who)'); Daniel@0: Daniel@0: names=cell(len,1); Daniel@0: Daniel@0: for i=1:len Daniel@0: string=cat(2,'getfield(who,{',num2str(i),'})'); Daniel@0: names(i)=evalin('base',string); Daniel@0: end Daniel@0: Daniel@0: set(variables_h,'String',names); Daniel@0: if(value > length(names)) Daniel@0: set(variables_h,'Value',1); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: sD_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function sD_names Daniel@0: Daniel@0: sets_h=getfield(get(gcf,'UserData'),'sets_h'); Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: sD_set = getfield(get(pre_h,'UserData'),'sD_set'); Daniel@0: Daniel@0: for i=1:length(sD_set) Daniel@0: names{i,1}=cat(2,sprintf('#%d: ',i),sD_set(i).name); Daniel@0: end Daniel@0: Daniel@0: set(sets_h,'String',names); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: sD_stats %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function sD_stats Daniel@0: Daniel@0: man_h=findobj(get(0,'Children'),'Tag','Management'); Daniel@0: c_names_h=getfield(get(man_h,'UserData'),'new_c_name_h'); Daniel@0: sD_name_h=getfield(get(man_h,'UserData'),'new_name_h'); Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: INDEX=getfield(getfield(get(pre_h,'UserData'),'sData'),'INDEX'); Daniel@0: MODIFIED=getfield(getfield(get(pre_h,'UserData'),'sData'),'MODIFIED'); Daniel@0: value=get(getfield(get(man_h,'UserData'),'sets_h'),'Value'); Daniel@0: Daniel@0: if value==INDEX Daniel@0: data=get(pre_h,'UserData'); Daniel@0: sData=rmfield(data.sData,[{'INDEX'};{'MODIFIED'}]); Daniel@0: data.sD_set(INDEX)=sData; Daniel@0: data.sData.MODIFIED=0; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: Daniel@0: sData=getfield(getfield(get(pre_h,'UserData'),'sD_set'),{value}); Daniel@0: string1=[{sData.name}]; Daniel@0: Daniel@0: Daniel@0: set(sD_name_h,'String',string1); Daniel@0: set(c_names_h,'String',sData.comp_names); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: import %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function import(varargin) Daniel@0: Daniel@0: if nargin==1 Daniel@0: LOG=1; Daniel@0: man_h=findobj(get(0,'Children'),'Tag','Management'); Daniel@0: set(0,'CurrentFigure',man_h); Daniel@0: name=varargin; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: variables_h=getfield(get(gcf,'UserData'),'variables_h'); Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: if ~LOG Daniel@0: name=getfield(get(variables_h,'String'),{get(variables_h,'Value')}); Daniel@0: end Daniel@0: errstr='Data to be imported must be real matrix or ''som_data_struct''.'; Daniel@0: new_sD=evalin('base',name{1}); Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess'' -figure does not exist. Terminating program...'); Daniel@0: close_preprocess; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if isstr(new_sD) | (~isstruct(new_sD) & ~isreal(new_sD)) Daniel@0: errordlg(errstr); Daniel@0: return; Daniel@0: elseif isstruct(new_sD) & length(new_sD) > 1 Daniel@0: errordlg(errstr) Daniel@0: return; Daniel@0: elseif ~isstruct(new_sD) Daniel@0: new_sD=som_data_struct(new_sD); Daniel@0: new_sD.name=name{1}; Daniel@0: end Daniel@0: Daniel@0: new_sD_names=fieldnames(new_sD); Daniel@0: right_names=fieldnames(som_data_struct(1)); Daniel@0: for i=1:length(new_sD_names) Daniel@0: if ~any(strcmp(new_sD_names(i),right_names)); Daniel@0: errordlg(errstr); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.sD_set(length(data.sD_set) + 1)=new_sD; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Import a data set from the workspace.'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''import'',''',... Daniel@0: name{1},''');'); Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: sD_names; Daniel@0: sD_stats; Daniel@0: old =gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: set_sD_stats; Daniel@0: set(0,'CurrentFigure',old); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: export %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function export(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: man_h=findobj(get(0,'Children'),'Tag','Management'); Daniel@0: set(0,'CurrentFigure',man_h); Daniel@0: index=str2num(varargin{1}); Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: sets_h=getfield(get(gcf,'UserData'),'sets_h'); Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: if ~LOG Daniel@0: index=get(sets_h,'Value'); Daniel@0: end Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess''-figure does not exist. Terminating program...'); Daniel@0: close(findobj(get(0,'Children'),'Tag','Management')); Daniel@0: close(findobj(get(0,'Children'),'Tag','PlotWin')); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: sData=getfield(getfield(get(pre_h,'UserData'),'sD_set'),{index}); Daniel@0: Daniel@0: if ~isvalid_var_name({sData.name}) Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: assignin('base',sData.name,sData); Daniel@0: disp(sprintf('Data set ''%s'' is set to the workspace.',sData.name)); Daniel@0: if ~LOG Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Export a data set to the workspace.'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''export'',''',... Daniel@0: num2str(index),''');'); Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: set_var_names; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: %%% Subfunction: rename %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function rename(arg) Daniel@0: Daniel@0: i=1; Daniel@0: while i <= length(arg) & arg(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: Daniel@0: arg2=arg(i+1:length(arg)); Daniel@0: arg=arg(1:i-1); Daniel@0: if ~isempty(arg2) Daniel@0: LOG=1; Daniel@0: i=1; Daniel@0: if arg2(1) ~= '{' Daniel@0: while i <= length(arg2) & arg2(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: index=str2num(arg2(i+1:length(arg2))); Daniel@0: arg2=arg2(1:i-1); Daniel@0: else Daniel@0: while i <= length(arg2) & arg2(i) ~= '}' Daniel@0: i=i+1; Daniel@0: end Daniel@0: index=str2num(arg2(i+1:length(arg2))); Daniel@0: arg2=arg2(1:i); Daniel@0: end Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: new_name_h=getfield(get(gcf,'UserData'),'new_name_h'); Daniel@0: new_c_name_h=getfield(get(gcf,'UserData'),'new_c_name_h'); Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess'' -figure does not exist. Terminating program...'); Daniel@0: close_preprocess; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: switch arg Daniel@0: case 'set' Daniel@0: if LOG Daniel@0: name={arg2}; Daniel@0: else Daniel@0: name=get(new_name_h,'String'); Daniel@0: end Daniel@0: if ~isempty(name{1}) & ~any(isspace(name{1})) Daniel@0: if ~isvalid_var_name(name) Daniel@0: sD_stats; Daniel@0: return; Daniel@0: end Daniel@0: if ~LOG Daniel@0: index=get(getfield(get(gcf,'UserData'),'sets_h'),'Value'); Daniel@0: end Daniel@0: data=get(pre_h,'UserData'); Daniel@0: tmp_set.name=name{1}; Daniel@0: data.sD_set(index).name=name{1}; Daniel@0: if data.sData.INDEX == index Daniel@0: data.sData.name=name{1}; Daniel@0: end Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Rename a data set.'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''rename'',''set ',... Daniel@0: name{1},' ',... Daniel@0: num2str(index),... Daniel@0: ''');'); Daniel@0: end Daniel@0: Daniel@0: set(pre_h,'UserData',data); Daniel@0: sD_names; Daniel@0: string=get(data.sD_set_h,'String'); Daniel@0: string{index}=cat(2,sprintf('#%d: ',index),name{1}); Daniel@0: set(data.sD_set_h,'String',string); Daniel@0: string=get(data.sD_name_h,'String'); Daniel@0: string{1}=cat(2,'Name: ',name{1}); Daniel@0: if index==data.sData.INDEX Daniel@0: set(data.sD_name_h,'String',string); Daniel@0: end Daniel@0: else Daniel@0: sD_stats; Daniel@0: end Daniel@0: case 'comp' Daniel@0: if ~LOG Daniel@0: names=get(new_c_name_h,'String'); Daniel@0: index=get(getfield(get(gcf,'UserData'),'sets_h'),'Value'); Daniel@0: else Daniel@0: names=eval(arg2); Daniel@0: end Daniel@0: if check_cell_names(names) Daniel@0: data=get(pre_h,'UserData'); Daniel@0: sData=data.sD_set(index); Daniel@0: if length(sData.comp_names)==length(names) Daniel@0: data.sD_set(index).comp_names=names; Daniel@0: if index == data.sData.INDEX Daniel@0: for i=1:length(names) Daniel@0: names{i}=cat(2,sprintf('#%d: ',i),names{i}); Daniel@0: end Daniel@0: set(data.comp_names_h,'String',names); Daniel@0: set(data.sel_comp_h,'String',names); Daniel@0: end Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Rename components.'; Daniel@0: str='preprocess(''rename'',''comp {'; Daniel@0: for i=1:length(names)-1 Daniel@0: str=cat(2,str,'''''',names{i},''''','); Daniel@0: end Daniel@0: str=cat(2,str,'''''',names{length(names)},'''''} ',... Daniel@0: num2str(index),''');'); Daniel@0: data.LOG{length(data.LOG)+1}=str; Daniel@0: else Daniel@0: set(new_c_name_h,'String',names); Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: else Daniel@0: errordlg('There are less components in data.'); Daniel@0: sD_stats; Daniel@0: return; Daniel@0: end Daniel@0: else Daniel@0: sD_stats; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%% Subfunction: check_cell_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function bool=check_cell_names(names) Daniel@0: Daniel@0: bool = 1; Daniel@0: Daniel@0: if isempty(names) Daniel@0: bool= 0; Daniel@0: return; Daniel@0: end Daniel@0: for i=1:length(names) Daniel@0: if isempty(names{i}) | isspace(names{i}) Daniel@0: bool = 0; Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: isvalid_var_name %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function bool=isvalid_var_name(name) Daniel@0: Daniel@0: bool=1; Daniel@0: Daniel@0: tmp=name{1}; Daniel@0: if ~((tmp(1)>='a' & tmp(1)<='z') | (tmp(1)>='A' & tmp(1)<='Z')) Daniel@0: errordlg('Invalid name.'); Daniel@0: bool=0; Daniel@0: return; Daniel@0: end Daniel@0: for j=1:length(tmp) Daniel@0: if ~((tmp(j)>='a' & tmp(j)<='z') | ... Daniel@0: (tmp(j)>='A' & tmp(j)<='Z') | ... Daniel@0: (j>1 & tmp(j) == '_') | ... Daniel@0: (tmp(j)>='0' & tmp(j) <= '9')) | tmp(j) == '.' Daniel@0: errordlg('Invalid name.'); Daniel@0: bool=0; Daniel@0: return; Daniel@0: end Daniel@0: if j == length(tmp) & tmp(j) == '_' Daniel@0: errordlg('Invalid name.'); Daniel@0: bool=0; Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: copy_delete %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function copy_delete(arg) Daniel@0: Daniel@0: i=1; Daniel@0: while i <= length(arg) & arg(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: Daniel@0: arg2=arg(i+1:length(arg)); Daniel@0: arg=arg(1:i-1); Daniel@0: Daniel@0: if ~isempty(arg2) Daniel@0: index=str2num(arg2); Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: sets_h=getfield(get(gcf,'UserData'),'sets_h'); Daniel@0: if ~LOG Daniel@0: index=get(sets_h,'Value'); Daniel@0: end Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess'' -figure does not exist. Terminating program.'); Daniel@0: close_preprocess; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: switch arg Daniel@0: case 'copy' Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.sD_set(length(data.sD_set)+1)=data.sD_set(index); Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Copy a data set.'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''copy_delete'',''',... Daniel@0: 'copy ',num2str(index),''');'); Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: sD_names; Daniel@0: old=gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: set_sD_stats; Daniel@0: set(0,'CurrentFigure',old); Daniel@0: case 'delete' Daniel@0: if length(get(sets_h,'String')) == 1 Daniel@0: msgbox('No data left. Closing program...') Daniel@0: close_preprocess; Daniel@0: return; Daniel@0: end Daniel@0: data=get(pre_h,'UserData'); Daniel@0: if ~isempty(data.undo) & any(strcmp('index',fieldnames(data.undo))) Daniel@0: if data.undo.index > index Daniel@0: data.undo.index = data.undo.index-1; Daniel@0: elseif data.undo.index==index; Daniel@0: data.undo=[]; Daniel@0: end Daniel@0: end Daniel@0: set1=data.sD_set(1:index-1); Daniel@0: set2=data.sD_set(index+1:length(data.sD_set)); Daniel@0: Daniel@0: if ~isempty(set1) Daniel@0: data.sD_set=[set1 set2]; Daniel@0: else Daniel@0: data.sD_set=set2; Daniel@0: end Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Delete a data set.'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''copy_delete'',''',... Daniel@0: 'delete ',num2str(index),''');'); Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: Daniel@0: set(sets_h,'Value',1); Daniel@0: sD_names; Daniel@0: sD_stats; Daniel@0: old = gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: Daniel@0: for i=1:length(data.sD_set) Daniel@0: string{i}=cat(2,sprintf('#%d: ',i),data.sD_set(i).name); Daniel@0: end Daniel@0: Daniel@0: set(data.sD_set_h,'String',string); Daniel@0: data.sData=data.sD_set(get(data.sD_set_h,'Value')); Daniel@0: data.sData.MODIFIED=0; Daniel@0: data.sData.INDEX=1; Daniel@0: set(gcf,'UserData',data); Daniel@0: write_sD_stats; Daniel@0: Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: if sData.INDEX > index Daniel@0: value=get(getfield(get(gcf,'UserData'),'sD_set_h'),'Value'); Daniel@0: set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',value-1); Daniel@0: sData.INDEX = sData.INDEX -1; Daniel@0: elseif sData.INDEX == index Daniel@0: set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',1); Daniel@0: end Daniel@0: Daniel@0: sel_sD; Daniel@0: set(0,'CurrentFigure',old); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function clipping(varargin) Daniel@0: Daniel@0: if nargin ~= 1 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: preh_udata=get(pre_h,'UserData'); Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}=... Daniel@0: '% Starting the ''Clipping'' -window...'; Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''clipping'',''foo'');'; Daniel@0: set(pre_h,'UserData',preh_udata); Daniel@0: end Daniel@0: Daniel@0: clip_h=findobj(get(0,'Children'),'Tag','Clipping'); Daniel@0: Daniel@0: if ~isempty(clip_h) Daniel@0: figure(clip_h); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: h0 = figure('Color',[0.8 0.8 0.8], ... Daniel@0: 'PaperPosition',[18 180 575 432], ... Daniel@0: 'PaperUnits','points', ... Daniel@0: 'Position',[718 389 300 249], ... Daniel@0: 'Tag','Clipping'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.03 0.03614457831325301 0.4666666666666667 0.9236947791164658], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.05333333333333334 0.5983935742971887 0.42 0.3333333333333333], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame2'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Style','frame', ... Daniel@0: 'Position',[0.05333333333333334 0.33 0.42 0.24], ... Daniel@0: 'Tag','Frame3'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Style','frame', ... Daniel@0: 'Position',[0.05333333333333334 0.06 0.42 0.24],... Daniel@0: 'Tag','Frame4'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5133333333333334 0.6385542168674698 0.4666666666666667 0.321285140562249], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame5'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5366666666666667 0.6666666666666666 0.42 0.2650602409638554], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame6'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.31 0.823293172690763 0.15 0.09638554216867469], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText1'); Daniel@0: Daniel@0: data.big_val_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.31 0.7148594377510039 0.15 0.09638554216867469], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText2'); Daniel@0: Daniel@0: data.small_val_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.31 0.606425702811245 0.15 0.09638554216867469], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText3'); Daniel@0: Daniel@0: data.equal_val_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.06000000000000001 0.8473895582329316 0.22 0.05622489959839357], ... Daniel@0: 'String','Bigger than', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText1'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.06000000000000001 0.7389558232931727 0.24 0.04819277108433735], ... Daniel@0: 'String','Smaller than', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText2'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.06000000000000001 0.610441767068273 0.22 0.07228915662650602], ... Daniel@0: 'String','Equal to', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText3'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.07000000000000001 0.465863453815261 0.06333333333333334 0.07228915662650602], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Value',1,... Daniel@0: 'Tag','Radiobutton1'); Daniel@0: Daniel@0: data.and_button_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.07000000000000001 0.3734939759036144 0.06333333333333334 0.07228915662650602], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton2'); Daniel@0: Daniel@0: data.or_button_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'Position',[0.1466666666666667 0.45 0.2333333333333333 0.07228915662650602], ... Daniel@0: 'String','AND', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText4'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'String','OR', ... Daniel@0: 'Position',[0.1466666666666667 0.35 0.2333333333333333 0.07228915662650602], ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText5'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.07000000000000001 0.1967871485943775 0.06333333333333334 0.07228915662650602], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Value',1,... Daniel@0: 'Tag','Radiobutton3'); Daniel@0: Daniel@0: data.all_button_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.07000000000000001 0.09236947791164658 0.06333333333333334 0.07228915662650602], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton4'); Daniel@0: Daniel@0: data.sel_vects_button_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1466666666666667 0.1927710843373494 0.2333333333333333 0.07228915662650602], ... Daniel@0: 'String','All vectors', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText6'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1466666666666667 0.09638554216867469 0.3133333333333334 0.05622489959839357], ... Daniel@0: 'String','Among selected', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText7'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.7866666666666667 0.823293172690763 0.1366666666666667 0.09236947791164658], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText4'); Daniel@0: Daniel@0: data.replace_val_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',6, ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5633333333333334 0.8273092369477911 0.2066666666666667 0.07630522088353413], ... Daniel@0: 'String','Replace', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText8'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5700000000000001 0.6827309236947791 0.3566666666666667 0.08032128514056225], ... Daniel@0: 'String','Replace', ... Daniel@0: 'Tag','Pushbutton1'); Daniel@0: Daniel@0: data.OK_button_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess close_c',... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.6633333333333333 0.07228915662650602 0.2833333333333333 0.09638554216867469], ... Daniel@0: 'String','Close', ... Daniel@0: 'Tag','Pushbutton2'); Daniel@0: Daniel@0: Daniel@0: data.state.and=1; Daniel@0: data.state.all=1; Daniel@0: data.state.big=[]; Daniel@0: data.state.small=[]; Daniel@0: data.state.equal=[]; Daniel@0: data.state.replace=[]; Daniel@0: Daniel@0: set(data.or_button_h,'Callback','preprocess and_or_cb or'); Daniel@0: set(data.and_button_h,'Callback','preprocess and_or_cb and'); Daniel@0: set(data.and_button_h,'Value',1); Daniel@0: set(data.all_button_h,'Callback','preprocess all_sel_cb all'); Daniel@0: set(data.sel_vects_button_h,'Callback','preprocess all_sel_cb sel'); Daniel@0: set(data.big_val_h,'Callback','preprocess set_state_vals big'); Daniel@0: set(data.small_val_h,'Callback','preprocess set_state_vals small'); Daniel@0: set(data.equal_val_h,'Callback','preprocess set_state_vals equal'); Daniel@0: set(data.replace_val_h,'Callback','preprocess set_state_vals replace'); Daniel@0: set(data.OK_button_h,'Callback','preprocess clip_data clip'); Daniel@0: set(h0,'UserData',data); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function select(varargin) Daniel@0: Daniel@0: if nargin ~= 1 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: preh_udata=get(pre_h,'UserData'); Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}=... Daniel@0: '% Starting the ''Select'' -window...'; Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''select'',''foo'');'; Daniel@0: set(pre_h,'UserData',preh_udata); Daniel@0: end Daniel@0: Daniel@0: sel_h=findobj(get(0,'Children'),'Tag','Select'); Daniel@0: Daniel@0: if ~isempty(sel_h) Daniel@0: figure(sel_h); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: h0 = figure('Color',[0.8 0.8 0.8], ... Daniel@0: 'PaperPosition',[18 180 576 432], ... Daniel@0: 'PaperUnits','points', ... Daniel@0: 'Position',[750 431 168 365], ... Daniel@0: 'Tag','Select'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.05357142857142857 0.2712328767123288 0.8333333333333333 0.6301369863013698], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.05357142857142857 0.1041095890410959 0.8333333333333333 0.1397260273972603], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame2'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0,... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.09523809523809523 0.6547945205479452 0.75 0.2273972602739726], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame3'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.09523809523809523 0.4794520547945206 0.75 0.1506849315068493], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame4'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.09523809523809523 0.2986301369863014 0.75 0.1506849315068493], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame5'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5535714285714285 0.8082191780821918 0.2678571428571429 0.06575342465753425], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText1'); Daniel@0: Daniel@0: data.big_val_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5535714285714285 0.7342465753424657 0.2678571428571429 0.06575342465753425], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText2'); Daniel@0: Daniel@0: data.small_val_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5535714285714285 0.6602739726027397 0.2678571428571429 0.06575342465753425], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText3'); Daniel@0: Daniel@0: data.equal_val_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1071 0.8247 0.3929 0.0384], ... Daniel@0: 'String','Bigger than', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1071 0.7507 0.4286 0.0329], ... Daniel@0: 'String','Smaller than', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText2'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1071 0.6630 0.3929 0.0493], ... Daniel@0: 'String','Equal to', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText3'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.125 0.5643835616438356 0.1130952380952381 0.04931506849315068], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton1'); Daniel@0: Daniel@0: data.and_button_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.125 0.5013698630136987 0.1130952380952381 0.04931506849315068], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton2'); Daniel@0: Daniel@0: data.or_button_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.2619047619047619 0.5561643835616439 0.3809523809523809 0.05205479452054795], ... Daniel@0: 'String','AND', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText4'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.2619047619047619 0.4986301369863014 0.3809523809523809 0.04657534246575343], ... Daniel@0: 'String','OR', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText5'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.125 0.3808219178082192 0.1130952380952381 0.04931506849315068], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton3'); Daniel@0: Daniel@0: data.all_button_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.125 0.3095890410958904 0.1130952380952381 0.04931506849315068], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton4'); Daniel@0: Daniel@0: data.sel_vects_button_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.2619047619047619 0.3780821917808219 0.4166666666666666 0.04931506849315068], ... Daniel@0: 'String','All vectors', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText6'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.2619047619047619 0.3123287671232877 0.5595238095238095 0.03835616438356165], ... Daniel@0: 'String','Among selected', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText7'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.0952 0.1178 0.7500 0.1068], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame6'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5298 0.1342 0.2738 0.0712], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText4'); Daniel@0: Daniel@0: data.replace_val_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontSize',8,... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1369047619047619 0.136986301369863 0.3214285714285714 0.06027397260273973], ... Daniel@0: 'String','Vectors', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText8'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.05357142857142857 0.01917808219178082 0.3869047619047619 0.0684931506849315], ... Daniel@0: 'String','OK', ... Daniel@0: 'Tag','Pushbutton1'); Daniel@0: Daniel@0: data.OK_button_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'Callback','preprocess close_s',... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5 0.01917808219178082 0.3869047619047619 0.0684931506849315], ... Daniel@0: 'String','Close', ... Daniel@0: 'Tag','Pushbutton2'); Daniel@0: Daniel@0: Daniel@0: Daniel@0: data.state.and=1; Daniel@0: data.state.all=1; Daniel@0: data.state.big=[]; Daniel@0: data.state.small=[]; Daniel@0: data.state.equal=[]; Daniel@0: data.state.replace=[]; Daniel@0: Daniel@0: set(data.or_button_h,'Callback','preprocess and_or_cb or'); Daniel@0: set(data.and_button_h,'Callback','preprocess and_or_cb and'); Daniel@0: set(data.and_button_h,'Value',1); Daniel@0: set(data.all_button_h,'Callback','preprocess all_sel_cb all'); Daniel@0: set(data.sel_vects_button_h,'Callback','preprocess all_sel_cb sel'); Daniel@0: set(data.big_val_h,'Callback','preprocess set_state_vals big'); Daniel@0: set(data.small_val_h,'Callback','preprocess set_state_vals small'); Daniel@0: set(data.equal_val_h,'Callback','preprocess set_state_vals equal'); Daniel@0: set(data.replace_val_h,'Callback','preprocess set_state_vals replace'); Daniel@0: set(data.OK_button_h,'Callback','preprocess clip_data sel'); Daniel@0: set(h0,'UserData',data); Daniel@0: Daniel@0: Daniel@0: Daniel@0: %%% Subfunction: and_or_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function and_or_cb(arg) Daniel@0: Daniel@0: %AND_OR_CB A callback function. Checks that only one of the radiobox Daniel@0: % buttons 'AND' and 'OR' is pressed down. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: and_button_h=getfield(get(gcf,'UserData'),'and_button_h'); Daniel@0: or_button_h=getfield(get(gcf,'UserData'),'or_button_h'); Daniel@0: data=get(gcf,'UserData'); Daniel@0: Daniel@0: switch arg Daniel@0: case 'or' Daniel@0: set(and_button_h,'Value',0); Daniel@0: set(or_button_h,'Value',1); Daniel@0: data.state.and=0; Daniel@0: case 'and' Daniel@0: set(or_button_h,'Value',0); Daniel@0: set(and_button_h,'Value',1); Daniel@0: data.state.and=1; Daniel@0: end Daniel@0: Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: all_sel_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function all_sel_cb(arg) Daniel@0: Daniel@0: all_button_h=getfield(get(gcf,'UserData'),'all_button_h'); Daniel@0: sel_vects_button_h=getfield(get(gcf,'UserData'),'sel_vects_button_h'); Daniel@0: data=get(gcf,'UserData'); Daniel@0: Daniel@0: switch arg Daniel@0: case 'all' Daniel@0: set(sel_vects_button_h,'Value',0); Daniel@0: set(all_button_h,'Value',1); Daniel@0: data.state.all=1; Daniel@0: case 'sel' Daniel@0: set(all_button_h,'Value',0); Daniel@0: set(sel_vects_button_h,'Value',1); Daniel@0: data.state.all=0; Daniel@0: end Daniel@0: Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: %%% Subfunction: set_state_vals %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function set_state_vals(arg) Daniel@0: Daniel@0: %SET_STATE_VALS sets the values to the UserData's state-struct. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: Daniel@0: switch arg Daniel@0: case 'big' Daniel@0: big_val_h=getfield(get(gcf,'UserData'),'big_val_h'); Daniel@0: val =str2num(get(big_val_h,'String')); Daniel@0: dims=size(val); Daniel@0: if dims(1) ~= 1 | dims(2) ~= 1 Daniel@0: errordlg('Argument of the operation must be scalar.'); Daniel@0: set(big_val_h,'String',''); Daniel@0: return; Daniel@0: end Daniel@0: if isreal(val) Daniel@0: data.state.big=val; Daniel@0: else Daniel@0: errordlg('Limits of the operation must be real.'); Daniel@0: set(big_val_h,'String',''); Daniel@0: return; Daniel@0: end Daniel@0: case 'small' Daniel@0: small_val_h=getfield(get(gcf,'UserData'),'small_val_h'); Daniel@0: val=str2num(get(small_val_h,'String')); Daniel@0: dims=size(val); Daniel@0: if dims(1) ~= 1 | dims(2) ~= 1 Daniel@0: errordlg('Argument of the operation must be scalar.') Daniel@0: set(small_val_h,'String',''); Daniel@0: return; Daniel@0: end Daniel@0: if isreal(val) Daniel@0: data.state.small=val; Daniel@0: else Daniel@0: errordlg('Limits of the operation must be real.'); Daniel@0: set(small_val_h,'String',''); Daniel@0: return; Daniel@0: end Daniel@0: case 'equal' Daniel@0: equal_val_h=getfield(get(gcf,'UserData'),'equal_val_h'); Daniel@0: val = str2num(get(equal_val_h,'String')); Daniel@0: dims=size(val); Daniel@0: if dims(1) ~= 1 | dims(2) ~= 1 Daniel@0: errordlg('Argument of the operation must be scalar.'); Daniel@0: set(equal_val_h,'String',''); Daniel@0: return; Daniel@0: end Daniel@0: if isreal(val) Daniel@0: data.state.equal=val; Daniel@0: else Daniel@0: errordlg('Limits of the operation must be real.'); Daniel@0: set(equal_val_h,'String',''); Daniel@0: return; Daniel@0: end Daniel@0: case 'replace' Daniel@0: replace_val_h=getfield(get(gcf,'UserData'),'replace_val_h'); Daniel@0: val=str2num(get(replace_val_h,'String')); Daniel@0: dims=size(val); Daniel@0: if (dims(1) ~= 1 | dims(2) ~= 1) & ~strcmp(get(gcf,'Tag'),'Select') Daniel@0: errordlg('Argument of the operation must be scalar.'); Daniel@0: set(replace_val_h,'String',''); Daniel@0: return; Daniel@0: end Daniel@0: if isreal(val) Daniel@0: data.state.replace=val; Daniel@0: else Daniel@0: errordlg('Limits of the operation must be real.'); Daniel@0: set(replace_val_h,'String',''); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: clip_data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function clip_data(arg) Daniel@0: Daniel@0: %CLIP_DATA A callback function. Filters the data. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: i=1; Daniel@0: while i <= length(arg) & arg(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: Daniel@0: arg2=arg(i+1:length(arg)); Daniel@0: arg=arg(1:i-1); Daniel@0: Daniel@0: if ~isempty(arg2) Daniel@0: LOG=1; Daniel@0: if strcmp(arg,'sel') Daniel@0: c_h=findobj(get(0,'Children'),'Tag','Select'); Daniel@0: else Daniel@0: c_h=findobj(get(0,'Children'),'Tag','Clipping'); Daniel@0: end Daniel@0: set(0,'CurrentFigure',c_h); Daniel@0: i=1; Daniel@0: while i <= length(arg2) & arg2(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: BT=str2num(arg2(1:i-1)); Daniel@0: i=i+1; Daniel@0: j=i; Daniel@0: while i <= length(arg2) & arg2(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: ST=str2num(arg2(j:i-1)); Daniel@0: i=i+1; Daniel@0: j=i; Daniel@0: while i <= length(arg2) & arg2(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: EQ=str2num(arg2(j:i-1)); Daniel@0: i=i+1; Daniel@0: j=i; Daniel@0: while i <= length(arg2) & arg2(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: AND_OR=str2num(arg2(j:i-1)); Daniel@0: i=i+1; Daniel@0: j=i; Daniel@0: while i <= length(arg2) & arg2(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: ALL_AMONG=str2num(arg2(j:i-1)); Daniel@0: i=i+1; Daniel@0: j=i; Daniel@0: while i <= length(arg2) Daniel@0: i=i+1; Daniel@0: end Daniel@0: VECT_REPL=str2num(arg2(j:i-1)); Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: if ~LOG Daniel@0: big_val_h=getfield(get(gcf,'UserData'),'big_val_h'); Daniel@0: small_val_h=getfield(get(gcf,'UserData'),'small_val_h'); Daniel@0: equal_val_h=getfield(get(gcf,'UserData'),'equal_val_h'); Daniel@0: replace_val_h=getfield(get(gcf,'UserData'),'replace_val_h'); Daniel@0: end Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess'' -figure does not exist. Terminating program...'); Daniel@0: pro_tools('close'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); Daniel@0: selected=getfield(get(pre_h,'UserData'),'selected_vects'); Daniel@0: sData=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: undo = sData; Daniel@0: state=getfield(get(gcf,'UserData'),'state'); Daniel@0: Daniel@0: if LOG Daniel@0: state.big=BT; Daniel@0: state.small=ST; Daniel@0: state.equal=EQ; Daniel@0: state.replace=VECT_REPL; Daniel@0: state.and=AND_OR; Daniel@0: state.all=ALL_AMONG; Daniel@0: end Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: pro_tools('close'); Daniel@0: end Daniel@0: Daniel@0: if isempty(get(comp_names_h,'Value')) Daniel@0: clear_state_vals; Daniel@0: errordlg('There must be one component chosen for the operation.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: n_th_comp=getfield(get_indices,{1}); Daniel@0: Daniel@0: if isempty(state.big) & isempty(state.small) & isempty(state.equal) & ... Daniel@0: strcmp(arg,'clip') Daniel@0: clear_state_vals; Daniel@0: errordlg('At least one limit must be chosen for the-operation.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if ~isempty(state.replace) & strcmp(arg,'sel') Daniel@0: if ~all(state.replace == round(state.replace)) | any(state.replace < 1) Daniel@0: errordlg('Indices of vectors must be positive integers.'); Daniel@0: return; Daniel@0: elseif any(state.replace > length(sData.data(:,1))) Daniel@0: errordlg('Indices of the vectors to be selected are too big.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if isempty(state.replace) & strcmp(arg,'clip') Daniel@0: clear_state_vals; Daniel@0: errordlg('Replace value must be determined for Clipping-operation.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if isempty(state.big) & isempty(state.small) & isempty(state.equal) & ... Daniel@0: isempty(state.replace) Daniel@0: clear_state_vals; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: bt_indices=[]; Daniel@0: lt_indices=[]; Daniel@0: equal_indices=[]; Daniel@0: Daniel@0: Daniel@0: if ~isempty(state.big) Daniel@0: if state.all Daniel@0: bt_indices=find(sData.data(:,n_th_comp) > state.big); Daniel@0: else Daniel@0: bt_indices=selected(find(sData.data(selected,n_th_comp) > state.big)); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if ~isempty(state.small) Daniel@0: if state.all Daniel@0: lt_indices=find(sData.data(:,n_th_comp) < state.small); Daniel@0: else Daniel@0: lt_indices=selected(find(sData.data(selected,n_th_comp) < state.small)); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if ~isempty(state.equal) Daniel@0: if isnan(state.equal) Daniel@0: if state.all Daniel@0: equal_indices=find(isnan(sData.data(:,n_th_comp))); Daniel@0: else Daniel@0: equal_indices=selected(find(isnan(sData.data(selected,n_th_comp)))); Daniel@0: end Daniel@0: elseif state.all Daniel@0: equal_indices=find(sData.data(:,n_th_comp)==state.equal); Daniel@0: else Daniel@0: equal_indices=selected(find(sData.data(selected,n_th_comp)==state.equal)); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if state.and Daniel@0: Daniel@0: if ~isempty(bt_indices) | ~isempty(lt_indices) | ~isempty(equal_indices)... Daniel@0: | strcmp(arg,'sel') Daniel@0: Daniel@0: if isempty(bt_indices) & isempty(lt_indices) & isempty(equal_indices) &... Daniel@0: isempty(state.replace) Daniel@0: clear_state_vals; Daniel@0: return; Daniel@0: end Daniel@0: if isempty(bt_indices) Daniel@0: if ~state.all Daniel@0: bt_indices=selected; Daniel@0: else Daniel@0: bt_indices=1:getfield(size(sData.data),{1}); Daniel@0: end Daniel@0: end Daniel@0: if isempty(lt_indices) Daniel@0: if ~state.all Daniel@0: lt_indices=selected; Daniel@0: else Daniel@0: lt_indices=1:getfield(size(sData.data),{1}); Daniel@0: end Daniel@0: end Daniel@0: if isempty(equal_indices) Daniel@0: if ~state.all Daniel@0: equal_indices=selected; Daniel@0: else Daniel@0: equal_indices=1:getfield(size(sData.data),{1}); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: indices=intersect(intersect(bt_indices,lt_indices),equal_indices); Daniel@0: if strcmp(arg,'sel') Daniel@0: if ~isempty(indices) | ~isempty(state.replace) Daniel@0: if isempty(state.replace) Daniel@0: NOTEMPTY=0; Daniel@0: if ~state.all Daniel@0: state.replace=selected; Daniel@0: else Daniel@0: state.replace=1:getfield(size(sData.data),{1}); Daniel@0: end Daniel@0: else Daniel@0: NOTEMPTY=1; Daniel@0: end Daniel@0: if isempty(indices) Daniel@0: indices=selected; Daniel@0: end Daniel@0: indices=intersect(indices,state.replace); Daniel@0: if isempty(indices) Daniel@0: indices=selected; Daniel@0: end Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.undo.sData=sData; Daniel@0: data.undo.selected=data.selected_vects; Daniel@0: data.selected_vects=indices; Daniel@0: if ~LOG Daniel@0: if ~NOTEMPTY Daniel@0: data.LOG{length(data.LOG)+1}='% Select vectors.'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',... Daniel@0: arg,... Daniel@0: ' ',num2str(state.big),... Daniel@0: ' ',num2str(state.small),... Daniel@0: ' ',num2str(state.equal),... Daniel@0: ' ',num2str(state.and),... Daniel@0: ' ',num2str(state.all),... Daniel@0: ''');'); Daniel@0: else Daniel@0: code=write_log_code(state.replace,... Daniel@0: arg,... Daniel@0: state.big,... Daniel@0: state.small,... Daniel@0: state.equal,... Daniel@0: state.and,... Daniel@0: state.all); Daniel@0: data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code; Daniel@0: end Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: old=gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: sel_comp; Daniel@0: cplot_mimema; Daniel@0: vect_means(data.sData,data.vect_mean_h,data.selected_vects); Daniel@0: set(0,'CurrentFigure',old); Daniel@0: end Daniel@0: clear_state_vals; Daniel@0: return; Daniel@0: end Daniel@0: sData.data(indices,n_th_comp) = state.replace; Daniel@0: sData.MODIFIED=1; Daniel@0: end Daniel@0: else Daniel@0: indices=union(union(bt_indices,lt_indices),equal_indices); Daniel@0: if ~isempty(indices) | strcmp(arg,'sel') Daniel@0: if strcmp(arg,'sel') Daniel@0: if ~isempty(indices) | ~isempty(state.replace') Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.undo.sData=sData; Daniel@0: data.undo.selected=data.selected_vects; Daniel@0: data.selected_vects=union(indices,state.replace); Daniel@0: if ~LOG Daniel@0: if isempty(state.replace); Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',... Daniel@0: arg,... Daniel@0: ' ',num2str(state.big),... Daniel@0: ' ',num2str(state.small),... Daniel@0: ' ',num2str(state.equal),... Daniel@0: ' ',num2str(state.and),... Daniel@0: ' ',num2str(state.all),... Daniel@0: ''');'); Daniel@0: else Daniel@0: code=write_log_code(state.replace,... Daniel@0: arg,... Daniel@0: state.big,... Daniel@0: state.small,... Daniel@0: state.equal,... Daniel@0: state.and,... Daniel@0: state.all); Daniel@0: data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code; Daniel@0: end Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: old=gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: sel_comp; Daniel@0: vect_means(data.sData,data.vect_mean_h,data.selected_vects); Daniel@0: cplot_mimema; Daniel@0: set(0,'CurrentFigure',old); Daniel@0: end Daniel@0: clear_state_vals; Daniel@0: return; Daniel@0: end Daniel@0: sData.data(indices,n_th_comp)=state.replace; Daniel@0: sData.MODIFIED=1; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if sData.MODIFIED Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: if strcmp(arg,'sel') Daniel@0: data.LOG{length(data.LOG)+1}='% Select vectors'; Daniel@0: else Daniel@0: data.LOG{length(data.LOG)+1}='% Clip values.'; Daniel@0: end Daniel@0: if strcmp(arg,'clip') | isempty(state.replace) Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',arg,... Daniel@0: ' ',num2str(state.big),... Daniel@0: ' ',num2str(state.small),... Daniel@0: ' ',num2str(state.equal),... Daniel@0: ' ',num2str(state.and),... Daniel@0: ' ',num2str(state.all),... Daniel@0: ' ',num2str(state.replace),... Daniel@0: ''');'); Daniel@0: else Daniel@0: code=write_log_code(state.replace,... Daniel@0: arg,... Daniel@0: state.big,... Daniel@0: state.small,... Daniel@0: state.equal,... Daniel@0: state.and,... Daniel@0: state.all); Daniel@0: data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code; Daniel@0: end Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: old=gcf; Daniel@0: set(0,'CurrentFigure',pre_h) Daniel@0: Daniel@0: vector_h=getfield(get(gcf,'UserData'),'vector_h'); Daniel@0: vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: set(gcf,'CurrentAxes',vector_h); Daniel@0: vect_means(sData,vect_mean_h,selected); Daniel@0: cplot_mimema; Daniel@0: sel_comp; Daniel@0: Daniel@0: set(0,'CurrentFigure',old); Daniel@0: end Daniel@0: Daniel@0: clear_state_vals; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: clear_state_vals %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function clear_state_vals Daniel@0: Daniel@0: %CLEAR_STATE_VALS Sets the fields of the UserData's state-struct empty. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: set(data.big_val_h,'String',''); Daniel@0: set(data.small_val_h,'String',''); Daniel@0: set(data.equal_val_h,'String',''); Daniel@0: set(data.replace_val_h,'String',''); Daniel@0: data.state.big=[]; Daniel@0: data.state.small=[]; Daniel@0: data.state.equal=[]; Daniel@0: data.state.replace=[]; Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function delay(varargin) Daniel@0: Daniel@0: delay_h=findobj(get(0,'Children'),'Tag','Delay'); Daniel@0: Daniel@0: if nargin ~= 1 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: preh_udata=get(pre_h,'UserData'); Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}=... Daniel@0: '% Starting the ''Delay'' -window...'; Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''delay'',''foo'');'; Daniel@0: set(pre_h,'UserData',preh_udata); Daniel@0: end Daniel@0: Daniel@0: if ~isempty(delay_h) Daniel@0: figure(delay_h); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: h0 = figure('Color',[0.8 0.8 0.8], ... Daniel@0: 'PaperPosition',[18 180 576 432], ... Daniel@0: 'PaperUnits','points', ... Daniel@0: 'Position',[759 664 162 215], ... Daniel@0: 'Tag','Delay'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.05555555555555555 0.2046511627906977 0.8950617283950617 0.7441860465116279], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.08641975308641975 0.6976744186046512 0.8333333333333333 0.2232558139534884], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame2'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.08641975308641975 0.227906976744186 0.8333333333333333 0.4418604651162791], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame3'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','preprocess delay_data',... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.0556 0.0326 0.4012 0.1163], ... Daniel@0: 'String','OK', ... Daniel@0: 'Tag','Pushbutton1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','preprocess close_d',... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.5494 0.0326 0.4012 0.1163], ... Daniel@0: 'String','Close', ... Daniel@0: 'Tag','Pushbutton2'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.4876543209876543 0.7534883720930232 0.3518518518518519 0.1255813953488372], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText1'); Daniel@0: Daniel@0: data.delay_val_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1173 0.7860 0.3086 0.0651], ... Daniel@0: 'String','Delay', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','preprocess clip_exp_cb c_this',... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1173 0.5349 0.1173 0.0837], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton1'); Daniel@0: Daniel@0: data.c_this_button_h=h1; Daniel@0: data.mode='c_this'; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess clip_exp_cb c_all',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1173 0.4047 0.1173 0.0837], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton2'); Daniel@0: Daniel@0: data.c_all_button_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess clip_exp_cb e_all',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.1173 0.2651 0.1173 0.0837], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton3'); Daniel@0: Daniel@0: data.e_all_button_h=h1; Daniel@0: Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.26 0.5534883720930233 0.4135802469135802 0.06511627906976744], ... Daniel@0: 'String','Clip this', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText2'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.26 0.413953488372093 0.3765432098765432 0.06511627906976744], ... Daniel@0: 'String','Clip all', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText3'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.26 0.2744186046511628 0.4197530864197531 0.06511627906976744], ... Daniel@0: 'String','Expand all', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText4'); Daniel@0: Daniel@0: Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: %%% Subfunction clip_exp_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function clip_exp_cb(arg) Daniel@0: Daniel@0: c_this_button_h=getfield(get(gcf,'UserData'),'c_this_button_h'); Daniel@0: c_all_button_h=getfield(get(gcf,'UserData'),'c_all_button_h'); Daniel@0: e_all_button_h=getfield(get(gcf,'UserData'),'e_all_button_h'); Daniel@0: data=get(gcf,'UserData'); Daniel@0: Daniel@0: Daniel@0: switch arg Daniel@0: case 'c_this' Daniel@0: set(c_all_button_h,'Value',0); Daniel@0: set(e_all_button_h,'Value',0); Daniel@0: set(c_this_button_h,'Value',1); Daniel@0: data.mode='c_this'; Daniel@0: case 'c_all' Daniel@0: set(c_this_button_h,'Value',0); Daniel@0: set(e_all_button_h,'Value',0); Daniel@0: set(c_all_button_h,'Value',1); Daniel@0: data.mode='c_all'; Daniel@0: case 'e_all' Daniel@0: set(c_this_button_h,'Value',0); Daniel@0: set(c_all_button_h,'Value',0); Daniel@0: set(e_all_button_h,'Value',1); Daniel@0: data.mode='e_all'; Daniel@0: end Daniel@0: Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: %%% Subfunction: delay_data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function delay_data(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: del_h=findobj(get(0,'Children'),'Tag','Delay'); Daniel@0: set(0,'CurrentFigure',del_h); Daniel@0: LOG=1; Daniel@0: arg=varargin{1}; Daniel@0: i=1; Daniel@0: while i <= length(arg) & arg(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: delay=str2num(arg(1:i-1)); Daniel@0: no=str2num(arg(i+1:length(arg))); Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: q='Delay operation is not evaluated.'; Daniel@0: t='Warning'; Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess'' -figure does not exist. Terminating program...'); Daniel@0: pro_tools('close'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: sData=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: undo = sData; Daniel@0: data=get(gcf,'UserData'); Daniel@0: if ~LOG Daniel@0: delay=str2num(get(data.delay_val_h,'String')); Daniel@0: if isempty(delay) Daniel@0: errordlg('Value of ''Delay'' must be defined.'); Daniel@0: return Daniel@0: end Daniel@0: set(data.delay_val_h,'String',''); Daniel@0: if round(delay) ~= delay Daniel@0: errordlg('Value of ''Delay'' must be integer.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); Daniel@0: if isempty(get(comp_names_h,'Value')) Daniel@0: errordlg('There are not components chosen.'); Daniel@0: return; Daniel@0: end Daniel@0: n_th_comp=getfield(get_indices,{1}); Daniel@0: len=length(sData.data(:,1)); Daniel@0: Daniel@0: if LOG Daniel@0: switch no Daniel@0: case 1 Daniel@0: data.mode='c_this'; Daniel@0: preprocess('clip_exp_cb','c_this'); Daniel@0: case 2 Daniel@0: data.mode='c_all'; Daniel@0: preprocess('clip_exp_cb','c_all'); Daniel@0: case 3 Daniel@0: data.mode='e_all'; Daniel@0: preprocess('clip_exp_cb','e_all'); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: switch data.mode Daniel@0: case 'c_this' Daniel@0: MODE='1'; Daniel@0: if delay > 0 Daniel@0: sData.data(delay+1:len,n_th_comp)=sData.data(1:len-delay); Daniel@0: if delay >= len Daniel@0: errordlg(q,t); Daniel@0: return; Daniel@0: else Daniel@0: sData.data(1:delay,n_th_comp)=NaN; Daniel@0: end Daniel@0: elseif delay < 0 Daniel@0: sData.data(1:len+delay,n_th_comp)=... Daniel@0: sData.data(abs(delay)+1:len,n_th_comp); Daniel@0: if abs(delay) >= len Daniel@0: errordlg(q,t); Daniel@0: return; Daniel@0: else Daniel@0: sData.data(len+delay+1:len,n_th_comp)=NaN; Daniel@0: end Daniel@0: end Daniel@0: if delay ~= 0 Daniel@0: data=get(pre_h,'UserData'); Daniel@0: sData.MODIFIED=1; Daniel@0: sData.comp_norm(n_th_comp)=[]; Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: set(pre_h,'UserData',data); Daniel@0: old = gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: sel_comp; Daniel@0: cplot_mimema; Daniel@0: set(0,'CurrentFigure',old); Daniel@0: end Daniel@0: case 'c_all' Daniel@0: MODE='2'; Daniel@0: if delay > 0 Daniel@0: sData.data(delay+1:len,n_th_comp)=sData.data(1:len-delay,n_th_comp); Daniel@0: if delay >= len Daniel@0: errordlg(q,t); Daniel@0: return; Daniel@0: else Daniel@0: sData.data=sData.data(delay+1:len,:); Daniel@0: end Daniel@0: elseif delay < 0 Daniel@0: sData.data(1:len+delay,n_th_comp)=sData.data(abs(delay)+1:len,n_th_comp); Daniel@0: if abs(delay) >= len Daniel@0: errordlg(q,t); Daniel@0: return; Daniel@0: else Daniel@0: sData.data=sData.data(1:len+delay,:); Daniel@0: end Daniel@0: end Daniel@0: if delay ~= 0 Daniel@0: data=get(pre_h,'UserData'); Daniel@0: sData.MODIFIED=1; Daniel@0: sData.comp_norm(:,:)={[]}; Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: data.undo.selected=data.selected_vects; Daniel@0: if delay > 0 Daniel@0: data.selected_vects=... Daniel@0: data.selected_vects(find(data.selected_vects>delay)); Daniel@0: data.selected_vects=data.selected_vects-delay; Daniel@0: elseif nargin == 1 Daniel@0: data.selected_vects=... Daniel@0: data.selected_vects(find(data.selected_vects<=len-abs(delay))); Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: old=gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: vects=zeros(1,length(sData.data(:,1))); Daniel@0: vects(data.selected_vects)=1; Daniel@0: write_sD_stats; Daniel@0: draw_vectors(vects,data.vector_h); Daniel@0: sel_comp; Daniel@0: cplot_mimema; Daniel@0: set(0,'CurrentFigure',old); Daniel@0: end Daniel@0: case 'e_all' Daniel@0: MODE='3'; Daniel@0: if delay > 0 Daniel@0: sData.data(len+1:len+delay,:)=NaN; Daniel@0: sData.data(1+delay:delay+len,n_th_comp)=sData.data(1:len,n_th_comp); Daniel@0: sData.data(1:delay,n_th_comp)=NaN; Daniel@0: elseif delay < 0 Daniel@0: delay=abs(delay); Daniel@0: sData.data(delay+1:len+delay,:)=sData.data; Daniel@0: sData.data(1:delay,:)=NaN; Daniel@0: sData.data(1:len,n_th_comp)=sData.data(delay+1:len+delay,n_th_comp); Daniel@0: sData.data(len+1:len+delay,n_th_comp)=NaN; Daniel@0: end Daniel@0: if delay ~= 0 Daniel@0: data=get(pre_h,'UserData'); Daniel@0: sData.MODIFIED=1; Daniel@0: sData.comp_norm(:,:)={[]}; Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: data.undo.selected=data.selected_vects; Daniel@0: set(pre_h,'UserData',data); Daniel@0: old=gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: write_sD_stats; Daniel@0: pro_tools('selall'); Daniel@0: set(0,'CurrentFigure',old); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if ~LOG Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Delay a component.'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''delay_data'',''',... Daniel@0: num2str(delay),' ',MODE,''');'); Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function window(varargin) Daniel@0: Daniel@0: if nargin ~= 1 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: preh_udata=get(pre_h,'UserData'); Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}=... Daniel@0: '% Starting the ''Windowed'' -window...'; Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''window'',''foo'');'; Daniel@0: set(pre_h,'UserData',preh_udata); Daniel@0: end Daniel@0: Daniel@0: win_h=findobj(get(0,'Children'),'Tag','Window'); Daniel@0: Daniel@0: if ~isempty(win_h) Daniel@0: figure(win_h); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: h0 = figure('Color',[0.8 0.8 0.8], ... Daniel@0: 'PaperPosition',[18 180 576 432], ... Daniel@0: 'PaperUnits','points', ... Daniel@0: 'Position',[513 703 288 219], ... Daniel@0: 'Tag','Window'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.03125 0.1552511415525114 0.9375 0.7990867579908676], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame1'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.04861111111111111 0.7214611872146118 0.9027777777777777 0.2009132420091324], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame2'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.04861111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame3'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.3611111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame4'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.6736111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ... Daniel@0: 'Style','frame', ... Daniel@0: 'Tag','Frame5'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Callback','preprocess eval_windowed',... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.03125 0.0319634703196347 0.2256944444444444 0.091324200913242], ... Daniel@0: 'String','OK', ... Daniel@0: 'Tag','Pushbutton1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Callback','preprocess close_w', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.7430555555555555 0.0319634703196347 0.2256944444444444 0.091324200913242], ... Daniel@0: 'String','Close', ... Daniel@0: 'Tag','Pushbutton2'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[1 1 1], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.7083333333333333 0.7625570776255708 0.2083333333333333 0.1232876712328767], ... Daniel@0: 'Style','edit', ... Daniel@0: 'Tag','EditText1'); Daniel@0: Daniel@0: data.win_len_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.07638888888888888 0.8036529680365296 0.3784722222222222 0.0547945205479452], ... Daniel@0: 'String','Window length', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText1'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess window_cb centered',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.06597222222222222 0.5616438356164384 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton1'); Daniel@0: Daniel@0: data.centered_h=h1; Daniel@0: data.position='center'; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess window_cb previous',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.06597222222222222 0.4018264840182648 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton2'); Daniel@0: Daniel@0: data.previous_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess window_cb next',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.06597222222222222 0.2465753424657534 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton3'); Daniel@0: Daniel@0: data.next_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess window_cb mean',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.3784722222222222 0.5799086757990868 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton4'); Daniel@0: Daniel@0: data.mean_h=h1; Daniel@0: data.mode='mean'; Daniel@0: Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess window_cb median',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.3784722222222222 0.4611872146118721 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton5'); Daniel@0: Daniel@0: Daniel@0: data.median_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess window_cb max',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.3784722222222222 0.3515981735159817 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton6'); Daniel@0: Daniel@0: data.max_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'Callback','preprocess window_cb min',... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.3784722222222222 0.2374429223744292 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton7'); Daniel@0: Daniel@0: data.min_h = h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess window_cb clip',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.6909722222222222 0.5525114155251141 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton8'); Daniel@0: Daniel@0: data.clip_h=h1; Daniel@0: data.eval_mode='clip'; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'Callback','preprocess window_cb expand',... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.6909722222222222 0.2922374429223744 0.06597222222222222 0.0821917808219178], ... Daniel@0: 'Style','radiobutton', ... Daniel@0: 'Tag','Radiobutton9'); Daniel@0: Daniel@0: data.expand_h=h1; Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.132 0.5799 0.19 0.0548], ... Daniel@0: 'String','Centered', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText2'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.132 0.4247 0.1667 0.0548], ... Daniel@0: 'String','Previous', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText3'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.132 0.2648 0.1632 0.0548], ... Daniel@0: 'String','Next', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText4'); Daniel@0: h1 = uicontrol('Parent',h0, ..., Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.445 0.6027397260273972 0.19 0.0547945205479452], ... Daniel@0: 'String','Mean', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText5'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.445 0.4795 0.1806 0.0548], ... Daniel@0: 'String','Median', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText6'); Daniel@0: Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.445 0.3699 0.1667 0.0548], ... Daniel@0: 'String','Max', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText7'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.445 0.2557077625570776 0.1597222222222222 0.0547945205479452], ... Daniel@0: 'String','Min', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText8'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.7535 0.5753 0.1354 0.054], ... Daniel@0: 'String','Clip', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText9'); Daniel@0: h1 = uicontrol('Parent',h0, ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor',[0.8 0.8 0.8], ... Daniel@0: 'FontWeight','demi', ... Daniel@0: 'FontSize',8,... Daniel@0: 'HorizontalAlignment','left', ... Daniel@0: 'ListboxTop',0, ... Daniel@0: 'Position',[0.7534722222222222 0.3150684931506849 0.1527777777777778 0.0547945205479452], ... Daniel@0: 'String','Expand', ... Daniel@0: 'Style','text', ... Daniel@0: 'Tag','StaticText10'); Daniel@0: Daniel@0: Daniel@0: Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function window_cb(arg) Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: Daniel@0: if any(strcmp(arg,[{'centered'},{'previous'},{'next'}])) Daniel@0: switch arg Daniel@0: case 'centered' Daniel@0: data.position='center'; Daniel@0: set(data.previous_h,'Value',0); Daniel@0: set(data.next_h,'Value',0); Daniel@0: set(data.centered_h,'Value',1); Daniel@0: case 'previous' Daniel@0: data.position='previous'; Daniel@0: set(data.centered_h,'Value',0); Daniel@0: set(data.next_h,'Value',0); Daniel@0: set(data.previous_h,'Value',1); Daniel@0: case 'next' Daniel@0: data.position='next'; Daniel@0: set(data.centered_h,'Value',0); Daniel@0: set(data.previous_h,'Value',0); Daniel@0: set(data.next_h,'Value',1); Daniel@0: end Daniel@0: elseif any(strcmp(arg,[{'mean'},{'median'},{'min'},{'max'}])) Daniel@0: switch arg Daniel@0: case 'mean' Daniel@0: data.mode='mean'; Daniel@0: set(data.median_h,'Value',0); Daniel@0: set(data.min_h,'Value',0); Daniel@0: set(data.max_h,'Value',0); Daniel@0: set(data.mean_h,'Value',1); Daniel@0: case 'median' Daniel@0: data.mode='median'; Daniel@0: set(data.mean_h,'Value',0); Daniel@0: set(data.max_h,'Value',0); Daniel@0: set(data.min_h,'Value',0); Daniel@0: set(data.median_h,'Value',1); Daniel@0: case 'max' Daniel@0: data.mode='max'; Daniel@0: set(data.mean_h,'Value',0); Daniel@0: set(data.median_h,'Value',0); Daniel@0: set(data.min_h,'Value',0); Daniel@0: set(data.max_h,'Value',1); Daniel@0: case 'min' Daniel@0: data.mode='min'; Daniel@0: set(data.mean_h,'Value',0); Daniel@0: set(data.median_h,'Value',0); Daniel@0: set(data.max_h,'Value',0); Daniel@0: set(data.min_h,'Value',1); Daniel@0: end Daniel@0: elseif any(strcmp(arg,[{'clip','expand'}])) Daniel@0: switch arg Daniel@0: case 'clip' Daniel@0: data.eval_mode='clip'; Daniel@0: set(data.expand_h,'Value',0); Daniel@0: set(data.clip_h,'Value',1); Daniel@0: case 'expand' Daniel@0: data.eval_mode='expand'; Daniel@0: set(data.clip_h,'Value',0); Daniel@0: set(data.expand_h,'Value',1); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function eval_windowed(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: i=1; Daniel@0: arg=varargin{1}; Daniel@0: while i <= length(arg) & arg(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: value=str2num(arg(1:i-1)); Daniel@0: i=i+1; Daniel@0: j=i; Daniel@0: while i <= length(arg) & arg(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: position=arg(j:i-1); Daniel@0: i=i+1; Daniel@0: j=i; Daniel@0: while i <= length(arg) & arg(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: mode=arg(j:i-1); Daniel@0: i=i+1; Daniel@0: j=i; Daniel@0: while i <= length(arg) & arg(i) ~= ' ' Daniel@0: i=i+1; Daniel@0: end Daniel@0: eval_mode=arg(j:i-1); Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: if LOG Daniel@0: data.position=position; Daniel@0: data.eval_mode=eval_mode; Daniel@0: data.mode=mode; Daniel@0: end Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess''-window does not exist. Terminating program...'); Daniel@0: pro_tools('close'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); Daniel@0: sData=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: undo=sData; Daniel@0: Daniel@0: if isempty(get(comp_names_h,'Value')) Daniel@0: errordlg('There are not components chosen.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if ~LOG Daniel@0: if isempty(get(data.win_len_h,'String')) Daniel@0: errordlg('Window length must be defined'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: value=str2num(get(data.win_len_h,'String')); Daniel@0: end Daniel@0: Daniel@0: set(data.win_len_h,'String',''); Daniel@0: Daniel@0: if ~LOG Daniel@0: if isempty(value) | value < 0 | value ~= round(value) Daniel@0: errordlg('Window length must be positive integer.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if value > length(sData.data(:,1)) Daniel@0: errordlg('Length of window is too big.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: index=getfield(get_indices,{1}); Daniel@0: Daniel@0: sData=eval_operation(sData,value,data.mode,data.eval_mode,data.position,index); Daniel@0: sData.comp_norm(index)={[]}; Daniel@0: u_data=get(pre_h,'UserData'); Daniel@0: u_data.sData=sData; Daniel@0: u_data.undo.sData=undo; Daniel@0: u_data.undo.selected=u_data.selected_vects; Daniel@0: Daniel@0: if ~LOG Daniel@0: u_data.LOG{length(u_data.LOG)+1}=... Daniel@0: '% Evaluating the wanted ''windowed'' -operation.'; Daniel@0: u_data.LOG{length(u_data.LOG)+1}=cat(2,'preprocess(''eval_windowed'',',... Daniel@0: '''',num2str(value),... Daniel@0: ' ',data.position,' ',data.mode,... Daniel@0: ' ',data.eval_mode,''');'); Daniel@0: end Daniel@0: Daniel@0: set(pre_h,'UserData',u_data); Daniel@0: old=gcf; Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: Daniel@0: if strcmp(data.eval_mode,'expand'); Daniel@0: write_sD_stats; Daniel@0: pro_tools('selall'); Daniel@0: else Daniel@0: sel_comp; Daniel@0: cplot_mimema; Daniel@0: end Daniel@0: Daniel@0: set(0,'CurrentFigure',old); Daniel@0: Daniel@0: Daniel@0: Daniel@0: %%% Subfunction: eval_operation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: Daniel@0: function sData=eval_operation(sData,winlen,mode,evalmode,position,n) Daniel@0: Daniel@0: Daniel@0: len=length(sData.data(:,1)); Daniel@0: dim=length(sData.data(1,:)); Daniel@0: Daniel@0: switch(position) Daniel@0: case 'center' Daniel@0: prev=round(winlen/2)-1; Daniel@0: next=winlen-round(winlen/2); Daniel@0: case 'previous' Daniel@0: prev=winlen-1; Daniel@0: next=0; Daniel@0: case 'next' Daniel@0: prev=0; Daniel@0: next=winlen-1; Daniel@0: end Daniel@0: Daniel@0: switch(evalmode) Daniel@0: case 'clip' Daniel@0: for center=1:len Daniel@0: win=center-prev:center-prev+winlen-1; Daniel@0: win=win(find(win > 0 & win <= len)); Daniel@0: str=cat(2,mode,'(sData.data(win(find(~isnan(sData.data(win,n)))),n))'); Daniel@0: tmp(center)=eval(str); Daniel@0: end Daniel@0: sData.data(:,n)=tmp; Daniel@0: case 'expand' Daniel@0: for i=1:len+winlen-1 Daniel@0: win=i-(winlen-1):i; Daniel@0: win=win(find(win > 0 & win <= len)); Daniel@0: str=cat(2,mode,'(sData.data(win(find(~isnan(sData.data(win,n)))),n))'); Daniel@0: tmp(i)=eval(str); Daniel@0: end Daniel@0: sData.data=cat(1,repmat(NaN,next,dim),sData.data,repmat(NaN,prev,dim)); Daniel@0: sData.data(:,n)=tmp; Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function pro_tools(arg) Daniel@0: Daniel@0: switch arg Daniel@0: case 'close' Daniel@0: close_preprocess; Daniel@0: case 'c_stat' Daniel@0: write_c_stats; Daniel@0: case 'plot_hist' Daniel@0: plot_hist; Daniel@0: case 'plot' Daniel@0: plot_button; Daniel@0: case 'plxy' Daniel@0: plxy_button; Daniel@0: case 'bplo' Daniel@0: bplo_button; Daniel@0: case 'hist' Daniel@0: hist_button; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: %%% Subfunction close_preprocess %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function close_preprocess Daniel@0: Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: man_h=findobj(get(0,'Children'),'Tag','Management'); Daniel@0: clip_h=findobj(get(0,'Children'),'Tag','Clipping'); Daniel@0: plot_h=findobj(get(0,'Children'),'Tag','PlotWin'); Daniel@0: delay_h=findobj(get(0,'Children'),'Tag','Delay'); Daniel@0: window_h=findobj(get(0,'Children'),'Tag','Window'); Daniel@0: sel_h=findobj(get(0,'Children'),'Tag','Select'); Daniel@0: Daniel@0: if ~isempty(man_h) Daniel@0: close(man_h); Daniel@0: end Daniel@0: if ~isempty(clip_h) Daniel@0: close(clip_h); Daniel@0: end Daniel@0: if ~isempty(plot_h) Daniel@0: close(plot_h); Daniel@0: end Daniel@0: if ~isempty(delay_h) Daniel@0: close(delay_h); Daniel@0: end Daniel@0: if ~isempty(window_h) Daniel@0: close(window_h); Daniel@0: end Daniel@0: if ~isempty(sel_h) Daniel@0: close(sel_h); Daniel@0: end Daniel@0: if ~isempty(pre_h) Daniel@0: close(pre_h); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: undo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function undo(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: if ~isempty(data.undo) Daniel@0: if any(strcmp('selected',fieldnames(data.undo))) Daniel@0: data.selected_vects=data.undo.selected; Daniel@0: end Daniel@0: if ~any(strcmp('index',fieldnames(data.undo))) Daniel@0: data.sData=data.undo.sData; Daniel@0: data.undo=[]; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Undo the most recent operation.'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''undo'',''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: set_compnames(data.sData,data.comp_names_h); Daniel@0: write_sD_stats; Daniel@0: vect_means(data.sData,data.vect_mean_h,data.selected_vects); Daniel@0: sel_comp; Daniel@0: cplot_mimema; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: % 'undo.sData' does not exist in sD_set - array Daniel@0: Daniel@0: index=data.undo.index; Daniel@0: data.undo.sData=rmfield(data.undo.sData,[{'INDEX'};{'MODIFIED'}]); Daniel@0: if index<=length(data.sD_set) Daniel@0: rest=data.sD_set(index:length(data.sD_set)); Daniel@0: else Daniel@0: rest=[]; Daniel@0: end Daniel@0: data.sD_set=cat(2,data.sD_set(1:index-1),data.undo.sData,rest); Daniel@0: data.undo=[]; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Undo the most recent operation.'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''undo'',''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',index); Daniel@0: set_sD_stats; Daniel@0: sel_sD; Daniel@0: else Daniel@0: msgbox('Can''t do...'); Daniel@0: end Daniel@0: Daniel@0: %%% Subfunction: write_c_stats %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function write_c_stats(varargin) Daniel@0: Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); Daniel@0: sel_comp_h=getfield(get(pre_h,'UserData'),'sel_comp_h'); Daniel@0: sel_chist_h=getfield(get(pre_h,'UserData'),'sel_chist_h'); Daniel@0: Daniel@0: if nargin==1 Daniel@0: val1=varargin(1); Daniel@0: else Daniel@0: val1=get(sel_comp_h,'String'); Daniel@0: end Daniel@0: Daniel@0: if ~isempty(val1) & iscell(val1) Daniel@0: selected_vects=getfield(get(pre_h,'UserData'),'selected_vects'); Daniel@0: sData=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: sel_cdata_h=getfield(get(pre_h,'UserData'),'sel_cdata_h'); Daniel@0: name=getfield(get(sel_comp_h,'String'),{get(sel_comp_h,'Value')}); Daniel@0: name=name{1}; Daniel@0: i=2; Daniel@0: Daniel@0: while ~isempty(str2num(name(i))) Daniel@0: value(i-1)=name(i); Daniel@0: i=i+1; Daniel@0: end Daniel@0: Daniel@0: value=str2num(value); Daniel@0: Daniel@0: Daniel@0: data=sData.data(selected_vects,value); Daniel@0: Daniel@0: string{1} = cat(2,'Min: ',sprintf('%-10.3g',min(data))); Daniel@0: string{2} = cat(2,'Mean: ',sprintf('%-10.3g',mean(data(find(~isnan(data)))))); Daniel@0: string{3} = cat(2,'Max: ',sprintf('%-10.3g',max(data))); Daniel@0: string{4} = cat(2,'Std: ',sprintf('%-10.3g',std(data(find(~isnan(data)))))); Daniel@0: string{5} = cat(2,'Number of NaNs: ',sprintf('%-10.3g',sum(isnan(data)))); Daniel@0: string{6} = cat(2,'NaN (%):',... Daniel@0: sprintf('%-10.3g',100*sum(isnan(data))/length(data))); Daniel@0: string{7} = cat(2,'Number of values: ',sprintf('%-10.3g',... Daniel@0: length(find(~isnan(unique(data)))))); Daniel@0: set(sel_cdata_h,'String',string); Daniel@0: set(sel_cdata_h,'HorizontalAlignment','left'); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction plot_hist %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function plot_hist Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: sel_chist_h=getfield(get(pre_h,'UserData'),'sel_chist_h'); Daniel@0: sData=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: selected=getfield(get(pre_h,'UserData'),'selected_vects'); Daniel@0: Daniel@0: value=get(getfield(get(pre_h,'UserData'),'sel_comp_h'),'Value'); Daniel@0: subplot(sel_chist_h); Daniel@0: hold off; Daniel@0: cla; Daniel@0: if all(isnan(sData.data(:,value))); Daniel@0: return; Daniel@0: end Daniel@0: hold on; Daniel@0: lim1=min(sData.data(:,value)); Daniel@0: lim2=max(sData.data(:,value)); Daniel@0: if lim2 - lim1 >= eps Daniel@0: x=lim1:(lim2-lim1)/(30-1):lim2; Daniel@0: set(sel_chist_h,'XLim',[lim1 lim2]); Daniel@0: elseif lim1 ~= 0 Daniel@0: x=(lim1)/2:lim1/(30-1):lim1+(lim1)/2; Daniel@0: set(sel_chist_h,'Xlim',[lim1-abs(lim1/2) lim1+abs(lim1/2)]); Daniel@0: else Daniel@0: x=-1:2/(30-1):1; Daniel@0: set(sel_chist_h,'XLim',[-1 1]); Daniel@0: end Daniel@0: Daniel@0: hist(sData.data(selected,value),x); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: select_all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function select_all(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.selected_vects=(1:length(data.sData.data(:,1))); Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Select all vectors.'; Daniel@0: data.LOG{length(data.LOG)+1}='selall(''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: tmp=zeros(1,length(data.sData.data(:,1))); Daniel@0: tmp(data.selected_vects)=1; Daniel@0: draw_vectors(tmp,data.vector_h); Daniel@0: cplot_mimema; Daniel@0: vect_means(data.sData,data.vect_mean_h,data.selected_vects); Daniel@0: sel_comp; Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: plot_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function plot_button Daniel@0: Daniel@0: %PLOT_BUTTON A callback function. Plots all the components and marks Daniel@0: % the chosen components. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: selected=getfield(get(gcf,'UserData'),'selected_vects'); Daniel@0: Daniel@0: indices=get_indices; Daniel@0: if isempty(indices) Daniel@0: return; Daniel@0: end Daniel@0: h=findobj(get(0,'Children'),'Tag','PlotWin'); Daniel@0: if isempty(h) Daniel@0: h= figure; Daniel@0: set(h,'Tag','PlotWin'); Daniel@0: end Daniel@0: Daniel@0: names=sData.comp_names(indices); Daniel@0: data=sData.data(:,indices); Daniel@0: Daniel@0: set(0,'CurrentFigure',h); Daniel@0: hold off; Daniel@0: clf; Daniel@0: t=0:1/(getfield(size(data),{1})-1):1; Daniel@0: tmp=setdiff(1:length(data(:,1)),selected); Daniel@0: for i=1:length(names) Daniel@0: subplot(length(names),1,i); Daniel@0: hold on; Daniel@0: if max(data(:,i))- min(data(:,i)) <= eps Daniel@0: set(gca,'YLim',[max(data(:,i))-1 max(data(:,i))+1]); Daniel@0: end Daniel@0: plot(t,data(:,i)); Daniel@0: if ~isempty(tmp); Daniel@0: data(tmp,i)=NaN; Daniel@0: end Daniel@0: plot(t,data(:,i),'red'); Daniel@0: ylabel(names{i}); Daniel@0: set(gca,'XTick',[]); Daniel@0: end Daniel@0: set(gcf,'Name','Plotted Data Components'); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: plxy_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function plxy_button Daniel@0: Daniel@0: %PLXY_BUTTON A callback function. XY-plots the first and the second Daniel@0: % components chosen. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: selected=getfield(get(gcf,'UserData'),'selected_vects'); Daniel@0: Daniel@0: inds = get_indices; Daniel@0: if length(inds) < 2 Daniel@0: errordlg('There must be two components chosen for XY-plot.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: inds=inds(1:2); Daniel@0: names=getfield(sData,'comp_names',{inds}); Daniel@0: Daniel@0: h=findobj(get(0,'Children'),'Tag','PlotWin'); Daniel@0: Daniel@0: if isempty(h) Daniel@0: h= figure; Daniel@0: set(h,'Tag','PlotWin'); Daniel@0: end Daniel@0: Daniel@0: set(0,'CurrentFigure',h); Daniel@0: clf; Daniel@0: axes; Daniel@0: if max(sData.data(:,inds(1))) - min(sData.data(:,inds(1))) <= eps Daniel@0: set(gca,'XLim',[max(sData.data(:,inds(1)))-1 max(sData.data(:,inds(1)))+1]); Daniel@0: end Daniel@0: if max(sData.data(:,inds(2))) - min(sData.data(:,inds(2))) <= eps Daniel@0: set(gca,'YLim',[max(sData.data(:,inds(2)))-1 max(sData.data(:,inds(2)))+1]); Daniel@0: end Daniel@0: hold on; Daniel@0: plot(sData.data(:,inds(1)),sData.data(:,inds(2)),'o'); Daniel@0: x=sData.data(selected,inds(1)); Daniel@0: y=sData.data(selected,inds(2)); Daniel@0: Daniel@0: plot(x,y,'ored','MarkerSize',4); Daniel@0: xlabel(names(1)); Daniel@0: ylabel(names(2)); Daniel@0: set(h,'Name','Plotted Data Components'); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Sub_function: bplo_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function bplo_button Daniel@0: Daniel@0: %BPLO_BUTTON A callback function. Box-plots the first component chosen. Daniel@0: Daniel@0: Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: selected=getfield(get(gcf,'UserData'),'selected_vects'); Daniel@0: Daniel@0: if length(selected) == 1 Daniel@0: errordlg('There are too few vectors chosen for box-plotting.'); Daniel@0: else Daniel@0: indices=get_indices; Daniel@0: if isempty(indices) Daniel@0: return; Daniel@0: end Daniel@0: for i=1:length(indices) Daniel@0: if length(unique(sData.data(selected,indices(i))))==1 Daniel@0: errordlg('All the values are the same. Operation can''t be evaluated.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: names=getfield(sData,'comp_names',{indices}); Daniel@0: h= findobj(get(0,'Children'),'Tag','PlotWin'); Daniel@0: if isempty(h) Daniel@0: h= figure; Daniel@0: set(h,'Tag','PlotWin'); Daniel@0: end Daniel@0: Daniel@0: data=sData.data(selected,indices); Daniel@0: Daniel@0: set(0,'CurrentFigure',h); Daniel@0: hold off; Daniel@0: clf; Daniel@0: hold on; Daniel@0: for i=1:getfield(size(data),{2}) Daniel@0: subplot(getfield(size(data),{2}),1,i); Daniel@0: if ~all(isnan(data(:,i))) Daniel@0: boxplot(data(:,i)); Daniel@0: end Daniel@0: name=names{i}; Daniel@0: tmp=get(get(gca,'YLabel'),'String'); Daniel@0: ylabel(cat(2,sprintf('[%s] ',name),tmp)); Daniel@0: end Daniel@0: set(h,'Name','Box-plot'); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: hist_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function hist_button Daniel@0: Daniel@0: no_of_bins_h=getfield(get(gcf,'UserData'),'no_of_bins_h'); Daniel@0: selected=getfield(get(gcf,'UserData'),'selected_vects'); Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: n=str2num(get(no_of_bins_h,'String')); Daniel@0: s1='Invalid number of bins.'; Daniel@0: s2=sprintf('\nSet new value to the box under the ''Histogram''-button.'); Daniel@0: Daniel@0: if isempty(n) Daniel@0: errordlg(cat(2,s1,s2)); Daniel@0: else Daniel@0: indices=get_indices; Daniel@0: if isempty(indices) Daniel@0: return; Daniel@0: end Daniel@0: n=round(n); Daniel@0: if n < 1 Daniel@0: errordlg('Number of bins must be positive integer.'); Daniel@0: else Daniel@0: h= findobj(get(0,'Children'),'Tag','PlotWin'); Daniel@0: if isempty(h) Daniel@0: h= figure; Daniel@0: set(h,'Tag','PlotWin'); Daniel@0: end Daniel@0: Daniel@0: set(0,'CurrentFigure',h); Daniel@0: hold off; Daniel@0: clf; Daniel@0: data=sData.data(selected,indices); Daniel@0: names=sData.comp_names(indices); Daniel@0: for i=1:length(names) Daniel@0: subplot(length(names),1,i); Daniel@0: hold on; Daniel@0: lim1=min(sData.data(:,indices(i))); Daniel@0: lim2=max(sData.data(:,indices(i))); Daniel@0: if n > 1 Daniel@0: if lim2 - lim1 >= eps Daniel@0: x=lim1:(lim2-lim1)/(n-1):lim2; Daniel@0: set(gca,'XLim',[lim1 lim2]); Daniel@0: elseif lim1 ~= 0 Daniel@0: x=lim1/2:lim1/(n-1):lim1/2+lim1; Daniel@0: if ~all(isnan([lim1 lim2])) Daniel@0: set(gca,'XLim',[lim1-abs(lim1/2) lim1+abs(lim1/2)]); Daniel@0: end Daniel@0: else Daniel@0: x=-1:2/(n-1):1; Daniel@0: set(gca,'XLim',[-1 1]); Daniel@0: end Daniel@0: else Daniel@0: x=1; Daniel@0: if lim2 ~= lim1 Daniel@0: set(gca,'XLim',[lim1 lim2]); Daniel@0: else Daniel@0: set(gca,'XLim',[lim1/2 lim1/2+lim1]); Daniel@0: end Daniel@0: end Daniel@0: if ~all(isnan(data(:,i))) Daniel@0: hist(data(:,i),x); Daniel@0: end Daniel@0: name=names{i}; Daniel@0: xlabel(name); Daniel@0: end Daniel@0: set(h,'Name','Histogram'); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: no_of_values %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function no_of_values(varargin); Daniel@0: Daniel@0: %NO_OF_VALUES A callback function. Calculates the number of different Daniel@0: % values of the chosen components. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: if nargin==1; Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: results_h=getfield(get(pre_h,'UserData'),'results_h'); Daniel@0: sData=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: selected=getfield(get(pre_h,'UserData'),'selected_vects'); Daniel@0: str1='There must be one component chosen for ''Number of Values''-operation'; Daniel@0: Daniel@0: Daniel@0: if ~LOG & isempty(get_indices) Daniel@0: errordlg(str1); Daniel@0: else Daniel@0: indices=get_indices; Daniel@0: data=sData.data(selected,indices); Daniel@0: Daniel@0: string{1} = 'Number of different values:'; Daniel@0: Daniel@0: for i=1:getfield(size(data),{2}) Daniel@0: Daniel@0: tmp=data(:,i); Daniel@0: string{i+1}=cat(2,sprintf('#%d:',indices(i)),... Daniel@0: sprintf('%d',length(find(~isnan(unique(data(:,i))))))); Daniel@0: end Daniel@0: Daniel@0: set(results_h,'String',string); Daniel@0: set(results_h,'HorizontalAlignment','left'); Daniel@0: if ~LOG Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Number of values'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''noof'',''foo'');'; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: correlation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function correlation(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: results_h=getfield(get(pre_h,'UserData'),'results_h'); Daniel@0: selected=getfield(get(pre_h,'UserData'),'selected_vects'); Daniel@0: sData=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: Daniel@0: if length(get_indices) < 2 Daniel@0: errordlg('There must be two components chosen for Correlation'); Daniel@0: else Daniel@0: indices=getfield(get_indices,{1:2}); Daniel@0: data=sData.data(selected,indices); Daniel@0: inds=find(~isnan(data(:,1)) & ~isnan(data(:,2))); Daniel@0: value=getfield(corrcoef(data(inds,1),data(inds,2)),{1,2}); Daniel@0: names=sData.comp_names(indices); Daniel@0: string{1}='Correlation between'; Daniel@0: string{2}=cat(2,names{1},' and ',names{2},':'); Daniel@0: string{3}=sprintf('%-10.3g',value); Daniel@0: Daniel@0: set(results_h,'String',string); Daniel@0: set(results_h,'HorizontalAlignment','left'); Daniel@0: if ~LOG Daniel@0: data=get(pre_h,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Correlation'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''corr'',''foo'');'; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: unit_length %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function unit_length(varargin) Daniel@0: Daniel@0: %UNIT_LENGTH A callback function Scales all the vectors to the unit Daniel@0: % length. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: if nargin==1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: sData.MODIFIED=1; Daniel@0: scaled=sData.data; Daniel@0: comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); Daniel@0: Daniel@0: if ~LOG & isempty(get(comp_names_h,'Value')) Daniel@0: errordlg('There must be components chosen for the ''unit length''- operation'); Daniel@0: return; Daniel@0: end Daniel@0: inds=get_indices; Daniel@0: for i=1:length(scaled(:,1)); Daniel@0: x=find(~isnan(scaled(i,inds))); Daniel@0: scaled(i,inds(x))=(1/sqrt(sum(scaled(i,inds(x)).^2)))*scaled(i,inds(x)); Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: Daniel@0: Daniel@0: data.undo.sData = sData; Daniel@0: data.sData.data=scaled; Daniel@0: Daniel@0: for i=1:length(inds) Daniel@0: data.sData.comp_norm{inds(i)}=[]; Daniel@0: end Daniel@0: Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Unit length'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''unit'',''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: vects=zeros(1,length(sData.data(:,1))); Daniel@0: vects(data.selected_vects)=1; Daniel@0: Daniel@0: draw_vectors(vects,data.vector_h); Daniel@0: vect_means(sData,vect_mean_h,data.selected_vects); Daniel@0: cplot_mimema; Daniel@0: plot_hist; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: one_of_n %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function one_of_n(varargin) Daniel@0: Daniel@0: if nargin==1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: vector_h=getfield(get(gcf,'Userdata'),'vector_h'); Daniel@0: comp_names_h=getfield(get(gcf,'Userdata'),'comp_names_h'); Daniel@0: vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: sData=data.sData; Daniel@0: undo=data.sData; Daniel@0: selected=getfield(get(gcf,'UserData'),'selected_vects'); Daniel@0: msg='Creating over 10 new components. Stop operation?'; Daniel@0: Daniel@0: if ~LOG Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: errordlg('There must be one component chosen for ''Add: N binary types'' -operation'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: index=getfield(get_indices,{1}); Daniel@0: Daniel@0: tmp=unique(sData.data(:,index)); Daniel@0: n=length(tmp); Daniel@0: Daniel@0: if ~LOG Daniel@0: if n>10 Daniel@0: answer=questdlg(msg,'Question','Yes','No','Yes'); Daniel@0: Daniel@0: if strcmp(answer,'Yes') Daniel@0: msgbox('Operation stopped.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: dim1=getfield(size(sData.data),{1}); Daniel@0: dim2=getfield(size(sData.data),{2}); Daniel@0: sData.data=cat(2,sData.data,zeros(dim1,n)); Daniel@0: Daniel@0: dim=dim2+n; Daniel@0: for i=1:n Daniel@0: sData.data(:,dim-(n-i))=(sData.data(:,index) == tmp(i)); Daniel@0: end Daniel@0: Daniel@0: INDEX=sData.INDEX; Daniel@0: for i=1:n Daniel@0: sData.comp_names{dim2+i}=sprintf('%dNewVar',dim2+i); Daniel@0: end Daniel@0: tmp_norm=cat(1,sData.comp_norm,cell(n,1)); Daniel@0: sData=som_data_struct(sData.data,... Daniel@0: 'name',sData.name,... Daniel@0: 'labels',sData.labels,... Daniel@0: 'comp_names',sData.comp_names); Daniel@0: Daniel@0: sData.MODIFIED=1; Daniel@0: sData.INDEX=INDEX; Daniel@0: sData.comp_norm=tmp_norm; Daniel@0: data.undo.sData=undo; Daniel@0: data.sData=sData; Daniel@0: data.selected_vects=1:length(sData.data(:,1)); Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Add: N binary types'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''oneo'',''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: clear_button; Daniel@0: write_sD_stats; Daniel@0: set_compnames(sData,comp_names_h); Daniel@0: tmp=ones(1,length(sData.data(:,1))); Daniel@0: draw_vectors(tmp,vector_h); Daniel@0: vect_means(sData,vect_mean_h,1:length(sData.data(:,1))); Daniel@0: cplot_mimema; Daniel@0: sel_comp; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: add_zeros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function add_zeros(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: vector_h=getfield(get(gcf,'Userdata'),'vector_h'); Daniel@0: comp_names_h=getfield(get(gcf,'Userdata'),'comp_names_h'); Daniel@0: vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: Daniel@0: dim1=getfield(size(sData.data),{1}); Daniel@0: dim2=getfield(size(sData.data),{2}); Daniel@0: sData.data=cat(2,sData.data,zeros(dim1,1)); Daniel@0: Daniel@0: INDEX=sData.INDEX; Daniel@0: Daniel@0: sData.comp_names{dim2+1}=sprintf('%dNewVar',dim2+1); Daniel@0: tmp_norm=cat(1,sData.comp_norm,cell(1,1)); Daniel@0: sData=som_data_struct(sData.data,... Daniel@0: 'name',sData.name,... Daniel@0: 'labels',sData.labels,... Daniel@0: 'comp_names',sData.comp_names); Daniel@0: Daniel@0: sData.MODIFIED=1; Daniel@0: sData.INDEX=INDEX; Daniel@0: sData.comp_norm=tmp_norm; Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: data.selected_vects=1:length(sData.data(:,1)); Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Add: zeros'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''zero'',''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: clear_button; Daniel@0: write_sD_stats; Daniel@0: set_compnames(sData,comp_names_h); Daniel@0: tmp=ones(1,length(sData.data(:,1))); Daniel@0: draw_vectors(tmp,vector_h); Daniel@0: vect_means(sData,vect_mean_h,1:length(sData.data(:,1))); Daniel@0: cplot_mimema; Daniel@0: sel_comp; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: move_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function move_component(varargin) Daniel@0: Daniel@0: %MOVE_COMPONENT A callback function. Moves one component of vectors to Daniel@0: % the position wanted. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: i=1; Daniel@0: while varargin{1}(i) ~= ' ' Daniel@0: value(i)=varargin{1}(i); Daniel@0: i=i+1; Daniel@0: end Daniel@0: value=str2num(value); % the new place Daniel@0: index=str2num(varargin{1}(i:length(varargin{1}))); % index of the chosen Daniel@0: % component Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: prompt='Enter the number of the new component place:'; Daniel@0: Daniel@0: Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: errordlg('There must be one component chosen for ''Move Component''-operation'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if ~LOG Daniel@0: index=getfield(get_indices,{1}); Daniel@0: answer=inputdlg(prompt); Daniel@0: Daniel@0: if isempty(answer) | (iscell(answer) & isempty(answer{1})) Daniel@0: msgbox('No components moved'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: value=str2num(answer{1}); Daniel@0: Daniel@0: Daniel@0: dims=size(value); Daniel@0: Daniel@0: if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value) Daniel@0: errordlg('The new component place must be positive integer.') Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if value <= 0 | round(value) ~= value Daniel@0: errordlg('The new component place must be positive integer.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if value > getfield(size(sData.data),{2}) Daniel@0: errordlg('Too big value for the new component place.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: sData.MODIFIED=1; Daniel@0: if index < value Daniel@0: indices1=setdiff(1:value,index); Daniel@0: indices2=setdiff(value+1:length(sData.data(1,:)),index); Daniel@0: elseif index > value Daniel@0: indices1=setdiff(1:value-1,index); Daniel@0: indices2=setdiff(value:length(sData.data(1,:)),index); Daniel@0: else Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: set(gcf,'UserData',data); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: tmp1=sData.data(:,indices1); Daniel@0: tmp2=sData.data(:,indices2); Daniel@0: sData.data=cat(2,tmp1,sData.data(:,index),tmp2); Daniel@0: Daniel@0: tmp1=sData.comp_names(indices1); Daniel@0: tmp2=sData.comp_names(indices2); Daniel@0: sData.comp_names=cat(1,tmp1,sData.comp_names(index),tmp2); Daniel@0: Daniel@0: tmp1=sData.comp_norm(indices1); Daniel@0: tmp2=sData.comp_norm(indices2); Daniel@0: sData.comp_norm=cat(1,tmp1,sData.comp_norm(index),tmp2); Daniel@0: Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Move component.'; Daniel@0: data.LOG{length(data.LOG)+1}=sprintf('preprocess(''move'',''%s %s'');',... Daniel@0: num2str(value),num2str(index)); Daniel@0: end Daniel@0: comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); Daniel@0: vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: vector_h=getfield(get(gcf,'UserData'),'vector_h'); Daniel@0: data.selected_vects=1:length(sData.data(:,1)); Daniel@0: set(gcf,'UserData',data); Daniel@0: clear_button; Daniel@0: set_compnames(sData,comp_names_h); Daniel@0: draw_vectors(ones(1,length(sData.data(:,1))),vector_h); Daniel@0: vect_means(sData,vect_mean_h,data.selected_vects); Daniel@0: cplot_mimema; Daniel@0: sel_comp; Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: copy_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function copy_component(varargin) Daniel@0: Daniel@0: %COPY_COMPONENT Copies one component of vectors to the position wanted. Daniel@0: % Daniel@0: % Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: i=1; Daniel@0: while varargin{1}(i) ~= ' ' Daniel@0: value(i)=varargin{1}(i); Daniel@0: i=i+1; Daniel@0: end Daniel@0: value=str2num(value); % the new place Daniel@0: index=str2num(varargin{1}(i:length(varargin{1}))); % index of the chosen Daniel@0: % component Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: if ~LOG Daniel@0: prompt='Enter the number of the new component place:'; Daniel@0: Daniel@0: Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: errordlg('There must be one component chosen for ''Copy Component''-operation'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: index=getfield(get_indices,{1}); Daniel@0: answer=inputdlg(prompt); Daniel@0: Daniel@0: if isempty(answer) | (iscell(answer) & isempty(answer{1})) Daniel@0: msgbox('No components moved'); Daniel@0: return Daniel@0: end Daniel@0: Daniel@0: Daniel@0: value=str2num(answer{1}); Daniel@0: dims=size(value); Daniel@0: Daniel@0: if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value) Daniel@0: errordlg('The new component place must be positive integer.') Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if value <= 0 | round(value) ~= value Daniel@0: errordlg('The new component place must be positive integer.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if value > getfield(size(sData.data),{2}) + 1 Daniel@0: errordlg('Too big value for the new component place.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: sData.MODIFIED=1; Daniel@0: Daniel@0: indices1=1:value-1; Daniel@0: indices2=value:length(sData.data(1,:)); Daniel@0: tmp1=sData.data(:,indices1); Daniel@0: tmp2=sData.data(:,indices2); Daniel@0: sData.data=cat(2,tmp1,sData.data(:,index),tmp2); Daniel@0: Daniel@0: tmp1=sData.comp_names(indices1); Daniel@0: tmp2=sData.comp_names(indices2); Daniel@0: name=cell(1,1); Daniel@0: name{1}=cat(2,'Copied',sData.comp_names{index}); Daniel@0: sData.comp_names=cat(1,tmp1,name,tmp2); Daniel@0: Daniel@0: tmp1=sData.comp_norm(indices1); Daniel@0: tmp2=sData.comp_norm(indices2); Daniel@0: norm=cell(1,1); Daniel@0: norm{1}=sData.comp_norm{index}; Daniel@0: sData.comp_norm=cat(1,tmp1,norm,tmp2); Daniel@0: Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Copy component'; Daniel@0: data.LOG{length(data.LOG)+1}=sprintf('preprocess(''copy'',''%s %s'');',... Daniel@0: num2str(value),num2str(index)); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); Daniel@0: vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: vector_h=getfield(get(gcf,'UserData'),'vector_h'); Daniel@0: data.selected_vects=1:length(sData.data(:,1)); Daniel@0: set(gcf,'UserData',data); Daniel@0: clear_button; Daniel@0: write_sD_stats; Daniel@0: set_compnames(sData,comp_names_h); Daniel@0: draw_vectors(ones(1,length(sData.data(:,1))),vector_h); Daniel@0: vect_means(sData,vect_mean_h,data.selected_vects); Daniel@0: cplot_mimema; Daniel@0: sel_comp; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: remove_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function remove_component(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: value=str2num(varargin{1}); Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); Daniel@0: vector_h=getfield(get(gcf,'UserData'),'vector_h'); Daniel@0: comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: prompt='Enter the number of component to be removed.'; Daniel@0: dim=length(sData.data(1,:)); Daniel@0: Daniel@0: if ~LOG Daniel@0: answer=inputdlg(prompt); Daniel@0: Daniel@0: if isempty(answer) | (iscell(answer) & isempty(answer{1})) Daniel@0: msgbox('Components not removed.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: value=str2num(answer{1}); Daniel@0: dims=size(value); Daniel@0: Daniel@0: if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value) Daniel@0: errordlg('Number of the component to be removed must be positive integer.') Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if value <= 0 | round(value) ~= value Daniel@0: errordlg('Number of the component to be removed must be positive integer.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if value > getfield(size(sData.data),{2}) Daniel@0: errordlg('There are less components.'); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: sD_set_h=getfield(get(gcf,'UserData'),'sD_set_h'); Daniel@0: index=get(sD_set_h,'Value'); Daniel@0: if value == 1 & getfield(size(sData.data),{2}) == 1 Daniel@0: if length(get(sD_set_h,'String')) == 1 Daniel@0: msgbox('No data left. Closing program...') Daniel@0: pro_tools('close'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: set1=data.sD_set(1:index-1); Daniel@0: set2=data.sD_set(index+1:length(data.sD_set)); Daniel@0: data.sD_set=[set1 set2]; Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: set_sD_stats; Daniel@0: sel_sD; Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.undo.sData=undo; Daniel@0: data.undo.index=index; Daniel@0: set(gcf,'UserData',data); Daniel@0: return; Daniel@0: end Daniel@0: dims=size(sData.data); Daniel@0: tmp_data=cat(2,sData.data(:,1:value-1),sData.data(:,value+1:dims(2))); Daniel@0: tmp_norm=cat(1,sData.comp_norm(1:value-1),sData.comp_norm(value+1:dims(2))); Daniel@0: names=cat(1,sData.comp_names(1:value-1),sData.comp_names(value+1:dims(2))); Daniel@0: INDEX=sData.INDEX; Daniel@0: comp_norm=sData.comp_norm; Daniel@0: sData=som_data_struct(tmp_data,... Daniel@0: 'name',sData.name,... Daniel@0: 'labels',sData.labels,... Daniel@0: 'comp_names',names); Daniel@0: sData.comp_norm=tmp_norm; Daniel@0: sData.MODIFIED=1; Daniel@0: sData.INDEX=INDEX; Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: data.selected_vects=1:length(sData.data(:,1)); Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Remove component'; Daniel@0: data.LOG{length(data.LOG)+1}=sprintf('preprocess(''remove'',''%s'');',... Daniel@0: answer{1}); Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: clear_button; Daniel@0: write_sD_stats; Daniel@0: set_compnames(sData,comp_names_h); Daniel@0: tmp=ones(1,length(sData.data(:,1))); Daniel@0: draw_vectors(tmp,vector_h); Daniel@0: vect_means(sData,vect_mean_h,1:length(sData.data(:,1))); Daniel@0: cplot_mimema; Daniel@0: sel_comp; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: remove_vects %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function remove_vects(varargin) Daniel@0: Daniel@0: if nargin==1 Daniel@0: LOG=1; Daniel@0: tmp_str=varargin{1}; Daniel@0: else Daniel@0: LOG=0; Daniel@0: tmp_str='_foo'; Daniel@0: end Daniel@0: data=get(gcf,'UserData'); Daniel@0: vect_mean_h=data.vect_mean_h; Daniel@0: vector_h=data.vector_h; Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: Daniel@0: if length(data.selected_vects) == getfield(size(sData.data),{1}) Daniel@0: if LOG Daniel@0: answer='Yes'; Daniel@0: else Daniel@0: answer=questdlg('Do you want to delete this data set?'); Daniel@0: end Daniel@0: if strcmp(answer,'No') Daniel@0: return; Daniel@0: else Daniel@0: index=get(data.sD_set_h,'Value'); Daniel@0: if length(get(data.sD_set_h,'String')) == 1 Daniel@0: msgbox('No data left. Closing program...') Daniel@0: pro_tools('close'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: set1=data.sD_set(1:index-1); Daniel@0: set2=data.sD_set(index+1:length(data.sD_set)); Daniel@0: data.sD_set=[set1 set2]; Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: set(data.sD_set_h,'Value',1); Daniel@0: set_sD_stats; Daniel@0: sel_sD; Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.undo.sData=undo; Daniel@0: data.undo.index=index; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Remove selected vectors'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''remove_vects'',''',... Daniel@0: tmp_str,''');'); Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: tmp=sData.data(data.selected_vects,:); Daniel@0: if ~LOG Daniel@0: answer=questdlg('Do you want to save removed values to workspace?'); Daniel@0: else Daniel@0: if ~strcmp(tmp_str,'_foo') Daniel@0: answer='Yes'; Daniel@0: else Daniel@0: answer='No'; Daniel@0: end Daniel@0: end Daniel@0: old=gcf; Daniel@0: if strcmp(answer,'Yes') Daniel@0: if ~LOG Daniel@0: answer=inputdlg('Give the name of the output -variable.'); Daniel@0: else Daniel@0: answer={tmp_str}; Daniel@0: end Daniel@0: if isvalid_var_name(answer) Daniel@0: assignin('base',answer{1},tmp); Daniel@0: disp(sprintf('Removed values are set to workspace as''%s''.',answer{1})); Daniel@0: tmp_str=answer{1}; Daniel@0: end Daniel@0: end Daniel@0: set(0,'CurrentFigure',old); Daniel@0: sData.data(data.selected_vects,:)=[]; Daniel@0: sData.labels(data.selected_vects,:)=[]; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: data.selected=1:length(sData.data(:,1)); Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)}='% Remove selected vectors'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''remove_vects'',''',... Daniel@0: tmp_str,''');'); Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: Daniel@0: draw_vectors(ones(1,length(data.selected)),data.vector_h); Daniel@0: write_sD_stats; Daniel@0: select_all('foo'); Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: Daniel@0: Daniel@0: Daniel@0: %%% Subfunction: eval1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function eval1(varargin); Daniel@0: Daniel@0: if nargin == 1 Daniel@0: answer=varargin Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess''-figure does not exist. Terminating program...'); Daniel@0: pro_tools('close'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: undo=getfield(get(pre_h,'UserData'),'sData'); Daniel@0: Daniel@0: if ~LOG Daniel@0: prompt={'Enter the expression to be evaluated.',... Daniel@0: 'Enter the inverse normalization method (optional).'}; Daniel@0: title='Single component eval.'; Daniel@0: answer= inputdlg(prompt,title,1); Daniel@0: end Daniel@0: Daniel@0: if ~isempty(answer) Daniel@0: tmp=[]; Daniel@0: if ~isempty(answer{1}) Daniel@0: [tmp,method]=build_expr(answer{1},'single'); Daniel@0: if ~isstr(tmp) Daniel@0: sData=getfield(get(gcf,'UserData'),'sData'); Daniel@0: tmp='Done.'; Daniel@0: %if ~isempty(answer{2}) Daniel@0: % sN=som_norm_struct('eval',{method,answer{2}}); Daniel@0: %else Daniel@0: % sN=som_norm_struct('eval',{method}); Daniel@0: %end Daniel@0: %sN=som_set(sN,'status','done'); Daniel@0: params={answer{1};answer{2}}; Daniel@0: ind=getfield(get_indices,{1}); Daniel@0: x.type=''; Daniel@0: x.method='eval'; Daniel@0: x.params={answer{1};answer{2}}; Daniel@0: x.status=''; Daniel@0: sData.comp_norm{ind}=x; Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.undo.sData=undo; Daniel@0: data.sData=sData; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Eval (1-comp)'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess eval1 ',... Daniel@0: sprintf('{''%s'' ''%s''};',answer{1},answer{2})); Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: Daniel@0: end Daniel@0: end Daniel@0: set(getfield(get(pre_h,'UserData'),'results_h'),'String',tmp); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: eval2 Daniel@0: Daniel@0: function eval2(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: answer=varargin{1}; Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: undo=getfield(get(gcf,'UserData'),'sData'); Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: errordlg('''Preprocess''-figure does not exist. Terminating program.'); Daniel@0: pro_tools('close'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if ~LOG Daniel@0: prompt='Enter the expression to be evaluated.'; Daniel@0: title ='Eval'; Daniel@0: answer=inputdlg(prompt,title,1); Daniel@0: end Daniel@0: Daniel@0: if ~isempty(answer) & ~isempty(answer{1}) Daniel@0: str=answer{1}; Daniel@0: [answer,foo]=build_expr(answer{1},'multiple'); Daniel@0: if ~isstr(answer) Daniel@0: Daniel@0: answer='Done.'; Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Eval'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''eval2'',',... Daniel@0: sprintf('{''%s''});',str)); Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: set(getfield(get(pre_h,'UserData'),'results_h'),'String',answer); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: zero2one_scale %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function zero2one_scale(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: INDEX=sData.INDEX; Daniel@0: sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]); Daniel@0: Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: errordlg('There must be components chosen for scaling.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: sData=som_normalize(sData,'range',get_indices); Daniel@0: sData.MODIFIED=1; Daniel@0: sData.INDEX=INDEX; Daniel@0: Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Scale [0,1]'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''zscale'', ''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: vects=zeros(1,length(sData.data(:,1))); Daniel@0: vects(data.selected_vects)=1; Daniel@0: Daniel@0: cplot_mimema; Daniel@0: plot_hist; Daniel@0: vect_means(sData,data.vect_mean_h,data.selected_vects); Daniel@0: draw_vectors(vects,data.vector_h); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: var_scale %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function var_scale(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: INDEX=sData.INDEX; Daniel@0: sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]); Daniel@0: Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: errordlg('There must be components chosen for scaling.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: sData=som_normalize(sData,'var',get_indices); Daniel@0: Daniel@0: sData.INDEX=INDEX; Daniel@0: sData.MODIFIED=1; Daniel@0: Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Scale var=1'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''vscale'', ''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: vects=zeros(1,length(sData.data(:,1))); Daniel@0: vects(data.selected_vects)=1; Daniel@0: Daniel@0: cplot_mimema; Daniel@0: plot_hist; Daniel@0: vect_means(sData,data.vect_mean_h,data.selected_vects); Daniel@0: draw_vectors(vects,data.vector_h); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: hist_eq %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function hist_eq(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: INDEX=sData.INDEX; Daniel@0: sData=rmfield(sData,[{'INDEX'},{'MODIFIED'}]); Daniel@0: Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: errordlg('There must be components chosen for ''Histogram eq''.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: sData=som_normalize(sData,'histD',get_indices); Daniel@0: Daniel@0: sData.INDEX=INDEX; Daniel@0: sData.MODIFIED=1; Daniel@0: Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Histogram eq'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''histeq'', ''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: vects=zeros(1,length(sData.data(:,1))); Daniel@0: vects(data.selected_vects)=1; Daniel@0: Daniel@0: cplot_mimema; Daniel@0: plot_hist; Daniel@0: vect_means(sData,data.vect_mean_h,data.selected_vects); Daniel@0: draw_vectors(vects,data.vector_h); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: hist_eq2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function hist_eq2(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: Daniel@0: INDEX=sData.INDEX; Daniel@0: sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]); Daniel@0: Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: errordlg('There must be components chosen for ''Histogram eq2''.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: inds=get_indices; Daniel@0: %%%[sData,ok]=som_normalize(sData,inds,'histC'); Daniel@0: sData=som_normalize(sData,'histC',inds); Daniel@0: sData.INDEX=INDEX; Daniel@0: sData.MODIFIED=1; Daniel@0: Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Histogram eq2'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''histeq2'', ''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: vects=zeros(1,length(sData.data(:,1))); Daniel@0: vects(data.selected_vects)=1; Daniel@0: Daniel@0: cplot_mimema; Daniel@0: plot_hist; Daniel@0: vect_means(sData,data.vect_mean_h,data.selected_vects); Daniel@0: draw_vectors(vects,data.vector_h); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: logarithm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function logarithm(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: data=get(gcf,'UserData'); Daniel@0: sData=data.sData; Daniel@0: undo=sData; Daniel@0: Daniel@0: INDEX=sData.INDEX; Daniel@0: sData=rmfield(sData,[{'INDEX'},{'MODIFIED'}]); Daniel@0: Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: errordlg('There must be components chosen for ''Log''.'); Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: Data=som_normalize(sData,'log',get_indices); Daniel@0: Daniel@0: sData.INDEX=INDEX; Daniel@0: sData.MODIFIED=1; Daniel@0: Daniel@0: data.sData=sData; Daniel@0: data.undo.sData=undo; Daniel@0: if ~LOG Daniel@0: data.LOG{length(data.LOG)+1}='% Log'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''log'', ''foo'');'; Daniel@0: end Daniel@0: set(gcf,'UserData',data); Daniel@0: Daniel@0: vects=zeros(1,length(sData.data(:,1))); Daniel@0: vects(data.selected_vects)=1; Daniel@0: Daniel@0: cplot_mimema; Daniel@0: plot_hist; Daniel@0: vect_means(sData,data.vect_mean_h,data.selected_vects); Daniel@0: draw_vectors(vects,data.vector_h); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function [answer,method]=build_expr(string,evaltype) Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: method=[]; Daniel@0: if isempty(pre_h) Daniel@0: close_preprocess; Daniel@0: errordlg('''Preprocess'' -figure does not exist. Terminating program...'); Daniel@0: return; Daniel@0: Daniel@0: end Daniel@0: Daniel@0: if isempty(string) Daniel@0: str = '[]'; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: tmp=[]; Daniel@0: [name,assign,skip]=check_assign(string,evaltype); Daniel@0: Daniel@0: if ~strcmp(assign,'NOTASSIGN') & ~strcmp(assign,'error') Daniel@0: string=string(skip:length(string)); Daniel@0: end Daniel@0: Daniel@0: if ~strcmp(assign,'error') Daniel@0: if isempty(string) Daniel@0: answer='Illegal expression.'; Daniel@0: return; Daniel@0: end Daniel@0: [str,skip]=check_token(string,evaltype); Daniel@0: method=string; Daniel@0: while ~strcmp(str,'error') & ~strcmp(tmp,'error') & skip < length(string) Daniel@0: if ~strcmp(tmp,')') Daniel@0: str=cat(2,str,tmp); Daniel@0: end Daniel@0: [tmp,skip2]=check_token(string(skip+1:length(string)),evaltype); Daniel@0: skip=skip+skip2; Daniel@0: Daniel@0: end Daniel@0: if ~strcmp(tmp,')') & ~strcmp(tmp,'error') Daniel@0: str=cat(2,str,tmp); Daniel@0: elseif strcmp(tmp,'error') Daniel@0: str='error'; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: if ~strcmp(assign,'error') & ~strcmp(str,'error'); Daniel@0: answer=evalin('caller',str,'lasterr'); Daniel@0: else Daniel@0: answer='??? Illegal expression.'; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: data=get(pre_h,'UserData'); Daniel@0: sData=data.sData; Daniel@0: if strcmp(assign,'NOTASSIGN') & strcmp(evaltype,'single') & ~isstr(answer) Daniel@0: if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) Daniel@0: errordlg('There are not components chosen.'); Daniel@0: answer='??? Illegal expression.'; Daniel@0: return; Daniel@0: end Daniel@0: index=getfield(get_indices,{1}); Daniel@0: if strcmp(assign,'NOTASSIGN') Daniel@0: if length(sData.data(:,index)) ~=length(answer) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: else Daniel@0: sData.data(:,index)=answer; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: else Daniel@0: if length(sData.data(str2num(assign),index)) ~=length(answer) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: else Daniel@0: sData.data(str2num(assign),index)=answer; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: end Daniel@0: elseif ~strcmp(assign,'error') & ~isstr(answer) & ~strcmp(assign,'NOTASSIGN') Daniel@0: switch name Daniel@0: case 'x' Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: return; Daniel@0: end Daniel@0: index = getfield(get_indices,{1}); Daniel@0: if isempty(assign) Daniel@0: if length(sData.data(:,index)) ~= length(answer) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: else Daniel@0: sData.data(:,index)=answer; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: if strcmp(evaltype,'multiple') Daniel@0: data.sData.comp_norm(index)={[]}; Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: else Daniel@0: args=create_args(assign,'x'); Daniel@0: if length(args) == 1 Daniel@0: len=max(str2num(args{1})); Daniel@0: if ~isscalar(len) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1 Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif ~all(size(sData.data(str2num(args{1}),index))) == size(answer) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: else Daniel@0: sData.data(str2num(args{1}),index)=answer; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: if strcmp(evaltype,'multiple') Daniel@0: data.sData.comp_norm(index)={[]}; Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: else Daniel@0: len=max(str2num(args{1})); Daniel@0: dim=max(str2num(args{2})); Daniel@0: asize=size(answer); Daniel@0: msize=size(sData.data); Daniel@0: if ~isscalar(len) | ~isscalar(dim) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif len > length(sData.data(:,1)) | len < 1 Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif dim > 1 | dim > msize(2) | min(str2num(args{2})) < 1 Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: end Daniel@0: len=length(str2num(args{1})); Daniel@0: dim=length(str2num(args{1})); Daniel@0: if ~all([len dim] == asize) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: else Daniel@0: tmp=sData.data(:,index); Daniel@0: tmp([str2num(args{1})],[str2num(args{2})])=answer; Daniel@0: sData.data(:,index)=tmp; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: if strcmp(evaltype,'multiple') Daniel@0: data.sData.comp_norm(index)={[]}; Daniel@0: end Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: case 'xs' Daniel@0: if isempty(get(data.comp_names_h,'Value')) Daniel@0: return; Daniel@0: end Daniel@0: indices=get_indices; Daniel@0: if isempty(assign) Daniel@0: if ~all(size(answer) == size(sData.data(:,indices))) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: else Daniel@0: sData.data(:,indices) = answer; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: data.sData.comp_norm(indices)={[]}; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: else Daniel@0: args=create_args(assign,'xs'); Daniel@0: if length(args) == 1 Daniel@0: len=max(str2num(args{1})); Daniel@0: if ~isscalar(len) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1 Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: end Daniel@0: if ~all(size(answer) == size(sData.data(str2num(args{1})))) &... Daniel@0: ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: else Daniel@0: tmp=sData.data(:,indices); Daniel@0: tmp(str2num(args{1}))=answer; Daniel@0: sData.data(:,indices)=tmp; Daniel@0: sData.MODIFIED=1; Daniel@0: sData.comp_norm{indices}={[]}; Daniel@0: data.sData=sData; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: else Daniel@0: len=max(str2num(args{1})); Daniel@0: dim=max(str2num(args{2})); Daniel@0: asize=size(answer); Daniel@0: msize=size(sData.data(:,indices)); Daniel@0: if ~isscalar(len) | ~isscalar(dim) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif len > msize(1) | min(str2num(args{1})) < 1 Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif dim > msize(2) | min(str2num(args{2})) < 1 Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: end Daniel@0: len=length(str2num(args{1})); Daniel@0: dim=length(str2num(args{2})); Daniel@0: if ~all([len dim] == asize) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment'; Daniel@0: return; Daniel@0: else Daniel@0: tmp=sData.data(:,indices); Daniel@0: tmp([str2num(args{1})],[str2num(args{2})])=answer; Daniel@0: sData.MODIFIED=1; Daniel@0: sData.data(:,indices)=tmp; Daniel@0: data.sData=sData; Daniel@0: data.sData.comp_norm(indices)={[]}; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: case 'D' Daniel@0: if isempty(assign) Daniel@0: if ~all(size(answer) == size(sData.data)) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: else Daniel@0: if isscalar(answer) Daniel@0: sData.data(:,:)=answer; Daniel@0: else Daniel@0: sData.data=answer; Daniel@0: end Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: data.sData.comp_norm(1:length(sData.data(1,:)))={[]}; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: else Daniel@0: args=create_args(assign,'D'); Daniel@0: if length(args) == 1 Daniel@0: len=max(str2num(args{1})); Daniel@0: if ~isscalar(len) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1 Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: end Daniel@0: if ~all(size(answer) == size(sData.data(str2num(args{1})))) &... Daniel@0: ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: else Daniel@0: sData.data(str2num(args{1}))=answer; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: [i,j]=ind2sub(size(sData.data),str2num(args{1})); Daniel@0: data.sData.comp_norm(j)={[]}; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: else Daniel@0: len=max(str2num(args{1})); Daniel@0: dim=max(str2num(args{2})); Daniel@0: asize=size(answer); Daniel@0: msize=size(sData.data); Daniel@0: if ~isscalar(len) | ~isscalar(dim) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif len > msize(1) | min(str2num(args{1})) < 1 Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: elseif dim > msize(2) | min(str2num(args{2})) < 1 Daniel@0: answer= '??? Illegal assignment.'; Daniel@0: return; Daniel@0: end Daniel@0: len = length(str2num(args{1})); Daniel@0: dim = length(str2num(args{2})); Daniel@0: if ~all([len dim] == asize) & ~isscalar(answer) Daniel@0: answer='??? Illegal assignment.'; Daniel@0: return; Daniel@0: else Daniel@0: sData.data([str2num(args{1})],[str2num(args{2})])=answer; Daniel@0: sData.MODIFIED=1; Daniel@0: data.sData=sData; Daniel@0: data.sData.comp_norm(str2num(args{2}))={[]}; Daniel@0: set(pre_h,'UserData',data); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: if sData.MODIFIED Daniel@0: selected=getfield(get(pre_h,'UserData'),'selected_vects'); Daniel@0: vector_h=getfield(get(pre_h,'UserData'),'vector_h'); Daniel@0: vect_mean_h=getfield(get(pre_h,'UserData'),'vect_mean_h'); Daniel@0: vects=zeros(length(sData.data(:,1))); Daniel@0: vects(selected)=1; Daniel@0: draw_vectors(vects,vector_h); Daniel@0: vect_means(sData,vect_mean_h,selected); Daniel@0: pro_tools('plot_hist'); Daniel@0: pro_tools('c_stat'); Daniel@0: cplot_mimema; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: %%% Subfunction: check_assign %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function [name,string,skip]=check_assign(string,evaltype) Daniel@0: Daniel@0: Daniel@0: reswords=[{'D'};{'x'};{'xs'}]; Daniel@0: flag=0; Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: if isempty(pre_h) Daniel@0: man_h=findobj(get(0,'Children'),'Tag','Management'); Daniel@0: clip_h=findobj(get(0,'Children'),'Tag','Clipping'); Daniel@0: errordlg('''Preprocess'' -window does not exist. Terminating program.'); Daniel@0: if ~isempty(man_h) Daniel@0: close man_h; Daniel@0: end Daniel@0: if ~isempty(clip_h) Daniel@0: close clip_h; Daniel@0: end Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: EMPTY=isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')); Daniel@0: Daniel@0: [name,s]=give_token(string,evaltype); Daniel@0: skip=length(s); Daniel@0: Daniel@0: if strcmp(evaltype,'single') & ~strcmp(name,'x') Daniel@0: string='NOTASSIGN'; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if strcmp(name,'other') & ~strcmp(s,'x') Daniel@0: string = 'error'; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if strcmp(name,[{'x'};{'xs'}]) Daniel@0: comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); Daniel@0: if isempty(get(comp_names_h,'Value')) Daniel@0: errordlg('There are not components chosen.'); Daniel@0: string='error'; Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: Daniel@0: if skip == length(string) | ~strcmp(name,reswords) Daniel@0: string = 'NOTASSIGN'; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if (strcmp(name,'x') | strcmp(name,'xs')) & EMPTY Daniel@0: errordlg('There are not components chosen.'); Daniel@0: string = 'error'; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: [t,s]=give_token(string(length(name)+1),evaltype); Daniel@0: Daniel@0: if strcmp(t,'(') Daniel@0: flag=1; Daniel@0: end Daniel@0: Daniel@0: [foo,skip]=check_token(string,evaltype); Daniel@0: if length(name) ~= skip-1 Daniel@0: skip=skip-1; Daniel@0: tmp=string(length(name)+1:skip); Daniel@0: else Daniel@0: tmp = []; Daniel@0: end Daniel@0: Daniel@0: if flag & tmp(length(tmp)) ~= ')' Daniel@0: tmp(length(tmp)+1)=')'; Daniel@0: end Daniel@0: Daniel@0: if skip==length(string) Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: skip=skip+1; Daniel@0: if length(string) ~= skip Daniel@0: [t,s]=give_token(string(skip+1:length(string)),evaltype); Daniel@0: else Daniel@0: string='NOTASSIGN'; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: if ~strcmp(t,'=') Daniel@0: string = 'NOTASSIGN'; Daniel@0: return; Daniel@0: end Daniel@0: string=tmp; Daniel@0: skip = skip+2; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: isscalar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function bool = isscalar(x) Daniel@0: Daniel@0: m= size(x); Daniel@0: Daniel@0: bool = m(1) == 1 & m(2) == 1; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: create_args %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function args=create_args(string,type) Daniel@0: Daniel@0: arg2=''; Daniel@0: i=2; Daniel@0: j=1; Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: msize=size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')); Daniel@0: Daniel@0: Daniel@0: if string(i) == ':' Daniel@0: arg1=num2str(cat(2,'1:',num2str(msize(1)))); Daniel@0: i=i+1; Daniel@0: j=j+length(arg1); Daniel@0: end Daniel@0: Daniel@0: while string(i) ~=',' & string(i) ~=')' Daniel@0: arg1(j)=string(i); Daniel@0: i=i+1; Daniel@0: j=j+1; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: Daniel@0: if string(i) ==',' Daniel@0: j=1; Daniel@0: i=i+1; Daniel@0: if string(i)==':' Daniel@0: switch type Daniel@0: case 'x' Daniel@0: arg2='1'; Daniel@0: case 'cs' Daniel@0: arg2=num2str(get_indices); Daniel@0: case 'D' Daniel@0: arg2=num2str(cat(2,'1:',num2str(msize(2)))); Daniel@0: end Daniel@0: i=i+1; Daniel@0: j=j+length(arg2); Daniel@0: end Daniel@0: Daniel@0: while string(i) ~= ')' Daniel@0: arg2(j)=string(i); Daniel@0: j=j+1; Daniel@0: i=i+1; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: Daniel@0: args{1}=arg1; Daniel@0: if ~isempty(arg2) Daniel@0: args{2} = arg2; Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function [str,skip] = check_token(string,evaltype) Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: tmp_string=string; Daniel@0: [t,s]=give_token(tmp_string,evaltype); Daniel@0: skip=length(s); Daniel@0: Daniel@0: if strcmp(t,'c') Daniel@0: if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) Daniel@0: errordlg('There are no components chosen.'); Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: index=getfield(get_indices,{1}); Daniel@0: str=cat(2,'[',num2str(index),']'); Daniel@0: if skip == length(tmp_string) Daniel@0: return; Daniel@0: end Daniel@0: tmp_string=tmp_string(skip+1:length(tmp_string)); Daniel@0: [t,s] = give_token(tmp_string,evaltype); Daniel@0: if ~strcmp(t,'(') Daniel@0: return; Daniel@0: end Daniel@0: [args,skip2] = get_args(tmp_string(length(s)+1:length(tmp_string)),'c',... Daniel@0: evaltype); Daniel@0: skip=skip+skip2+2; Daniel@0: if strcmp(args,'error') Daniel@0: str = 'error' Daniel@0: return; Daniel@0: elseif ~strcmp(args,'all') Daniel@0: str=cat(2,'getfield(',str,',',args,')'); Daniel@0: else Daniel@0: str=cat(2,'getfield(',str,',{[1]})'); Daniel@0: end Daniel@0: elseif strcmp(t,'cs') Daniel@0: if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) Daniel@0: errordlg('There are no components chosen.'); Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: str =cat(2,'[',num2str(get_indices),']'); Daniel@0: if length(s) == length(string) Daniel@0: return; Daniel@0: end Daniel@0: tmp_string=tmp_string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(tmp_string,evaltype); Daniel@0: if ~strcmp(t,'(') Daniel@0: return; Daniel@0: else Daniel@0: [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'cs',... Daniel@0: evaltype); Daniel@0: skip=2+skip+skip2; Daniel@0: if strcmp(args,'error') Daniel@0: str='error'; Daniel@0: return; Daniel@0: elseif ~strcmp(args,'all') Daniel@0: str = cat(2,'getfield(',str,',',args,')'); Daniel@0: else Daniel@0: tmp_str=str; Daniel@0: str=cat(2,'[getfield(',str,',','{1})'); Daniel@0: for i=2:length(get_indices) Daniel@0: str=cat(2,str,';getfield(',tmp_str,',',sprintf('{%d})',i)); Daniel@0: end Daniel@0: str=cat(2,str,']'); Daniel@0: end Daniel@0: end Daniel@0: elseif strcmp(t,'dim') Daniel@0: ind1=getfield(size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')),{2}); Daniel@0: str=cat(2,'[',num2str(ind1),']'); Daniel@0: if length(s)==length(string) Daniel@0: return; Daniel@0: end Daniel@0: tmp_string=string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(tmp_string,evaltype); Daniel@0: if ~strcmp(t,'(') Daniel@0: return; Daniel@0: end Daniel@0: skip=1+skip+length(s); Daniel@0: [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'dim',... Daniel@0: evaltype); Daniel@0: if strcmp(args,'error') Daniel@0: str = 'error'; Daniel@0: return; Daniel@0: else Daniel@0: skip=skip+skip2; Daniel@0: if ~strcmp(args,'all') Daniel@0: str=cat(2,'getfield(',str,',',args,')'); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: elseif strcmp(t,'dlen') Daniel@0: ind1=getfield(size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')),{1}); Daniel@0: str=cat(2,'[',num2str(ind1),']'); Daniel@0: if length(s)==length(string) Daniel@0: return; Daniel@0: end Daniel@0: tmp_string=string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(tmp_string,evaltype); Daniel@0: if ~strcmp(t,'(') Daniel@0: return; Daniel@0: end Daniel@0: skip=skip+length(s); Daniel@0: [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'dlen',... Daniel@0: evaltype); Daniel@0: if strcmp(args,'error') Daniel@0: str='error'; Daniel@0: return; Daniel@0: else Daniel@0: skip=1+skip+skip2; Daniel@0: if ~strcmp(args,'all') Daniel@0: str=cat(2,'getfield(',str,',',args,')'); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: elseif strcmp(t,'x') Daniel@0: if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) Daniel@0: errordlg('There are not components chosen.'); Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: len=getfield(size(getfield(getfield(get(pre_h,'UserData'),... Daniel@0: 'sData'),'data')),{1}); Daniel@0: index=num2str(getfield(get_indices,{1})); Daniel@0: h_str='findobj(get(0,''Children''),''Tag'',''Preprocess'')'; Daniel@0: get_str=cat(2,'getfield(get(',h_str,',''UserData''),''sData'')'); Daniel@0: get_str=cat(2,'getfield(',get_str,',''data'')'); Daniel@0: str=cat(2,'getfield(',get_str,',{[1:',num2str(len),'],',index,'})'); Daniel@0: if length(s) == length(string) Daniel@0: return; Daniel@0: end Daniel@0: tmp_string=string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(tmp_string,evaltype); Daniel@0: if ~strcmp(t,'('); Daniel@0: return; Daniel@0: end Daniel@0: skip=skip+length(s); Daniel@0: [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'x',... Daniel@0: evaltype); Daniel@0: if strcmp(args,'error') Daniel@0: str = 'error'; Daniel@0: return; Daniel@0: else Daniel@0: skip=1+skip+skip2; Daniel@0: if ~strcmp(args,'all') Daniel@0: str=cat(2,'getfield(',str,',',args,')'); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: elseif strcmp(t,'xs') Daniel@0: if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) Daniel@0: errordlg('There are not components chosen.'); Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: len=getfield(size(getfield(getfield(get(pre_h,'UserData'),... Daniel@0: 'sData'),'data')),{1}); Daniel@0: index=get_indices; Daniel@0: index=cat(2,'[',num2str(index),']'); Daniel@0: h_str='findobj(get(0,''Children''),''Tag'',''Preprocess'')'; Daniel@0: get_str=cat(2,'getfield(get(',h_str,',''UserData''),''sData'')'); Daniel@0: get_str=cat(2,'getfield(',get_str,',''data'')'); Daniel@0: str=cat(2,'getfield(',get_str,',{[1:',num2str(len),'],',index,'})'); Daniel@0: if length(s) == length(string) Daniel@0: return; Daniel@0: end Daniel@0: tmp_string=string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(tmp_string,evaltype); Daniel@0: if ~strcmp(t,'(') Daniel@0: return; Daniel@0: end Daniel@0: skip=1+skip+length(s); Daniel@0: Daniel@0: [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'xs',... Daniel@0: evaltype); Daniel@0: if strcmp(args,'error') Daniel@0: str = 'error'; Daniel@0: return; Daniel@0: elseif ~strcmp(args,'all') Daniel@0: str=cat(2,'getfield(',str,',',args,')'); Daniel@0: skip=skip+skip2; Daniel@0: else Daniel@0: skip=skip+skip2; Daniel@0: [dlen,dim]=size(eval(str)); Daniel@0: tmp_str=str; Daniel@0: str=cat(2,'[','getfield(',tmp_str,sprintf(',{1:%d,1})',dlen)); Daniel@0: for i=2:dim Daniel@0: tmp=sprintf(',{1:%d,%d})',dlen,dim); Daniel@0: str=cat(2,str,';','getfield(',tmp_str,tmp); Daniel@0: end Daniel@0: str=cat(2,str,']'); Daniel@0: end Daniel@0: elseif strcmp(t,'D') Daniel@0: get_h='findobj(get(0,''Children''),''Tag'',''Preprocess'')'; Daniel@0: str=cat(2,'getfield(getfield(get(',get_h,',''UserData''),''sData''),''data'')'); Daniel@0: Daniel@0: if length(s) >= length(tmp_string) Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: tmp_string=tmp_string(1+length(s):length(tmp_string)); Daniel@0: [t,s]=give_token(tmp_string,evaltype); Daniel@0: if ~strcmp(t,'(') Daniel@0: return; Daniel@0: else Daniel@0: tmp_string=tmp_string(1+length(s):length(tmp_string)); Daniel@0: skip = skip+length(s); Daniel@0: [args, skip2]=get_args(tmp_string,'D',evaltype); Daniel@0: if strcmp(args,'error') Daniel@0: str='error'; Daniel@0: return; Daniel@0: elseif ~strcmp(args,'all') Daniel@0: str=cat(2,'getfield(',str,',',args,')'); Daniel@0: skip=1+skip+skip2; Daniel@0: else Daniel@0: skip=1+skip+skip2; Daniel@0: [dlen,dim]=size(eval(str)); Daniel@0: tmp_str=str; Daniel@0: str=cat(2,'[getfield(',str,sprintf(',{1:%d,1})',dlen)); Daniel@0: for i=2:dim Daniel@0: tmp=sprintf(',{1:%d,%d}',dlen,i); Daniel@0: str=cat(2,str,';getfield(',tmp_str,tmp,')'); Daniel@0: end Daniel@0: str=cat(2,str,']'); Daniel@0: end Daniel@0: end Daniel@0: else Daniel@0: if strcmp(t,'(') Daniel@0: str = t; Daniel@0: str2=''; Daniel@0: tmp_string=tmp_string(1+length(s):length(tmp_string)); Daniel@0: while ~strcmp(str2,')') & ~isempty(tmp_string) Daniel@0: [str2,skip2]=check_token(tmp_string,evaltype); Daniel@0: if strcmp(str2,'error') Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: skip=skip+skip2; Daniel@0: tmp_string=tmp_string(skip2+1:length(tmp_string)); Daniel@0: str=cat(2,str,str2); Daniel@0: end Daniel@0: if ~strcmp(str2,')') Daniel@0: str = 'error'; Daniel@0: end Daniel@0: else Daniel@0: str = s; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%% Subfunction: get_args %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function [str,skip] = get_args(string,flag,evaltype) Daniel@0: Daniel@0: res_words=[{'D'};{'c'};{'cs'};{'dim'};{'dlen'};{'x'};{'xs'}]; Daniel@0: NOTALL=1; Daniel@0: if isempty(string) Daniel@0: str='error' Daniel@0: skip=[]; Daniel@0: return; Daniel@0: end Daniel@0: [t,s] = give_token(string,evaltype); Daniel@0: Daniel@0: Daniel@0: skip=length(s); Daniel@0: if any(strcmp(t,res_words)); Daniel@0: [str,skip2] = check_token(string,evaltype); Daniel@0: string=string(1+length(s):length(string)); Daniel@0: str=cat(2,'{[',str); Daniel@0: [t,s]=give_token(string,evaltype); Daniel@0: elseif t==')' | t==',' Daniel@0: str = 'error'; Daniel@0: return; Daniel@0: elseif strcmp(t,':'); Daniel@0: if length(s) == length(string) Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: [t,s]=give_token(string(1+length(s):length(string)),evaltype); Daniel@0: if t == ')' Daniel@0: str = 'all'; Daniel@0: return; Daniel@0: end Daniel@0: switch flag Daniel@0: case {'c','cs','dim','dlen'} Daniel@0: str= '{[1'; Daniel@0: otherwise Daniel@0: str=cat(2,'{[',get_all('vect')); Daniel@0: end Daniel@0: NOTALL=0; Daniel@0: string=string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(string,evaltype); Daniel@0: skip=skip+1; Daniel@0: else Daniel@0: str = cat(2,'{[',s); Daniel@0: end Daniel@0: str2 =[]; Daniel@0: Daniel@0: Daniel@0: if ~strcmp(t,',') & ~strcmp(t,')') Daniel@0: skip=skip-length(s); Daniel@0: end Daniel@0: Daniel@0: Daniel@0: Daniel@0: while ~strcmp(t,',') & ~strcmp(t,')') & NOTALL; Daniel@0: str=cat(2,str,str2); Daniel@0: [t,s] = give_token(string,evaltype); Daniel@0: if length(s) == length(string) Daniel@0: str = 'error'; Daniel@0: return; Daniel@0: end Daniel@0: string=string(1+length(s):length(string)); Daniel@0: skip=skip+length(s); Daniel@0: [t,s]=give_token(string,evaltype); Daniel@0: if length(s) == length(string) & ~strcmp(t,')') Daniel@0: str = 'error'; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: [str2,foo]=check_token(string,evaltype); Daniel@0: end Daniel@0: Daniel@0: if NOTALL & ~strcmp(t,')') Daniel@0: skip=skip+1; Daniel@0: end Daniel@0: Daniel@0: if strcmp(t,')') Daniel@0: str=cat(2,str,']}'); Daniel@0: return Daniel@0: end Daniel@0: Daniel@0: str=cat(2,str,']',',','['); Daniel@0: str2 = []; Daniel@0: Daniel@0: Daniel@0: [t,s] = give_token(string,evaltype); Daniel@0: if strcmp(t,')') Daniel@0: str = 'error' Daniel@0: return; Daniel@0: end Daniel@0: NOTALL=1; Daniel@0: string=string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(string,evaltype); Daniel@0: if strcmp(t,':'); Daniel@0: switch flag Daniel@0: case {'c','dim','dlen','x'} Daniel@0: str=cat(2,str,'1'); Daniel@0: case 'D' Daniel@0: str=cat(2,str,get_all('comp')); Daniel@0: case {'cs','xs'} Daniel@0: str=cat(2,str,'1:',num2str(length(get_indices))); Daniel@0: end Daniel@0: NOTALL=0; Daniel@0: if length(s) == length(string) Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: string=string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(string,evaltype); Daniel@0: end Daniel@0: Daniel@0: if ~strcmp(t,')') & NOTALL Daniel@0: skip=skip-1; Daniel@0: end Daniel@0: Daniel@0: while ~strcmp(t,')') & NOTALL Daniel@0: str=cat(2,str,str2); Daniel@0: skip=skip+length(s); Daniel@0: if length(s) == length(string) & ~strcmp(t,')') Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: [str2,foo]=check_token(string,evaltype); Daniel@0: string=string(1+length(s):length(string)); Daniel@0: [t,s]=give_token(string,evaltype); Daniel@0: end Daniel@0: if ~strcmp(t,')') Daniel@0: str='error'; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: str=cat(2,str,str2,']}'); Daniel@0: skip=skip+length(s); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: get_all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function str=get_all(vect_or_comp) Daniel@0: Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: Daniel@0: switch vect_or_comp Daniel@0: case 'vect' Daniel@0: dim=getfield(size(getfield(getfield(get(pre_h,'UserData'),... Daniel@0: 'sData'),'data')),{1}); Daniel@0: str=cat(2,'1:',num2str(dim)); Daniel@0: case 'comp' Daniel@0: dim=getfield(size(getfield(getfield(get(pre_h,'UserData'),... Daniel@0: 'sData'),'data')),{2}); Daniel@0: str=cat(2,'1:',num2str(dim)); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function [token,str]=give_token(string,evaltype) Daniel@0: Daniel@0: n=length(string); Daniel@0: i=1; Daniel@0: char=string(i); Daniel@0: Daniel@0: switch analyze_char(string(i)); Daniel@0: case 'num' Daniel@0: token='num'; Daniel@0: while i <= n & strcmp('num',analyze_char(string(i))) Daniel@0: str(i)=string(i); Daniel@0: i=i+1; Daniel@0: end Daniel@0: case 'other' Daniel@0: switch string(i) Daniel@0: case ':' Daniel@0: token = ':'; Daniel@0: case ',' Daniel@0: token = ','; Daniel@0: case '(' Daniel@0: token = '('; Daniel@0: case ')' Daniel@0: token = ')'; Daniel@0: case '=' Daniel@0: token = '='; Daniel@0: otherwise Daniel@0: token='other'; Daniel@0: end Daniel@0: str=string(i); Daniel@0: case 'alpha' Daniel@0: while i <= n & strcmp('alpha',analyze_char(string(i))) Daniel@0: str(i)=string(i); Daniel@0: i=i+1; Daniel@0: end Daniel@0: token = find_res_word(str,evaltype); Daniel@0: end Daniel@0: Daniel@0: %%% Subfunction: analyze_char %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function type=analyze_char(char) Daniel@0: Daniel@0: Daniel@0: if ((char-0) >= ('0'-0) & (char-0) <= ('9'-0)) Daniel@0: type='num'; Daniel@0: elseif ((char-0) >= ('a'-0) & (char-0) <= ('z'-0)) ... Daniel@0: | ((char-0) >= ('A'-0) & (char-0) <= ('Z'-0)) Daniel@0: type='alpha'; Daniel@0: else Daniel@0: type='other'; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: %%% Subfunction: find_res_word %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function token = find_res_word(string,evaltype) Daniel@0: Daniel@0: reswords=[{'D'};{'c'};{'cs'};{'dim'};{'dlen'};{'x'};{'xs'};{'other'}]; Daniel@0: Daniel@0: for i=1:length(reswords); Daniel@0: token=reswords{i}; Daniel@0: if strcmp(string,reswords{i}) Daniel@0: if strcmp(evaltype,'single') & ~strcmp(string,'x') Daniel@0: token = 'other'; Daniel@0: end Daniel@0: return; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function close_func(varargin) Daniel@0: Daniel@0: switch varargin{1} Daniel@0: case 'close_c' Daniel@0: str='% Closing the ''Clipping'' -window...'; Daniel@0: clip_h=findobj(get(0,'Children'),'Tag','Clipping'); Daniel@0: close(clip_h); Daniel@0: case 'close_sD' Daniel@0: str='% Closing the ''Data Set Management'' -window...'; Daniel@0: sD_h=findobj(get(0,'Children'),'Tag','Management'); Daniel@0: close(sD_h); Daniel@0: case 'close_w' Daniel@0: str='% Closing the ''Windowed'' -window...'; Daniel@0: win_h=findobj(get(0,'Children'),'Tag','Window'); Daniel@0: close(win_h); Daniel@0: case 'close_s' Daniel@0: str='% Closing the ''Select'' -window...'; Daniel@0: sel_h=findobj(get(0,'Children'),'Tag','Select'); Daniel@0: close(sel_h); Daniel@0: case 'close_d' Daniel@0: str='% Closing the ''Delay'' -window...'; Daniel@0: del_h=findobj(get(0,'Children'),'Tag','Delay'); Daniel@0: close(del_h); Daniel@0: end Daniel@0: Daniel@0: if nargin ~= 2 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: preh_udata=get(pre_h,'UserData'); Daniel@0: str2=cat(2,'preprocess(''',varargin{1},''',''foo'');'); Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}=str; Daniel@0: preh_udata.LOG{length(preh_udata.LOG)+1}=str2; Daniel@0: set(pre_h,'UserData',preh_udata); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function log_file Daniel@0: Daniel@0: answer=inputdlg('Give the name of the outputfile:','LOG function',1,... Daniel@0: {'log_function'}); Daniel@0: Daniel@0: if isempty(answer) Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: tmp=clock; Daniel@0: str =cat(2,'% Created: ',... Daniel@0: date,... Daniel@0: ' ',sprintf('%d:%d\n%\n\n',tmp(4),tmp(5))); Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: LOG=getfield(get(pre_h,'UserData'),'LOG'); Daniel@0: file=cat(2,pwd,'/',answer{1},'.m'); Daniel@0: fid =fopen(file,'w'); Daniel@0: Daniel@0: arg=LOG{2}(12:length(LOG{2})-2); Daniel@0: fprintf(fid,'%s\n \n',cat(2,'function ',answer{1},'(',arg,')')); Daniel@0: fprintf(fid,'%s\n',str); Daniel@0: for i=1:length(LOG) Daniel@0: fprintf(fid,'%s\n',LOG{i}); Daniel@0: end Daniel@0: fclose(fid); Daniel@0: disp(sprintf('LOG-file ''%s'' is done.',file)); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function get_selected_inds(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: LOG=1; Daniel@0: answer = {varargin{1}}; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: selected=getfield(get(gcf,'UserData'),'selected_vects'); Daniel@0: if ~LOG Daniel@0: answer=inputdlg('Give the name of the output variable:',... Daniel@0: '',1,{'indices'}); Daniel@0: end Daniel@0: Daniel@0: if isempty(answer) | isempty(answer{1}) Daniel@0: return; Daniel@0: else Daniel@0: assignin('base',answer{1},selected); Daniel@0: disp(cat(2,'Indices of the selected vectors are set to the workspace ',... Daniel@0: sprintf(' as ''%s''.',answer{1}))); Daniel@0: if ~LOG Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}=... Daniel@0: '% Saving indices of the selected vectors to the workspace.'; Daniel@0: data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''get_inds'',',... Daniel@0: '''',answer{1},''');'); Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function no_of_selected(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: LOG = 1; Daniel@0: else Daniel@0: LOG = 0; Daniel@0: end Daniel@0: Daniel@0: results_h=getfield(get(gcf,'UserData'),'results_h'); Daniel@0: no=length(getfield(get(gcf,'UserData'),'selected_vects')); Daniel@0: str={sprintf('Number of selected vectors: %d\n', no)}; Daniel@0: set(results_h,'String',str,'HorizontalAlignment','left'); Daniel@0: Daniel@0: if ~LOG Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Number of selected vectors'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''no_of_sel'',''foo'');'; Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function select_all_comps(varargin) Daniel@0: Daniel@0: if nargin == 1 Daniel@0: pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); Daniel@0: set(0,'CurrentFigure',pre_h); Daniel@0: LOG=1; Daniel@0: else Daniel@0: LOG=0; Daniel@0: end Daniel@0: Daniel@0: comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); Daniel@0: Daniel@0: set(comp_names_h,'Value',[1:length(get(comp_names_h,'String'))]); Daniel@0: sel_comp; Daniel@0: Daniel@0: if ~LOG Daniel@0: data=get(gcf,'UserData'); Daniel@0: data.LOG{length(data.LOG)+1}='% Select all components'; Daniel@0: data.LOG{length(data.LOG)+1}='preprocess(''sel_all_comps'',''foo'');'; Daniel@0: set(gcf,'UserData',data); Daniel@0: end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function code=write_log_code(indices,arg1,arg2,arg3,arg4,arg5,arg6); Daniel@0: Daniel@0: str=textwrap({num2str(indices)},500); Daniel@0: Daniel@0: code{1}=sprintf('inds=[];'); Daniel@0: for i=1:length(str); Daniel@0: code{i+1}=sprintf(' inds=cat(2,inds,[%s]);',str{i}); Daniel@0: end Daniel@0: str=cat(2,'preprocess(''''clip_data'''',''''',arg1,' ',num2str(arg2),' ',... Daniel@0: num2str(arg3),' ',num2str(arg4),... Daniel@0: ' ',num2str(arg5),' ',num2str(arg6),' '); Daniel@0: code{length(code)+1}=cat(2,'eval(cat(2,',... Daniel@0: '''',str,'''',... Daniel@0: ',num2str(inds),'''''');''));'); Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%