📄 fmri_plot_scores.m
字号:
end
hold off
return; % PlotDesignLV
%---------------------------------------------------------------------------
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 DisplayLegend(on_off)
l_hdls = getappdata(gcf,'LegendHdl');
l_hdls2 = getappdata(gcf,'LegendHdl2');
l_hdls3 = getappdata(gcf,'LegendHdl3');
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(l_hdls2) & ishandle(l_hdls2{1})
set(l_hdls2{1},'Visible',on_off);
num_obj = length(l_hdls2{2});
for i=1:num_obj,
set(l_hdls2{2}(i),'Visible',on_off);
end;
end
if ~isempty(l_hdls3) & ishandle(l_hdls3{1})
set(l_hdls3{1},'Visible',on_off);
num_obj = length(l_hdls3{2});
for i=1:num_obj,
set(l_hdls3{2}(i),'Visible',on_off);
end;
end
return; % DisplayLegend
%---------------------------------------------------------------------------
function ToggleBrainDesignScores
brain_design_state = getappdata(gcf,'PlotBrainDesignState');
m_hdl = findobj(gcf,'Tag','BrainDesignMenu');
switch (brain_design_state)
case {0},
set(m_hdl,'Label','Hide &Brain vs Design Scores');
setappdata(gcf,'PlotBrainDesignState',1);
DisplayBrainDesignScores('on');
% set(findobj(gcf,'Tag','LegendMenu'),'Enable','on');
setappdata(gcf,'PlotDesignLVState',0);
m_hdl = findobj(gcf,'Tag','DesignLVMenu');
set(m_hdl,'Label','Show Design &Latent Variables');
case {1},
set(m_hdl,'Label','Show &Brain vs Design Scores');
setappdata(gcf,'PlotBrainDesignState',0);
DisplayBrainDesignScores('off');
% set(findobj(gcf,'Tag','LegendMenu'),'Enable','off');
end;
return; % ToggleBrainDesignScores
%---------------------------------------------------------------------------
function DisplayBrainDesignScores(on_off)
design_state = getappdata(gcf,'PlotDesignState');
switch (on_off)
case {'on'},
if (design_state == 1), % need to display design scores
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','off');
set(getappdata(gcf,'ScoreAxes_top'),'Visible','on');
PlotDesignScores;
set(getappdata(gcf,'ScoreAxes_bottom'),'Visible','on');
PlotBrainDesignScores;
else
h = getappdata(gcf,'ScoreAxes_top');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes_bottom');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','on');
PlotBrainDesignScores;
end;
case {'off'},
old_legend = getappdata(gcf,'LegendHdl');
if ~isempty(old_legend),
try
delete(old_legend{1});
catch
end;
end;
% DisplayLegend('off');
if (design_state == 1)
h = getappdata(gcf,'ScoreAxes_top');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes_bottom');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','on');
PlotDesignScores;
else
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','off');
end;
end; % switch
return; % DisplayBrainDesignScores
%---------------------------------------------------------------------------
function ToggleDesignScores
design_state = getappdata(gcf,'PlotDesignState');
m_hdl = findobj(gcf,'Tag','DesignMenu');
switch (design_state)
case {0},
set(m_hdl,'Label','Hide &Design Scores');
setappdata(gcf,'PlotDesignState',1);
DisplayDesignScores('on');
setappdata(gcf,'PlotDesignLVState',0);
m_hdl = findobj(gcf,'Tag','DesignLVMenu');
set(m_hdl,'Label','Show Design &Latent Variables');
case {1},
new_state = 0;
set(m_hdl,'Label','Show &Design Scores');
setappdata(gcf,'PlotDesignState',0);
DisplayDesignScores('off');
end;
return; % ToggleDesignScores
%---------------------------------------------------------------------------
function DisplayDesignScores(on_off)
brain_design_state = getappdata(gcf,'PlotBrainDesignState');
switch (on_off)
case {'on'},
if (brain_design_state == 1), % need to display brain/design scores
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','off');
set(getappdata(gcf,'ScoreAxes_top'),'Visible','on');
PlotDesignScores;
set(getappdata(gcf,'ScoreAxes_bottom'),'Visible','on');
PlotBrainDesignScores;
else
h = getappdata(gcf,'ScoreAxes_top');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes_bottom');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','on');
PlotDesignScores;
end;
case {'off'},
old_legend = getappdata(gcf,'LegendHdl2');
if ~isempty(old_legend),
try
delete(old_legend{1});
catch
end;
end;
if (brain_design_state == 1), % need to display brain/design scores
h = getappdata(gcf,'ScoreAxes_top');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes_bottom');
axes(h); cla; set(h,'Visible','off');
set(getappdata(gcf,'ScoreAxes'),'Visible','on');
PlotBrainDesignScores;
else
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','off');
end;
end; % switch
return; % DisplayDesignScores
%---------------------------------------------------------------------------
function ToggleDesignLV
designlv_state = getappdata(gcf,'PlotDesignLVState');
m_hdl = findobj(gcf,'Tag','DesignLVMenu');
switch (designlv_state)
case {0},
set(m_hdl,'Label','Hide Design &Latent Variables');
setappdata(gcf,'PlotDesignLVState',1);
DisplayDesignLV('on');
setappdata(gcf,'PlotBrainDesignState',0);
m_hdl = findobj(gcf,'Tag','BrainDesignMenu');
set(m_hdl,'Label','Show &Brain vs Design Scores');
DisplayBrainDesignScores('off');
setappdata(gcf,'PlotDesignState',0);
m_hdl = findobj(gcf,'Tag','DesignMenu');
set(m_hdl,'Label','Show &Design Scores');
DisplayDesignScores('off');
% set(findobj(gcf,'Tag','LegendMenu'),'Enable','off');
case {1},
new_state = 0;
set(m_hdl,'Label','Show Design &Latent Variables');
setappdata(gcf,'PlotDesignLVState',0);
DisplayDesignLV('off');
setappdata(gcf,'PlotBrainDesignState',1);
m_hdl = findobj(gcf,'Tag','BrainDesignMenu');
set(m_hdl,'Label','Hide &Brain vs Design Scores');
DisplayBrainDesignScores('on');
setappdata(gcf,'PlotDesignState',1);
m_hdl = findobj(gcf,'Tag','DesignMenu');
set(m_hdl,'Label','Hide &Design Scores');
DisplayDesignScores('on');
end;
return; % ToggleDesignLV
%---------------------------------------------------------------------------
function DisplayDesignLV(on_off)
design_state = getappdata(gcf,'PlotDesignState');
brain_design_state = getappdata(gcf,'PlotBrainDesignState');
switch (on_off)
case {'on'},
if (design_state == 1)
ToggleDesignScores;
end;
if (brain_design_state == 1)
ToggleBrainDesignScores;
end;
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes_top');
axes(h); cla; set(h,'Visible','on');
h = getappdata(gcf,'ScoreAxes_bottom');
axes(h); cla; set(h,'Visible','on');
PlotDesignLV;
case {'off'},
old_legend = getappdata(gcf,'LegendHdl3');
if ~isempty(old_legend),
try
delete(old_legend{1});
catch
end;
end;
h = getappdata(gcf,'ScoreAxes');
axes(h); cla; set(h,'Visible','off');
h = getappdata(gcf,'ScoreAxes_top');
axes(h); cla; set(h,'Visible','off');
% PlotDesignScores;
h = getappdata(gcf,'ScoreAxes_bottom');
axes(h); cla; set(h,'Visible','off');
% PlotBrainDesignScores;
end; % switch
return; % DesignLV
%---------------------------------------------------------------------------
function delete_fig(),
link_info = getappdata(gcbf,'LinkFigureInfo');
try
rmappdata(link_info.hdl,link_info.name);
end;
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
fmri_plot_scores_pos = get(gcbf,'position');
save(pls_profile, '-append', 'fmri_plot_scores_pos');
catch
end
return; % delete_fig
%-----------------------------------------------------------
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 edit_group
return; % edit_group
%-----------------------------------------------------------
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 [b_scores,d_scores,designlv,s,perm_result,conditions,evt_list,fname, ...
subj_name,subj_group,num_subj_lst,num_cond_lst,subj_name_lst, ...
num_grp] = load_pls_scores(fname)
b_scores = [];
d_scores = [];
designlv = [];
conditions = [];
s = [];
perm_result = [];
evt_list = [];
subj_name = {};
num_subj_lst = [];
subj_name_lst = {};
num_cond_lst = [];
% the following part will not get called in plsgui
%
if ~exist('fname','var') | isempty(fname),
f_pattern = '*_fMRIresult.mat';
[PLSresultFile,PLSresultFilePath] = uigetfile(f_pattern,'Load PLS scores');
if isequal(PLSresultFile,0),
return;
end;
fname = [PLSresultFilePath,PLSresultFile];
end;
try
warning off;
load( fname,'b_scores','d_scores','lv_evt_list','designlv','subj_group', ...
's','perm_result','SessionProfiles','subj_name','num_subj_lst');
warning on;
catch
msg = sprintf('Cannot load the PLS result from file: %s',PLSresultFile);
disp(['ERROR: ' msg]);
return;
end;
rri_changepath('fmriresult');
evt_list = lv_evt_list;
if isempty(subj_group)
num_grp = 1;
else
num_grp = length(subj_group);
end
load(SessionProfiles{1}{1}); % load the condition from session profile
conditions = session_info.condition;
try
warning off;
load( fname, 'cond_selection');
warning on;
catch
end;
if exist('cond_selection','var')
conditions = conditions(find(cond_selection));
end
if isempty(subj_group) | isempty(num_subj_lst)
num_cond_lst = sum(cond_selection);
subj_name_lst{1} = subj_name;
return;
end
num_cond_lst = ones(1,length(num_subj_lst))*sum(cond_selection);
first = 1;
last = 0;
for i = 1:length(num_subj_lst)
last = last + num_subj_lst(i);
subj_name_lst{i} = {};
for j = first:last
% subj_name_lst{i} = [subj_name_lst{i} {['Grp',num2str(i),subj_name{j}]}];
subj_name_lst{i} = [subj_name_lst{i} {[subj_name{j}]}];
end
first = first + num_subj_lst(i);
end
return; % load_pls_scores
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -