📄 mfbox_pos_selectcompg.m
字号:
function varargout=mfbox_pos_selectcompg(varargin)% MFBOX_POS_SELECTCOMPG M-file for mfbox_pos_selectcompg.fig%% See also: GUIDE, GUIDATA, GUIHANDLES%% Copyright by Peter Gruber and Fabian J. Theis% Signal Processing & Information Theory group% Institute of Biophysics, University of Regensburg, Germany% Homepage: http://research.fabian.theis.name% http://www-aglang.uni-regensburg.de%% This file is free software, subject to the % GNU GENERAL PUBLIC LICENSE, see gpl.txt% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',mfilename, ... 'gui_Singleton',gui_Singleton, ... 'gui_OpeningFcn',@mfbox_pos_selectcompg_OpeningFcn, ... 'gui_OutputFcn',@mfbox_pos_selectcompg_OutputFcn, ... 'gui_LayoutFcn',[] , ... 'gui_Callback',[]);if (nargin&&(ischar(varargin{1}))) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State,varargin{:});else gui_mainfcn(gui_State,varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before mfbox_pos_selectcompg is made visible.function mfbox_pos_selectcompg_OpeningFcn(hObject,eventdata,handles,varargin)% varargin{1} contains data A% varargin{2} contains data W% varargin{3} contains data S% varargin{4} (optional) contains data X% varargin{5} (optional) contains the parametershandles.output = hObject;handles.A = varargin{1};handles.W = varargin{2};handles.S = varargin{3};s = size(handles.S.dat);handles.dim = s(1:(end-1));handles.n = size(handles.S.map,2);if (nargin>6), handles.X = varargin{4}; endif (nargin>7), handles.params = varargin{5};else handles.params = [];endif (isfield(handles.S,'tag')), handles.params.names = handles.S.tag; end;if (isfield(handles.params,'mapping') && length(handles.params.mapping)~=handles.n) handles.params.mapping = 1:handles.n;endhandles.mapping = handles.params.mapping;handles.names = handles.params.names;set(handles.comp_pos,'Value',1,'Min',1,'Max',handles.n, ... 'SliderStep',min(ones(1,2)*1/max(handles.n-1,1),1));set(handles.details,'String',getdetails(handles.mapping,handles.names));comp_pos_Callback(handles.comp_pos,[],handles);guidata(hObject,handles);uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout=mfbox_pos_selectcompg_OutputFcn(hObject,eventdata,handles)% varargout{1} contains the (edited) paramsif (isstruct(handles)) varargout{1} = handles.params; close(handles.figure1);else varargout{1} = [];end% --- Executes on button press in run.function run_Callback(hObject,eventdata,handles)handles.params.mapping = zeros(size(handles.mapping));m = handles.mapping;u = unique(m(m>0));for i=1:length(u), handles.params.mapping(m==u(i)) = i; endhandles.params.names = handles.names;guidata(hObject,handles);uiresume(gcf);% --- Executes on slider movement.function comp_pos_Callback(hObject,eventdata,handles)pos = floor(get(hObject,'Value'));set(hObject,'Value',pos);a = logical(ones(1,handles.n));u = sort(unique(handles.mapping));if (u(1)==0) u = u(2:end); endtext = {'ignore'};act = 0;for i=1:length(u) if (u(i)==handles.mapping(pos)) act = i; end v = find(handles.mapping==u(i)); text{i+1} = sprintf('group %d (%s)',i,handles.names{v(1)});endtext{length(u)+2} = 'new group';set(handles.target,'String',text,'Value',act+1);set(handles.comp,'String',sprintf('comp %d/%d',pos,handles.n));set(handles.group_name,'String',handles.names{pos});guidata(hObject,handles);% --- Executes during object creation, after setting all properties.function comp_pos_CreateFcn(hObject,eventdata,handles)if (isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))) set(hObject,'BackgroundColor',[.9,.9,.9]);end% --- Executes on selection change in target.function target_Callback(hObject,eventdata,handles)act = get(hObject,'Value');pos = floor(get(handles.comp_pos,'Value'));a = logical(ones(1,handles.n));u = sort(unique(handles.mapping));if (u(1)==0), u = u(2:end); enda(u) = 0;f = min(find(a));if (act==1) handles.mapping(pos) = 0; handles.names{pos} = '';elseif ((act-1)<=length(u)) v = find(handles.mapping==u(act-1)); handles.mapping(pos) = u(act-1); handles.names{pos} = handles.names{v(1)};else handles.mapping(pos) = f; handles.names{pos} = 'new group';endset(handles.group_name,'String',handles.names{pos});set(handles.details,'String',getdetails(handles.mapping,handles.names));comp_pos_Callback(handles.comp_pos,[],handles);guidata(hObject,handles);function group_name_Callback(hObject,eventdata,handles)pos = floor(get(handles.comp_pos,'Value'));pos = find(handles.mapping==handles.mapping(pos));for i=1:length(pos), handles.names{pos(i)} = get(hObject,'String'); endset(handles.details,'String',getdetails(handles.mapping,handles.names));guidata(hObject,handles);comp_pos_Callback(handles.comp_pos,eventdata,handles);% --- Executes during object creation, after setting all properties.function group_name_CreateFcn(hObject,eventdata,handles)if (ispc&&(isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor')))) set(hObject,'BackgroundColor','white');end% --- Executes on button press in auto.function auto_Callback(hObject,eventdata,handles)handles.mapping = mfbox_findgroups(handles.S.dat)';for i=1:length(handles.mapping) handles.names{i} = sprintf('Group %d',handles.mapping(i));endset(handles.comp_pos,'Value',1);set(handles.group_name,'String',handles.names{1});set(handles.details,'String',getdetails(handles.mapping,handles.names));comp_pos_Callback(handles.comp_pos,[],handles);guidata(hObject,handles);% --- Executes during object creation, after setting all properties.function target_CreateFcn(hObject,eventdata,handles)if (ispc&&(isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor')))) set(hObject,'BackgroundColor','white');endfunction s=getdetails(map,names)ncomp = length(map);a = logical(ones(1,ncomp));c = 1:ncomp;n = 1;text = {};for i=1:ncomp p = (map==i); if (sum(p)>0) q = find(p); text{n} = [sprintf('%d',n) ' (' names{q(1)} ') consists of [' sprintf('%d ',c(p)) ']']; n = n+1; a = a&~p; endendif (sum(a)>0), text{n} = ['[' sprintf('%d ',c(a)) '] are ignored']; ends = strvcat(text);% --- Executes on button press in clear.function clear_Callback(hObject, eventdata, handles)handles.mapping = ones(1,handles.n);for i=1:handles.n handles.names{i} = 'All';endset(handles.comp_pos,'Value',1);set(handles.group_name,'String',handles.names{1});set(handles.details,'String',getdetails(handles.mapping,handles.names));comp_pos_Callback(handles.comp_pos,[],handles);guidata(hObject,handles);% --- Executes on button press in reset.function reset_Callback(hObject, eventdata, handles)handles.mapping = 1:handles.n;for i=1:handles.n handles.names{i} = sprintf('Component %d',handles.mapping(i));endset(handles.comp_pos,'Value',1);set(handles.group_name,'String',handles.names{1});set(handles.details,'String',getdetails(handles.mapping,handles.names));comp_pos_Callback(handles.comp_pos,[],handles);guidata(hObject,handles);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -