📄 pet_result_sa_ui.m
字号:
function fig = pet_result_sa_ui(action,varargin)
if ~exist('action','var') | isempty(action)
[PLSresultFile,PLSresultFilePath] = ...
uigetfile('*PETresult.mat','Open PET Result');
if (PLSresultFilePath == 0), return; end;
PLSResultFile = fullfile(PLSresultFilePath,PLSresultFile);
sa = 1;
elseif exist('action','var') & iscell(action)
PLSResultFile = action{1};
sa = action{2}; % sagittal view
end
if ~exist('action','var') | ~ischar(action)
msg = 'Loading PLS results for PET data ... Please wait!';
h = rri_wait_box(msg,[0.5 0.1]);
fig_h = init(PLSResultFile, sa);
setappdata(gcf,'CallingFigure',gcbf);
set(gcbf,'visible','off');
rot_amount = load_pls_result;
pet_result_sa_ui('Rotation', rot_amount);
if (nargout > 0),
fig = fig_h;
end;
delete(h);
sa = getappdata(gcf,'sa');
dims = getappdata(gcf,'STDims');
if sa
dims = dims([2 4 3 1]);
else
dims = dims([1 4 3 2]);
end
origin = getappdata(gcf,'STOrigin');
if origin(1) < 1, origin(1) = 1; end
if origin(2) < 1, origin(2) = 1; end
if origin(3) < 1, origin(3) = 1; end
if origin(1) > dims(1), origin(1) = dims(1); end
if origin(2) > dims(2), origin(2) = dims(2); end
if origin(3) > dims(4), origin(3) = dims(4); end
h = findobj(gcf,'Tag','XYZVoxel');
set(h, 'string', num2str(origin));
h = findobj(gcf,'Tag','MessageLine');
set(h,'String','');
EditXYZ;
return;
end;
% clear the message line,
%
h = findobj(gcf,'Tag','MessageLine');
set(h,'String','');
if (strcmp(action,'PlotBnPress'))
ShowResult(0,1); % display brainlv inside the Plot BLV figure
elseif (strcmp(action,'PlotOnNewFigure'))
ShowResult(1,0); % display brainlv in a new figure;
elseif (strcmp(action,'Zooming'))
zoom_on_state = get(gcbo,'Userdata');
if (zoom_on_state == 1)
zoom on;
set(gcbo,'Userdata',0,'Label','&Zoom off');
set(gcf,'pointer','crosshair');
else
zoom off;
set(gcbo,'Userdata',1,'Label','&Zoom on');
set(gcf,'pointer','arrow');
end;
elseif (strcmp(action,'ClusterMask'))
cluster_mask_state = get(gcbo,'Userdata');
isbsr = getappdata(gcbf,'ViewBootstrapRatio');
if isbsr
cluster_info = getappdata(gcbf, 'cluster_bsr');
else
cluster_info = getappdata(gcbf, 'cluster_blv');
end
curr_lv_idx = getappdata(gcbf,'CurrLVIdx');
if length(cluster_info) < curr_lv_idx
cluster_info = [];
else
cluster_info = cluster_info{curr_lv_idx};
end
if isempty(cluster_info)
msgbox('Please either Load or Create a cluster report for this scenario');
return;
end
if (cluster_mask_state == 1)
set(gcbo,'Userdata',0,'check','on');
ShowResult(0,1);
else
set(gcbo,'Userdata',1,'check','off');
ShowResult(0,1);
end;
elseif (strcmp(action,'Toggle_View'))
DeleteLinkedFigure;
ToggleView;
set(findobj(gcbf,'tag','ClusterMask'),'Userdata',1,'check','off');
ShowResult(0,1);
elseif (strcmp(action,'Rotation'))
p_img = getappdata(gcf,'p_img');
if ~isempty(p_img)
p_img = [-1 -1];
setappdata(gcf,'p_img',p_img);
end
setappdata(gcf,'img_xhair',[]);
rot_amount = varargin{1};
setappdata(gcf,'RotateAmount',rot_amount);
switch mod(rot_amount,4)
case {0}, % 0 degree
h = findobj(gcf,'Tag','Rotate0Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate90Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate180Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate270Menu');
set(h,'Checked','on');
case {1}, % 90 degree by default
h = findobj(gcf,'Tag','Rotate0Menu');
set(h,'Checked','on');
h = findobj(gcf,'Tag','Rotate90Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate180Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate270Menu');
set(h,'Checked','off');
case {2}, % 180 degree
h = findobj(gcf,'Tag','Rotate0Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate90Menu');
set(h,'Checked','on');
h = findobj(gcf,'Tag','Rotate180Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate270Menu');
set(h,'Checked','off');
case {3}, % 270 degree
h = findobj(gcf,'Tag','Rotate0Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate90Menu');
set(h,'Checked','off');
h = findobj(gcf,'Tag','Rotate180Menu');
set(h,'Checked','on');
h = findobj(gcf,'Tag','Rotate270Menu');
set(h,'Checked','off');
end;
ShowResult(0,0);
EditXYZ;
elseif (strcmp(action,'EditLV'))
EditLV;
set(findobj(gcbf,'tag','ClusterMask'),'Userdata',1,'check','off');
ShowResult(0,1);
elseif (strcmp(action,'UpdatePValue'))
UpdatePValue;
set(findobj(gcbf,'tag','ClusterMask'),'Userdata',1,'check','off');
isbsr = getappdata(gcbf,'ViewBootstrapRatio');
if isappdata(gcbf,'cluster_blv') & ~isbsr
rmappdata(gcbf,'cluster_blv');
end
if isappdata(gcbf,'cluster_bsr') & isbsr
rmappdata(gcbf,'cluster_bsr');
end
ShowResult(0,1);
elseif (strcmp(action,'EditThresh'))
set(findobj(gcbf,'tag','ClusterMask'),'Userdata',1,'check','off');
isbsr = getappdata(gcbf,'ViewBootstrapRatio');
if isappdata(gcbf,'cluster_blv') & ~isbsr
rmappdata(gcbf,'cluster_blv');
end
if isappdata(gcbf,'cluster_bsr') & isbsr
rmappdata(gcbf,'cluster_bsr');
end
ShowResult(0,1);
elseif (strcmp(action,'EditMin'))
isbsr = getappdata(gcbf,'ViewBootstrapRatio');
lv = getappdata(gcbf,'CurrLVIdx');
if isbsr
data = getappdata(gcbf,'BSRatio');
thresh = getappdata(gcbf,'BSThreshold');
setting = getappdata(gcbf,'setting');
old_data = setting.min_ratio;
else
data = getappdata(gcbf,'BLVData');
thresh = getappdata(gcbf,'BLVThreshold');
setting = getappdata(gcbf,'setting');
old_data = setting.min_blv;
end
if str2num(get(gco,'string')) < min(data(:,lv)) | str2num(get(gco,'string')) > thresh
msg = ['Valid number should be within [' num2str([min(data(:,lv)) thresh]) ']'];
set(findobj(gcbf,'Tag','MessageLine'),'String',msg);
set(gco,'string',num2str(old_data{lv}));
return;
end
set(findobj(gcbf,'tag','ClusterMask'),'Userdata',1,'check','off');
if isappdata(gcbf,'cluster_blv') & ~isbsr
rmappdata(gcbf,'cluster_blv');
end
if isappdata(gcbf,'cluster_bsr') & isbsr
rmappdata(gcbf,'cluster_bsr');
end
ShowResult(0,1);
elseif (strcmp(action,'EditMax'))
isbsr = getappdata(gcbf,'ViewBootstrapRatio');
lv = getappdata(gcbf,'CurrLVIdx');
if isbsr
data = getappdata(gcbf,'BSRatio');
thresh = getappdata(gcbf,'BSThreshold');
setting = getappdata(gcbf,'setting');
old_data = setting.max_ratio;
else
data = getappdata(gcbf,'BLVData');
thresh = getappdata(gcbf,'BLVThreshold');
setting = getappdata(gcbf,'setting');
old_data = setting.max_blv;
end
if str2num(get(gco,'string')) > max(data(:,lv)) | str2num(get(gco,'string')) < thresh
msg = ['Valid number should be within [' num2str([thresh max(data(:,lv))]) ']'];
set(findobj(gcbf,'Tag','MessageLine'),'String',msg);
set(gco,'string',num2str(old_data{lv}));
return;
end
set(findobj(gcbf,'tag','ClusterMask'),'Userdata',1,'check','off');
if isappdata(gcbf,'cluster_blv') & ~isbsr
rmappdata(gcbf,'cluster_blv');
end
if isappdata(gcbf,'cluster_bsr') & isbsr
rmappdata(gcbf,'cluster_bsr');
end
ShowResult(0,1);
elseif (strcmp(action,'SelectPixel'))
SelectPixel;
elseif (strcmp(action,'ResizeFigure'))
ResizeFigure(varargin{1},varargin{2});
elseif (strcmp(action,'DeleteNewFigure'))
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
pet_result_newfig_pos = get(gcbf,'position');
save(pls_profile, '-append', 'pet_result_newfig_pos');
catch
end
elseif (strcmp(action,'DeleteFigure'))
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
pet_result_pos = get(gcbf,'position');
save(pls_profile, '-append', 'pet_result_pos');
catch
end
old_setting = getappdata(gcbf,'old_setting');
setting = getappdata(gcbf,'setting');
save_display_status = 'off';
try
load('pls_profile');
catch
end
if strcmpi(save_display_status, 'off')
setting = [];
end
if ~isequal(setting, old_setting) & strcmpi(save_display_status, 'on')
% save_setting = ...
% questdlg('Would you like to save the display setting?', ...
% 'Save current fields', 'yes', 'no', 'yes');
if 1 % strcmp(save_setting, 'yes')
try
PLSresultFile = get(findobj(gcbf,'Tag','ResultFile'),'UserData');
if getappdata(gcbf,'sa')
setting2 = setting;
save(PLSresultFile, '-append', 'setting2');
else
setting3 = setting;
save(PLSresultFile, '-append', 'setting3');
end
catch
msg = 'Cannot save setting information';
msgbox(msg,'ERROR','modal');
end
end
end
DeleteLinkedFigure;
calling_fig = getappdata(gcf,'CallingFigure');
set(calling_fig,'visible','on');
elseif (strcmp(action,'OpenBrainPlot'))
OpenBrainPlot;
elseif (strcmp(action,'OpenResponseFnPlot'))
OpenResponseFnPlot;
elseif (strcmp(action,'OpenCorrelationPlot'))
OpenCorrelationPlot;
elseif (strcmp(action,'OpenDatamatcorrsPlot'))
OpenDatamatcorrsPlot;
elseif (strcmp(action,'OpenScoresPlot'))
OpenScoresPlot(varargin{1});
elseif (strcmp(action,'OpenEigenPlot'))
OpenEigenPlot;
elseif (strcmp(action,'OpenContrastWindow'))
OpenContrastWindow;
elseif (strcmp(action,'SetClusterReportOptions'))
SetClusterReportOptions;
elseif (strcmp(action,'LoadClusterReport'))
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('LoadClusterReport',gcbf);
if ishandle(cluster_hdl)
link_info.hdl = gcbf;
link_info.name = 'cluster_hdl';
setappdata(cluster_hdl,'LinkFigureInfo',link_info);
setappdata(gcbf,'cluster_hdl',cluster_hdl);
end
elseif (strcmp(action,'OpenClusterReport'))
OpenClusterReport;
elseif (strcmp(action,'MENU_TogglePermResult'))
TogglePermResultDisplay;
elseif (strcmp(action,'LoadBackgroundImage'))
LoadBackgroundImage;
elseif (strcmp(action,'SaveBackgroundImage'))
SaveBackgroundImage;
elseif (strcmp(action,'LoadTemplateFile'))
LoadTemplateFile;
elseif (strcmp(action,'LoadResultFile'))
LoadResultFile;
elseif (strcmp(action,'SaveResultToIMG'))
SaveResultToIMG(0);
elseif (strcmp(action,'SaveDisplayToIMG'))
SaveResultToIMG(1);
elseif (strcmp(action,'DisplayIMG'))
DisplayIMG;
elseif (strcmp(action,'RescaleBnPress'))
RescaleBnPress;
ShowResult(0,1);
elseif (strcmp(action,'CloseFigure'))
CloseFigure;
elseif (strcmp(action,'EditXYZ'))
EditXYZ;
elseif (strcmp(action,'EditXYZmm'))
EditXYZmm;
elseif (strcmp(action,'XYZmmLabel'))
XYZmmLabel;
end;
return;
%---------------------------------------------------------------------------
%
function h0 = init(PLSResultFile, sa)
setting2 = [];
setting3 = [];
warning off;
if sa
load(PLSResultFile, 'setting2');
setting = setting2;
else
load(PLSResultFile, 'setting3');
setting = setting3;
end
warning on;
save_display_status = 'off';
try
load('pls_profile');
catch
end
if strcmpi(save_display_status, 'off')
setting = [];
end
save_setting_status = 'on';
pet_result_pos = [];
if sa
xyz_label = 'YZX:';
xyz_mm_label = 'YZX(mm):';
else
xyz_label = 'XZY:';
xyz_mm_label = 'XZY(mm):';
end
try
load('pls_profile');
catch
end
if ~isempty(pet_result_pos) & strcmp(save_setting_status,'on')
pos = pet_result_pos;
else
fig_w = 0.85;
fig_h = 0.8;
fig_x = (1 - fig_w)/2;
fig_y = (1 - fig_h)/2;
pos = [fig_x fig_y fig_w fig_h];
end
[r_path,r_file,r_ext] = fileparts(PLSResultFile);
h0 = figure('Units','normal', ...
'Color',[0.8 0.8 0.8], ...
'NumberTitle','off', ...
'DoubleBuffer','on', ...
'MenuBar','none',...
'Position',pos, ...
'DeleteFcn','pet_result_sa_ui(''DeleteFigure'')', ...
'Tag','PlotBrainLV');
%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -