📄 erp_plot_cond_stim_ui.m
字号:
end;
curr_row = curr_row+1;
end;
setappdata(gcf,'FirstCondition',start_cond);
setappdata(gcf,'FirstStimulus',start_stim);
return;
%--------------------------------------------------------------------------
%
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;
%
show_avg = getappdata(gcf,'ShowAverage');
if (show_avg == 1),
num_cols = num_cols + 1;
end;
% 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;
old_hdls = getappdata(gcf,'AxesCombineHdls');
if ~isempty(old_hdls)
for i=1:length(old_hdls(:))
if ishandle(old_hdls{i}), delete(old_hdls{i}); end
end;
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);
ax_combine_hdls = cell(num_rows,1);
ax_combine_pos = cell(num_rows,1);
plot_width = (axes_boundary(2) - axes_boundary(1)) / num_cols;
plot_height = (axes_boundary(4) - axes_boundary(3)) / 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);
if (col == num_cols & show_avg == 1)
axes_pos = [axes_x+0.02 axes_y plot_width-0.01 plot_height-0.03];
else
axes_pos = [axes_x axes_y plot_width-0.01 plot_height-0.03];
end;
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,
% for combine plots within each condition
%
combine_axes_x = axes_min_x;
combine_axes_y = axes_y;
if (show_avg == 1)
combine_axes_w = plot_width*(num_cols-1)-0.01;
else
combine_axes_w = plot_width*num_cols-0.01;
end;
combine_axes_h = plot_height-0.03;
axes_pos = [combine_axes_x combine_axes_y combine_axes_w combine_axes_h];
ax = axes('units','normal','Position',axes_pos);
set(ax,'units',get(gcf,'defaultaxesunits'));
set(ax,'visible','off');
ax_combine_hdls{row} = ax;
ax_combine_pos{row} = axes_pos;
end;
setappdata(gcf,'AxesHdls',ax_hdls);
setappdata(gcf,'AxesPos',ax_pos);
setappdata(gcf,'AxesCombineHdls',ax_combine_hdls);
setappdata(gcf,'AxesCombinePos',ax_combine_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;
% set up sliders when needed
%
plot_dims = getappdata(gcf,'PlotDims');
cond_idx = getappdata(gcf,'PlotCondIdx');
stim_cnts = getappdata(gcf,'PlotStimCnts');
if ( plot_dims(1) < length(cond_idx) )
set_cond_slider;
end;
max_num_stim = max(stim_cnts(cond_idx));
if ( (plot_dims(2)-1) < max_num_stim )
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.05;
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=['erp_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()
%
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];
stim_cnt_list = getappdata(gcf,'PlotStimCnts');
max_value = max(stim_cnt_list) - 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=['erp_plot_cond_stim_ui(''MOVE_STIM_SLIDE'')'];
if (combine_plots)
visible_state = 'off';
else
visible_state = 'on';
end;
h_stim_bar = uicontrol('Parent',gcf, ...
'Style', 'slider', ...
'Units', 'normal', ...
'Position', pos, ...
'Value', value, ...
'SliderStep', slider_step, ...
'Min', 1, ...
'Max', max_value, ...
'Visible', visible_state, ...
'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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -