⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfbox_rel_windowg.m

📁 toolbox for spm 5 for data, model free analysis
💻 M
字号:
function varargout=mfbox_rel_windowg(varargin)% MFBOX_REL_WINDOWG M-file for mfbox_rel_windowg.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_rel_windowg_OpeningFcn, ...    'gui_OutputFcn',@mfbox_rel_windowg_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_rel_windowg is made visible.function mfbox_rel_windowg_OpeningFcn(hObject,eventdata,handles,varargin)% varargin{1} contains the mfbss struct% varargin{2} (optional) contains the parameters% varargin{3} (optional) contains runflag (0: param edit only, 1: param+run, 2: run only)handles.output = hObject;handles.mfbss = varargin{1};tmethod = {'none','variance'};if (~isempty(handles.mfbss.design)), tmethod{end+1} = 'design'; endif (~isempty(handles.mfbss.reference)), tmethod{end+1} = 'reference'; endhandles.radios = struct('equal',handles.equalspace,'design',handles.designspace);set(handles.overlap_slider,'Min',0,'Max',1);desc = 1;if (~isempty(handles.mfbss.design))    desc = size(handles.mfbss.design,2);    set(handles.descomp,'Min',1,'Max',0.01+desc, ...        'SliderStep',min(ones(1,2)/max(desc-1,1),1));else    set(handles.designspace,'Enable','off');    set(handles.follow_design,'Enable','off');    set(handles.descomp,'Min',0,'Max',1.01,'SliderStep',ones(1,2),'Enable','off');endif (nargin>4), handles.params = varargin{2};else handles.params = [];endif (nargin>5), handles.runflag = varargin{3};else handles.runflag = 1;endhandles.params.descomp = min(desc,handles.params.descomp);set(handles.overlap,'String',mat2str(handles.params.overlap));set(handles.overlap_slider,'Value',handles.params.overlap);set(handles.windows,'String',mat2str(handles.params.windows));set(handles.variance,'String',mat2str(handles.params.variance));set(handles.variance_slider,'Value',handles.params.variance);set(handles.descomp,'Value',handles.params.descomp);v = fieldnames(handles.radios);for i=1:length(v)    if (strcmp(v{i},handles.params.spacing)), set(handles.radios.(v{i}),'Value',1);    else set(handles.radios.(v{i}),'Value',0);    endendt = find(strcmp(tmethod,handles.params.threshold_type));if (isempty(t)), t = 1; endset(handles.thresholdtype,'String',tmethod,'Value',t);set(handles.threshold,'String',sprintf('%1.4f',handles.params.threshold));switch handles.params.threshold_type    case 'none'        set(handles.threshold,'Enable','off');    otherwise        set(handles.threshold,'Enable','on');endhandles = redrawpre(handles);if (handles.runflag<1), set(handles.run,'String','Set ...'); endguidata(hObject,handles);if (abs(handles.runflag-0.5)<1), uiwait(handles.figure1); end% --- Outputs from this function are returned to the command line.function varargout=mfbox_rel_windowg_OutputFcn(hObject,eventdata,handles) % varargout{1} contains the (modified) parametersif (isstruct(handles))    close(handles.figure1);    varargout{1} = handles.params;else    varargout{1} = [];end% --- Executes on button press in run.function run_Callback(hObject,eventdata,handles)handles.params.windows = str2double(get(handles.windows,'String'));handles.params.overlap = str2double(get(handles.overlap,'String'));v = fieldnames(handles.radios);for i=1:length(v)    if (get(handles.radios.(v{i}),'Value')==1), handles.params.spacing = v{i}; endendhandles.params.descomp = floor(get(handles.descomp,'Value'));handles.params.variance = str2double(get(handles.variance,'String'));handles.params.follow_design = get(handles.follow_design,'Value');handles.params.threshold = str2double(get(handles.threshold,'String'));t = get(handles.thresholdtype,'String');handles.params.threshold_type = t{get(handles.thresholdtype,'Value')};guidata(hObject,handles);uiresume(handles.figure1);% --- Executes on button press in equalspace.function equalspace_Callback(hObject,eventdata,handles)v = fieldnames(handles.radios);for i=1:length(v)    if (strcmp(v{i},'equal')), set(handles.radios.(v{i}),'Value',1);    else set(handles.radios.(v{i}),'Value',0);    endendset(handles.descomp,'Enable','off');handles = redrawpre(handles);guidata(hObject,handles);% --- Executes on button press in designspace.function designspace_Callback(hObject,eventdata,handles)v = fieldnames(handles.radios);for i=1:length(v)    if (strcmp(v{i},'design')), set(handles.radios.(v{i}),'Value',1);    else set(handles.radios.(v{i}),'Value',0);    endendset(handles.descomp,'Enable','on');handles = redrawpre(handles);guidata(hObject,handles);% --- Executes on slider movement.function descomp_Callback(hObject,eventdata,handles)handles = redrawpre(handles);guidata(hObject,handles);% --- Executes during object creation, after setting all properties.function descomp_CreateFcn(hObject,eventdata,handles)if (isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor')))    set(hObject,'BackgroundColor',[.9,.9,.9]);end% --- Executes during object creation, after setting all properties.function overlap_slider_CreateFcn(hObject,eventdata,handles)if (isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor')))    set(hObject,'BackgroundColor',[.9,.9,.9]);end% --- Executes during object creation, after setting all properties.function variance_Callback(hObject, eventdata, handles)v = min(max(str2double(get(hObject,'String')),0),1);set(hObject,'String',sprintf('%1.3f',v));set(handles.variance_slider,'Value',v);handles = redrawpre(handles);guidata(hObject,handles);% --- Executes during object creation, after setting all properties.function variance_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on slider movement.function variance_slider_Callback(hObject, eventdata, handles)set(handles.variance,'String',sprintf('%1.3f',get(hObject,'Value')));handles = redrawpre(handles);guidata(hObject,handles);% --- Executes during object creation, after setting all properties.function variance_slider_CreateFcn(hObject, eventdata, handles)if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on overlap.function overlap_Callback(hObject,eventdata,handles)v = min(max(str2double(get(hObject,'String')),0),1);set(hObject,'String',sprintf('%1.3f',v));set(handles.overlap_slider,'Value',v);handles = redrawpre(handles);guidata(hObject,handles);% --- Executes on windows.function overlap_slider_Callback(hObject,eventdata,handles)set(handles.overlap,'String',sprintf('%1.3f',get(hObject,'Value')));handles = redrawpre(handles);guidata(hObject,handles);% --- Executes on overlap.function windows_Callback(hObject,eventdata,handles)set(hObject,'String',mat2str(abs(round(str2double(get(hObject,'String'))))));handles = redrawpre(handles);guidata(hObject,handles);% --- Executes during object creation, after setting all properties.function overlap_CreateFcn(hObject,eventdata,handles)if (ispc&&(isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))))    set(hObject,'BackgroundColor','white');end% --- Executes during object creation, after setting all properties.function windows_CreateFcn(hObject,eventdata,handles)if (ispc&&(isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))))    set(hObject,'BackgroundColor','white');end% ---function w=getwindows(l,w,o,d)if (isempty(d))    l = length(l);    wl = l/(w*(1-o)+o);    wlr = wl*(1-o);    w = repmat(floor((0:(w-1))*wlr),ceil(wl),1)'+repmat(1:ceil(wl),w,1);else    d = interp1(0:(length(d)-1),d,l)';    l = length(l);    dn = false(size(d(:)));    dn(2:(end-1)) = (d(2:(end-1))>d(1:(end-2)))&(d(2:(end-1))>=d(3:end));    f = find(dn);    if (length(f)>w)        df = f(2:end)-f(1:(end-1));        [x,p] = sort(df);        dn(f(p(1:(length(f)-w))+1)) = false;        f = find(dn);    end    if (min(f)>1), f = [1;f]; end    if (max(f)<l), f = [f;l]; end    df = f(3:end)-f(1:(end-2));    wn = length(f)-2;    wl = floor((1-o)*min(df)+o*l);    w = zeros(wn,wl);    for i=1:wn        s = max(1,floor(f(i+1)-wl/2));        e = s+wl-1;        if (e>l), s = s-e+l; e = l; end        w(i,:) = s:e;    endendw = unique(w,'rows');% --- Executes on button press in follow_design.function follow_design_Callback(hObject, eventdata, handles)% ---function handles=redrawpre(handles)w = str2double(get(handles.windows,'String'));o = str2double(get(handles.overlap,'String'));v = fieldnames(handles.radios);for i=1:length(v)    if (get(handles.radios.(v{i}),'Value')==1), s = v{i}; endendd = floor(get(handles.descomp,'Value'));switch s    case 'equal'        d  = [];    case 'design'        d = handles.mfbss.design(:,d);endl = length(handles.mfbss.timeline);windows = getwindows(handles.mfbss.timeline,w,o,d);I = ones(35,200,3);for i=1:size(windows,1)    x = (6:15)+mod(i,2)*15;    y = 1+floor(199*(windows(i,:)-1)/l);    y = min(y):max(y);    N = ones(35,200,3);    N(x,y,:) = 0;    N(x(2:(end-1)),y(2:(end-1)),1) = 1;    N(x(2:(end-1)),y(2:(end-1)),2) = 0.5;    N(x(2:(end-1)),y(2:(end-1)),3) = 0.5;    I = I.*N;endimage(I,'Parent',handles.part_vis);set(handles.part_vis,'XTickMode','manual','Color',.8*ones(3,1), ...    'XTickLabelMode','manual','YTickMode','manual', ...    'YTickLabelMode','manual','XTick',[],'XTickLabel',{}, ...    'YTick',[],'YTickLabel',{});% --- Executes on selection change in thresholdtype.function thresholdtype_Callback(hObject, eventdata, handles)t = get(handles.thresholdtype,'String');threshold_type = t{get(handles.thresholdtype,'Value')};switch threshold_type    case 'none'        set(handles.threshold,'Enable','off');    otherwise        set(handles.threshold,'Enable','on');endguidata(hObject,handles);% --- Executes during object creation, after setting all properties.function thresholdtype_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction threshold_Callback(hObject, eventdata, handles)v = str2double(get(hObject,'String'));v = max(v,0);set(hObject,'String',sprintf('%1.4f',v));guidata(hObject,handles);% --- Executes during object creation, after setting all properties.function threshold_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -