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

📄 rri_input_contrast_ui.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
📖 第 1 页 / 共 4 页
字号:
function contrast_fig = rri_input_contrast_ui(varargin) 
% 
%  USAGE: contrast_fig = rri_input_contrast_ui(prefix, pls_session, ...
%						cond_selection, num_groups)
%	or
%  USAGE: contrast_fig = rri_input_contrast_ui(prefix, cond_name, ...
%						[], num_groups, design, 1)
% 

   if nargin == 0 
      old_contrasts = {};
   end;

   if nargin == 0 | ~ischar(varargin{1})
      prefix='PLS';
      pls_session='';
      cond_selection=[];
      num_groups = 0;
      design = [];
      old_contrasts = {};
      conditions = [];
      view_only = 0;

      if (nargin >= 1) 
         prefix = varargin{1}{1};
      end;

      if (nargin >= 2) 
         pls_session = varargin{2};
      end;

      if (nargin >= 3) 
         cond_selection = varargin{3};
      end;

      if (nargin >= 4) 
         num_groups = varargin{4};
      end;

      if (nargin >= 5) 
         design = varargin{5};
      end;

      if (nargin >= 6) 
         view_only = varargin{6};
      end;

      fig_hdl = init(old_contrasts,conditions,view_only,prefix,pls_session,...
			cond_selection,num_groups,design);

      if nargout >= 1,
         contrast_fig = fig_hdl;
      end;
      
      return;
   end;

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

   action = upper(varargin{1});

   switch (action)
     case {'MENU_LOAD_CONTRASTS'},
	LoadContrasts;
        DisplayContrasts;
        UpdateSlider;
        ShowGroups;
        ShowConditions;
     case {'MENU_SAVE_CONTRASTS'},
        DisplayContrasts;			% refresh the contrasts first
	SaveContrasts(0);
     case {'MENU_SAVE_AS_CONTRASTS'},
	SaveContrasts(1);
     case {'MENU_LOAD_TEXT'},
        prefix=getappdata(gcf,'prefix');
	LoadText(prefix);
        DisplayContrasts;
        UpdateSlider;
        ShowGroups;
        ShowConditions;
     case {'MENU_SAVE_TEXT'},
        DisplayContrasts;			% refresh the contrasts first
        prefix=getappdata(gcf,'prefix');
	SaveText(prefix,0);
     case {'MENU_SAVE_AS_TEXT'},
        prefix=getappdata(gcf,'prefix');
	SaveText(prefix,1);
     case {'MENU_HELMERT_MATRIX'},
        HelmertMatrix;
        DisplayContrasts;
        UpdateSlider;
        ShowGroups;
        ShowConditions;
     case {'MENU_CLOSE_CONTRASTS'},
        if (CloseContrastInput == 1)
            close(gcbf);
        end;
     case {'DELETE_FIGURE'},
        DeleteFigure;
     case {'MENU_CLEAR_CONTRASTS'},
	ClearContrasts;
     case {'MENU_LOAD_CONDITIONS'},
        prefix=getappdata(gcf,'prefix');
	LoadConditions(prefix);
     case {'UPDATE_CONTRAST_NAME'},
        UpdateContrastName;
     case {'UPDATE_CONTRAST_VALUE'},
        UpdateContrastValue;
     case {'DELETE_CONTRAST'},
        DeleteContrast;
     case {'ADD_CONTRAST'},
        AddContrast;
     case {'PLOT_CONTRAST'},
        PlotContrast;
     case {'MOVE_SLIDER'},
        MoveSlider;
     case {'RESIZE_FIGURE'},
        ResizeFigure;
     case {'CHANGE_GROUP'},
	ChangeGroup;
     otherwise
        disp(sprintf('ERROR: Unknown action "%s".',action));
   end;
   
   return;


%----------------------------------------------------------------------------
function fig_hdl = init(old_contrasts,conditions,view_only,prefix,pls_session,...
			cond_selection,num_groups,design)

   curr_dir = pwd;

   save_setting_status = 'on';
   fmri_input_contrast_pos = [];

   try
      load('pls_profile');
   catch
   end

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

      pos = fmri_input_contrast_pos;

   else

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

      pos = [x y w h];

   end

   h0 = figure('Color',[0.8 0.8 0.8], ...
   	'Units','normal', ...
        'Name','New Contrasts', ...
        'NumberTitle','off', ...
        'Doublebuffer', 'on', ...
   	'Position',pos, ...
   	'DeleteFcn','rri_input_contrast_ui(''DELETE_FIGURE'');', ...
        'Menubar','none', ...
   	'Tag','InputContrast', ...
   	'ToolBar','none');

   %-------------------------- contrast --------------------------------

   x = 0.04;
   y = 0.38;
   w = 0.46;
   h = 0.57;

   pos = [x y w h];

   c = uicontrol('Parent',h0, ...               	% Contrast Frame
        'Style','frame', ...
        'Units','normal', ...
        'BackgroundColor',[0.7 0.7 0.7], ...
	'fontunit','normal',...
        'Position',pos, ...
        'Tag','ContrastFrame');

   x = x+.01;
   y = 0.88;
   w = 0.3;
   h = 0.05;

   pos = [x y w h];

   fnt = 0.6;

   c = uicontrol('Parent',h0, ...			% contrast label
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.7 0.7 0.7], ...
	'fontunit','normal',...
   	'FontSize',fnt, ...
	'FontName', 'FixedWidth', ...
   	'FontAngle','italic', ...
   	'FontWeight','bold', ...
   	'HorizontalAlignment','left', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','Contrasts for Group 1: ', ...
   	'Tag','ContrastTitleLabel');

   x = 0.05;
   y = 0.82;
   w = 0.03;

   pos = [x y w h];

   fnt = fnt-0.1;

   c_h1 = uicontrol('Parent',h0, ...		% contrast idx
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.7 0.7 0.7], ...
	'fontunit','normal',...
   	'FontSize',fnt, ...
   	'HorizontalAlignment','right', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','1.', ...
   	'Tag','ContrastIdxLabel');

   x = x+w+.01;
   w = 0.24;

   pos = [x y w h];

   c_h2 = uicontrol('Parent',h0, ...		% contrast name 
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.7 0.7 0.7], ...
	'fontunit','normal',...
   	'FontSize',fnt, ...
   	'HorizontalAlignment','left', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','edit string', ...
   	'Tag','ContrastNameEdit');
%	'TooltipString','Enter the name of the contrast', ...
%   	'Style','edit', ...
%   	'BackgroundColor',[1 1 1], ...

   x = x+w+.02;
   w = 0.1;

   pos = [x y w h];

   c_h3 = uicontrol('Parent',h0, ...		% contrast button
   	'Units','normal', ...
   	'ListboxTop',0, ...
	'fontunit','normal',...
   	'FontSize',fnt, ...
   	'Position',pos, ...
   	'String','Add', ...
   	'Tag','ADD/DELButton');

   x = .10;
   y = y - .05;
   w = 0.24;

   pos = [x y w h];

   c_h4 = uicontrol('Parent',h0, ...		% contrast value
   	'Style','edit', ...
   	'Units','normal', ...
   	'BackgroundColor',[1 1 1], ...
	'fontunit','normal',...
   	'FontSize',fnt, ...
   	'HorizontalAlignment','left', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','contrast value', ...
        'TooltipString','Enter a series of contrast values', ...
   	'Tag','ContrastValueEdit');

   x = x+w+.01;
   w = 0.1;

   pos = [x y w h];

   c_h5 = uicontrol('Parent',h0, ...		% plot button
   	'Units','normal', ...
   	'ListboxTop',0, ...
	'fontunit','normal',...
   	'FontSize',fnt, ...
   	'Position',pos, ...
   	'String','Plot', ...
   	'Tag','PLOTButton');

   x = x+w+.02;
   y = 0.4;
   w = 0.03;
   h = 0.55;

   pos = [x y w h];

   h1 = uicontrol('Parent',h0, ...		% scroll bar
	'Style', 'slider', ...
   	'Units','normal', ...
   	'Min',1, ...
   	'Max',20, ...
   	'Value',20, ...
   	'Position',pos, ...
   	'Callback','rri_input_contrast_ui(''MOVE_SLIDER'');', ...
   	'Tag','ContrastSlider');

   %-------------------------- group list -----------------------------

   x = 0.54;
   y = 0.68;
   w = 0.42;
   h = 0.27;

   pos = [x y w h];

   c = uicontrol('Parent',h0, ...               	% Group Frame
        'Style','frame', ...
        'Units','normal', ...
        'BackgroundColor',[0.7 0.7 0.7], ...
	'fontunit','normal',...
        'Position',pos, ...
        'Tag','GroupFrame');
   	
   x = x+.01;
   y = 0.88;
   w = 0.3;
   h = 0.05;

   pos = [x y w h];

   fnt = fnt+0.1;

   c = uicontrol('Parent',h0, ...
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.7 0.7 0.7], ...
	'fontunit','normal',...
   	'FontSize',fnt, ...
	'FontName', 'FixedWidth', ...
   	'FontAngle','italic', ...
   	'FontWeight','bold', ...
   	'HorizontalAlignment','left', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','Groups: ', ...
   	'Tag','GroupTitleLabel');

   x = x+.03;
   y = .73;
   w = .34;
   h = .15;

   pos = [x y w h];

   c = uicontrol('Parent',h0, ...               % group list box
        'Style','listbox', ...
        'Units','normal', ...
	'fontunit','normal', ...
        'FontSize',.15, ...              
        'HorizontalAlignment','left', ...
        'ListboxTop',1, ...
        'Position',pos, ...
        'String','', ...
        'Callback','rri_input_contrast_ui(''CHANGE_GROUP'');', ...
        'Tag','GroupListBox');

   %-------------------------- condition list -----------------------------

   x = 0.54;
   y = 0.38;
   w = 0.42;
   h = 0.27;

   pos = [x y w h];

   c = uicontrol('Parent',h0, ...               	% Condition Frame
        'Style','frame', ...
        'Units','normal', ...
        'BackgroundColor',[0.7 0.7 0.7], ...
	'fontunit','normal',...
        'Position',pos, ...
        'Tag','ConditionFrame');
   	
   x = x+.01;
   y = 0.58;
   w = 0.3;
   h = 0.05;

   pos = [x y w h];

   c = uicontrol('Parent',h0, ...
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.7 0.7 0.7], ...
	'fontunit','normal',...
   	'FontSize',fnt, ...
	'FontName', 'FixedWidth', ...
   	'FontAngle','italic', ...
   	'FontWeight','bold', ...
   	'HorizontalAlignment','left', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','Conditions: ', ...
   	'Tag','ConditionTitleLabel');

   x = x+.03;
   y = .43;
   w = .34;
   h = .15;

   pos = [x y w h];

   c = uicontrol('Parent',h0, ...               % condition list box
        'Style','listbox', ...
        'Units','normal', ...
	'fontunit','normal', ...
        'FontSize',.15, ...
        'HorizontalAlignment','left', ...
        'ListboxTop',1, ...
        'Position',pos, ...
        'String','', ...
        'Tag','ConditionListBox');


   x = .01;
   y = 0;
   w = 1;
   h = .05;

   pos = [x y w h];

   fnt = fnt-0.1;

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

   %-------------------------- condition axes -----------------------------

   x = .08;
   y = .1;
   w = 1 - x*2;
   h = .22;

   pos = [x y w h];

⌨️ 快捷键说明

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