📄 pet_plot_scores_ui.m
字号:
try
rmappdata(link_info.hdl,link_info.name);
end;
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
pet_plot_scores_pos = get(gcbf,'position');
save(pls_profile, '-append', 'pet_plot_scores_pos');
catch
end
h0 = gcbf;
axis_fig = getappdata(h0,'axis_fig');
dlv_fig = getappdata(h0,'dlv_fig');
try
if ishandle(axis_fig)
delete(axis_fig);
end
if ishandle(dlv_fig)
delete(dlv_fig);
end
catch
end
return; % delete_fig
%------------------------------------------------
function toggle_axis
hm_axis = getappdata(gcf,'hm_axis');
axis_status = get(hm_axis,'userdata');
if ~axis_status % was not checked
set(hm_axis, 'userdata',1, 'check','on');
view_axis;
else
set(hm_axis, 'userdata',0, 'check','off');
try
axis_fig_name = get(getappdata(gcf,'axis_fig'),'name');
if ~isempty(axis_fig_name) & strcmp(axis_fig_name,'Current Axis')
close(getappdata(gcf,'axis_fig'));
end
catch
end
end
return; % toggle_axis
%--------------------------------------------------
function view_axis
h0 = gcf;
axis_old = gca;
if ~ischar(get(axis_old,'userdata')) | (...
~strcmp(get(axis_old,'userdata'),'PlotBrainDesignScores') ...
& ~strcmp(get(axis_old,'userdata'),'PlotDesignScores') ...
& ~strcmp(get(axis_old,'userdata'),'topPlotDesignLV') ...
& ~strcmp(get(axis_old,'userdata'),'bottomPlotDesignLV'))
msgbox('Please click a plot in PLS Scores Plot.', 'modal');
hm_axis = getappdata(h0,'hm_axis');
set(hm_axis, 'userdata',0, 'check','off');
return;
end
axis_fig_name = [];
try
axis_fig_name = get(getappdata(h0,'axis_fig'),'name');
catch
end
if ~isempty(axis_fig_name) & strcmp(axis_fig_name,'Current Axis')
msg = 'ERROR: Current Axis window has already been opened.';
msgbox(msg,'ERROR','modal');
else
% It seems that Matlab has a lot of bugs in Legend function,
% Slow, not working after copyobj, etc. ...
%
if strcmp(get(axis_old,'userdata'),'PlotBrainDesignScores')
old_legend = getappdata(gcf,'LegendHdl');
if ~isempty(old_legend),
try
delete(old_legend{1});
catch
end;
end;
end;
if strcmp(get(axis_old,'userdata'),'PlotDesignScores')
old_legend = getappdata(gcf,'LegendHdl2');
if ~isempty(old_legend),
try
delete(old_legend{1});
catch
end;
end;
end;
if strcmp(get(axis_old,'userdata'),'PlotDesignLV')
old_legend = getappdata(gcf,'LegendHdl3');
if ~isempty(old_legend),
try
delete(old_legend{1});
catch
end;
end;
end;
h01 = erp_new_axis_ui;
set(h01,'name','Current Axis');
axis_new = gca;
conditions = getappdata(h0, 'conditions');
% redraw legend
%
if strcmp(get(axis_old,'userdata'),'PlotBrainDesignScores') ...
& ~isempty(conditions)
legend_state = get(findobj(h0,'Tag','LegendMenu'),'Userdata');
axes(axis_old);
[l_hdl, o_hdl] = legend(conditions, 0);
legend_txt(o_hdl);
set(l_hdl,'color',[0.9 1 0.9]);
setappdata(h0, 'LegendHdl',[{l_hdl} {o_hdl}]);
if (legend_state == 1),
DisplayLegend('on');
else
DisplayLegend('off');
end;
figure(h01)
axes(axis_new);
[l_hdl, o_hdl] = legend(conditions, 0);
legend_txt(o_hdl);
set(l_hdl,'color',[0.9 1 0.9]);
setappdata(h01, 'LegendHdl',[{l_hdl} {o_hdl}]);
if (legend_state == 1),
DisplayLegend('on');
else
DisplayLegend('off');
end;
end
if strcmp(get(axis_old,'userdata'),'PlotDesignScores') ...
& ~isempty(conditions)
legend_state = get(findobj(h0,'Tag','LegendMenu'),'Userdata');
axes(axis_old);
[l_hdl, o_hdl] = legend(conditions, 0);
legend_txt(o_hdl);
set(l_hdl,'color',[0.9 1 0.9]);
setappdata(h0, 'LegendHdl2',[{l_hdl} {o_hdl}]);
if (legend_state == 1),
DisplayLegend('on');
else
DisplayLegend('off');
end;
figure(h01)
axes(axis_new);
[l_hdl, o_hdl] = legend(conditions, 0);
legend_txt(o_hdl);
set(l_hdl,'color',[0.9 1 0.9]);
setappdata(h01, 'LegendHdl2',[{l_hdl} {o_hdl}]);
if (legend_state == 1),
DisplayLegend('on');
else
DisplayLegend('off');
end;
end
if strcmp(get(axis_old,'userdata'),'topPlotDesignLV') ...
& ~isempty(conditions)
legend_state = get(findobj(h0,'Tag','LegendMenu'),'Userdata');
axes(axis_old);
[l_hdl, o_hdl] = legend(conditions, 0);
legend_txt(o_hdl);
set(l_hdl,'color',[0.9 1 0.9]);
setappdata(h0, 'LegendHdl3',[{l_hdl} {o_hdl}]);
if (legend_state == 1),
DisplayLegend('on');
else
DisplayLegend('off');
end;
figure(h01)
axes(axis_new);
[l_hdl, o_hdl] = legend(conditions, 0);
legend_txt(o_hdl);
set(l_hdl,'color',[0.9 1 0.9]);
setappdata(h01, 'LegendHdl3',[{l_hdl} {o_hdl}]);
if (legend_state == 1),
DisplayLegend('on');
else
DisplayLegend('off');
end;
end
if ~isempty(h01)
setappdata(h0,'axis_fig',h01);
setappdata(h01,'main_fig',h0);
end
end
return; % view_axis
%-----------------------------------------------------------
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
userdata = get(gco, 'userdata');
grp_idx = userdata(1);
subj_idx = userdata(2); % subj idx
score_hdl = getappdata(gcf,'score_hdl');
subj_name_lst = getappdata(gcf, 'subj_name_lst');
num_cond_lst = getappdata(gcf, 'num_cond_lst');
num_subj_lst = getappdata(gcf, 'num_subj_lst');
num_conds = num_cond_lst(grp_idx);
num_subjs = num_subj_lst(grp_idx);
subj_name = subj_name_lst{grp_idx};
% deselect other subj
%
for m=1:length(num_subj_lst) %grp
for n = 1:num_subj_lst(m) %n=1:num_subjs
for k=1:num_conds
set(score_hdl(m,n,k),'selected','off');
end
end
end
for k=1:num_conds
set(score_hdl(grp_idx,subj_idx,k),'selected','on'); % select only this subj
end
txtbox_hdl = rri_txtbox(gca, 'Subject Name', subj_name{subj_idx});
setappdata(gcf, 'txtbox_hdl', txtbox_hdl);
return; % select_subj
%------------------------------------------------
function toggle_dlv
hm_dlv = getappdata(gcf,'hm_dlv');
dlv_status = get(hm_dlv,'userdata');
if ~dlv_status % was not checked
set(hm_dlv, 'userdata',1, 'check','on');
view_dlv;
else
set(hm_dlv, 'userdata',0, 'check','off');
try
dlv_fig_user = get(getappdata(gcf,'dlv_fig'),'user');
if ~isempty(dlv_fig_user) & strcmp(dlv_fig_user,'LV Plot')
close(getappdata(gcf,'dlv_fig'));
end
catch
end
end
return; % toggle_dlv
%--------------------------------------------------
function view_dlv
h0 = gcf;
dlv_fig_user = [];
try
dlv_fig_user = get(getappdata(h0,'dlv_fig'),'user');
catch
end
lv_state = getappdata(gcbf,'CurrLVState');
lv_idx = find(lv_state == 1);
if ~isempty(dlv_fig_user) & strcmp(dlv_fig_user,'LV Plot') % update lv_idx
h01 = getappdata(h0,'dlv_fig');
figure(h01);
% msg = 'ERROR: Design LV Plot window has already been opened.';
% msgbox(msg,'ERROR','modal');
else
h01 = erp_plot_dlv_ui;
end
tit_fn = getappdata(gcbf,'tit_fn');
tit = ['Design LV Plot [', tit_fn, ']'];
set(h01,'name',tit);
s = getappdata(gcbf,'s');
cb = erp_per(s);
perm_result = getappdata(gcbf,'perm_result');
designlv = getappdata(gcbf,'designlv');
num_cond_lst = getappdata(gcbf, 'num_cond_lst');
num_subj_lst = getappdata(gcbf, 'num_subj_lst');
num_grp = length(num_subj_lst);
num_conds = num_cond_lst(1);
min_x = 0.5; max_x = size(designlv,1)+0.5;
min_y = min(designlv(:)); max_y = max(designlv(:));
margin_x = abs((max_x - min_x) / 20);
margin_y = abs((max_y - min_y) / 20);
% plot of the designlv
%
cla;hold on;
% the rows are stacked by groups. each group has several conditions.
% each condition could have several contrasts.
%
load('rri_color_code');
for g=1:num_grp
for k=1:num_conds
bar_hdl = bar((g-1)*num_conds+k, designlv((g-1)*num_conds+k,lv_idx));
set(bar_hdl,'facecolor',color_code(k,:));
end
end
hold off;
axis([min_x,max_x,min_y-margin_y,max_y+margin_y]);
set(gca,'tickdir','out','ticklength', [0.005 0.005], ...
'box','on');
ylabel('Design LV');
if isempty(perm_result)
title(sprintf('LV %d: %.2f%% crossblock', lv_idx, 100*cb(lv_idx)));
else
title(sprintf('LV %d: %.2f%% crossblock, p < %.3f', lv_idx, 100*cb(lv_idx), perm_result.sprob(lv_idx)));
end
% if(getappdata(gcbf, 'is_design_plot'))
% title('Weights of the contrasts for the Design LV');
% else
% title('Weights of the contrasts for the Behavior LV');
% end
grid on;
set(gca,'xtick',[1:num_grp]*num_conds - num_conds + 0.5);
set(gca,'xticklabel',1:num_grp);
conditions = getappdata(gcbf, 'conditions');
if ~isempty(conditions),
% remove the old legend to avoid the bug in the MATLAB5
old_legend = getappdata(gcbf,'LegendHdl3');
if ~isempty(old_legend),
try
delete(old_legend{1});
catch
end;
end;
% create a new legend, and save the handles
[l_hdl, o_hdl] = legend(conditions, 0);
legend_txt(o_hdl);
set(l_hdl,'color',[0.9 1 0.9]);
setappdata(gcbf,'LegendHdl3',[{l_hdl} {o_hdl}]);
legend_state = get(findobj(gcbf,'Tag','LegendMenu'),'Userdata');
if (legend_state == 1),
DisplayLegend('on');
else
DisplayLegend('off');
end;
else
setappdata(gcbf,'LegendHdl3',[]);
end;
xlabel('Groups');
if ~isempty(h01)
setappdata(h0,'dlv_fig',h01);
setappdata(h01,'main_fig',h0);
end
% end
return; % view_dlv
%---------------------------------------------------------------------------
function SelectLV(selected_lv)
lv_state = getappdata(gcf,'CurrLVState');
LV_hlist = getappdata(gcf,'LV_hlist');
top_lv = getappdata(gcf,'TopLVButton');
rows = getappdata(gcf,'NumLVRows');
bottom_lv = top_lv + rows - 1;
% remove the previous selection
%
prev_selected_lv = find(lv_state == 1);
if (prev_selected_lv >= top_lv & prev_selected_lv <= bottom_lv),
row_idx = prev_selected_lv - top_lv + 1;
set(LV_hlist(row_idx),'Value',0);
end;
UpdateLVButtonList = 0;
if ~exist('selected_lv','var') % select LV interactively
curr_row = get(gcbo,'Userdata');
curr_lv = top_lv + curr_row -1;
set(LV_hlist(curr_row),'Value',1);
else % select LV by specifying the index
curr_lv = selected_lv;
if (selected_lv >= top_lv & selected_lv <= bottom_lv),
row_idx = selected_lv - top_lv + 1;
set(LV_hlist(row_idx),'Value',1);
else
UpdateLVButtonList = 1;
end;
end;
lv_state = zeros(1,length(lv_state));
lv_state(curr_lv) = 1;
setappdata(gcf,'CurrLVState',lv_state);
if (UpdateLVButtonList)
SetTopLVButton(curr_lv);
end;
return; % SelectLV
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -