📄 bfm_plot_rf.m
字号:
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','bfm_plot_rf(''SliderMotion'');');
SetObjPosition('ConditionChkBoxes');
setappdata(gcf,'SelectedCondition',ones(1,num_cond));
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');
bfm_plot_rf_pos = get(gcbf,'position');
save(pls_profile, '-append', 'bfm_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)
hh = getappdata(gcf,'VoxelIntensityFig');
obj = getappdata(hh,'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(hh,'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(hh,'Tag', 'PlotButton'),'Position');
lowest_v_pos = plot_pos(2) + plot_pos(4) * 1.5;
chk_box_hlist = get(findobj(hh,'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(hh,'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 {2} % 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 {1} % 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 = 'left';
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 = 'Click a voxel to see the plot';
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(DatamatFileList)
%
% INPUT:
% sessionFileList - vector of cell structure, each element contains
% the full path of a session file.
%
num_groups = length(DatamatFileList);
for i=1:num_groups,
fn = DatamatFileList{i};
load( fn, 'session_info', 'selected_conditions' );
[pname, fname] = fileparts(fn);
st_filename{i}.name = fname;
st_filename{i}.fullname = fn;
st_filename{i}.group = i;
st_filename{i}.profile = session_info;
st_filename{i}.selected_conditions = selected_conditions;
end;
setappdata(gcf,'STFiles',st_filename);
return; % get_st_datamat_filename
%--------------------------------------------------------------------------
%
function [raw_datamat,coords,num_subj,subj_name,behavname] = ...
load_plotted_datamat
old_pointer = get(gcf,'Pointer');
set(gcf,'Pointer','watch');
selected_files = get_selected_filename;
if (length(selected_files) == 1)
warning off;
load(selected_files{1},'raw_datamat','coords','session_info', ...
'behavdata','behavname');
warning on;
if ~exist('behavname','var')
behavname = {};
if exist('behavdata','var')
for i=1:size(behavdata, 2)
behavname = [behavname, {['behav', num2str(i)]}];
end
end
end
num_subj = session_info.num_subjects;
subj_name = session_info.subj_name;
else % merge files together
% [st_datamat,st_coords,st_win_size,st_evt_list] = ...
% merge_st_datamat(selected_files);
[tmp,datmat,coords,dims,num_cond_lst,num_subj_lst,...
voxel_size,origin] = pet_get_common(selected_files);
end;
set(gcf,'Pointer',old_pointer);
return; % load_plotted_datamat
%--------------------------------------------------------------------------
%
function [selected_files] = get_selected_filename(select_all_flg),
st_filename = getappdata(gcf,'STFiles');
if exist('select_all_flg','var') & (select_all_flg == 1)
data_option = 3;
else
h = findobj(gcf,'Tag','STDatamatPopup');
selected_idx = get(h,'Value');
data_option = get(h,'Userdata');
end;
switch (data_option)
case {1}, % individual file
selected_files{1} = st_filename{selected_idx}.fullname;
case {3}, % all data
for i=1:length(st_filename),
selected_files{i} = st_filename{i}.fullname;
end;
end;
return; % get selected filenames
%--------------------------------------------------------------------------
%
function [grp_st_datamat,coords,win_size,evt_list] = ...
merge_st_datamat(selected_files),
num_files = length(selected_files);
% compute the common coords first and the total number of events
%
load(selected_files{1},'st_dims','st_win_size');
total_num_evt = 0;
m = zeros(st_dims);
for i=1:num_files,
load(selected_files{i},'st_coords','st_evt_list');
total_num_evt = total_num_evt + length(st_evt_list);
m(st_coords) = m(st_coords) + 1;
end;
coords = find(m == num_files);
% ready to merge the st_datamat together now ...
%
win_size = st_win_size;
num_voxels = length(coords);
num_cols = win_size * num_voxels;
grp_st_datamat = zeros(total_num_evt,num_cols);
evt_list = [];
first_row = 1;
for i=1:num_files,
load(selected_files{i});
coord_idx = find(m(st_coords) == num_files);
nr = length(st_evt_list);
nc = length(st_coords);
last_row = nr + first_row - 1;
tmp_datamat = reshape(st_datamat,[nr,win_size,nc]);
tmp_datamat = reshape(tmp_datamat(:,:,coord_idx),[nr,num_cols]);
grp_st_datamat(first_row:last_row,:) = tmp_datamat;
evt_list = [evt_list st_evt_list];
first_row = last_row + 1;
clear st_datamat tmp_datamat;
end;
return; % merge_st_datamat
%--------------------------------------------------------------------------
%
function plot_response_fn()
axes_margin = [.37 .05 .15 .1];
% set up axes, and the values of 'AxesMargin', 'AxesHlds' and 'AxesPos'
%
setappdata(gcf,'AxesMargin',axes_margin);
set_cond_axes(1,1,axes_margin); % set up axes
% extract the currect ploting data
%
cur_coord = getappdata(gcf,'Coord');
if isempty(cur_coord)
msg = 'ERROR: No point has been seleted to plot.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
set(gca,'visible','off');
return;
end;
% find out the coord_idx
%
st_coords = getappdata(gcf,'STCoords');
common_coords = getappdata(gcf,'common_coords');
coord_idx = find(common_coords == cur_coord);
if isempty(coord_idx)
msg = 'ERROR: The selected point is outside the brain region.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
set(gca,'visible','off');
return;
end;
% in blocked fmri, st_datamat only contain common_coords (because
% the each group needs to be averaged). So, the following statement
% is commneted. Also see load_voxel_intensity to see how st_datamat
% get only common_coords. 13-Apr-2005
%
% coord_idx = find(st_coords == cur_coord);
st_datamat = getappdata(gcf,'STDatamat');
st_data = st_datamat;
selected_condition = getappdata(gcf,'SelectedCondition');
% generate the plots
%
cond_idx = find(selected_condition == 1);
setappdata(gcf,'ST_data',st_data);
setappdata(gcf,'PlotCondIdx',cond_idx);
if isempty(getappdata(gcf,'CombinePlots'))
setappdata(gcf,'CombinePlots',0);
end;
if isempty(getappdata(gcf,'ShowAverage'))
setappdata(gcf,'ShowAverage',0);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -