📄 fmri_plot_rf.m
字号:
'Callback','fmri_plot_rf(''MENU_PlotIndividualData'');');
h0 = uimenu('Parent',h_plot, ...
'Label','Plot group data', ...
'Tag','PlotGroupData', ...
'Callback','fmri_plot_rf(''MENU_PlotGroupData'');');
h0 = uimenu('Parent',h_plot, ...
'Label','Plot all data', ...
'Tag','PlotAllData', ...
'Callback','fmri_plot_rf(''MENU_PlotAllData'');');
h_option = uimenu('Parent',hh, ...
'Label','&Option', ...
'Tag','OptionMenu', ...
'Enable','off',...
'Visible','on');
h0 = uimenu('Parent',h_option, ...
'Label','Hide Average Plot', ...
'Tag','ToggleShowAvgMenu', ...
'Callback','set(findobj(gcf,''tag'',''Stable''),''Userdata'',0,''Label'',''&Stable off''); 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_rf(''MENU_CombinePlots'');');
h0 = uimenu('Parent',h_option, ...
'Label','Enable Data Normalization', ...
'Tag','NormalizePlots', ...
'Userdata', 0, ...
'Callback','fmri_plot_rf(''MENU_NormalizePlots'');');
h0 = uimenu('Parent',h_option, ...
'Label','Change plot dimension', ...
'Separator','on',...
'Tag','ChgPlotDims', ...
'Callback','set(findobj(gcf,''tag'',''Stable''),''Userdata'',0,''Label'',''&Stable off''); fmri_plot_cond_stim_ui(''CHANGE_PLOT_DIMS'');');
h0 = uimenu('Parent',h_option, ...
'Label','Number of points to be plotted', ...
'Tag','NumPtsPlotted', ...
'Callback','fmri_plot_rf(''MENU_NumPtsPlotted'');');
h_option = uimenu('Parent',hh, ...
'Label','&Data', ...
'Tag','DataMenu', ...
'Enable','off',...
'Visible','on');
h0 = uimenu('Parent',h_option, ...
'Label','Export data', ...
'Tag','ExportData', ...
'Callback','fmri_plot_rf(''MENU_ExportData'');');
h0 = uimenu('Parent',h_option, ...
'Label','Export data for behav analysis', ...
'Tag','ExportBehavData', ...
'visible', 'off', ...
'Callback','fmri_plot_rf(''MENU_ExportBehavData'');');
h_bs = uimenu('Parent',hh, ...
'Label','&Stable Off', ...
'user', 0, ...
'enable','off', ...
'Tag','Stable', ...
'callback','fmri_plot_rf(''toggle_stable'');');
% set up object location records
%
x = 0.05;
y = 0.77;
w = 0.15;
h = 0.05;
obj(1).name = 'STDatamatLabel'; obj(1).pos = [x 1-y w h];
y = 0.72;
w = 0.22;
obj(2).name = 'STDatamatPopup'; obj(2).pos = [x 1-y w h];
x = 0.09;
y = 0.64;
w = 0.14;
h = 0.05;
obj(3).name = 'ConditionLabel'; obj(3).pos = [x 1-y w h];
y = 0.58;
obj(4).name = 'Condition1'; obj(4).pos = [x 1-y w h];
setappdata(hh,'ObjPosition',obj);
setappdata(hh,'CallBackFig',CallBackFig');
setappdata(hh,'cond_selection',cond_selection);
bsr = getappdata(gcbf, 'BSRatio');
bs_thresh = getappdata(gcbf, 'BSThreshold');
setappdata(hh, 'org_bsr', bsr);
setappdata(hh, 'bs_thresh', bs_thresh);
st_coords = getappdata(gcbf, 'BLVCoords');
if isempty(st_coords)
st_coords = getappdata(gcbf, 'BSRatioCoords');
end
setappdata(hh, 'STCoords', st_coords);
setappdata(gcf, 'sa', getappdata(gcbf, 'sa'));
% construct the popup label list
%
get_st_datamat_filename(sessionFileList);
make_datamat_popup(1);
if (nargout >= 1),
fig = hh;
end;
return;
%--------------------------------------------------------------------------
%
function gen_condition_chk_box(selected_idx)
cond_selection = getappdata(gcf,'cond_selection');
st_files = getappdata(gcf,'STFiles');
sessionFile = st_files{selected_idx}.profile;
load(sessionFile);
cname = session_info.condition;
if isempty(cond_selection)
num_cond = session_info.num_conditions;
cond_selection = ones(1,num_cond);
setappdata(gcf,'cond_selection',cond_selection);
else
num_cond = sum(cond_selection);
cname = cname(find(cond_selection));
end
% display 'Conditions: '
%
h0 = findobj(gcf,'Tag','ConditionLabel');
if ~isempty(h0) % no condition has been defined yet
cond_h = get(h0,'UserData');
for i=1:length(cond_h);
delete(cond_h(i)); % remove the old conditions
end;
end;
% create check box for the conditions
%
h_list = [];
for i=1:num_cond,
% callback function to update the condition selection
%
cbf = ['selected_cond = getappdata(gcf,''SelectedCondition''); ' ...
'selected_cond(',num2str(i),')=~selected_cond(',num2str(i),'); ' ...
'setappdata(gcf,''SelectedCondition'',selected_cond); ', ...
'if (sum(selected_cond) == 0), ' ...
' set(findobj(gcf,''Tag'',''PlotButton''),''Enable'',''off''); '...
'else, ' ...
' set(findobj(gcf,''Tag'',''PlotButton''),''Enable'',''on''); '...
'end; '];
% create the condition check box
%
h1 = uicontrol('Parent',gcf, ...
'Units','normal', ...
'BackgroundColor', [0.8 0.8 0.8], ...
'Value', 1, ...
'Style', 'check', ...
'String', sprintf(' (%d) %s', i,cname{i}), ...
'HorizontalAlignment', 'left',...
'SelectionHighlight', 'off',...
'FontSize', 10, ...
'Tag', sprintf('Condition%d',i), ...
'Callback',cbf);
h_list = [h_list h1];
end;
set(h0,'UserData',h_list);
% set up the scroll bar for the conditions
%
h1 = uicontrol('Parent',gcf, ...
'Style', 'slider', ...
'Units','normal', ...
'Tag', 'CondSlider', ...
'Callback','fmri_plot_rf(''SliderMotion'');');
SetObjPosition('ConditionChkBoxes');
setappdata(gcf,'SelectedCondition',ones(1,num_cond));
setappdata(gcf,'Conditions',cname);
return;
%--------------------------------------------------------------------------
%
function h = delete_fig()
link_figure = getappdata(gcbf,'LinkFigureInfo');
try
rmappdata(link_figure.hdl,link_figure.name);
end;
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
fmri_plot_rf_pos = get(gcbf,'position');
save(pls_profile, '-append', 'fmri_plot_rf_pos');
catch
end
return; % delete_fig
%--------------------------------------------------------------------------
%
function obj_pos = GetObjPosition(ObjName)
obj = getappdata(gcf,'ObjPosition');
i = 1;
while i <= length(obj);
if strcmp(ObjName,obj(i).name)
obj_pos = obj(i).pos;
return;
end;
i = i+1;
end;
return; % get_obj_pos
%--------------------------------------------------------------------------
%
function SetObjPosition(ObjName)
obj = getappdata(gcf,'ObjPosition');
% set the positions for all objects
%
if ~exist('ObjName','var') | isempty(ObjName)
ObjName = 'STDatamat';
end;
if strcmp(ObjName,'STDatamat') | strcmp(ObjName,'ALL'),
for i=1:length(obj),
obj_pos = obj(i).pos;
obj_pos(2) = 1 - obj_pos(2);
set(findobj(gcf,'Tag',obj(i).name),'Position',obj_pos);
end;
end;
% set positions for the condition check box
%
if strcmp(ObjName,'ConditionChkBoxes') | strcmp(ObjName,'ALL'),
% find the position of the PLOT Button
plot_pos = get(findobj(gcf,'Tag', 'PlotButton'),'Position');
lowest_v_pos = plot_pos(2) + plot_pos(4) * 1.5;
chk_box_hlist = get(findobj(gcf,'Tag','ConditionLabel'),'UserData');
num_cond = length(chk_box_hlist);
cond1_pos = GetObjPosition('Condition1');
cond1_pos(2) = 1 - cond1_pos(2);
cond_h = 0.06;
rows = floor((cond1_pos(2) - lowest_v_pos) / cond_h);
pages = ceil(num_cond / rows);
v_pos = cond1_pos(2)-mod([1:num_cond]-1,rows)*cond_h;
for i=1:num_cond,
obj_pos = [cond1_pos(1) v_pos(i) cond1_pos(3) cond1_pos(4)];
if (i <= rows),
visibility = 'on';
else
visibility = 'off';
end;
set(chk_box_hlist(i),'Position',obj_pos,'Visible',visibility);
end;
% set the slider position
%
h = findobj(gcf,'Tag', 'CondSlider');
if (pages <= 1)
set(h,'Visible','off');
else
s_pos = [cond1_pos(1)+cond1_pos(3)+0.01 v_pos(rows) 0.02 cond_h*rows];
set(h,'Min',1,'Max',pages, ...
'Position',s_pos, ...
'Value',pages, ...
'Sliderstep',[1/(pages-1)-0.00001 1/(pages-1)] );
set(h,'Visible','on');
set(h,'UserData',rows);
end;
end;
return; % get_obj_pos
%--------------------------------------------------------------------------
function make_datamat_popup(data_option)
% data_option = 1 - plot individual ST datamat
% data_option = 2 - plot group data
% data_option = 3 - plot all data
popup_h = findobj(gcf,'Tag','STDatamatPopup');
curr_option = get(popup_h,'Userdata');
if ~isempty(curr_option) & (curr_option == data_option)
return; % no change, do nothing
end;
st_filenames = getappdata(gcf,'STFiles');
switch (data_option)
case {1} % plot individual data
num_st_datamat = length(st_filenames);
popup_list = cell(1,num_st_datamat);
for i=1:num_st_datamat,
% get rid of ".mat" extension if there is any
if strcmp(st_filenames{i}.name(end-3:end),'.mat')==1
popup_list{i} = sprintf('[%d] %s', ...
st_filenames{i}.group, st_filenames{i}.name(1:end-4));
else
popup_list{i} = sprintf('[%d] %s', ...
st_filenames{i}.group, st_filenames{i}.name);
end;
end;
alignment = 'left';
case {2} % plot group data
num_group = st_filenames{end}.group;
popup_list = cell(1,num_group);
for i=1:num_group,
popup_list{i} = sprintf('[ Group #%d ]',i);
end;
alignment = 'center';
case {3} % plot all data
popup_list{1} = '< All Data >';
alignment = 'center';
end;
set(popup_h,'String',popup_list,'Userdata',data_option, ...
'HorizontalAlignment', alignment,'Value',1);
msg = 'Press "Plot" Button or select datamat to see the response function';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return; % make_datamat_popup
%--------------------------------------------------------------------------
function condition_update(sessionFileList,with_path)
%
h = findobj(gcf,'Tag', 'CondSlider');
rows = get(h,'UserData');
max_page = get(h,'Max');
slider_value = round(get(h,'Value'));
page = max_page - slider_value +1;
set(h,'Value',slider_value);
chk_box_hlist = get(findobj(gcf,'Tag','ConditionLabel'),'UserData');
num_cond = length(chk_box_hlist);
visible_list = zeros(1,num_cond);
visible_list((page-1)*rows+1:page*rows) = 1;
for i=1:num_cond,
if(visible_list(i) == 0)
set(chk_box_hlist(i),'Visible','off');
else
set(chk_box_hlist(i),'Visible','on');
end;
end;
return;
%
%--------------------------------------------------------------------------
function get_st_datamat_filename(sessionFileList)
%
% INPUT:
% sessionFileList - vector of cell structure, each element contains
% the full path of a session file.
%
cnt = 0;
num_groups = length(sessionFileList);
fn = sessionFileList{1}{1};
for i=1:num_groups,
num_files = length(sessionFileList{i});
for j=1:num_files,
cnt = cnt + 1;
load( sessionFileList{i}{j} );
rri_changepath('fmrisession');
if findstr('BfMRIsession.mat', fn)
fname = sprintf('%s_BfMRIdatamat.mat',session_info.datamat_prefix);
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -