📄 bfm_result_3v_ui.m
字号:
if ~isempty(rf_plot) & ishandle(rf_plot)
delete(rf_plot);
end;
rf1_plot = getappdata(gcbf,'RF1PlotHdl');
if ~isempty(rf1_plot) & ishandle(rf1_plot)
delete(rf1_plot);
end;
scores_fig = getappdata(gcbf,'ScorePlotHdl');
if ~isempty(scores_fig)
delete(scores_fig);
end;
bscores_fig = getappdata(gcbf,'BSPlotHdl');
if ~isempty(bscores_fig) & ishandle(bscores_fig)
delete(bscores_fig);
end;
eigen_fig = getappdata(gcbf,'EigenPlotHdl');
if ~isempty(eigen_fig) & ishandle(eigen_fig)
delete(eigen_fig);
end;
datamatcorrs_fig = getappdata(gcbf,'DatamatcorrsPlotHdl');
if ~isempty(datamatcorrs_fig) & ishandle(datamatcorrs_fig)
delete(datamatcorrs_fig);
end;
brain_fig = getappdata(gcbf,'brain_plot');
if ~isempty(brain_fig) & ishandle(brain_fig)
delete(brain_fig);
end;
contrast_fig = getappdata(gcbf,'ContrastFigHdl');
if ~isempty(contrast_fig) & ishandle(contrast_fig)
delete(contrast_fig);
end;
cluster_hdl = getappdata(gcbf,'cluster_hdl');
if ~isempty(cluster_hdl) & ishandle(cluster_hdl)
delete(cluster_hdl);
end;
return; % DeleteLinkedFigure
%---------------------------------------------------------------------------
%
function rot_amount = load_pls_result()
cond_selection = [];
% wait message
old_pointer = get(gcf,'Pointer');
set(gcf,'Pointer','watch');
msg = 'Loading PLS result ... please wait';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
h = findobj(gcf,'Tag','ResultFile');
PLSresultFile = get(h,'UserData');
load(PLSresultFile);
rri_changepath('bfmriresult');
if exist('datamatcorrs_lst','var')
setappdata(gcf,'isbehav',1);
set(findobj(gcf,'tag','OpenRF1Plot'), 'visible', 'on');
set(findobj(gcf,'tag','OpenRFPlot'), 'visible', 'on');
set(findobj(gcf,'tag','OpenDatamatcorrsPlot'), 'visible', 'on');
else
setappdata(gcf,'isbehav',0);
set(findobj(gcf,'tag','OpenRF1Plot'), 'visible', 'off');
set(findobj(gcf,'tag','OpenRFPlot'), 'visible', 'on');
set(findobj(gcf,'tag','OpenDatamatcorrsPlot'), 'visible', 'off');
end
if isfield(boot_result,'compare')
boot_result.compare_brain = boot_result.compare;
end
setting = getappdata(gcf,'setting');
if isempty(setting)
lv_idx = 1;
rot_amount = 1;
else
lv_idx = setting.lv_idx;
rot_amount = setting.rot_amount;
end;
num_lv = size(brainlv,2);
if exist('behavlv','var') & exist('ismultiblock','var')
set(findobj(gcf,'Tag','OpenBehavPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenDesignPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenBrainPlot'), 'Visible', 'On');
elseif exist('behavlv','var')
set(findobj(gcf,'Tag','OpenBehavPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenDesignPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenBrainPlot'), 'Visible', 'On');
elseif exist('designlv','var')
set(findobj(gcf,'Tag','OpenBehavPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenDesignPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenBrainPlot'), 'Visible', 'Off');
end
h = findobj(gcf,'Tag','LVIndexEdit');
set(h,'String',num2str(lv_idx),'Userdata',lv_idx);
h = findobj(gcf,'Tag','LVNumberEdit');
set(h,'String',num2str(num_lv),'Userdata',num_lv);
setappdata(gcf,'brainlv',brainlv);
setappdata(gcf, 's', s);
set_blv_fields(lv_idx);
if ~exist('boot_result','var') | isempty(boot_result)
ToggleView(0);
set(findobj(gcf,'Tag','ViewMenu'),'Visible','off');
else % show bootstrap ratio if exist
ToggleView(1);
set(findobj(gcf,'Tag','ViewMenu'),'Visible','on');
% set the bootstrap ratio field values
%
setappdata(gcf,'BSRatio',boot_result.compare_brain);
set_bs_fields(lv_idx);
UpdatePValue;
end;
h = findobj(gcf,'Tag','OpenContrastWindow');
if isequal(ContrastFile,'NONE') | isequal(ContrastFile,'BEHAV') | isequal(ContrastFile,'MULTIBLOCK')
set(h,'Visible','off');
else
set(h,'Visible','on');
end;
set(gcf,'Pointer',old_pointer);
set(findobj(gcf,'Tag','MessageLine'),'String','');
setappdata(gcf,'SessionFileList', SessionProfiles);
setappdata(gcf,'RotateAmount',rot_amount);
setappdata(gcf,'CurrLVIdx',lv_idx);
setappdata(gcf,'STDims',st_dims);
setappdata(gcf,'cond_selection',cond_selection);
return; % load_pls_result
%-------------------------------------------------------------------------
%
function OpenResponseFnPlot()
h = findobj(gcbf,'Tag','ResultFile');
PLSresultFile = get(h,'UserData');
setappdata(gcbf,'actualHRF',1);
% load(PLSresultFile);
rf_plot = getappdata(gcbf,'RFPlotHdl');
if ~isempty(rf_plot)
msg = 'ERROR: Response function plot is already been opened';
set(findobj(gcbf,'Tag','MessageLine'),'String',msg);
return;
end;
rf_plot = bfm_plot_rf_task('LINK',PLSresultFile);
link_info.hdl = gcbf;
link_info.name = 'RFPlotHdl';
setappdata(rf_plot,'LinkFigureInfo',link_info);
setappdata(gcbf,'RFPlotHdl',rf_plot);
% make sure the Coord of the Response Function Plot contains
% the current point in the Response
%
cur_coord = getappdata(gcbf,'Coord');
setappdata(rf_plot,'Coord',cur_coord);
return; %%%%%%
sessionFileList = getappdata(gcbf,'SessionFileList');
rf_plot = getappdata(gcf,'RFPlotHdl');
if ~isempty(rf_plot)
msg = 'ERROR: Response function plot is already been opened';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
rf_plot = fmri_plot_rf('LINK',sessionFileList);
link_info.hdl = gcbf;
link_info.name = 'RFPlotHdl';
setappdata(rf_plot,'LinkFigureInfo',link_info);
setappdata(gcbf,'RFPlotHdl',rf_plot);
% make sure the Coord of the Response Function Plot contains
% the current point in the Response
%
cur_coord = getappdata(gcf,'Coord');
setappdata(rf_plot,'Coord',cur_coord);
return; % OpenResponseFnPlot
%-------------------------------------------------------------------------
%
function OpenCorrelationPlot
h = findobj(gcbf,'Tag','ResultFile');
PLSresultFile = get(h,'UserData');
setappdata(gcbf,'actualHRF',0);
% load(PLSresultFile);
rf1_plot = getappdata(gcbf,'RF1PlotHdl');
if ~isempty(rf1_plot)
msg = 'ERROR: Response function plot is already been opened';
set(findobj(gcbf,'Tag','MessageLine'),'String',msg);
return;
end;
rf1_plot = bfm_plot_rf('LINK',PLSresultFile);
link_info.hdl = gcbf;
link_info.name = 'RF1PlotHdl';
setappdata(rf1_plot,'LinkFigureInfo',link_info);
setappdata(gcbf,'RF1PlotHdl',rf1_plot);
% make sure the Coord of the Response Function Plot contains
% the current point in the Response
%
cur_coord = getappdata(gcbf,'Coord');
setappdata(rf1_plot,'Coord',cur_coord);
return; %%%%%%
sessionFileList = getappdata(gcbf,'SessionFileList');
rf_plot = getappdata(gcf,'RFPlotHdl');
if ~isempty(rf_plot)
msg = 'ERROR: Response function plot is already been opened';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
rf_plot = fmri_plot_rf('LINK',sessionFileList);
link_info.hdl = gcbf;
link_info.name = 'RFPlotHdl';
setappdata(rf_plot,'LinkFigureInfo',link_info);
setappdata(gcbf,'RFPlotHdl',rf_plot);
% make sure the Coord of the Response Function Plot contains
% the current point in the Response
%
cur_coord = getappdata(gcf,'Coord');
setappdata(rf_plot,'Coord',cur_coord);
return; % OpenCorrelationPlot
%-------------------------------------------------------------------------
%
function SetClusterReportOptions()
st_origin = getappdata(gcbf,'Origin');
st_dims = getappdata(gcbf,'STDims');
setting = getappdata(gcf,'setting');
if isempty(setting) | ~isfield(setting,'cluster_mask_size')
cluster_mask_size = getappdata(gcbf,'ClusterMaskSize');
cluster_min_size = getappdata(gcbf,'ClusterMinSize');
cluster_min_dist = getappdata(gcbf,'ClusterMinDist');
else
cluster_mask_size = setting.cluster_mask_size;
cluster_min_size = setting.cluster_min_size;
cluster_min_dist = setting.cluster_min_dist;
end;
if isempty(st_origin) | all(st_origin == 0)
st_voxel_size = getappdata(gcf,'STVoxelSize');
if all(st_dims == [40 48 1 34]) & all(st_voxel_size == [4 4 4])
st_origin = [20 29 12];
elseif all(st_dims == [91 109 1 91]) & all(st_voxel_size == [2 2 2])
st_origin = [46 64 37];
else
% according to SPM: if the origin field contains 0, then the origin is
% assumed to be at the center of the volume.
%
st_origin = floor((dims([1 2 4])+1)/2);
% st_origin = round(st_dims([1 2 4])/2);
end;
end;
xyz = getappdata(gcf,'xyz');
% prompt = {'Cluster Mask marker size', ...
prompt = {'Minimum cluster size (in voxels)', ...
'Minimum distance (in mm) between cluster peaks', ...
'Origin location (in voxels)' };
% 'Current location (in voxels)' };
% defValues = { num2str(cluster_mask_size), ...
defValues = { num2str(cluster_min_size), ...
num2str(cluster_min_dist), ...
num2str(st_origin) };
% num2str(xyz) };
dlgTitle='Cluster Report Options';
lineNo = 1;
answer = inputdlg(prompt,dlgTitle,lineNo,defValues);
if isempty(answer),
return;
end;
invalid_options = 0;
% mask_size = str2num(answer{1});
min_size = str2num(answer{1});
min_dist = str2num(answer{2});
origin_xyz = str2num(answer{3});
% cur_xyz = str2num(answer{4});
%isempty(mask_size) | (mask_size <= 0) |
if isempty(min_size) | isempty(min_dist) | isempty(origin_xyz)
invalid_options = 1;
elseif (min_size <= 0) | (min_dist <= 0) | (sum(origin_xyz<= 0) ~= 0)
invalid_options = 1;
end;
if (invalid_options)
msg = 'Invalid cluster report options. Options did not changed';
set(findobj(gcbf,'Tag','MessageLine'),'String',msg);
return;
end;
nii_view = getappdata(gcf,'nii_view');
nii_view.origin = origin_xyz;
setappdata(gcf,'nii_view',nii_view);
setappdata(gcbf,'ClusterMaskSize',4); %mask_size);
setappdata(gcbf,'ClusterMinSize',min_size);
setappdata(gcbf,'ClusterMinDist',min_dist);
setappdata(gcbf,'Origin',origin_xyz);
setappdata(gcbf,'STOrigin',origin_xyz);
setting.cluster_mask_size = 4; %mask_size;
setting.cluster_min_size = min_size;
setting.cluster_min_dist = min_dist;
setting.origin = origin_xyz;
setappdata(gcf,'setting',setting);
if 0
if isempty(cur_xyz) | ~all(size(cur_xyz) == [1 3])
msg = 'Please use 3 numbers for xyz.';
set(findobj(gcbf,'Tag','MessageLine'),'String',msg);
return;
else
EditXYZ(cur_xyz);
end
end
% xyz = getappdata(gcf,'xyz'); % move ahead
if 0
if ~isempty(xyz)
EditXYZ;
end
end
if ~isempty(xyz)
voxel_size = getappdata(gcf,'STVoxelSize');
xyz_offset = xyz - origin_xyz;
xyz_mm = xyz_offset .* voxel_size;
h = findobj(gcbf,'Tag','XYZmm');
set(h,'String',sprintf('%2.1f %2.1f %2.1f',xyz_mm));
end;
return; % SetClusterReportOptions
%-------------------------------------------------------------------------
%
function OpenClusterReport()
% wait message
old_pointer = get(gcbf,'Pointer');
set(gcbf,'Pointer','watch');
msg = 'Generating Cluster Report ... please wait';
h = rri_wait_box(msg, [0.5 0.1]);
cluster_min_size = getappdata(gcbf,'ClusterMinSize');
cluster_min_dist = getappdata(gcbf,'ClusterMinDist');
cluster_hdl = getappdata(gcbf,'cluster_hdl');
if ~isempty(cluster_hdl)
msg = 'Please close any opening cluster report window';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
[tmp cluster_hdl] = fmri_cluster_report(cluster_min_size,cluster_min_dist);
link_info.hdl = gcbf;
link_info.name = 'cluster_hdl';
setappdata(cluster_hdl,'LinkFigureInfo',link_info);
setappdata(gcbf,'cluster_hdl',cluster_hdl);
set(gcbf,'Pointer',old_pointer);
set(findobj(gcbf,'Tag','MessageLine'),'String','');
delete(h);
return; % OpenClusterReport
%-------------------------------------------------------------------------
function OpenContrastWindow()
contrast_fig = getappdata(gcbf,'ContrastFigHdl');
if ~isempty(contrast_fig)
msg = 'ERROR: Constrasts information has already been dispalyed.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
h = findobj(gcbf,'Tag','ResultFile');
PLSresultFile = get(h,'UserData');
load(PLSresultFile,'cond_name','design');
num_groups = length(getappdata(gcf,'SessionFileList'));
if num_groups * length(cond_name) ~= size(design, 1)
design = repmat(design, [num_groups 1]);
end
contrast_fig = rri_input_contrast_ui({'BfMRI'}, cond_name, [], num_groups, design, 1);
if 0
if isequal(ContrastFile,'NONE'),
msg = 'No contrast was used for this PLS analysis.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
if isequal(ContrastFile,'HELMERT'), % using Helmert matrix for contrasts
load(SessionProfiles{1}{1});
conditions = session_info.condition;
num_conditions = length(conditions);
helmert_contrasts = rri_helmert_matrix(num_conditions);
for i=1:num_conditions-1,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -