📄 fmri_plot_brain_scores.m
字号:
function fig = fmri_plot_brain_scores(action,varargin)
%
% fmri_plot_brain_scores(action,action_arg1,...)
if ~exist('action','var') | isempty(action) % no action argument
return;
end;
fig = [];
if strcmp(action,'STARTUP')
sessionFileList = varargin{1};
plsResultFile = varargin{2};
init(sessionFileList,plsResultFile);
SetupLVButtonRows;
SetupSlider;
DisplayLVButtons;
return;
elseif strcmp(action,'LINK') % call from other figure
sessionFileList = varargin{1};
plsResultFile = varargin{2};
fig = init(sessionFileList,plsResultFile);
SetupLVButtonRows;
SetupSlider;
DisplayLVButtons;
return;
elseif strcmp(action,'MENU_ExportData')
save_response_fn;
elseif strcmp(action,'MENU_ExportBehavData')
save_response_fn2;
end;
% clear the message line,
%
% h = findobj(gcf,'Tag','MessageLine');
% set(h,'String','');
switch (upper(action))
case {'LOAD_STDATAMAT'}
plot_brain_scores;
case {'MOVE_SLIDER'},
MoveSlider;
case {'SET_TOP_LV_BUTTON'},
lv_idx = varargin{2};
SetTopLVButton(lv_idx);
case {'SELECT_LV'},
SelectLV;
active_plot = getappdata(gcf,'PLS_PLOT_BS_ACTIVE');
if ~isempty(active_plot) & (active_plot == 1)
plot_brain_scores;
end;
case {'DELETE_FIGURE'}
delete_fig;
case {'PLOT_BRAINSCORES'}
plot_brain_scores;
case {'MENU_PLOTINDIVIDUALDATA'}
make_datamat_popup(1);
case {'MENU_PLOTGROUPDATA'}
make_datamat_popup(2);
case {'MENU_PLOTALLDATA'}
make_datamat_popup(3);
case {'MENU_COMBINEPLOTS'}
set_combine_plot;
end
return;
%--------------------------------------------------------------------------
%
function fig = init(sessionFileList,plsResultFile)
cond_selection = getappdata(gcf,'cond_selection');
save_setting_status = 'on';
fmri_plot_brain_scores_pos = [];
try
load('pls_profile');
catch
end
if ~isempty(fmri_plot_brain_scores_pos) & strcmp(save_setting_status,'on')
pos = fmri_plot_brain_scores_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','Temporal Brain Scores Plot', ...
'NumberTitle','off', ...
'Color', [0.8 0.8 0.8], ...
'DoubleBuffer','on', ...
'Menubar', 'none', ...
'DeleteFcn', 'fmri_plot_brain_scores(''Delete_Figure'');', ...
'Position',pos, ...
'Tag','PlotBrainScoreFig');
% display 'ST datamat: '
%
x = 0.05;
y = 0.9;
w = 0.15;
h = 0.06;
pos = [x y w h];
fnt = 0.4;
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.84;
w = 0.22;
pos = [x y w h];
cb_fn = [ 'fmri_plot_brain_scores(''Load_STDatamat'');'];
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.62;
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', 'LVFrame');
x = 0.09;
y = 0.76;
w = 0.14;
h = 0.06;
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', 'Display LVs', ...
'Tag', 'DisplayLVLabel');
y = 0.7;
pos = [x y w h];
lv_h = uicontrol('Parent',hh, ...
'Units','normal', ...
'BackgroundColor', [0.8 0.8 0.8], ...
'Style', 'radiobutton', ...
'Position', pos, ...
'HorizontalAlignment', 'left',...
'FontSize', 10, ...
'String', 'LV #1', ...
'Visible', 'on', ...
'Callback','fmri_plot_brain_scores(''SELECT_LV'');', ...
'Tag', 'LVRadioButton');
x = x+w+0.01;
w = 0.02;
pos = [x y w h];
h0 = uicontrol('Parent',hh, ... % LV Button Slider
'Style','slider', ...
'Units','normal', ...
'Min', 0, ...
'Max', 1, ...
'Visible', 'on', ...
'Position',pos, ...
'Callback','fmri_plot_brain_scores(''MOVE_SLIDER'');', ...
'Tag','LVButtonSlider');
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_brain_scores(''PLOT_BRAINSCORES'');');
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');
% menu
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', ...
'Callback','fmri_plot_brain_scores(''MENU_PlotIndividualData'');');
h0 = uimenu('Parent',h_plot, ...
'Label','Plot group data', ...
'Tag','PlotGroupData', ...
'Callback','fmri_plot_brain_scores(''MENU_PlotGroupData'');');
h0 = uimenu('Parent',h_plot, ...
'Label','Plot all data', ...
'Tag','PlotAllData', ...
'Callback','fmri_plot_brain_scores(''MENU_PlotAllData'');');
h_option = uimenu('Parent',hh, ...
'Label','&Option', ...
'Tag','OptionMenu', ...
'Enable','on',...
'Visible','on');
h0 = uimenu('Parent',h_option, ...
'Label','Hide Average Plot', ...
'Tag','ToggleShowAvgMenu', ...
'Callback','fmri_plot_cond_stim_ui(''TOGGLE_SHOW_AVERAGE'');');
h0 = uimenu('Parent',h_option, ...
'Label','Combine plots within conditions', ...
'Tag','CombinePlots', ...
'Userdata', 0, ...
'Callback','fmri_plot_brain_scores(''MENU_CombinePlots'');');
h0 = uimenu('Parent',h_option, ...
'Label','Change plot dimension', ...
'Separator','on',...
'Tag','ChgPlotDims', ...
'Callback','fmri_plot_cond_stim_ui(''CHANGE_PLOT_DIMS'');');
h_option = uimenu('Parent',hh, ...
'Label','&Data', ...
'Tag','DataMenu', ...
'Visible','on');
h0 = uimenu('Parent',h_option, ...
'Label','Export data', ...
'Tag','ExportData', ...
'Callback','fmri_plot_brain_scores(''MENU_ExportData'');');
h0 = uimenu('Parent',h_option, ...
'Label','Export data to text file', ...
'Tag','ExportBehavData', ...
'visible', 'off', ...
'Callback','fmri_plot_brain_scores(''MENU_ExportBehavData'');');
% construct the popup label list
%
get_st_datamat_filename(sessionFileList);
make_datamat_popup(1);
lv_template = copyobj(lv_h,hh);
set(lv_template,'Tag','LVTemplate','Visible','off');
setappdata(hh,'cond_selection',cond_selection);
% load the brain scores, conditions, evt_list
%
[brainlv,pls_coords,dims,conditions] = load_pls_brainlv(plsResultFile);
num_lv = size(brainlv,2);
curr_lv_state = zeros(1,num_lv);
curr_lv_state(1) = 1;
setappdata(hh,'BrainLV',brainlv);
setappdata(hh,'PLSCoords',pls_coords);
setappdata(hh,'Dims',dims);
setappdata(hh,'Conditions',conditions);
setappdata(hh,'CurrLVState',curr_lv_state);
% for GUI
setappdata(hh,'LVButtonHeight',0.06);
setappdata(hh,'LV_hlist',[lv_h]);
setappdata(hh,'LVButtonTemplate',lv_template);
setappdata(hh,'TopLVButton',1);
setappdata(hh,'PLS_BS_PLOTTED_DATA',[]);
setappdata(hh,'PLS_BS_PLOTTED_CONDITON',[]);
if (nargout >= 1),
fig = hh;
end;
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;
% setup slider position
%
h = findobj(gcf,'Tag','LVButtonSlider');
s_pos = get(h,'Position');
s_pos(2) = v_pos(end);
s_pos(4) = v_pos(1) - v_pos(end) + row_height;
set(h,'Position',s_pos);
setappdata(gcf,'LV_hlist',lv_hdls);
setappdata(gcf,'NumLVRows',rows);
return; % SetupLVButtonRows
% --------------------------------------------------------------------
function DisplayLVButtons()
curr_lv_state = getappdata(gcf,'CurrLVState');
top_lv_button = getappdata(gcf,'TopLVButton');
lv_hdls = getappdata(gcf,'LV_hlist');
rows = getappdata(gcf,'NumLVRows');
num_lvs = length(curr_lv_state);
lv_idx = top_lv_button;
for i=1:rows,
l_hdl = lv_hdls(i);
if (lv_idx <= num_lvs),
set(lv_hdls(i),'String',sprintf('LV #%d',lv_idx), ...
'Value',curr_lv_state(lv_idx), ...
'Visible','on', ...
'Userdata',i);
lv_idx = lv_idx + 1;
else
set(lv_hdls(i),'String','','Visible','off');
end
end;
if (top_lv_button ~= 1) | (num_lvs > rows)
set(findobj(gcf,'Tag','LVButtonSlider'),'Visible','on');
else
set(findobj(gcf,'Tag','LVButtonSlider'),'Visible','off');
end;
return; % DisplayLVButtons
%----------------------------------------------------------------------------
function MoveSlider()
slider_hdl = findobj(gcf,'Tag','LVButtonSlider');
curr_value = round(get(slider_hdl,'Value'));
total_rows = round(get(slider_hdl,'Max'));
top_lv_button = total_rows - curr_value + 1;
setappdata(gcf,'TopLVButton',top_lv_button);
DisplayLVButtons;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -