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

📄 fmri_plot_rf.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
📖 第 1 页 / 共 4 页
字号:
function fig = fmri_plot_rf(action,varargin)
%
% fmri_plot_rf(action,action_arg1,...)

%  Application Data
%
%	STDatamat
%	SelectedCondition
%	ObjPositin
%	PlottedDatamat
%	AxesBoundary
%

  if ~exist('action','var') | isempty(action) 		% no action argument
      return;
  end;

  fig = [];
  if strcmp(action,'STARTUP')			    

      sessionFileList = varargin{1};
      init(sessionFileList);
      gen_condition_chk_box(1);
      SetObjPosition;

      return;
  elseif strcmp(action,'LINK')			    % call from other figure

      sessionFileList = varargin{1};
      fig = init(sessionFileList);
      gen_condition_chk_box(1);
      SetObjPosition;

      figure(gcbf);

      return;
  end;

  %  clear the message line,
  %
%  h = findobj(gcf,'Tag','MessageLine');
 % set(h,'String','');

  if strcmp(action,'LoadSTDatamat')
      selected_datamat = get(findobj(gcbf,'Tag','STDatamatPopup'),'Value');
      gen_condition_chk_box(selected_datamat);
      plot_response_fn;
  elseif strcmp(action,'NewCoord')
      new_coord = varargin{1};
      new_xyz = varargin{2};
      new_lag = varargin{3};
      setappdata(gcf,'Coord',new_coord);
      setappdata(gcf,'XYZ',new_xyz);
      setappdata(gcf,'lag',new_lag);
      plot_response_fn;
  elseif strcmp(action,'PlotBnPress')
      set(gcf,'pointer','watch');
      coord = getappdata(gcf,'Coord');
      plot_response_fn;
      set(gcf,'pointer','arrow');
  elseif strcmp(action,'SliderMotion')
      condition_update;
  elseif strcmp(action,'ResizeFigure')
      resize_fig;
  elseif strcmp(action,'DeleteFigure')
      delete_fig;
  elseif strcmp(action,'MENU_PlotIndividualData')
      make_datamat_popup(1);
  elseif strcmp(action,'MENU_PlotGroupData')
      make_datamat_popup(2);
  elseif strcmp(action,'MENU_PlotAllData')
      make_datamat_popup(3);
  elseif strcmp(action,'MENU_NumPtsPlotted')
      st_win_size = getappdata(gcf,'STWinSize');
      win_size_str = num2str(st_win_size);
      input_num_pts = inputdlg({'Number of points to be plotted'}, ...
			   'Input',1,{win_size_str});
      if ~isempty(input_num_pts)
         num_pts = str2num(input_num_pts{1});
         if ~isempty(num_pts)
            if (num_pts < 1) | (num_pts > st_win_size),
                msg = 'ERROR: Invalid input number of points';
                set(findobj(gcf,'Tag','MessageLine'),'String',msg);
            else
                setappdata(gcf,'NumPtsPlotted',num_pts);
            end
         end
      end;
  elseif strcmp(action,'MENU_CombinePlots')
      curr_state = get(gcbo,'Userdata');
      if (curr_state == 1),		% currently combining plots
         new_state = 0;
         set(gcbo,'Label','Combine plots within conditions');
      else
         new_state = 1;
         set(gcbo,'Label','Separate plots within conditions');
      end;
      set(gcbo,'Userdata',new_state);

      set(findobj(gcf,'tag','Stable'),'Userdata',0,'Label','&Stable off');

      fmri_plot_cond_stim_ui('COMBINE_PLOTS',new_state);
  elseif strcmp(action,'MENU_NormalizePlots')
      curr_state = get(gcbo,'Userdata');
      if (curr_state == 1),		% current plot is normalized plot
         new_state = 0;
         set(gcbo,'Label','Enable Data Normalization');
      else
         new_state = 1;
         set(gcbo,'Label','Disable Data Normalization');
      end;
      set(gcbo,'Userdata',new_state);
      plot_response_fn;
  elseif strcmp(action,'MENU_ExportData')
      save_response_fn;
  elseif strcmp(action,'MENU_ExportBehavData')
      save_response_fn2;
  elseif strcmp(action,'toggle_stable')
     stable_state = get(gcbo,'Userdata');
     if (stable_state == 1)
        bs1 = getappdata(gcf,'bs1');
        bs2 = getappdata(gcf,'bs2');
        bs3 = getappdata(gcf,'bs3');
        bs4 = getappdata(gcf,'bs4');

        for h = bs1
           if ishandle(h), set(h,'visible','on'); end
        end

        for h = bs2
           if ishandle(h), set(h,'visible','on'); end
        end

        for h = bs3
           if ishandle(h), set(h,'visible','on'); end
        end

        for h = bs4
           if ishandle(h), set(h,'visible','on'); end
        end

        set(gcbo,'Userdata',0,'Label','&Stable off');
     else
        bs1 = getappdata(gcf,'bs1');
        bs2 = getappdata(gcf,'bs2');
        bs3 = getappdata(gcf,'bs3');
        bs4 = getappdata(gcf,'bs4');

        for h = bs1
           if ishandle(h), set(h,'visible','of'); end
        end

        for h = bs2
           if ishandle(h), set(h,'visible','of'); end
        end

        for h = bs3
           if ishandle(h), set(h,'visible','of'); end
        end

        for h = bs4
           if ishandle(h), set(h,'visible','of'); end
        end

        set(gcbo,'Userdata',1,'Label','&Stable on');
     end;
  end;

  return;


