我必须分析一些脑电图数据,并且我正在尝试自动化预处理过程。
我有 40 名参与者。每个参与者有 4 个不同的文件,用于 4 个条件。
所以文件保存为
1-1
1-2
1-3
1-4
2-1
2-2
2-3
2-4
...
高达 40-4
这些文件来自 BioSemi (.bdf)
我已经能够自动化预处理过程,但每次我必须选择不同的文件,运行脚本并保存它。
我想运行一个 for 循环,它自己完成所有操作(取 1-1,运行预处理,保存,取 1-2 ......等等)。
接下来,我将粘贴到目前为止的内容。
我整天都在尝试编写一个 for 循环,但它就是行不通。
我真的很感激任何帮助。
这是当前的预处理脚本:
subject = '1-1.bdf'
%Open EEGLAB and inizialize several EEGLAB variables (listed in the output
%function
[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
%Load a file
%EEG=pop_loadset; % pop up window to input arguments
EEG = pop_biosig(subject) %Reads in the dataset frin a BIOSEMI file
% Stores the dataset into EEGLAB
[ALLEEG EEG CURRENTSET ] = eeg_store(ALLEEG, EEG);
%Change sampling rate to 512
EEG = eeg_checkset( EEG );
EEG = pop_resample( EEG, 512);
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET); %save it as a new dataset
% Edit Channel Location
EEG = eeg_checkset( EEG );
EEG=pop_chanedit(EEG, 'lookup','D:\\Matlab\\eeglab_current\\eeglab13_5_4b\\plugins\\dipfit2.3\\standard_BESA\\standard-10-5-cap385.elp');
% Store the dataset into EEGLAB
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 2,'overwrite','on','gui','off');
% Add some comments
EEG.comments = pop_comments(EEG.comments,'','Sampling rate was changed to 512.',1);
% You can see the comments stored with the dataset either by typing >> EEG.comments or selecting the menu option Edit->About this dataset.
%Select Data. Remove EXG5:EXG8
EEG = eeg_checkset( EEG );
EEG = pop_select( EEG,'nochannel',{'EXG5' 'EXG6' 'EXG7' 'EXG8'});
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 2,'overwrite','on','gui','off');
%HighPassFilter 0.5
EEG = eeg_checkset( EEG );
EEG = pop_eegfilt( EEG, 0.5, 0, [], [0], 0, 0, 'fir1', 0);
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 2,'overwrite','on','gui','off');
%LowPassFilter 50
EEG = eeg_checkset( EEG );
EEG = pop_eegfilt( EEG, 0, 50, [], [0], 0, 0, 'fir1', 0);
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 2,'overwrite','on','gui','off');
%ReReference to 35 36 (EXG3. EXG4)
EEG = eeg_checkset( EEG );
EEG = pop_reref( EEG, [35 36] );
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 2,'overwrite','on','gui','off');
% Reject Continuous By Eye
EEG = eeg_checkset( EEG );
pop_eegplot( EEG, 1, 0, 1);
eeglab redraw % Update the EEGLAB window to view changes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Automatic Channel Rejection
EEG = eeg_checkset( EEG );
EEG = pop_rejchan(EEG, 'elec',[1:34] ,'threshold',5,'norm','on','measure','prob');
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 2,'overwrite','on','gui','off');
eeglab redraw % Update the EEGLAB window to view changes