📄 struct_result_3v_ui.m
字号:
function fig = struct_result_3v_ui(action,varargin)
if ~exist('action','var') | isempty(action)
[PLSresultFile,PLSresultFilePath] = ...
uigetfile('*STRUCTresult.mat','Open STRUCT Result');
if (PLSresultFilePath == 0), return; end;
PLSResultFile = fullfile(PLSresultFilePath,PLSresultFile);
elseif exist('action','var') & iscell(action)
PLSResultFile = action{1};
end
if ~exist('action','var') | ~ischar(action)
msg = 'Loading PLS results for STRUCT data ... Please wait!';
h = rri_wait_box(msg,[0.5 0.1]);
fig_h = init(PLSResultFile);
setappdata(gcf,'CallingFigure',gcbf);
set(gcbf,'visible','off');
rot_amount = load_pls_result;
% struct_result_3v_ui('Rotation', rot_amount);
ShowResult(0,0);
if (nargout > 0),
fig = fig_h;
end;
delete(h);
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,'crosshair'))
nii_view = getappdata(gcbf,'nii_view');
xhair_on_state = get(gcbo,'Userdata');
if (xhair_on_state == 1)
set(gcbo,'Userdata',0,'Label','Crosshair off');
set(nii_view.axi_xhair.lx,'visible','on');
set(nii_view.axi_xhair.ly,'visible','on');
set(nii_view.cor_xhair.lx,'visible','on');
set(nii_view.cor_xhair.ly,'visible','on');
set(nii_view.sag_xhair.lx,'visible','on');
set(nii_view.sag_xhair.ly,'visible','on');
set(nii_view.handles.axial_axes,'selected','on');
set(nii_view.handles.axial_axes,'selected','off');
set(nii_view.handles.coronal_axes,'selected','on');
set(nii_view.handles.coronal_axes,'selected','off');
set(nii_view.handles.sagittal_axes,'selected','on');
set(nii_view.handles.sagittal_axes,'selected','off');
else
set(gcbo,'Userdata',1,'Label','Crosshair on');
set(nii_view.axi_xhair.lx,'visible','off');
set(nii_view.axi_xhair.ly,'visible','off');
set(nii_view.cor_xhair.lx,'visible','off');
set(nii_view.cor_xhair.ly,'visible','off');
set(nii_view.sag_xhair.lx,'visible','off');
set(nii_view.sag_xhair.ly,'visible','off');
end;
elseif (strcmp(action,'set_xhair_color'))
nii_view = getappdata(gcbf,'nii_view');
old_color = get(gcbo,'Userdata');
new_color = uisetcolor(old_color);
set(gcbo,'Userdata',new_color);
set(nii_view.axi_xhair.lx,'color',new_color);
set(nii_view.axi_xhair.ly,'color',new_color);
set(nii_view.cor_xhair.lx,'color',new_color);
set(nii_view.cor_xhair.ly,'color',new_color);
set(nii_view.sag_xhair.lx,'color',new_color);
set(nii_view.sag_xhair.ly,'color',new_color);
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);
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');
struct_result_newfig_pos = get(gcbf,'position');
save(pls_profile, '-append', 'struct_result_newfig_pos');
catch
end
elseif (strcmp(action,'DeleteFigure'))
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
struct_result_pos = get(gcbf,'position');
save(pls_profile, '-append', 'struct_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');
setting5 = setting;
save(PLSresultFile, '-append', 'setting5');
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] = struct_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,'PlotSagittalView'))
PLSresultFile = get(findobj(gcf,'Tag','ResultFile'),'UserData');
DeleteLinkedFigure;
struct_result_sa_ui({PLSresultFile,1})
elseif (strcmp(action,'PlotCoronalView'))
PLSresultFile = get(findobj(gcf,'Tag','ResultFile'),'UserData');
DeleteLinkedFigure;
struct_result_sa_ui({PLSresultFile,0})
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);
setting5 = [];
warning off;
load(PLSResultFile, 'setting5');
setting = setting5;
warning on;
save_display_status = 'off';
try
load('pls_profile');
catch
end
if strcmpi(save_display_status, 'off')
setting = [];
end
save_setting_status = 'on';
struct_result_pos = [];
try
load('pls_profile');
catch
end
if ~isempty(struct_result_pos) & strcmp(save_setting_status,'on')
pos = struct_result_pos;
else
fig_w = 0.85;
fig_h = 0.8;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -