📄 plsgui.m
字号:
%PLSGUI Splash screen to run PLS programs with Graphical User Interface.
% It allow user to choose PET, ERP, Event Related fMRI, Blocked
% fMRI, and Structure Module.
%
% Usage: plsgui
%
% Starting function. Called by nothing.
%
% I - none
% O - handle to the splash screen
%
% Modified on 12-SEP-2002 by Jimmy Shen
% Modified on 23-oct-2002 to add ERP option
% Modifyed on 12-feb-2003 to add format choose button
% Modified on 08-jul-2004 to remove the prompt dialog box (%jul08)
% Modified on 19-jan-2007 to add structure module
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function fig = plsgui(action)
if get(0,'ScreenDepth') == 0
disp('ERROR: Cannot open figure window. ');
disp('ERROR: Make sure the DISPLAY environment has been set.');
return;
end;
v = '';
r = version;
[t r] = strtok(r,'.');
v = [v t '.'];
[t r] = strtok(r,'.');
v = [v t '.'];
v = str2num(v(1:end-1));
if v > 7.2
feature accel off;
end;
if ~exist('action','var') | isempty(action) | isnumeric(action)
pls = [];
if nargin > 0
pls = action;
end
f_hdl = init(pls);
if (nargout >= 1),
fig = f_hdl;
end;
return
end
switch action
case {'ChoosePET'}
ChoosePET;
case {'ChooseERP'}
ChooseERP;
case {'ChoosefMRI'}
ChoosefMRI;
case {'ChooseBfMRI'}
ChooseBfMRI;
case {'ChooseSTRUCT'}
ChooseSTRUCT;
case {'toggle_save_setting'}
toggle_save_setting;
case {'toggle_save_display'}
toggle_save_display;
case {'change_pwd'}
new_pwd = rri_getdirectory;
if isempty(new_pwd)
return;
end
try
cd(new_pwd);
catch
msg = ['Can''t access directory: ', new_pwd];
msgbox(msg,'Error','modal');
end
case {'delete_fig'}
delete_fig;
end
return; % plsgui
%--------------------------------------------------------------------------
function fig = init(pls)
save_setting_status = 'off'; % 'on'; %jul08
save_display_status = 'off';
plsgui_pos = [];
curr_dir = pwd;
if isempty(curr_dir)
curr_dir = filesep;
end
try
addpath(curr_dir);
load('pls_profile');
pls_profile = which('pls_profile.mat');
% save(pls_profile, '-append', 'save_setting_status'); %jul08
catch
msg = {'The program could not locate file "pls_profile.mat", '};
msg = [msg; {'which can keep your GUI window positions.'}];
msg = [msg;{[]}; {'You may want to create one if this is the first time you'}];
msg = [msg; {'use this program. You can also open an existing one'}];
msg = [msg; {'that you saved before.'}];
tit = 'PLS position profile';
% response = questdlg(msg,tit,'Create','Open','Cancel','Create'); %jul08
if 1 %jul08
pls_profile = fullfile(curr_dir,'pls_profile.mat');
try
save_setting_status = 'off';
save_display_status = 'off';
save(pls_profile, 'save_setting_status', 'save_display_status');
addpath(curr_dir);
catch
pls_profile = [];
save_setting_status = 'off';
save_display_status = 'off';
end
else
switch response
case 'Create'
msg = ['Do you want to put it under directory "',curr_dir,'"?'];
tit = 'Confirm directory';
response = questdlg(msg,tit,'Yes','No','Yes');
switch response
case 'Yes'
pls_profile = fullfile(curr_dir,'pls_profile.mat');
try
save_setting_status = 'on';
save_display_status = 'on';
save(pls_profile, 'save_setting_status', 'save_display_status');
addpath(curr_dir);
catch
msg = ['Can not save "pls_profile.mat" under "',curr_dir,'"'];
msg = [msg, ', Do you want to try another directory?'];
tit = 'Save Error';
pls_profile = [];
response = questdlg(msg,tit,'Yes','No','Yes');
switch response
case 'Yes'
pls_profile = try_new_dir(curr_dir);
case 'No'
pls_profile = [];
save_setting_status = 'off';
save_display_status = 'off';
end
end
case 'No'
pls_profile = try_new_dir(curr_dir);
end
case 'Open'
[fn, new_dir] = uigetfile('pls_profile.mat', ...
'PLS position profile');
if new_dir == 0
pls_profile = [];
save_setting_status = 'off';
save_display_status = 'off';
else
try
addpath(new_dir);
load('pls_profile');
pls_profile=which('pls_profile.mat');
save(pls_profile, 'save_setting_status', 'save_display_status');
catch
msg = ['Can not save "pls_profile.mat" under ',new_dir];
msg = [msg, ', Do you want to try another directory?'];
tit = 'Save Error';
pls_profile = [];
response = questdlg(msg,tit,'Yes','No','Yes');
switch response
case 'Yes'
pls_profile = try_new_dir(new_dir);
case 'No'
pls_profile = [];
save_setting_status = 'off';
save_display_status = 'off';
end
end
end
case 'Cancel'
pls_profile = [];
save_setting_status = 'off';
save_display_status = 'off';
end
end
end
if isempty(pls_profile)
save_setting_status = 'off';
save_display_status = 'off';
end
if ~isempty(plsgui_pos) & strcmp(save_setting_status,'on')
pos = plsgui_pos;
else
w = 0.7;
h = 0.6;
pos = [(1-w)/2 (1-h)/2 w h];
end
% create figure
%
h0 = figure('Units','normal', ...
'Color',[0.8 0.8 0.8], ...
'Name','PLS for PET data', ...
'NumberTitle','off', ...
'Position',pos, ...
'Menubar','none', ...
'Tag','RunPLSFigure', ...
'deletefcn','plsgui(''delete_fig'');', ...
'ToolBar','none');
% create frame
%
margin = 0.06;
x = margin;
y = margin;
w = 1-2*x;
h = 1-2*y;
pos = [x y w h];
h1 = uicontrol('Parent',h0, ...
'Units','normal', ...
'BackgroundColor',[0.9 0.9 0.9], ...
'ListboxTop',0, ...
'position',pos, ...
'Style','frame', ...
'Tag','PLSFrame');
% several sets of buttons. PETs' are visible, others are invisible.
%
w = 0.82;
x = (1-w)/2;
y = 0.78;
h = 0.1;
pos = [x y w h];
Hc_textPET = uicontrol('Parent',h0, ...
'Units','normal', ...
'position',pos, ...
'BackgroundColor',[0.9 0.9 0.9], ...
'FontUnits','normal', ...
'FontSize',0.4, ...
'FontWeight','bold', ...
'String','PLS Analysis for:', ...
'Style','text', ...
'Visible', 'on', ...
'Tag','PETLabel');
% 'FontAngle','italic', ...
% 'FontName', 'FixedWidth', ...
Hc_textBfMRI = uicontrol('Parent',h0, ...
'Units','normal', ...
'BackgroundColor',[0.9 0.9 0.9], ...
'FontUnits','normal', ...
'FontSize',0.4, ...
'FontWeight','bold', ...
'position',pos, ...
'String','PLS Analysis for:', ...
'Style','text', ...
'Visible', 'off', ...
'Tag','BfMRILabel');
Hc_textfMRI = uicontrol('Parent',h0, ...
'Units','normal', ...
'BackgroundColor',[0.9 0.9 0.9], ...
'FontUnits','normal', ...
'FontSize',0.4, ...
'FontWeight','bold', ...
'position',pos, ...
'String','PLS Analysis for:', ...
'Style','text', ...
'Visible', 'off', ...
'Tag','fMRILabel');
Hc_textERP = uicontrol('Parent',h0, ...
'Units','normal', ...
'BackgroundColor',[0.9 0.9 0.9], ...
'FontUnits','normal', ...
'FontSize',0.4, ...
'FontWeight','bold', ...
'position',pos, ...
'String','PLS Analysis for:', ...
'Style','text', ...
'Visible', 'off', ...
'Tag','ERPLabel');
Hc_textSTRUCT = uicontrol('Parent',h0, ...
'Units','normal', ...
'BackgroundColor',[0.9 0.9 0.9], ...
'FontUnits','normal', ...
'FontSize',0.4, ...
'FontWeight','bold', ...
'position',pos, ...
'String','PLS Analysis for:', ...
'Style','text', ...
'Visible', 'off', ...
'Tag','STRUCTLabel');
x = margin+0.01;
w = (1-2*x)/5;
y = y - 0.1;
pos = [x y w h];
h_pet = uicontrol('Parent',h0, ...
'Units','normal', ...
'Position',pos, ...
'back',[0 0 0], ...
'fore',[1 1 1], ...
'CallBack', 'plsgui(''ChoosePET'');', ...
'FontUnits','normal', ...
'FontSize',0.3, ...
'FontWeight','bold', ...
'String','PET', ...
'Visible', 'on', ...
'Tag','PETButton');
x = x+w;
pos = [x y w h];
h_erp = uicontrol('Parent',h0, ...
'Units','normal', ...
'Position',pos, ...
'back',[0.7 0.7 0.7], ...
'fore',[0 0 0], ...
'CallBack', 'plsgui(''ChooseERP'');', ...
'FontUnits','normal', ...
'FontSize',0.3, ...
'FontWeight','bold', ...
'String','ERP', ...
'Visible', 'on', ...
'Tag','ERPButton');
x = x+w;
pos = [x y w h];
h_fmri = uicontrol('Parent',h0, ...
'Units','normal', ...
'Position',pos, ...
'back',[0.7 0.7 0.7], ...
'fore',[0 0 0], ...
'CallBack', 'plsgui(''ChoosefMRI'');', ...
'FontUnits','normal', ...
'FontSize',0.3, ...
'FontWeight','bold', ...
'String','E.R. fMRI', ...
'Visible', 'on', ...
'Tag','fMRIButton');
x = x+w;
pos = [x y w h];
h_bfmri = uicontrol('Parent',h0, ...
'Units','normal', ...
'Position',pos, ...
'back',[0.7 0.7 0.7], ...
'fore',[0 0 0], ...
'CallBack', 'plsgui(''ChooseBfMRI'');', ...
'FontUnits','normal', ...
'FontSize',0.3, ...
'FontWeight','bold', ...
'String','Blocked fMRI', ...
'Visible', 'on', ...
'Tag','BfMRIButton');
x = x+w;
pos = [x y w h];
h_struct = uicontrol('Parent',h0, ...
'Units','normal', ...
'Position',pos, ...
'back',[0.7 0.7 0.7], ...
'fore',[0 0 0], ...
'CallBack', 'plsgui(''ChooseSTRUCT'');', ...
'FontUnits','normal', ...
'FontSize',0.3, ...
'FontWeight','bold', ...
'String','STRUCT', ...
'Visible', 'on', ...
'Tag','STRUCTButton');
button_gap = 0.14;
w = 0.7;
x = (1-w)/2;
y = y - button_gap;
button_pos = [x y w h];
Hc_pushPETsession = uicontrol('Parent',h0, ...
'Units','normal', ...
'Position',button_pos, ...
'BackgroundColor',[0.7 0.7 0.7], ...
'Callback','pet_session_profile_ui;', ...
'FontUnits','normal', ...
'FontSize',0.3, ...
'FontWeight','bold', ...
'String','Session Profile for PET data', ...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -