📄 fmri_input_contrast_ui.m
字号:
function contrast_fig = fmri_input_contrast_ui(varargin)
%
% USAGE: contrast_fig = fmri_input_contrast_ui(contrasts,conditions,view_only)
%
if nargin == 0
old_contrasts = [];
end;
if nargin == 0 | ~ischar(varargin{1})
old_contrasts = [];
conditions = [];
view_only = 0;
if (nargin >= 1)
old_contrasts = varargin{1};
end;
if (nargin >= 2)
conditions = varargin{2};
end;
if (nargin >= 3)
view_only = varargin{3};
end;
fig_hdl = init(old_contrasts,conditions,view_only);
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;
ShowConditions;
case {'MENU_SAVE_CONTRASTS'},
DisplayContrasts; % refresh the contrasts first
SaveContrasts(0);
case {'MENU_SAVE_AS_CONTRASTS'},
SaveContrasts(1);
case {'MENU_CLOSE_CONTRASTS'},
if (CloseContrastInput == 1)
close(gcbf);
end;
case {'DELETE_FIGURE'},
DeleteFigure;
case {'MENU_CLEAR_CONTRASTS'},
ClearContrasts;
case {'MENU_LOAD_CONDITIONS'},
LoadConditions;
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;
otherwise
disp(sprintf('ERROR: Unknown action "%s".',action));
end;
return;
%----------------------------------------------------------------------------
function fig_hdl = init(old_contrasts,conditions,view_only)
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.75;
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','fmri_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: ', ...
'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','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'fontunit','normal',...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'ListboxTop',0, ...
'Position',pos, ...
'String','edit string', ...
'TooltipString','Enter the name of the contrast', ...
'Tag','ContrastNameEdit');
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','fmri_input_contrast_ui(''MOVE_SLIDER'');', ...
'Tag','ContrastSlider');
%-------------------------- condition list -----------------------------
x = .54;
y = 0.38;
w = 0.42;
h = 0.57;
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.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','Conditions: ', ...
'Tag','ConditionTitleLabel');
x = x+.03;
y = .45;
w = .34;
h = .42;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % condition list box
'Style','listbox', ...
'Units','normal', ...
'fontunit','normal', ...
'FontSize',.06, ...
'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];
ax_hdl = axes('Parent',h0, ...
'units', 'normal', ...
'Position', pos, ...
'box','on', ...
'XTick',[], 'YTick', []);
%---------------------------- figure menu ------------------------------
h_file = uimenu('Parent',h0, ...
'Label', '&File', ...
'Tag', 'FileMenu');
m1 = uimenu(h_file, ...
'Label', '&Load', ...
'Callback','fmri_input_contrast_ui(''MENU_LOAD_CONTRASTS'');', ...
'Tag', 'LoadContrasts');
m1 = uimenu(h_file, ...
'Label', '&Save', ...
'Callback','fmri_input_contrast_ui(''MENU_SAVE_CONTRASTS'');', ...
'Tag', 'SaveContrasts');
m1 = uimenu(h_file, ...
'Label', 'S&ave as', ...
'Callback','fmri_input_contrast_ui(''MENU_SAVE_AS_CONTRASTS'');', ...
'Tag', 'SaveAsContrasts');
m1 = uimenu(h_file, ...
'Label', '&Close', ...
'Callback','fmri_input_contrast_ui(''MENU_CLOSE_CONTRASTS'');', ...
'Tag', 'CloseContrasts');
h_file = uimenu('Parent',h0, ...
'Label', '&Edit', ...
'Tag', 'EditMenu');
m1 = uimenu(h_file, ...
'Label', '&Clear', ...
'Callback','fmri_input_contrast_ui(''MENU_CLEAR_CONTRASTS'');', ...
'Tag', 'ClearContrasts');
h_file = uimenu('Parent',h0, ...
'Label', '&Condition', ...
'Tag', 'ConditionMenu');
m1 = uimenu(h_file, ...
'Label', '&Load', ...
'Callback','fmri_input_contrast_ui(''MENU_LOAD_CONDITIONS'');', ...
'Tag', 'LoadConditions');
% save handles for contrast#1
contrast1_hdls = [c_h1,c_h2,c_h3,c_h4,c_h5];
setappdata(h0,'Contrast_hlist',contrast1_hdls);
contrast_template = copyobj(contrast1_hdls,h0);
for i=1:length(contrast_template),
set(contrast_template(i),'visible','off','Tag', sprintf('Template%d',i));
end;
setappdata(h0,'OldContrasts',old_contrasts);
setappdata(h0,'CurrContrasts',old_contrasts);
setappdata(h0,'ContrastTemplate',contrast_template);
setappdata(h0,'ContrastHeight',.105);
setappdata(h0,'TopContrastIdx',1);
setappdata(h0,'ContrastFile','');
setappdata(h0,'PlotAxes',ax_hdl);
setappdata(h0,'ViewOnly',view_only);
if isempty(conditions)
LoadConditions;
else
ShowConditions;
end;
setappdata(h0,'Conditions',conditions);
if (view_only),
HideMenuEntries;
end;
SetupContrastRows;
SetupSlider;
CreateAddRow;
DisplayContrasts;
UpdateSlider;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -