📄 erp_plot_canonical_scores.m
字号:
%ERP_PLOT_CANONICAL_SCORES Plot Canonical Scores
%
% USAGE: canonical_fig = erp_plot_canonical_scores('STARTUP', resultfile)
%
%--------------------------------------------------------------------
function fig = erp_plot_canonical_scores(action,varargin)
%
% erp_plot_canonical_scores(action,action_arg1,...)
if ~exist('action','var') | isempty(action) % no action argument
return;
end;
fig = [];
if strcmp(action,'STARTUP')
plsResultFile = varargin{1};
[tmp tit_fn] = rri_fileparts(get(gcf,'name'));
fig = init(plsResultFile, tit_fn);
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_FIG'}
delete_fig;
case {'PLOT_CANONICALSCORES'}
plot_brain_scores;
case {'MENU_PLOTGROUPDATA'}
make_datamat_popup(1);
case {'MENU_PLOTALLDATA'}
make_datamat_popup(2);
case {'MENU_COMBINEPLOTS'}
set_combine_plot;
end
return;
%--------------------------------------------------------------------------
%
function fig = init(plsResultFile, tit_fn)
tit = ['Temporal scores plot [', tit_fn, ']'];
save_setting_status = 'on';
erp_plot_canonical_scores_pos = [];
try
load('pls_profile');
catch
end
if ~isempty(erp_plot_canonical_scores_pos) & strcmp(save_setting_status,'on')
pos = erp_plot_canonical_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', ...
'user','Temporal scores plot', ...
'name',tit, ...
'NumberTitle','off', ...
'Color', [0.8 0.8 0.8], ...
'DoubleBuffer','on', ...
'Menubar', 'none', ...
'DeleteFcn', 'erp_plot_canonical_scores(''delete_fig'');', ...
'Position',pos, ...
'Tag','PlotBrainScoreFig');
% display 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 = [ 'erp_plot_canonical_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','erp_plot_canonical_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','erp_plot_canonical_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', 'erp_plot_canonical_scores(''PLOT_CANONICALSCORES'');');
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');
% file
%
rri_file_menu(hh);
% plot
%
h_plot = uimenu('Parent',hh, ...
'Label','&Plot', ...
'Enable','on',...
'Tag','PlotMenu');
h0 = uimenu('Parent',h_plot, ...
'Label','Plot group data', ...
'Tag','PlotGroupData', ...
'Callback','erp_plot_canonical_scores(''MENU_PlotGroupData'');');
h0 = uimenu('Parent',h_plot, ...
'Label','Plot all data', ...
'Tag','PlotAllData', ...
'Callback','erp_plot_canonical_scores(''MENU_PlotAllData'');');
% option
%
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','erp_plot_cond_stim_ui(''TOGGLE_SHOW_AVERAGE'');');
h0 = uimenu('Parent',h_option, ...
'Label','Combine plots within conditions', ...
'Tag','CombinePlots', ...
'Userdata', 0, ...
'Callback','erp_plot_canonical_scores(''MENU_CombinePlots'');');
h0 = uimenu('Parent',h_option, ...
'Label','Change plot dimension', ...
'Separator','on',...
'Tag','ChgPlotDims', ...
'Callback','erp_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','erp_plot_canonical_scores(''MENU_ExportData'');');
h0 = uimenu('Parent',h_option, ...
'Label','Export data to text file', ...
'Tag','ExportBehavData', ...
'visible', 'off', ...
'Callback','erp_plot_canonical_scores(''MENU_ExportBehavData'');');
% construct the popup label list
%
get_st_datamat_filename(plsResultFile);
make_datamat_popup(1);
lv_template = copyobj(lv_h,hh);
set(lv_template,'Tag','LVTemplate','Visible','off');
[brainlv,conditions,cond_selection,chan_selection,common_time_info] = ...
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,'Conditions',conditions);
setappdata(hh,'cond_selection',cond_selection);
setappdata(hh,'chan_selection',chan_selection);
setappdata(hh,'common_time_info',common_time_info);
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',[]);
setappdata(hh,'plsResultFile',plsResultFile);
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');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -