📄 erp_plot_scores_ui.m
字号:
%ERP_PLOT_SCORES_UI Plot the scatter graph for the followings:
% scalp scores vs. design (or behavior) scores
% design (or behavior) scores vs. LV
%
% Usage: score_fig = erp_plot_scores_ui({result_file, is_design_plot});
%
% Required variable in result_file:
% scalpscores: datamat * salience
% designlv (or behavlv)
% designscores (or behavscores)
% common_conditions: conditions that all groups selected
% cond_name: all condition names
% num_cond_lst: num of conditions in each group
% num_subj_lst: num of subjects in each group
% s: eigenvector
%
% Called by erp_plot_ui
%
% See also: PET_PLOT_SCORES_UI
%
%------------------------------------------------------------
function score_fig = erp_plot_scores_ui(varargin)
if nargin == 0 | ~ischar(varargin{1}) % input is not action
result_file = varargin{1}{1};
is_design_plot = varargin{1}{2};
[tmp tit_fn] = rri_fileparts(get(gcf,'name'));
score_fig = init(result_file, is_design_plot, tit_fn);
old_pointer = get(gcf,'Pointer');
set(gcf,'Pointer','watch');
PlotDesignScores;
PlotScalpDesignScores;
set(gcf,'Pointer',old_pointer);
return;
end
% clear the message line,
%
h = findobj(gcf,'Tag','MessageLine');
set(h,'String','');
action = varargin{1};
switch (action),
case {'move_slider'}
MoveSlider;
case {'select_lv'}
old_pointer = get(gcf,'Pointer');
set(gcf,'Pointer','watch');
SelectLV;
PlotScalpDesignScores;
PlotDesignScores;
PlotDesignLV;
dlv_fig_user = [];
try
dlv_fig_user = get(getappdata(gcf,'dlv_fig'),'user');
catch
end
if ~isempty(dlv_fig_user) & strcmp(dlv_fig_user,'LV Plot')
set(gcf,'Pointer',old_pointer);
view_dlv
end
set(gcf,'Pointer',old_pointer);
case {'remove_subject'}
remove_subject;
case {'un_remove_subject'}
un_remove_subject;
case {'modify_datamat'}
modify_datamat;
case {'toggle_axis'}
toggle_axis;
case {'toggle_dlv'}
toggle_dlv;
case {'ToggleLegend'},
ToggleLegend;
case {'ToggleScalpDesignScores'},
ToggleScalpDesignScores;
case {'ToggleDesignScores'},
ToggleDesignScores;
case {'ToggleDesignLV'},
ToggleDesignLV;
case {'zoom'}
zoom_on_state = get(gcbo,'Userdata');
if (zoom_on_state == 1) % zoom on
zoom on;
set(gcbo,'Userdata',0,'Label','&Zoom off');
set(gcf,'pointer','crosshair');
else % zoom off
zoom off;
set(gcf,'buttondown','erp_plot_scores_ui(''fig_bt_dn'');');
set(gcbo,'Userdata',1,'Label','&Zoom on');
set(gcf,'pointer','arrow');
end
case {'fig_bt_dn'}
fig_bt_dn;
case {'select_subj'}
select_subj;
case {'delete_fig'}
delete_fig;
otherwise
msgbox(sprintf('ERROR: Unknown action "%s"',action),'modal');
end;
return; % erp_plot_scores_ui
%
%
%---------------------------------------------------------------------------
function h0 = init(result_file, is_design_plot, tit_fn)
tit = ['PLS Scores Plot [', tit_fn, ']'];
h0 = [];
[scalpscores, designscores, designlv, ...
common_conditions, cond_name, subj_name_lst, ...
num_cond_lst, num_subj_lst, s, perm_result, datamat_files, num_grp] = ...
load_pls_scores(result_file, is_design_plot);
if isempty(scalpscores)
return;
end
num_grp = length(num_cond_lst);
num_lv = size(scalpscores, 2);
grp_str = [];
for i=1:num_grp
% grp_str = [grp_str, {['Group ', num2str(i)]}];
file_name = datamat_files{i};
[tmp file_name] = fileparts(file_name);
grp_str = [grp_str, {file_name}];
subj_select_lst{i} = ones(1, num_subj_lst(i));
end
lv_str = [];
for i=1:num_lv
lv_str = [lv_str, {['LV ', num2str(i)]}];
end
% ----------------------- Figure --------------------------
save_setting_status = 'on';
erp_plot_scores_pos = [];
try
load('pls_profile');
catch
end
if ~isempty(erp_plot_scores_pos) & strcmp(save_setting_status,'on')
pos = erp_plot_scores_pos;
else
w = 0.85;
h = 0.75;
x = (1-w)/2;
y = (1-h)/2;
pos = [x y w h];
end
xp = 0.0227273;
yp = 0.0294118;
wp = 1-2*xp;
hp = 1-2*yp;
pos_p = [xp yp wp hp];
h0 = figure('units','normal', ...
'paperunit','normal', ...
'paperorient','land', ...
'paperposition',pos_p, ...
'papertype','usletter', ...
'numberTitle','off', ...
'menubar', 'none', ...
'toolbar', 'none', ...
'user','PLS Scores Plot', ...
'name',tit, ...
'color', [0.8 0.8 0.8], ...
'deleteFcn', 'erp_plot_scores_ui(''delete_fig'');', ...
'doubleBuffer','on', ...
'position',pos);
% ---------------------- Left Panel ------------------------
x = 0.03;
y = 0.16;
w = 0.18;
h = 0.78;
pos = [x y w h];
h1 = uicontrol('parent',h0, ...
'units','normal', ...
'back', [0.8 0.8 0.8], ...
'style', 'frame', ...
'fontunit', 'normal', ...
'fontsize', 0.5, ...
'Tag', 'LVFrame', ...
'position', pos);
x = 0.06;
y = 0.9;
w = 0.12;
h = 0.05;
pos = [x y w h];
h1 = uicontrol('parent',h0, ...
'units','normal', ...
'back', [0.8 0.8 0.8], ...
'style', 'text', ...
'fontunit', 'normal', ...
'fontsize', 0.5, ...
'string', 'Display LVs', ...
'Tag', 'DisplayLVLabel', ...
'position', pos);
x = 0.07;
y = 0.85;
w = 0.1;
pos = [x y w h];
lv_h = uicontrol('parent',h0, ...
'unit','normal', ...
'BackgroundColor', [0.8 0.8 0.8], ...
'style', 'radio', ...
'string', 'LV #1', ...
'fontunit', 'normal', ...
'fontsize', 0.5, ...
'callback', 'erp_plot_scores_ui(''select_lv'');', ...
'tag','LVRadioButton', ...
'visible','off', ...
'position', pos);
x = x+w+.01;
w = 0.02;
pos = [x y w h];
h1 = uicontrol('parent',h0, ...
'units','normal', ...
'style', 'slider', ...
'min', 0, ...
'max', 1, ...
'callback', 'erp_plot_scores_ui(''move_slider'');', ...
'tag','LVButtonSlider', ...
'visible','off', ...
'position', pos);
x = 0.07;
y = 0.08;
w = 0.1;
pos = [x y w h];
h1 = uicontrol('parent',h0, ...
'units','normal', ...
'style', 'push', ...
'fontunit', 'normal', ...
'fontsize', 0.5, ...
'string', 'Close', ...
'callback', 'close(gcf)', ...
'position', pos);
% ----------------------- Axes --------------------------
% set up the axes for plotting
%
% 'FontUnits', 'normal', ...
% 'FontSize', 0.07, ...
% axes were not normalized because the Legend can't display properly
%
%
x = 0.28;
y = 0.1;
w = 0.69;
h = 0.85;
pos = [x y w h];
main_axes = axes('units', 'normal', ...
'box', 'on', ...
'tickdir', 'out', ...
'ticklength', [0.005 0.005], ...
'fontsize', 10, ...
'xtickmode', 'auto', ...
'xticklabelmode', 'auto', ...
'ytickmode', 'auto', ...
'yticklabelmode', 'auto', ...
'visible', 'off', ...
'position',pos);
h = 0.37;
pos = [x y w h];
bottom_axes = axes('units','normal', ...
'box', 'on', ...
'tickdir', 'out', ...
'ticklength', [0.005 0.005], ...
'fontsize', 10, ...
'xtickmode', 'auto', ...
'xticklabelmode', 'auto', ...
'ytickmode', 'auto', ...
'yticklabelmode', 'auto', ...
'position',pos);
y = 0.58;
pos = [x y w h];
top_axes = axes('units','normal', ...
'box', 'on', ...
'tickdir', 'out', ...
'ticklength', [0.005 0.005], ...
'fontsize', 10, ...
'xtickmode', 'auto', ...
'xticklabelmode', 'auto', ...
'ytickmode', 'auto', ...
'yticklabelmode', 'auto', ...
'position',pos);
x = 0.01;
y = 0;
w = .5;
h = 0.04;
pos = [x y w h];
h1 = uicontrol('Parent',h0, ... % Message Line
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'ForegroundColor',[0.8 0.0 0.0], ...
'FontUnits', 'normal', ...
'FontSize', 0.6, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','', ...
'Tag','MessageLine');
% ----------------------- Menu --------------------------
% file
%
rri_file_menu(h0);
% edit
%
h_edit = uimenu('parent',h0, ...
'visible','on', ...
'label','&Edit');
h1 = uimenu('parent', h_edit, ...
'callback','erp_plot_scores_ui(''un_remove_subject'');', ...
'label','&Undo Subject Removal');
h1 = uimenu('parent', h_edit, ...
'callback','erp_plot_scores_ui(''remove_subject'');', ...
'label','&Remove Selected Subject');
% view
%
h_view = uimenu('parent',h0, ...
'label','&View', ...
'tag','ViewMenu');
hm_axis = uimenu('parent',h_view, ...
'userdata', 0, ...
'callback', 'erp_plot_scores_ui(''toggle_axis'');', ...
'visible', 'off', ...
'label','&Plot Current Figure');
hm_dlv = uimenu('parent',h_view, ...
'userdata', 0, ...
'callback', 'erp_plot_scores_ui(''toggle_dlv'');', ...
'visible', 'off', ...
'label','&Plot Design LV Figure');
% 'sepa','on', ...
if(is_design_plot)
h1 = uimenu('parent',h_view, ...
'label','Hide &Scalp vs Design Scores', ...
'userdata',1, ... % show scalp vs design scores
'callback', 'erp_plot_scores_ui(''ToggleScalpDesignScores'');', ...
'tag','ScalpDesignMenu');
h1 = uimenu('parent',h_view, ...
'label','Show &Design Scores', ...
'userdata',0, ... % show design scores
'callBack', 'erp_plot_scores_ui(''ToggleDesignScores'');', ...
'tag','DesignMenu');
h1 = uimenu('parent',h_view, ...
'label','Show Design &Latent Variables', ...
'userdata',0, ... % show design lv
'callBack', 'erp_plot_scores_ui(''ToggleDesignLV'');', ...
'tag','DesignLVMenu');
else
h1 = uimenu('parent',h_view, ...
'sepa','on', ...
'label','Hide &Scalp vs Behavior Scores', ...
'userdata',1, ... % show brain vs behavior scores
'callback', 'erp_plot_scores_ui(''ToggleScalpDesignScores'');', ...
'tag','ScalpBehavMenu');
h1 = uimenu('parent',h_view, ...
'label','Show Be&havior Scores', ...
'userdata',0, ... % show behavior scores
'callBack', 'erp_plot_scores_ui(''ToggleDesignScores'');', ...
'tag','BehavMenu');
h1 = uimenu('parent',h_view, ...
'label','Show Behavior &Latent Variables', ...
'userdata',0, ... % show behavior lv
'callBack', 'erp_plot_scores_ui(''ToggleDesignLV'');', ...
'tag','BehavLVMenu');
end
h1 = uimenu('parent',h_view, ...
'sepa','on', ...
'label','&Hide Legend', ...
'userdata',1, ... % show legend
'callBack', 'erp_plot_scores_ui(''ToggleLegend'');', ...
'tag','LegendMenu');
% zoom
%
h2 = uimenu('parent',h0, ...
'userdata', 1, ...
'callback','erp_plot_scores_ui(''zoom'');', ...
'label','&Zoom on');
lv_template = copyobj(lv_h,gcf);
set(lv_template,'Tag','LVTemplate','Visible','off');
curr_lv_state = zeros(1,num_lv);
curr_lv_state(1) = 1;
setappdata(gcf,'tit_fn',tit_fn);
setappdata(gcf, 'scalpscores', scalpscores);
setappdata(gcf, 'designscores', designscores);
setappdata(gcf, 'designlv', designlv);
setappdata(gcf, 'conditions', cond_name(find(common_conditions)));
setappdata(gcf, 'subj_name_lst', subj_name_lst);
setappdata(gcf, 'num_cond_lst', num_cond_lst);
setappdata(gcf, 'num_subj_lst', num_subj_lst);
setappdata(gcf, 's', s);
setappdata(gcf, 'perm_result', perm_result);
setappdata(gcf, 'datamat_files', datamat_files);
setappdata(gcf, 'is_design_plot', is_design_plot);
setappdata(gcf, 'num_grp', num_grp);
setappdata(gcf, 'num_lv', num_lv);
setappdata(gcf, 'subj_select_lst', subj_select_lst);
setappdata(gcf, 'old_subj_select_lst', subj_select_lst);
setappdata(gcf, 'hm_axis', hm_axis);
setappdata(gcf, 'hm_dlv', hm_dlv);
setappdata(gcf, 'main_axes', main_axes);
setappdata(gcf, 'bottom_axes', bottom_axes);
setappdata(gcf, 'top_axes', top_axes);
setappdata(gcf, 'PlotDesignState',1);
setappdata(gcf, 'PlotScalpDesignState',1)
setappdata(gcf, 'PlotDesignLVState',0);
% for GUI
setappdata(gcf,'LVButtonHeight',0.05);
setappdata(gcf,'LV_hlist',[lv_h]);
setappdata(gcf,'LVButtonTemplate',lv_template);
setappdata(gcf,'TopLVButton',1);
setappdata(gcf,'CurrLVState',curr_lv_state);
setappdata(gcf,'num_grp',num_grp);
SetupLVButtonRows;
DisplayLVButtons;
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 + -