📄 pet_result_ui.m
字号:
datamatcorrs_lst{i} = blv';
end
end
brainlv =rri_xy_orient_data(brainlv,old_coord,new_coord,dims,origin_pattern);
if ~isempty(bsr)
bsr =rri_xy_orient_data(bsr,old_coord,new_coord,dims,origin_pattern);
end
set(findobj(gcf,'Tag','PlotSagittalView'),'enable','off');
set(findobj(gcf,'Tag','PlotCoronalView'),'enable','off');
set(findobj(gcf,'Tag','Plot3View'),'enable','off');
end
% brainlv = brainlv * diag(s); % will be rescaled in 'set_blv_fields' below
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('ismultiblock','var')
set(gcf,'Name', ...
sprintf('PET Multiblock PLS Brain LV Plot: %s',PLSresultFile));
set(findobj(gcf,'Tag','OpenBrainPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenBehavPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenDesignPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenRFPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenRF1Plot'), 'Visible', 'On');
set(findobj(gcf,'tag','OpenDatamatcorrsPlot'), 'visible', 'on');
setappdata(gcf,'ismultiblock',1);
setappdata(gcf,'isbehav',1);
setappdata(gcf,'datamatcorrs_lst',datamatcorrs_lst);
elseif exist('behavlv','var')
set(gcf,'Name', ...
sprintf('PET Behavioral PLS Brain LV Plot: %s',PLSresultFile));
set(findobj(gcf,'Tag','OpenBrainPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenBehavPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenDesignPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenRFPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenRF1Plot'), 'Visible', 'On');
set(findobj(gcf,'tag','OpenDatamatcorrsPlot'), 'visible', 'on');
setappdata(gcf,'isbehav',1);
setappdata(gcf,'datamatcorrs_lst',datamatcorrs_lst);
elseif exist('designlv','var')
set(gcf,'Name', ...
sprintf('PET Task PLS Brain LV Plot: %s',PLSresultFile));
set(findobj(gcf,'Tag','OpenBrainPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenBehavPlot'), 'Visible', 'Off');
set(findobj(gcf,'Tag','OpenDesignPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenRFPlot'), 'Visible', 'On');
set(findobj(gcf,'Tag','OpenRF1Plot'), 'Visible', 'Off');
set(findobj(gcf,'tag','OpenDatamatcorrsPlot'), 'visible', 'off');
setappdata(gcf,'isbehav',0);
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',bsr);
set_bs_fields(lv_idx);
UpdatePValue;
end;
h = findobj(gcf,'Tag','OpenContrastWindow');
% if isequal(ContrastFile,'NONE') | isequal(ContrastFile,'BEHAV')
if ~exist('design','var')
set(h,'Visible','off');
else
set(h,'Visible','on');
end;
set(gcf,'Pointer',old_pointer);
set(findobj(gcf,'Tag','MessageLine'),'String','');
setappdata(gcf,'DatamatFileList', datamat_files);
setappdata(gcf,'RotateAmount',rot_amount);
setappdata(gcf,'CurrLVIdx',lv_idx);
% setappdata(gcf,'Dims',dims);
setappdata(gcf,'cond_selection',cond_selection);
return; % load_pls_result
%-------------------------------------------------------------------------
%
function OpenBrainPlot()
h = findobj(gcf,'Tag','ResultFile');
PLSresultFile = get(h,'UserData');
brain_plot = getappdata(gcf,'brain_plot');
if ~isempty(brain_plot)
msg = 'ERROR: Brain scores plot is already been opened';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
brain_plot = pet_plot_brain_scores('STARTUP',PLSresultFile);
link_info.hdl = gcbf;
link_info.name = 'brain_plot';
setappdata(brain_plot,'LinkFigureInfo',link_info);
setappdata(gcbf,'brain_plot',brain_plot);
return; % OpenBrainPlot
%-------------------------------------------------------------------------
%
function OpenResponseFnPlot()
DatamatFileList = getappdata(gcbf,'DatamatFileList');
setappdata(gcbf,'actualHRF',1);
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 = pet_plot_rf_task('LINK',DatamatFileList);
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; % OpenResponseFnPlot
%-------------------------------------------------------------------------
%
function OpenCorrelationPlot
DatamatFileList = getappdata(gcbf,'DatamatFileList');
setappdata(gcbf,'actualHRF',0);
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 = pet_plot_rf('LINK',DatamatFileList);
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; % OpenCorrelationPlot
%-------------------------------------------------------------------------
%
function SetClusterReportOptions()
st_origin = getappdata(gcbf,'Origin');
dims = getappdata(gcbf,'Dims');
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;
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,'VoxelSize');
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] = pet_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,'datamat_files','cond_selection','design');
rri_changepath('petresult');
load(datamat_files{1},'session_info');
cond_name = session_info.condition(find(cond_selection));
num_groups = length(getappdata(gcf,'DatamatFileList'));
% if length(cond_name) == size(design, 1)
% num_groups = 1;
% end
if num_groups * length(cond_name) ~= size(design, 1)
design = repmat(design, [num_groups 1]);
end
contrast_fig = rri_input_contrast_ui({'PET'}, cond_name, [], num_groups, design, 1);
if 0
if isequal(contrast_file,'NONE'),
msg = 'No contrast was used for this PLS analysis.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
if isequal(contrast_file,'HELMERT'), % using Helmert matrix for contrasts
load(datamat_files{1});
conditions = session_info.condition;
num_conditions = length(conditions);
helmert_contrasts = rri_helmert_matrix(num_conditions);
for i=1:num_conditions-1,
pls_contrasts(i).name = sprintf('Contrast #%d',i);
pls_contrasts(i).value = helmert_contrasts(:,i)';
end;
else
try
load(contrast_file);
catch
msg = sprintf('ERROR: Cannot open contrast file "%s".',contrast_file);
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
end;
end
% contrast_fig = pls_input_contrast_ui(pls_contrasts,conditions,1);
link_info.hdl = gcbf;
link_info.name = 'ContrastFigHdl';
setappdata(contrast_fig,'LinkFigureInfo',link_info);
setappdata(gcbf,'ContrastFigHdl',contrast_fig);
return; % OpenContrastWindow
%-------------------------------------------------------------------------
%
function plot_bs_ratio(PLSresultFile,lv_idx,slice_idx,thresh,range,new_fig)
%
if (new_fig)
bg_img = getappdata(gcbf,'BackgroundImg');
rot_amount = getappdata(gcbf,'RotateAmount');
else
bg_img = getappdata(gcf,'BackgroundImg');
rot_amount = getappdata(gcf,'RotateAmount');
end;
% load(PLSresultFile,'boot_result','dims','st_win_size','st_coords', ...
% 'st_voxel_size','st_origin');
load(PLSresultFile,'boot_result','dims','st_win_size','st_coords', ...
'st_voxel_size','st_origin');
bs_ratio = boot_result.compare;
if ~exist('slice_idx','var')
slice_idx = [1:slices];
end
num_slices = length(slice_idx);
num_lv = size(bs_ratio,2);
min_ratio =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -