📄 pet_session_profile_ui.m
字号:
'Units','normal', ...
'BackgroundColor',[0.9 0.9 0.9], ...
'FontUnits','normal', ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','0', ...
'Enable','Inactive', ...
'ButtonDownFcn','pet_session_profile_ui(''EDIT_CONDITIONS_NUM'');', ...
'Tag','NumberConditionsEdit');
x = x+w+0.01;
w = 0.22;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Number of Conditions Button
'Style','pushbutton', ...
'Units','normal', ...
'FontUnits','normal', ...
'FontSize',fnt, ...
'Position',pos, ...
'String','Input Conditions ...', ...
'Enable','On', ...
'Callback','pet_session_profile_ui(''EDIT_CONDITIONS'');', ...
'Tag','NumberConditionsButton');
x = x+w+0.04;
w = 0.25;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Create Datamat
'Style','pushbutton', ...
'Units','normal', ...
'fontunit','normal', ...
'FontSize',fnt, ...
'Position',pos, ...
'String','Create Datamat ...', ...
'Callback','pet_session_profile_ui(''MENU_CREATE_DATAMAT'');', ...
'Tag','CreateDatamatButton');
x = 0.05;
y = (num_inputline-3) * factor_inputline;
w = 0.25;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Number of Subjects Label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',fnt, ...
'HorizontalAlignment','right', ...
'Position',pos, ...
'String','* Number of Subjects: ', ...
'Tag','NumberSubjectsLabel');
x = x+w+0.01;
w = 0.07;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Number of Subjects Edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[0.9 0.9 0.9], ...
'FontUnits','normal', ...
'FontSize',fnt, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','0', ...
'Enable','Inactive', ...
'ButtonDownFcn','pet_session_profile_ui(''EDIT_NUM_SUBJECTS'');', ...
'Tag','NumberSubjectsEdit');
x = x+w+0.01;
w = 0.22;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Number of Subjects Button
'Style','pushbutton', ...
'Units','normal', ...
'FontUnits','normal', ...
'FontSize',fnt, ...
'Position',pos, ...
'String','Select Subjects ...', ...
'Enable','On', ...
'Callback','pet_session_profile_ui(''EDIT_SUBJECTS'');', ...
'Tag','NumberSubjectsButton');
x = x+w+0.04;
w = 0.25;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Close Button
'Style','pushbutton', ...
'Units','normal', ...
'FontUnits','normal', ...
'FontSize',fnt, ...
'Position',pos, ...
'String','CLOSE', ...
'Callback','pet_session_profile_ui(''DELETE_FIG'');', ...
'Tag','CloseButton');
x = 0.01;
y = 0;
w = 1;
h = 0.3 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Message Line
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'ForegroundColor',[0.8 0.0 0.0], ...
'FontUnits','normal', ...
'FontSize',0.8, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','', ...
'Tag','MessageLine');
% menu bar
%
h_file = uimenu('Parent',h0, ...
'Label', '&File', ...
'Tag', 'FileMenu');
m1 = uimenu(h_file, ...
'Label', '&Load', ...
'Callback','pet_session_profile_ui(''MENU_LOAD_PLS_SESSION_INFO'');', ...
'Tag', 'LoadPLSsession');
m1 = uimenu(h_file, ...
'Label', '&Save', ...
'Callback','pet_session_profile_ui(''MENU_SAVE_PLS_SESSION_INFO'');', ...
'Tag', 'SavePLSsession');
m1 = uimenu(h_file, ...
'Label', 'S&ave as', ...
'Callback','pet_session_profile_ui(''MENU_SAVE_AS_PLS_SESSION_INFO'');', ...
'Tag', 'SaveAsPLSsession');
m1 = uimenu(h_file, ...
'Label', '&Close', ...
'Callback','pet_session_profile_ui(''MENU_CLOSE_SESSION_INPUT'');', ...
'Tag', 'CloseSsessionInput');
h_file = uimenu('Parent',h0, ...
'Label', '&Edit', ...
'Tag', 'EditMenu');
m1 = uimenu(h_file, ...
'Label', 'Change Data Paths', ...
'Callback','pet_session_profile_ui(''MENU_PATH_PLS_SESSION_INFO'');', ...
'Enable','off', ...
'Tag', 'PathPLSsessionMenu');
m1 = uimenu(h_file, ...
'separator', 'on', ...
'Label', '&Clear Session', ...
'Callback','pet_session_profile_ui(''MENU_CLEAR_PLS_SESSION_INFO'');', ...
'Tag', 'ClearPLSsessionMenu');
h_file = uimenu('Parent',h0, ...
'Label', '&Datamat', ...
'Tag', 'DatamatMenu');
m1 = uimenu(h_file, ...
'Label', '&Create Datamat File ...', ...
'Callback','pet_session_profile_ui(''MENU_CREATE_DATAMAT'');', ...
'Tag', 'CreateDatamatMenu');
m1 = uimenu(h_file, ...
'Label', 'Input Seed PLS Behav Data and Modify Datamat', ...
'Callback','pet_session_profile_ui(''MENU_MODIFY_BEHAV'');', ...
'Enable','off', ...
'visible', 'off', ...
'Tag', 'ModifyBehavMenu');
% Help submenu
%
Hm_topHelp = uimenu('Parent',h0, ...
'Label', '&Help', ...
'Tag', 'Help');
% 'Callback','rri_helpfile_ui(''pet_session_profile_hlp.txt'',''How to use SESSION PROFILE'');', ...
Hm_how = uimenu('Parent',Hm_topHelp, ...
'Label', '&How to use this window?', ...
'Callback','web([''file:///'', which(''UserGuide.htm''), ''#_Toc128820714'']);', ...
'visible', 'on', ...
'Tag', 'How');
Hm_new = uimenu('Parent',Hm_topHelp, ...
'Label', '&What''s new', ...
'Callback','rri_helpfile_ui(''whatsnew.txt'',''What''''s new'');', ...
'Tag', 'New');
Hm_about = uimenu('Parent',Hm_topHelp, ...
'Label', '&About this program', ...
'Tag', 'About', ...
'Tag', 'About', ...
'CallBack', 'plsgui_version');
ClearSessionInfo(1);
return; % init
%----------------------------------------------------------------------------
function delete_fig()
if (CloseSessionInput == 1);
uiresume
end
return
%----------------------------------------------------------------------------
function delete_figure()
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
pet_session_profile_pos = get(gcbf,'position');
save(pls_profile, '-append', 'pet_session_profile_pos');
catch
end
calling_fig = getappdata(gcf,'CallingFigure');
set(calling_fig,'visible','on');
return
%----------------------------------------------------------------------------
function ClearSessionInfo(init_flag)
% init_flag = 0 for clear operation
% init_flag = 1 for initialization
%
if (init_flag == 0 & ChkModified == 0)
return; % error
end;
curr = pwd;
if isempty(curr)
curr = filesep;
end
session_info.description = '';
session_info.pls_data_path = curr;
% session_info.behav_data_file = '';
session_info.num_behavior = 0;
session_info.behavdata = [];
session_info.behavname = {};
session_info.datamat_prefix = '';
session_info.num_conditions = 0;
session_info.condition = {};
session_info.num_subjects = 0;
session_info.subject = {};
session_info.subj_name = {};
session_info.subj_files = {};
session_info.img_ext = '*.img';
session_info.num_subj_init = -1;
setappdata(gcf,'reselect_subj', 0);
SetSessionInfo(session_info,'')
set(findobj(gcf,'Tag','ModifyBehavMenu'),'enable','off');
set(findobj(gcf,'Tag','PathPLSsessionMenu'),'enable','off');
return; % ClearSessionInfo
%----------------------------------------------------------------------------
function LoadSessionInfo()
if ~isempty(getappdata(gcf,'OldSessionInfo'))
if (ChkModified == 0)
return; % error
end;
end;
[filename, pathname] = uigetfile( '*_PETsession.mat', 'Load a PLS session file');
if isequal(filename,0) | isequal(pathname,0)
return;
end;
cd(pathname);
session_file = fullfile(pathname, filename);
try
pls_session = load(session_file);
catch
msg = 'ERROR: Cannot load the session information';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
if ~exist(pls_session.session_info.pls_data_path,'dir') | ~exist(pls_session.session_info.subject{1},'dir')
msg = 'Invalid path inside. Click Edit menu to Change Data Paths';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
end
try
tmp = pls_session.session_info.subj_files;
catch
msgbox('The version of this program has been changed, you have to create your session file, and run analysis again. Sorry for the inconvenience. -Jan.8,2003');
return;
end
% move to the PLS directory
%
pls_dir = pls_session.session_info.pls_data_path;
if ( exist(pls_dir,'dir') == 7 ) % specified directory exists
% cd(pls_dir);
else
% msg = 'WARNING: The PLS directory does not exist!';
% set(findobj(gcf,'Tag','MessageLine'),'String',msg);
end;
SetSessionInfo(pls_session.session_info,session_file)
set(findobj(gcf,'Tag','ModifyBehavMenu'),'enable','on');
set(findobj(gcf,'Tag','PathPLSsessionMenu'),'enable','on');
return; % LoadSessionInfo
%----------------------------------------------------------------------------
function status = SaveSessionInfo(save_as_flag)
% save_as_flag = 0, save to the loaded file
% save_as_flag = 1, save to a new file
%
status = 0;
if ~exist('save_as_flag','var')
save_as_flag = 0;
end;
[session_info,session_file,old_session_info] = GetSessionInfo;
if (getappdata(gcf,'reselect_subj'))
msg = sprintf('All subjects need to be modified with new conditions before saving.');
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end;
if isempty(session_info.pls_data_path),
msg = sprintf('A working directory needs to be specified before saving.');
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end;
if isempty(session_info.datamat_prefix),
msg = sprintf('A datamat prefix needs to be specified before saving.');
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end;
% if isempty(session_info.behav_data_file),
% msg = sprintf('A Behavior Data file needs to be specified before saving.');
% set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
% return;
% end;
if (session_info.num_subjects == 0),
msg = sprintf('Subjects need to be selected before saving.');
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end;
if (session_info.num_conditions == 0),
msg = sprintf('Conditions need to be selected before saving.');
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end;
if ~isempty(session_info.behavdata)
[r_behav,c_behav] = size(session_info.behavdata);
if (r_behav ~= session_info.num_conditions * session_info.num_subjects)
msg = sprintf('Rows in behavior data file do not match.');
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end;
end
if(0)
% if ~isempty(session_info.behav_data_file)
try
behavdata = load(session_info.behav_data_file);
catch
msg = sprintf('Invalid behavior data file.');
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end
[r_behav,c_behav] = size(behavdata);
if (r_behav ~= session_info.num_conditions * session_info.num_subjects)
msg = sprintf('Rows in behavior data file do not match.');
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end;
else
behavdata = '';
end
if (save_as_flag ~= 0) | isempty(session_file)
curr = pwd;
if isempty(curr)
curr = filesep;
end
savepwd = curr;
% cd(session_info.pls_data_path);
[filename, pathname] = ...
uiputfile([session_info.datamat_prefix, '_PETsession.mat'], ...
'Save the PLS session information');
if isequal(filename,0)
cd(savepwd);
return;
end;
if ~rri_chkfname(filename, 'PET', 'session')
msg = ['File name must be ended with _PETsession.mat'];
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
session_file = '';
return;
end
session_file = [pathname, filename];
cd(savepwd);
else
[pathname, filename] = rri_fileparts(session_file);
end;
create_ver = plsgui_vernum;
try
save (session_file, 'session_info', 'create_ver');
catch
msg = sprintf('Cannot save session information to ''%s'' ',filename);
set(findobj(gcf,'Tag','MessageLine'),'String',['ERROR: ', msg]);
return;
end;
[fpath, fname, fext] = fileparts(session_file);
msg = sprintf('Session information has been saved into ''%s'' ',[fname, fext]);
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
setappdata(gcf,'SessionFile',session_file);
setappdata(gcf,'OldSessionInfo',session_info);
set(gcf,'Name',['Session File: ' session_file]);
set(findobj(gcf,'Tag','ModifyBehavMenu'),'enable','on');
set(findobj(gcf,'Tag','PathPLSsessionMenu'),'enable','on');
status = 1;
return; % SaveSessionInfo
%----------------------------------------------------------------------------
function status = CloseSessionInput()
if (ChkModified == 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -