📄 erp_single_folder.m
字号:
function erp_single_folder(varargin)
if nargin == 0,
if exist('plslog.m','file')
plslog('Edit ERP Session');
end
init;
setappdata(gcf,'CallingFigure',gcbf);
set(gcbf,'visible','off');
% uiwait(gcf); % wait for user finish
% close(gcf);
% cd(curr_dir);
return;
end;
% clear the message line,
%
h = findobj(gcf,'Tag','MessageLine');
set(h,'String','');
action = upper(varargin{1});
if strcmp(action,'MENU_LOAD_PLS_SESSION_INFO'),
LoadSessionInfo;
ShowSessionInfo;
elseif strcmp(action,'MENU_SAVE_PLS_SESSION_INFO'),
SaveSessionInfo(0);
elseif strcmp(action,'MENU_SAVE_AS_PLS_SESSION_INFO'),
SaveSessionInfo(1);
elseif strcmp(action,'MENU_CLOSE_SESSION_INPUT'),
if (CloseSessionInput == 1);
curr_dir = getappdata(gcf,'curr_dir');
% cd(curr_dir);
% uiresume;
close(gcbf);
end
elseif strcmp(action,'MENU_CLEAR_PLS_SESSION_INFO'),
ClearSessionInfo(0);
ShowSessionInfo;
elseif strcmp(action,'MENU_PATH_PLS_SESSION_INFO'),
PathSessionInfo(0);
ShowSessionInfo;
elseif strcmp(action,'MENU_CREATE_DATAMAT'),
CreateDatamat;
elseif strcmp(action,'MENU_MODIFY_DATAMAT'),
ModifyDatamat;
elseif strcmp(action,'EDIT_DESCRIPTION'),
description = deblank(strjust(get(gcbo,'String'),'left'));
set(gcbo,'String',description);
setappdata(gcf,'SessionDescription',description);
elseif strcmp(action,'EDIT_PLS_DATA_DIR'),
EditPLSDataDir;
elseif strcmp(action,'SELECT_PLS_DATA_DIR'),
SelectPLSDataDir;
elseif strcmp(action,'EDIT_CONTRAST_DATA'),
is_dir_empty = isempty(getappdata(gcf,'SessionPLSDir'));
if is_dir_empty
msg = 'A working directory needs to be specified before inputting contrast data file.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
EditContrastData;
elseif strcmp(action,'SELECT_CONTRAST_DATA'),
is_dir_empty = isempty(getappdata(gcf,'SessionPLSDir'));
if is_dir_empty
msg = 'A working directory needs to be specified before inputting contrast data file.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
SelectContrastData;
elseif strcmp(action,'EDIT_BEHAV_DATA'),
is_dir_empty = isempty(getappdata(gcf,'SessionPLSDir'));
if is_dir_empty
msg = 'A working directory needs to be specified before inputting behav data file.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
EditBehavData;
elseif strcmp(action,'SELECT_BEHAV_DATA'),
is_dir_empty = isempty(getappdata(gcf,'SessionPLSDir'));
if is_dir_empty
msg = 'A working directory needs to be specified before inputting behav data file.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
SelectBehavData;
elseif strcmp(action,'EDIT_CHAN_ORDER'),
is_dir_empty = isempty(getappdata(gcf,'SessionPLSDir'));
if is_dir_empty
msg = 'A working directory needs to be specified before inputting channel data file.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
is_subj_empty = ...
strcmp(get(findobj(gcf,'Tag','NumberSubjectsEdit'),'String'),'0');
if is_subj_empty
msg = 'Subjects need to be selected before selecting channels';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
EditChanOrder;
elseif strcmp(action,'LOAD_MEG_SENSORS'),
is_dir_empty = isempty(getappdata(gcf,'SessionPLSDir'));
if is_dir_empty
msg = 'A working directory needs to be specified before inputting channel data file.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
elseif strcmp(action,'EDIT_DIGIT_INTERVAL')
digit_interval = str2num(get(gcbo,'string'));
if digit_interval <= 0
msg = 'Digitization Interval should be greater than 0';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
set(gcbo,'string',num2str(getappdata(gcf,'SessionDigitInterval')));
return;
end
setappdata(gcf,'SessionDigitInterval',digit_interval);
elseif strcmp(action,'EDIT_PRESTIM_BASELINE')
prestim = str2num(get(gcbo,'string'));
if prestim > 0
msg = 'Prestim Baseline should be less than or equal to 0';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
set(gcbo,'string',num2str(getappdata(gcf,'SessionPrestimBaseline')));
return;
end
digit_interval = getappdata(gcf,'SessionDigitInterval');
if ~isempty(digit_interval) & round(prestim/digit_interval)*digit_interval ~= prestim
prestim = round(prestim/digit_interval)*digit_interval;
set(gcbo,'string',num2str(prestim));
end
setappdata(gcf,'SessionPrestimBaseline',prestim);
elseif strcmp(action,'EDIT_DATAMAT_PREFIX'),
prefix_name = deblank(strjust(get(gcbo,'String'),'left'));
setappdata(gcf,'SessionDatamatPrefix',prefix_name);
elseif strcmp(action,'EDIT_CONDITIONS_NUM'),
msg = 'Click the "Input Conditions" button to set the condition names';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
elseif strcmp(action,'EDIT_CONDITIONS'),
is_dir_empty = isempty(getappdata(gcf,'SessionPLSDir'));
if is_dir_empty
msg = 'A working directory needs to be specified before inputting conditions.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
EditConditions;
elseif strcmp(action,'EDIT_NUM_SUBJECTS'),
edit_single_folder;
elseif strcmp(action,'EDIT_NUM_CHANNELS'),
msg = 'Click the "Edit Channel Order" to load channels';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
elseif strcmp(action,'EDIT_NUM_CONTRAST'),
msg = 'Click the "Edit Contrast Data" button to edit contrast data';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
elseif strcmp(action,'EDIT_NUM_BEHAVIOR'),
msg = 'Click the "Edit Behavior Data" button to edit behavior data';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
elseif strcmp(action,'EDIT_SUBJECTS'),
EditSubject2;
return;
is_cond_empty = ...
strcmp(get(findobj(gcf,'Tag','NumberConditionsEdit'),'String'),'0');
if is_cond_empty
msg = 'Conditions need to be selected before selecting subjects';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
EditSubjects;
elseif strcmp(action,'DELETE_FIG'),
delete_fig;
elseif strcmp(action,'DELETE_FIGURE'),
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
erp_session_profile_pos = get(gcbf,'position');
save(pls_profile, '-append', 'erp_session_profile_pos');
catch
end
calling_fig = getappdata(gcf,'CallingFigure');
if ishandle(calling_fig)
set(calling_fig,'visible','on');
end
elseif strcmp(action,'CLICK_CHAN_IN_COL'),
click_chan_in_col;
end;
return;
%----------------------------------------------------------------------------
function init
curr = pwd;
if isempty(curr)
curr = filesep;
end
curr_dir = curr;
save_setting_status = 'on';
erp_session_profile_pos = [];
try
load('pls_profile');
catch
end
if ~isempty(erp_session_profile_pos) & strcmp(save_setting_status,'on')
pos = erp_session_profile_pos;
else
w = 0.7;
h = 0.55;
x = (1-w)/2;
y = (1-h)/2;
pos = [x y w h];
end
h0 = figure('Color',[0.8 0.8 0.8], ...
'Units','normal', ...
'Name','', ...
'NumberTitle','off', ...
'Menubar', 'none', ...
'Position', pos, ...
'DeleteFcn','erp_single_folder(''DELETE_FIGURE'');', ...
'Tag','EditSessionInformation', ...
'ToolBar','none');
% numbers of inputing line excluding 'MessageLine'
num_inputline = 6;
factor_inputline = 1/(num_inputline+1);
% left label
x = 0.03;
y = (num_inputline-0) * factor_inputline;
w = 0.25;
h = 0.3 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Session Description Label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',0.8, ...
'HorizontalAlignment','right', ...
'Position',pos, ...
'String','Session Description:', ...
'Tag','SessionDescriptionLabel');
x = x+w+0.01;
y = (num_inputline-0) * factor_inputline - 0.1 * factor_inputline;
w = 0.25;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Session Description Edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String',' ', ...
'Callback','erp_single_folder(''EDIT_DESCRIPTION'');', ...
'Tag','SessionDescriptionEdit');
x = x+w;
y = (num_inputline-0) * factor_inputline;
w = 0.2;
h = 0.3 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Datamat Prefix Label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',0.8, ...
'HorizontalAlignment','right', ...
'Position',pos, ...
'String','* Datamat Prefix:', ...
'Tag','DatamatPrefixLabel');
x = x+w+0.01;
y = (num_inputline-0) * factor_inputline - 0.1 * factor_inputline;
w = 0.15;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Datamat Prefix Edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String',' ', ...
'Callback','erp_single_folder(''EDIT_DATAMAT_PREFIX'');', ...
'Tag','DatamatPrefixEdit');
% left label
x = 0.03;
y = (num_inputline-1) * factor_inputline;
w = 0.25;
h = 0.3 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % PLS Data Directory Label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',0.8, ...
'HorizontalAlignment','right', ...
'Position',pos, ...
'String','* Working Directory:', ...
'visible','off', ...
'Tag','PLSDataDirectoryLabel');
x = x+w+0.01;
y = (num_inputline-1) * factor_inputline - 0.1 * factor_inputline;
w = 0.45;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % PLS Data Directory Edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String',' * REQUIRED FIELD', ...
'Callback','erp_single_folder(''EDIT_PLS_DATA_DIR'');', ...
'visible','off', ...
'Tag','PLSDataDirectoryEdit');
x = x+w+0.01;
w = 0.15;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % PLS Data Directory Button
'Units','normal', ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'Position',pos, ...
'String','Browse', ...
'Enable','On', ...
'Callback','erp_single_folder(''SELECT_PLS_DATA_DIR'');', ...
'visible','off', ...
'Tag','PLSDataDirectoryButton');
% left label
x = 0.03;
y = (num_inputline-1) * factor_inputline;
w = 0.25;
h = 0.3 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Digitization Interval Label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',0.8, ...
'HorizontalAlignment','right', ...
'Position',pos, ...
'String','* Digitization Interval:', ...
'Tag','DigitizationIntervalLabel');
x = x+w+0.01;
y = (num_inputline-1) * factor_inputline - 0.1 * factor_inputline;
w = 0.07;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Digitization Interval Edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontUnits','normal', ...
'FontSize',0.5, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','2', ...
'Callback','erp_single_folder(''EDIT_DIGIT_INTERVAL'');', ...
'Tag','DigitIntervalEdit');
x = x+w+0.01;
y = (num_inputline-1) * factor_inputline;
w = 0.06;
h = 0.3 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % (ms)
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',0.8, ...
'HorizontalAlignment','left', ...
'Position',pos, ...
'String','(ms)');
x = 0.49;
w = 0.25;
h = 0.3 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Prestim Baseline Label
'Style','text', ...
'Units','normal', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'FontUnits','normal', ...
'FontSize',0.8, ...
'HorizontalAlignment','right', ...
'Position',pos, ...
'String','* Prestim Baseline:', ...
'Tag','PrestimBaselineLabel');
x = x+w+0.01;
y = (num_inputline-1) * factor_inputline - 0.1 * factor_inputline;
w = 0.1;
h = 0.5 * factor_inputline;
pos = [x y w h];
c = uicontrol('Parent',h0, ... % Prestim Baseline Edit
'Style','edit', ...
'Units','normal', ...
'BackgroundColor',[1 1 1], ...
'FontUnits','normal', ...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -