📄 pet_plot_cond_stim_ui.m
字号:
else
DisplayLegend('off');
end;
else
setappdata(gcf,'LegendHdl',[]);
end;
if ~isempty(st_data.ulcorr)
h2=errorbar(1:length(llcorr), orig_corr(mask), llcorr(mask), ulcorr(mask), 'ok');
end
hold off;
min_x = 0.5; max_x = num_conds * numbehav + 0.5;
min_y =-1; max_y = 1;
margin_x = abs((max_x - min_x) / 20);
margin_y = abs((max_y - min_y) / 20);
axis([min_x-margin_x,max_x+margin_x,min_y-margin_y,max_y+margin_y]);
set(err_ax,'xtick',[0.5:num_conds:length(llcorr)]);
% set(err_ax,'xticklabel',[1:num_conds:length(llcorr)]);
set(err_ax,'xticklabel',behavname);
%xlabel(sprintf('Conditions',j));
% set(gca,'XTick',[1:length(llcorr)])
%ylabel(sprintf('Correlations',cond_idx(i)));
end;
figure (curr_fig);
return;
%---------------------------------------------------------------------------
%
function DisplayLegend(on_off)
l_hdls = getappdata(gcf,'LegendHdl');
txtbox = getappdata(gcf, 'txtbox');
if ~isempty(l_hdls) & ishandle(l_hdls{1})
set(l_hdls{1},'Visible',on_off);
num_obj = length(l_hdls{2});
for i=1:num_obj,
set(l_hdls{2}(i),'Visible',on_off);
end;
end
if ~isempty(txtbox) & ishandle(txtbox)
[r c] = size(txtbox);
for i=1:r
for j=1:c
set(txtbox(i,j),'visible',on_off);
txt = get(txtbox(i,j),'child');
for k=1:length(txt);
set(txt(k),'visible',on_off);
end
end
end
end
return; % DisplayLegend
%---------------------------------------------------------------------------
function ToggleLegend
h = findobj(gcf,'Tag','LegendMenu');
l_hdls = getappdata(gcf,'LegendHdl');
legend_state = get(h,'Userdata');
switch (legend_state)
case {0},
set(h,'Userdata',1,'Label','&Hide Legend');
DisplayLegend('on');
case {1},
set(h,'Userdata',0,'Label','&Show Legend');
DisplayLegend('off');
end;
return; % ToggleLegend
%--------------------------------------------------------------------------
%
function combining_plots(combine_toggle)
combine_plots = getappdata(gcf,'CombinePlots');
if (combine_plots == combine_toggle) % do nothing
return;
end;
h = findobj(gcf,'Tag','StimulusSlider');
switch (combine_toggle),
case 0,
if ~isempty(h), set(h,'Visible','on'); end;
case 1,
if ~isempty(h), set(h,'Visible','off'); end;
end;
setappdata(gcf,'CombinePlots',combine_toggle);
start_cond = getappdata(gcf,'FirstCondition');
start_stim = getappdata(gcf,'FirstStimulus');
plot_stims(start_cond,start_stim);
return; % combine_plots
%--------------------------------------------------------------------------
%
function set_cond_axes(num_rows,num_cols,axes_margin)
%
% Define the axes for the response functions of different conditions
%
% axes_margin: [left right bottom top], which specified in terms of
% normal unit respect to the figure;
%
% clear up the old handles
%
old_hdls = getappdata(gcf,'AxesHdls');
if ~isempty(old_hdls)
for i=1:length(old_hdls(:))
if ishandle(old_hdls{i}), delete(old_hdls{i}); end
end;
end;
% also clear up other axes handle, if available
err_ax = getappdata(gcf,'ErrHdls');
if ~isempty(err_ax)
delete(err_ax);
end
f_pos = get(gcf,'Position');
axes_boundary(1) = axes_margin(1);
axes_boundary(2) = 1 - axes_margin(2);
axes_boundary(3) = axes_margin(3);
axes_boundary(4) = 1 - axes_margin(4);
% plot data in each axis
%
ax_hdls = cell(num_rows,num_cols);
ax_pos = cell(num_rows,num_cols);
plot_width = (axes_boundary(2) - axes_boundary(1)) / num_cols;
plot_height = (axes_boundary(4) - axes_boundary(3) + 0.03) / num_rows;
axes_min_x = axes_boundary(1);
axes_min_y = axes_boundary(3);
for row=1:num_rows,
axes_y = axes_min_y + plot_height*(num_rows-row);
% for separate plots within each condition
%
for col=1:num_cols,
% determine the position of the figure
%
axes_x = axes_min_x + plot_width*(col-1);
axes_pos = [axes_x axes_y plot_width-0.09 plot_height-0.09];
ax = axes('units','normal','Position',axes_pos);
set(ax,'units',get(gcf,'defaultaxesunits'));
set(ax,'visible','off');
ax_hdls{row,col} = ax;
ax_pos{row,col} = axes_pos;
end,
end;
err_ax_pos = [axes_min_x, axes_min_y-0.04, ...
axes_boundary(2)-axes_boundary(1), ...
axes_boundary(4)-axes_boundary(3)+0.02];
err_ax = axes('units','normal','Position',err_ax_pos);
set(err_ax,'visible','off');
setappdata(gcf,'ErrHdls',err_ax);
setappdata(gcf,'AxesHdls',ax_hdls);
setappdata(gcf,'AxesPos',ax_pos);
return; % set_cond_axes
%--------------------------------------------------------------------------
%
function setup_sliders()
%
% remove the old sliders first
%
h = findobj(gcf,'Tag','ConditionSlider');
if ~isempty(h), delete(h); end;
h = findobj(gcf,'Tag','StimulusSlider');
if ~isempty(h), delete(h); end;
% return if draw error bar
%
error_state = getappdata(gcf,'PlotErrorState');
if error_state, return; end;
% set up sliders when needed
%
plot_dims = getappdata(gcf,'PlotDims');
cond_idx = getappdata(gcf,'PlotCondIdx');
behavdata = getappdata(gcf,'behavdata');
if ( plot_dims(1) < length(cond_idx) )
set_cond_slider;
end;
if ( (plot_dims(2)) < size(behavdata,2) )
set_stim_slider;
end;
return; % setup_sliders
%--------------------------------------------------------------------------
%
function set_cond_slider()
%
ax_pos = getappdata(gcf,'AxesPos');
[rows cols] = size(ax_pos);
pos = ax_pos{rows,cols};
pos_h = ax_pos{1,cols};
x = pos(1)+pos(3)+0.03;
y = pos(2);
w = 0.02;
% h = pos(4)*rows;
h = pos_h(2)+pos_h(4)-pos(2);
pos = [x y w h];
cond_idx = getappdata(gcf,'PlotCondIdx');
max_value = length(cond_idx) - rows + 1;
value = max_value;
small_advance = 1/(max_value-1);
big_advance = rows * small_advance;
if (big_advance > 1), big_advance = 1; end;
if (small_advance == big_advance)
small_advance = small_advance - 0.00001;
end;
slider_step = [small_advance big_advance];
cb_fn=['pet_plot_cond_stim_ui(''MOVE_COND_SLIDE'')'];
h_cond_bar = uicontrol('Parent',gcf, ...
'Style', 'slider', ...
'Units', 'normal', ...
'Position', pos, ...
'Value', value, ...
'SliderStep', slider_step, ...
'Min', 1, ...
'Max', max_value, ...
'Tag', 'ConditionSlider', ...
'Callback',cb_fn);
return; % set_cond_slicer
%--------------------------------------------------------------------------
%
function set_stim_slider()
%
ax_pos = getappdata(gcf,'AxesPos');
[rows cols] = size(ax_pos);
pos = ax_pos{rows,1}; % [x y width height]
pos_w = ax_pos{rows,cols}; % [x y width height]
x = pos(1);
y = pos(2)-0.1;
% w = pos(3)*cols;
w = pos_w(1)+pos_w(3)-pos(1);
h = 0.03;
pos = [x y w h];
behavdata = getappdata(gcf,'behavdata');
max_value = size(behavdata,2) - cols + 1;
value = 1;
if (max_value < 2),
return;
end;
small_advance = 1/(max_value-1);
big_advance = cols * small_advance;
if (big_advance > 1), big_advance = 1; end;
if (small_advance == big_advance)
small_advance = small_advance - 0.00001;
end;
slider_step = [small_advance big_advance];
cb_fn=['pet_plot_cond_stim_ui(''MOVE_STIM_SLIDE'')'];
h_stim_bar = uicontrol('Parent',gcf, ...
'Style', 'slider', ...
'Units', 'normal', ...
'Position', pos, ...
'Value', value, ...
'SliderStep', slider_step, ...
'Min', 1, ...
'Max', max_value, ...
'Tag', 'StimulusSlider', ...
'Callback',cb_fn);
set(h_stim_bar,'position',pos);
return; % set_stim_slicer
%--------------------------------------------------------------------------
%
function set_stim_slider_pos()
%
hh = findobj(gcf,'Tag','StimulusSlider');
if isempty(hh),
return;
end;
show_avg = getappdata(gcf,'ShowAverage');
combine_plots = getappdata(gcf,'CombinePlots');
ax_pos = getappdata(gcf,'AxesPos');
[rows cols] = size(ax_pos);
if (show_avg == 1),
cols = cols - 1;
end;
pos = ax_pos{rows,1}; % [x y width height]
pos_w = ax_pos{rows,cols}; % [x y width height]
x = pos(1);
y = pos(2)-0.08;
% w = pos(3)*cols;
w = pos_w(1)+pos_w(3)-pos(1);
h = 0.03;
pos = [x y w h];
set(hh, 'Position', pos);
return; % set_stim_slicer_pos
%-----------------------------------------------------------
%
function fig_bt_dn()
score_hdl = getappdata(gcf,'score_hdl');
for i=1:length(score_hdl(:))
set(score_hdl(i), 'selected', 'off'); % remove selection
end
try
txtbox_hdl = getappdata(gcf,'txtbox_hdl');
delete(txtbox_hdl); % clear rri_txtbox
catch
end
return; % fig_bt_dn
%-----------------------------------------------------------
%
function select_subj
% don't do anything if we're supposed to be zooming
tmp = zoom(gcf,'getmode');
if (isequal(tmp,'in') | isequal(tmp,'on')), return; end
score_hdl = getappdata(gcf,'score_hdl');
start_cond = getappdata(gcf,'FirstCondition');
start_stim = getappdata(gcf,'FirstStimulus');
% load the information using getappdata
%
ax_hdls = getappdata(gcf,'AxesHdls');
st_data = getappdata(gcf,'ST_data');
condition = getappdata(gcf,'ST_condition');
plot_dims = getappdata(gcf,'PlotDims');
cond_idx1 = getappdata(gcf,'PlotCondIdx');
curr_fig = gcf;
rows = plot_dims(1);
cols = plot_dims(2);
end_cond = start_cond+rows-1;
if (end_cond > length(cond_idx1))
end_cond = length(cond_idx1);
end;
cond_idx = cond_idx1(start_cond:end_cond);
end_stim = start_stim + cols - 1;
subj_name = condition.subj_name;
behav_wave = st_data.behav_wave;
numbehav = size(behav_wave, 2);
num_conds = size(behav_wave, 3);
for i = 1:rows
if (i > num_conds)
break;
end;
if (end_stim > numbehav)
end_stim = numbehav;
end;
for j=start_stim:end_stim,
if (start_stim <= numbehav)
for n=1:length(subj_name)
set(score_hdl(i,j,n),'selected','off');
end
end
end
end
n = get(gco, 'userdata');
for i = 1:rows
if (i > num_conds)
break;
end;
if (end_stim > numbehav)
end_stim = numbehav;
end;
for j=start_stim:end_stim,
if (start_stim <= numbehav)
set(score_hdl(i,j,n),'selected','on');
end
end
end
txtbox_hdl = rri_txtbox(gca, 'Subject Name', subj_name{n});
setappdata(gcf, 'txtbox_hdl', txtbox_hdl);
return; % select_subj
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -