📄 preprocess.m
字号:
'ListboxTop',0, ... 'Position',[0.01833333333333333 0.9341935483870968 0.1616666666666667 0.02064516129032258], ... 'String','DATA SETS', ... 'Style','text', ... 'Tag','StaticText13');h1 = uicontrol('Parent',h0, ... 'Units','normalized', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontSize',10, ... 'FontWeight','demi', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[0.2516666666666667 0.9341935483870968 0.2833333333333333 0.02064516129032258], ... 'String','SELECTED DATA SET', ... 'Style','text', ... 'Tag','StaticText14');if ~isstruct(sData), sData=som_data_struct(sData);endui_h=uimenu('Label','&Normalization');uimenu(ui_h,'Label','Scale [0,1]','Callback','preprocess zscale');uimenu(ui_h,'Label','Scale var=1','Callback','preprocess vscale');uimenu(ui_h,'Label','HistD','Callback','preprocess histeq');uimenu(ui_h,'Label','HistC','Callback','preprocess histeq2');uimenu(ui_h,'Label','Log','Callback','preprocess log');uimenu(ui_h,'Label','Eval (1-comp)','Callback','preprocess eval1');ui_h=uimenu('Label','&Components');uimenu(ui_h,'Label','Move component','Callback','preprocess move');uimenu(ui_h,'Label','Copy component','Callback','preprocess copy');uimenu(ui_h,'Label','Add: N binary types','Callback','preprocess oneo');uimenu(ui_h,'Label','Add: zeros','Callback','preprocess zero');uimenu(ui_h,'Label','Remove component','Callback','preprocess remove');uimenu(ui_h,'Label','Remove selected vectors',... 'Callback','preprocess remove_vects');uimenu(ui_h,'Label','Select all components',... 'Callback','preprocess sel_all_comps');ui_h=uimenu('Label','&Misc');ui_h1=uimenu(ui_h,'Label','Calculate');ui_h2=uimenu(ui_h,'Label','Process');uimenu(ui_h,'Label','Get LOG-file','Callback','preprocess LOG');uimenu(ui_h,'Label','Indices of the selected vectors',... 'Callback','preprocess get_inds');uimenu(ui_h,'Label','Undo','Callback','preprocess undo');uimenu(ui_h1,'Label','Number of values','Callback','preprocess noof');uimenu(ui_h1,'Label','Number of selected vectors',... 'Callback','preprocess no_of_sel');uimenu(ui_h1,'Label','Correlation','Callback','preprocess corr');uimenu(ui_h2,'Label','Unit length','Callback','preprocess unit');uimenu(ui_h2,'Label','Eval','Callback','preprocess eval2');uimenu(ui_h2,'Label','Clipping','Callback','preprocess clipping');uimenu(ui_h2,'Label','Delay','Callback','preprocess delay');uimenu(ui_h2,'Label','Windowed','Callback','preprocess window');uimenu(ui_h2,'Label','Select vectors','Callback','preprocess select');len=getfield(size(sData(1).data),{1});data.selected_vects=find(ones(1,len));data.sD_set=sData;set(data.vector_h,'ButtonDownFcn','preprocess(''vector_bdf'',''down'')');set(gcf,'UserData',data);if ~set_sD_stats; return;endsel_sD;return; %%% Preprocess-window is ready.else arg=sData; if strcmp(arg,'rename') rename(arg2); elseif strcmp(arg,'sel_sD') if isempty(arg2) sel_sD; else sel_sD(arg2); end elseif strcmp(arg,'zscale') if isempty(arg2) zero2one_scale; else zero2one_scale(arg2); end elseif strcmp(arg,'vscale'); if isempty(arg2) var_scale; else var_scale(arg2); end elseif strcmp(arg,'histeq2') if isempty(arg2) hist_eq2; else hist_eq2(arg2); end elseif strcmp(arg,'log') if isempty(arg2) logarithm; else logarithm(arg2); end elseif strcmp(arg,'eval1') if isempty(arg2) eval1; else eval1(arg2); end elseif strcmp(arg,'eval2') if isempty(arg2) eval2; else eval2(arg2); end elseif strcmp(arg,'histeq'); if isempty(arg2) hist_eq; else hist_eq(arg2); end elseif strcmp(arg,'selall') if isempty(arg2) select_all; else select_all(arg2); end elseif strcmp(arg,'sel_button'); if isempty(arg2) sel_button; else sel_button(arg2); end elseif strcmp(arg,'clear_button') if isempty(arg2) clear_button; else clear_button(arg2) end elseif(strcmp(arg,'move')) if isempty(arg2) move_component; else move_component(arg2); end elseif(strcmp(arg,'copy')) if isempty(arg2) copy_component; else copy_component(arg2); end elseif strcmp(arg,'oneo') if isempty(arg2) one_of_n; else one_of_n(arg2); end elseif strcmp(arg,'zero') if isempty(arg2) add_zeros; else add_zeros(arg2); end elseif strcmp(arg,'remove') if isempty(arg2) remove_component; else remove_component(arg2); end elseif strcmp(arg,'remove_vects') if isempty(arg2) remove_vects; else remove_vects(arg2); end elseif strcmp(arg,'noof') if isempty(arg2) no_of_values; else no_of_values(arg2); end elseif strcmp(arg,'corr'); if isempty(arg2) correlation; else correlation(arg2); end elseif strcmp(arg,'unit') if isempty(arg2) unit_length; else unit_length(arg2); end elseif strcmp(arg,'clip_data') clip_data(arg2); elseif strcmp(arg,'copy_delete') copy_delete(arg2); elseif strcmp(arg,'and_or_cb') and_or_cb(arg2); elseif strcmp(arg,'all_sel_cb') all_sel_cb(arg2); elseif strcmp(arg,'clip_exp_cb') clip_exp_cb(arg2); elseif strcmp(arg,'window_cb') window_cb(arg2); elseif strcmp(arg,'set_state_vals') set_state_vals(arg2); elseif strcmp(arg,'vector_bdf') vector_bdf(arg2); elseif strcmp(arg,'sD_management'); if isempty(arg2) sD_management; else sD_management(arg2); end elseif strcmp(arg,'clipping') if isempty(arg2) clipping; else clipping(arg2); end elseif strcmp(arg,'delay') if isempty(arg2) delay; else delay(arg2); end elseif strcmp(arg,'window'); if isempty(arg2) window; else window(arg2); end elseif strcmp(arg,'select'); if isempty(arg2) select; else select(arg2); end elseif strcmp(arg,'import') if isempty(arg2) import; else import(arg2); end elseif strcmp(arg,'export') if isempty(arg2) export; else export(arg2); end elseif strcmp(arg,'undo'); if isempty(arg2) undo; else undo(arg2); end elseif strcmp(arg,'delay_data') if isempty(arg2) delay_data; else delay_data(arg2); end elseif strcmp(arg,'eval_windowed') if isempty(arg2) eval_windowed; else eval_windowed(arg2); end elseif strcmp(arg,'get_inds') if isempty(arg2) get_selected_inds; else get_selected_inds(arg2); end elseif strcmp(arg,'no_of_sel') if isempty(arg2) no_of_selected; else no_of_selected(arg2); end elseif strcmp(arg,'sel_comp'); if isempty(arg2) sel_comp; else sel_comp(arg2); end elseif strcmp(arg,'sel_all_comps') if isempty(arg2) select_all_comps; else select_all_comps(arg2); end elseif strcmp(arg,'refresh') set_var_names; elseif any(strcmp(arg,{'close_c','close_d','close_s','close_w','close_sD'})) if isempty(arg2) close_func(arg) else close_func(arg,arg2); end end switch arg case 'sD_stats' sD_stats; case 'LOG' log_file; otherwise pro_tools(arg); endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function set_compnames(sData,h)%SET_COMPNAMES%% set_compnames(sData,h)%% ARGUMENTS%% sData (struct) som_data_struct% h (scalar) handle to a list box object%%% This function sets the component names of sData to the list box% indicated by 'h'. %pre_h=findobj(get(0,'Children'),'Tag','Preprocess');if isempty(pre_h) error('Figure ''Preprocess'' does not exist. Closing program...'); close_preprocess;endudata=get(pre_h,'UserData');set(h,'Value',[]);for i=1:length(sData.comp_names) tmp=sprintf('#%d: ',i); names{i,1}=cat(2,tmp, sData.comp_names{i});endset(h,'String',names,'Max',2);set(udata.sel_comp_h,'String',names);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function draw_vectors(vectors,h)%DRAW_VECTORS%% draw_vectors(vectors,h)%% ARGUMENTS%% vectors (vector) vector of 0's and 1's% h (scalar) handle to an axis object%%% This function draws an horizontal bar of 'vectors' in the axis% indicated by 'h'.%%pre_h=findobj(get(0,'Children'),'Tag','Preprocess');subplot(h);hold off;cla;set(h,'YLim',[0 1]);set(h,'YTick',[]);set(h,'XLim',[0 length(vectors)+1]);hold on;comp_no=get(getfield(get(pre_h,'UserData'),'sel_comp_h'),'Value');comp=getfield(get(pre_h,'UserData'),'sData');comp=comp.data(:,comp_no);Max = max(comp);Min = min(comp);lims=get(gca,'YLim');lims(1)=Min;h=abs(0.1*Max);lims(2)=Max;if Max - Min <= eps tmp=Max; lims(1)=tmp-1; lims(2)=tmp+1;endlims(2)=lims(2)+h;if ~all(isnan(lims)) set(gca,'YLim',lims);endh=(lims(2)-lims(1))/4;set(gca,'YTickMode','auto'); t=1:length(vectors);h=plot(t,comp);set(h,'ButtonDownFcn','preprocess(''vector_bdf'',''down'')');indices =find(vectors);vectors(indices)=0.1*(getfield(get(gca,'YLim'),... {2})-getfield(get(gca,'YLim'),{1}));plot(indices,vectors(indices)+getfield(get(gca,'YLim'),{1}),... 'ored','MarkerSize',4);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function vect_means(sData,handle,indices)%VECT_MEANS%% vect_means(sData,handle,indices)%% ARGUMENTS% % sData (struct) som_data_struct% handle (scalar) handle to the static text box object% indices (vector) indices of selected vectors%%% This function calculates means of selected vectors' components% and writes them in the static text box indicated by 'handle'.%%sData= sData.data(indices,:);for i=1:length(sData(1,:)) names{i}=sprintf('#%d: ',i);endfor i=1:length(sData(1,:)) tmp=sData(:,i); tmp=cat(2,names{i},sprintf('%-10.3g',mean(tmp(find(~isnan(tmp)))))); string{i}=tmp;endset(handle,'String',string);set(handle,'HorizontalAlignment','left');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function vector_bdf(arg)%VECTOR_BDF A button down function.%% vector_bdf(arg)%% ARGUMENTS%% arg (string) 'down' or 'up', tells the mouse button's state.% %% This function selects vectors in the vector-window and plots maxima,% minima and means of the selected vectors. It also writes means of the% selected vectors' components in a static text box and takes care of% changes of the chosen component's data.%% See also VECTOR_MEANS, SEL_COMP%% arg2=arg(6:length(arg));if ~isempty(arg2) LOG=1;else LOG=0;endarg=arg(1:4);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -