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

📄 pet_plot_scores_ui.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
📖 第 1 页 / 共 4 页
字号:
%
%   Usage: fig = pet_plot_scores_ui(LINK, fname, is_design_plot);
%   Called by pet_result_ui
%
function score_fig = pet_plot_scores_ui(varargin)

   if ~ischar(varargin{1})
      h = findobj(gcbf,'Tag','ResultFile');
      result_file = get(h,'UserData');
      is_design_plot = varargin{1};

      [tmp tit_fn] = rri_fileparts(get(gcf,'name'));
      score_fig = init(result_file, is_design_plot, tit_fn);

      old_pointer = get(gcf,'Pointer');
      set(gcf,'Pointer','watch');

      PlotDesignScores;
      PlotBrainDesignScores;

      set(gcf,'Pointer',old_pointer);

      return;
   end

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

   action = varargin{1};

   switch (action),
     case {'move_slider'}
         MoveSlider;
     case {'select_lv'}
         old_pointer = get(gcf,'Pointer');
         set(gcf,'Pointer','watch');

	 SelectLV;

         PlotBrainDesignScores;
         PlotDesignScores;
         PlotDesignLV;

         dlv_fig_user = [];
         try
            dlv_fig_user = get(getappdata(gcf,'dlv_fig'),'user');
         catch
         end

         if ~isempty(dlv_fig_user) & strcmp(dlv_fig_user,'LV Plot')
            set(gcf,'Pointer',old_pointer);
            view_dlv
         end

         set(gcf,'Pointer',old_pointer);
     case {'toggle_axis'}
         toggle_axis;
     case {'toggle_dlv'}
         toggle_dlv;
     case {'ToggleLegend'},
         ToggleLegend;
     case {'ToggleBrainDesignScores'},
         ToggleBrainDesignScores;
     case {'ToggleDesignScores'},
         ToggleDesignScores;
     case {'ToggleDesignLV'},
         ToggleDesignLV;
     case {'zoom'}
         zoom_on_state = get(gcbo,'Userdata');
         if (zoom_on_state == 1)                   % zoom on
            zoom on;
            set(gcbo,'Userdata',0,'Label','&Zoom off');
            set(gcf,'pointer','crosshair');
         else                                      % zoom off
            zoom off;
            set(gcf,'buttondown','pet_plot_scores_ui(''fig_bt_dn'');');
            set(gcbo,'Userdata',1,'Label','&Zoom on');
            set(gcf,'pointer','arrow');
         end
     case {'fig_bt_dn'}
         fig_bt_dn;
     case {'select_subj'}
  	 select_subj;
     case {'delete_fig'}
  	 delete_fig;
     otherwise
	 msgbox(sprintf('ERROR: Unknown action "%s"',action),'modal');
   end;

   return;					% pet_plot_scores_ui


%
%
%---------------------------------------------------------------------------

function h0 = init(result_file, is_design_plot, tit_fn)

   tit = ['PLS Scores Plot  [', tit_fn, ']'];
   cond_selection = getappdata(gcf,'cond_selection');

   h0 = [];
   [brainscores, designscores, designlv, ...
	cond_name, subj_name_lst, ...
	num_cond_lst, num_subj_lst, s, perm_result, datamat_files, num_grp] = ...
		load_pls_scores(result_file, is_design_plot);

   if isempty(brainscores)
      return;
   end

   num_grp = length(num_cond_lst);
   num_lv = size(brainscores,2);

   grp_str = [];
   for i=1:num_grp
%      grp_str = [grp_str, {['Group ', num2str(i)]}];
      file_name = datamat_files{i};
      [tmp file_name] = fileparts(file_name);
      grp_str = [grp_str, {file_name}];

      subj_select_lst{i} = ones(1, num_subj_lst(i));
   end

   lv_str = [];
   for i=1:num_lv
      lv_str = [lv_str, {['LV ', num2str(i)]}];
   end

   % ----------------------- Figure --------------------------

   save_setting_status = 'on';
   pet_plot_scores_pos = [];

   try
      load('pls_profile');
   catch
   end

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

      pos = pet_plot_scores_pos;

   else

      w = 0.85;
      h = 0.75;
      x = (1-w)/2;
      y = (1-h)/2;

      pos = [x y w h];

   end

   xp = 0.0227273;
   yp = 0.0294118;
   wp = 1-2*xp;
   hp = 1-2*yp;

   pos_p = [xp yp wp hp];

   h0 = figure('units','normal', ...
        'paperunit','normal', ...
        'paperorient','land', ...
        'paperposition',pos_p, ...
        'papertype','usletter', ...
	'numberTitle','off', ...
	'menubar', 'none', ...
	'toolbar', 'none', ...
	'user','PLS Scores Plot', ...
	'name',tit, ...
	'color', [0.8 0.8 0.8], ...
	'deleteFcn', 'pet_plot_scores_ui(''delete_fig'');', ...
	'doubleBuffer','on', ...
	'position',pos);

   % ----------------------- Menu --------------------------

   %  file
   %
   rri_file_menu(h0);

   %  view
   %
   h_view = uimenu('parent',h0, ...
	'label','&View', ...
	'tag','ViewMenu');

   hm_axis = uimenu('parent',h_view, ...
	'userdata', 0, ...
	'callback', 'pet_plot_scores_ui(''toggle_axis'');', ...
		'visible', 'off', ...
	'label','&Plot Current Figure');

   hm_dlv = uimenu('parent',h_view, ...
	'userdata', 0, ...
	'callback', 'pet_plot_scores_ui(''toggle_dlv'');', ...
		'visible', 'off', ...
	'label','&Plot Design LV Figure');

%	'sepa','on', ...

   if(is_design_plot)
      h1 = uimenu('parent',h_view, ...
	'label','Hide &Brain vs Design Scores', ...
	'userdata',1, ...		% show brain vs design scores
	'callback', 'pet_plot_scores_ui(''ToggleBrainDesignScores'');', ...
	'tag','BrainDesignMenu');
      h1 = uimenu('parent',h_view, ...
	'label','Show &Design Scores', ...
	'userdata',0, ...		% show design scores
	'callBack', 'pet_plot_scores_ui(''ToggleDesignScores'');', ...
	'tag','DesignMenu');
      h1 = uimenu('parent',h_view, ...
	'label','Show Design &Latent Variables', ...
	'userdata',0, ...		% show design lv
	'callBack', 'pet_plot_scores_ui(''ToggleDesignLV'');', ...
	'tag','DesignLVMenu');
   else
      h1 = uimenu('parent',h_view, ...
	'sepa','on', ...
	'label','Hide &Brain vs Behavior Scores', ...
	'userdata',1, ...		% show brain vs behavior scores
	'callback', 'pet_plot_scores_ui(''ToggleBrainDesignScores'');', ...
	'tag','BrainBehavMenu');
      h1 = uimenu('parent',h_view, ...
	'label','Show Be&havior Scores', ...
	'userdata',0, ...		% show behavior scores
	'callBack', 'pet_plot_scores_ui(''ToggleDesignScores'');', ...
	'tag','BehavMenu');
      h1 = uimenu('parent',h_view, ...
	'label','Show Behavior &Latent Variables', ...
	'userdata',0, ...		% show behavior lv
	'callBack', 'pet_plot_scores_ui(''ToggleDesignLV'');', ...
	'tag','BehavLVMenu');
   end

   h1 = uimenu('parent',h_view, ...
	'sepa','on', ...
	'label','&Hide Legend', ...
	'userdata',1, ...		% show legend
	'callBack', 'pet_plot_scores_ui(''ToggleLegend'');', ...
	'tag','LegendMenu');

   %  zoom
   %
   h2 = uimenu('parent',h0, ...
        'userdata', 1, ...
        'callback','pet_plot_scores_ui(''zoom'');', ...
        'label','&Zoom on');

   pause(0.01);

   % ---------------------- Left Panel ------------------------

   x = 0.03;
   y = 0.16;
   w = 0.18;
   h = 0.78;
   pos = [x y w h];

   h1 = uicontrol('parent',h0, ...
	'units','normal', ...
	'back', [0.8 0.8 0.8], ...
	'style', 'frame', ...
	'fontunit', 'normal', ...
	'fontsize', 0.5, ...
	'Tag', 'LVFrame', ...
	'position', pos);

   x = 0.06;
   y = 0.9;
   w = 0.12;
   h = 0.05;
   pos = [x y w h];

   h1 = uicontrol('parent',h0, ...
	'units','normal', ...
	'back', [0.8 0.8 0.8], ...
	'style', 'text', ...
	'fontunit', 'normal', ...
	'fontsize', 0.5, ...
	'string', 'Display LVs', ...
	'Tag', 'DisplayLVLabel', ...
	'position', pos);

   x = 0.07;
   y = 0.85;
   w = 0.1;

   pos = [x y w h];

   lv_h = uicontrol('parent',h0, ...
	'unit','normal', ...
	'BackgroundColor', [0.8 0.8 0.8], ...
	'style', 'radio', ...
	'string', 'LV #1', ...
	'fontunit', 'normal', ...
	'fontsize', 0.5, ...
	'callback', 'pet_plot_scores_ui(''select_lv'');', ...
	'tag','LVRadioButton', ...
	'visible','off', ...
	'position', pos);

   x = x+w+.01;
   w = 0.02;

   pos = [x y w h];

   h1 = uicontrol('parent',h0, ...
	'units','normal', ...
	'style', 'slider', ...
	'min', 0, ...
	'max', 1, ...
	'callback', 'pet_plot_scores_ui(''move_slider'');', ...
	'tag','LVButtonSlider', ...
	'visible','off', ...
	'position', pos);

   x = 0.07;
   y = 0.08;
   w = 0.1;

   pos = [x y w h];

   h1 = uicontrol('parent',h0, ...
	'units','normal', ...
	'style', 'push', ...
	'fontunit', 'normal', ...
	'fontsize', 0.5, ...
	'string', 'Close', ...
	'callback', 'close(gcf)', ...
	'position', pos);

   % ----------------------- Axes --------------------------

   %  set up the axes for plotting
   %
%	   'FontUnits', 'normal', ...
%	   'FontSize', 0.07, ...
%    axes were not normalized because the Legend can't display properly
%
   %
   x = 0.28;
   y = 0.1;
   w = 0.69;
   h = 0.85;

   pos = [x y w h];

   main_axes = axes('units', 'normal', ...
        'box', 'on', ...
        'tickdir', 'out', ...
        'ticklength', [0.005 0.005], ...
	'fontsize', 10, ...
	'xtickmode', 'auto', ...
	'xticklabelmode', 'auto', ...
	'ytickmode', 'auto', ...
	'yticklabelmode', 'auto', ...
	'visible', 'off', ...
	'position',pos);

   h = 0.37;

   pos = [x y w h];

   bottom_axes = axes('units','normal', ...
        'box', 'on', ...
        'tickdir', 'out', ...
        'ticklength', [0.005 0.005], ...
	'fontsize', 10, ...
	'xtickmode', 'auto', ...
	'xticklabelmode', 'auto', ...
	'ytickmode', 'auto', ...
	'yticklabelmode', 'auto', ...
	'position',pos);

   y = 0.58;

   pos = [x y w h];

   top_axes = axes('units','normal', ...
        'box', 'on', ...
        'tickdir', 'out', ...
        'ticklength', [0.005 0.005], ...
	'fontsize', 10, ...
	'xtickmode', 'auto', ...
	'xticklabelmode', 'auto', ...
	'ytickmode', 'auto', ...
	'yticklabelmode', 'auto', ...
	'position',pos);

   x = 0.01;
   y = 0;
   w = .5;
   h = 0.04;

   pos = [x y w h];

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

   lv_template = copyobj(lv_h,gcf);
   set(lv_template,'Tag','LVTemplate','Visible','off');
   curr_lv_state = zeros(1,num_lv); 
   curr_lv_state(1) = 1;

   setappdata(gcf,'tit_fn',tit_fn);
   setappdata(gcf,'brainscores',brainscores);
   setappdata(gcf,'designscores',designscores);
   setappdata(gcf,'designlv',designlv);
   setappdata(gcf, 'conditions', cond_name);
   setappdata(gcf, 'subj_name_lst', subj_name_lst);
   setappdata(gcf, 'num_cond_lst', num_cond_lst);
   setappdata(gcf, 'num_subj_lst', num_subj_lst);
   setappdata(gcf,'s',s);
   setappdata(gcf,'perm_result',perm_result);
   setappdata(gcf, 'datamat_files', datamat_files);
   setappdata(gcf, 'is_design_plot', is_design_plot);

   setappdata(gcf, 'num_grp', num_grp);
   setappdata(gcf, 'num_lv', num_lv);
   setappdata(gcf, 'subj_select_lst', subj_select_lst);

   setappdata(gcf, 'hm_axis', hm_axis);
   setappdata(gcf, 'hm_dlv', hm_dlv);
   setappdata(gcf, 'main_axes', main_axes);
   setappdata(gcf, 'bottom_axes', bottom_axes);
   setappdata(gcf, 'top_axes', top_axes);

   setappdata(gcf,'PlotDesignState',1);
   setappdata(gcf,'PlotBrainDesignState',1)
   setappdata(gcf,'PlotDesignLVState',0);

   setappdata(gcf, 'cond_selection', cond_selection);

   % for GUI
   setappdata(gcf,'LVButtonHeight',0.05);
   setappdata(gcf,'LV_hlist',[lv_h]);
   setappdata(gcf,'LVButtonTemplate',lv_template);
   setappdata(gcf,'TopLVButton',1);
   setappdata(gcf,'CurrLVState',curr_lv_state);
   setappdata(gcf,'num_grp',num_grp);
   SetupLVButtonRows;
   DisplayLVButtons;

   return;					% init


% --------------------------------------------------------------------
function  SetupLVButtonRows()

   lv_hdls = getappdata(gcf,'LV_hlist');
   lv_template = getappdata(gcf,'LVButtonTemplate');

   row_height = getappdata(gcf,'LVButtonHeight');
   frame_pos = get(findobj(gcf,'Tag','LVFrame'),'Position');
   first_button_pos = get(findobj(gcf,'Tag','LVRadioButton'),'Position');

   top_frame_pos = frame_pos(2) + frame_pos(4);
   margin = top_frame_pos - (first_button_pos(2) + first_button_pos(4));
   rows = floor((frame_pos(4) - margin*1.5) / row_height);

   v_pos = (top_frame_pos - margin) - [1:rows]*row_height;

   nr = size(lv_hdls,1);
   if (rows < nr)				% too many rows
      for i=rows+1:nr,
         delete(lv_hdls(i));
      end;
      lv_hdls = lv_hdls(1:rows);
   else						% add more rows
      for i=nr+1:rows,
        new_s_hdls = copyobj(lv_template,gcf);
        lv_hdls = [lv_hdls; new_s_hdls'];
      end;
   end;

   v = 'on';
   for i=1:rows,
      new_s_hdls = lv_hdls(i);
      pos = get(new_s_hdls(1),'Position'); pos(2) = v_pos(i);
      set(new_s_hdls,'String','','Position',pos,'Visible',v,'UserData',i);
   end;

⌨️ 快捷键说明

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