%--------------------------------------------------------------------------
%
function fig = init(sessionFileList)

   cond_selection = getappdata(gcf,'cond_selection');
   CallBackFig = gcbf;

   save_setting_status = 'on';
   fmri_plot_rf_pos = [];

   try
      load('pls_profile');
   catch
   end

   if ~isempty(fmri_plot_rf_pos) & strcmp(save_setting_status,'on')

      pos = fmri_plot_rf_pos;

   else

      w = 0.8;
      h = 0.7;
      x = (1-w)/2;
      y = (1-h)/2;

      pos = [x y w h];

   end

   hh = figure('Units','normal', ...
	   'Name','Response Function Plot', ...	
	   'NumberTitle','off', ...
	   'Color', [0.8 0.8 0.8], ...
 	   'DoubleBuffer','on', ...
	   'Menubar', 'none', ...
	   'DeleteFcn', 'fmri_plot_rf(''DeleteFigure'');', ...
	   'Position',pos, ...
	   'Tag','PlotRFFig');

   %  display 'Neighborhood Size: '
   %
   x = 0.05;
   y = 0.9;
   w = 0.22;
   h = 0.05;

   pos = [x y w h];

   fnt = 0.5;

   h0 = uicontrol('Parent',hh, ...
   	   'Units','normal', ...
	   'FontUnits', 'normal', ...
	   'FontSize', fnt, ...
	   'BackgroundColor', [0.8 0.8 0.8], ...
 	   'Style', 'text', ...
	   'Position', pos, ...	
           'HorizontalAlignment', 'left',...
           'String', 'Neighborhood Size: ', ...
	   'Tag', 'neighborhoodLabel');

   %  edit 'Neighborhood Size: '
   %
   y = 0.85;
   w = 0.04;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...
   	   'Units','normal', ...
	   'FontUnits', 'normal', ...
	   'FontSize', fnt, ...
	   'BackgroundColor', [1 1 1], ...
 	   'Style', 'edit', ...
	   'Position', pos, ...	
           'HorizontalAlignment', 'left',...
           'String', '0', ...
	   'tooltipstring', 'Use average intensity of its neighborhood voxels for intensity of this voxel. Neighborhood size is number of voxels from this voxel.', ...
           'CallBack', 'fmri_plot_rf(''PlotBnPress'');', ...
	   'Tag', 'neighborhoodEdit');

   x = x + w + 0.01;
   w = 0.12;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...
   	   'Units','normal', ...
	   'FontUnits', 'normal', ...
	   'FontSize', fnt, ...
	   'BackgroundColor', [0.8 0.8 0.8], ...
 	   'Style', 'text', ...
	   'Position', pos, ...	
           'HorizontalAlignment', 'right',...
           'String', 'has neighbor #:', ...
	   'Tag', 'neighbornumberLabel');

   x = x + w + 0.01;
   w = 0.04;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...
   	   'Units','normal', ...
	   'FontUnits', 'normal', ...
	   'FontSize', fnt, ...
	   'BackgroundColor', [0.8 0.8 0.8], ...
 	   'Style', 'text', ...
	   'Position', pos, ...	
           'HorizontalAlignment', 'right',...
           'String', '1', ...
	   'Tag', 'neighbornumberEdit');

   %  display 'ST datamat: '
   %
   x = 0.05;
   y = 0.77;
   w = 0.22;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...
   	   'Units','normal', ...
	   'FontUnits', 'normal', ...
	   'FontSize', fnt, ...
	   'BackgroundColor', [0.8 0.8 0.8], ...
 	   'Style', 'text', ...
	   'Position', pos, ...	
           'HorizontalAlignment', 'left',...
	   'String', 'Datamat:', ...
	   'Tag', 'STDatamatLabel');

   %  create ST datamat popup menu
   %
   y = 0.72;

   pos = [x y w h];

   cb_fn = [ 'fmri_plot_rf(''LoadSTDatamat'');'];
   popup_h = uicontrol('Parent',hh, ...
   	   'units','normal', ...
	   'FontUnits', 'normal', ...
	   'FontSize', fnt, ...
           'Style', 'popupmenu', ...
	   'Position', pos, ...
           'HorizontalAlignment', 'left',...
	   'String', '', ...
	   'Value', 1, ...
	   'Tag', 'STDatamatPopup', ...
	   'Callback',cb_fn);

   y = 0.18;
   h = 0.5;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...
           'Units','normal', ...
	   'BackgroundColor', [0.8 0.8 0.8], ...
 	   'Style', 'frame', ...
	   'Position', pos, ...	
           'HorizontalAlignment', 'left',...
	   'Tag', 'CondFrame');

   x = 0.09;
   y = 0.64;
   w = 0.14;
   h = 0.05;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...
           'Units','normal', ...
	   'FontUnits', 'normal', ...
	   'FontSize', fnt, ...
	   'BackgroundColor', [0.8 0.8 0.8], ...
 	   'Style', 'text', ...
	   'Position', pos, ...	
           'HorizontalAlignment', 'center',...
	   'String', 'Conditions', ...
	   'Tag', 'ConditionLabel');

   x = 0.05;
   y = 0.08;
   w = 0.1;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...
          'Units','normal', ...
          'FontUnits', 'normal', ...
          'FontSize', fnt, ...
          'Style', 'push', ...
	  'Position', pos, ...
          'String', 'Plot', ...
   	  'Enable', 'on', ...
	  'Tag', 'PlotButton', ...
          'CallBack', 'fmri_plot_rf(''PlotBnPress'');');

   x = x+w+.02;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...
          'Units','normal', ...
          'FontUnits', 'normal', ...
          'FontSize', fnt, ...
          'Style', 'push', ...
	  'Position', pos, ...
          'String', 'Close', ...
          'CallBack', 'close(gcf)', ...
	  'Tag', 'CloseButton');

   x = 0.01;
   y = 0;
   w = 1;
   h = 0.05;

   pos = [x y w h];

   h0 = uicontrol('Parent',hh, ...		% Message Line
   	'Style','text', ...
   	'Units','normal', ...
        'FontUnits', 'normal', ...
        'FontSize', fnt, ...
   	'BackgroundColor',[0.8 0.8 0.8], ...
   	'ForegroundColor',[0.8 0.0 0.0], ...
   	'HorizontalAlignment','left', ...
   	'Position',pos, ...
   	'String','', ...
   	'Tag','MessageLine');

  rri_file_menu(hh);

  h_plot = uimenu('Parent',hh, ...
	     'Label','&Plot', ...
             'Enable','on',...
	     'Tag','PlotMenu');
  h0 = uimenu('Parent',h_plot, ...
	     'Label','Plot individual ST datamat', ...
	     'Tag','PlotIndividualData', ...

⌨️ 快捷键说明

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