Contents
clear all;
close all;
eeglab;
V_Folder_RawData = '/home/muralir/Documents/AB/Experiments/NeuroFemi/Raw_NeuroFemi_RAW/';
V_Folder_EEGLabData = '/home/muralir/Documents/AB/Experiments/NeuroFemi/EEGLab-Data/';
V_Participant = 'filled_in_below';
CA_Participants = {'NF01','NF02','NF03','NF05','NF06','NF07','NF09','NF10','NF11','NF12','NF13','NF14','NF15','NF16','NF20','NF21','NF22','NF23','NF24','NF25','NF27','NF28','NF30','NF32','NF33','NF34','NF37','NF38','NF39','NF42','NF43','NF45','NF46','NF47','NF48','NF49','NF51','NF52','NF53','NF54','NF55','NF56'};
Participants who are ruled out a priori, and for whom NO ICA needs to be done
ICA Preparation
CA_Participants = {'NF39'};
for V_Counter = 1:length(CA_Participants)
Load the preprocessed re-referenced dataset
V_Participant = CA_Participants{V_Counter};
V_DataFile = fullfile(V_Folder_EEGLabData, V_Participant, [V_Participant, '_bp03_40r_.set']);
EEG = pop_loadset('filename', V_DataFile);
Automatic Bad Channel Rejection
[EEG, V_Channels_Excluded] = pop_rejchan(EEG, 'elec',[1:EEG.nbchan],'threshold',2,'norm','on','measure','spec','freqrange',[0.3 40] );
V_BadChannelsFile = fullfile(V_Folder_EEGLabData, V_Participant, [V_Participant, '_Bad_Channel_Indices.txt']);
dlmwrite(V_BadChannelsFile, V_Channels_Excluded, 'delimiter', ',');
EEG.filename = [V_Participant '_bp03_40r_ica_bc'];
EEG.filepath = [V_Folder_EEGLabData, V_Participant];
EEG.comments = char([V_Participant, '_bp03_40r_ica_bc'], '; Sampling Rate: 500 Hz; BPF: 0.3-40 Hz; ReRef: Linked Mastoids;');
pop_saveset(EEG, 'filename', EEG.filename, 'filepath', EEG.filepath);
Automatic Continuous Rejection -- NOT DONE -- MANUAL CLEANUP DONE BELOW!
[EEG, V_Rejected_Sample_Range] = pop_rejcont(EEG, 'elecrange',[1:EEG.nbchan] ,'freqlimit',[0.3 40] ,'threshold',10,'epochlength',0.5,'contiguous',4,'addlength',0.25,'taper','hamming');
% Save the resultant file as an EEGLab .set
EEG.filename = [V_Participant '_bp03_40r_ica_in'];
EEG.filepath = [V_Folder_EEGLabData, V_Participant];
EEG.comments = char([V_Participant, '_bp03_40r_ica_in'], '; Sampling Rate: 500 Hz; BPF: 0.3-40 Hz; ReRef: Linked Mastoids;');
pop_saveset(EEG, 'filename', EEG.filename, 'filepath', EEG.filepath);
close all;
V_DataFile = fullfile(V_Folder_EEGLabData, V_Participant, [V_Participant, '_bp03_40r_ica_in.set']);
EEG = pop_loadset('filename', V_DataFile);
end;
MANUAL PRE-ICA REJECTION
CA_Participants = {'NF39'};
for V_Counter = 1:length(CA_Participants)
Load the dataset with bad-channels already removed in the previous step
V_Participant = CA_Participants{V_Counter};
V_DataFile = fullfile(V_Folder_EEGLabData, V_Participant, [V_Participant, '_bp03_40r_ica_bc.set']);
EEG = pop_loadset('filename', V_DataFile);
V_Command = 'V_Rejected_Sample_Range = TMPREJ(:,1:2);';
winlength = 5;
scale = 70;
eegplot(EEG.data,'command',V_Command,'title',[V_Participant ' - Reject time intervals manually'],'events',EEG.event,'spacing',scale,'eloc_file',EEG.chanlocs);
waitfor(gcf);
fprintf('%d interval(s) marked for pre-ICA rejection\n', size(V_Rejected_Sample_Range,1));
Save rejection information as EEP-style .rej file. (Adapted from Katrin Cunitz)
V_RejectionsFile = fullfile(V_Folder_EEGLabData, V_Participant, [V_Participant, '.rej_pre_ICA']);
dlmwrite(V_RejectionsFile,(V_Rejected_Sample_Range-1)/EEG.srate,'delimiter','-','precision','%.3f');
fprintf('Saved file %s.\n',V_RejectionsFile);
Actually Reject the bad sample segments that were marked just now in the data
EEG = pop_select(EEG,'nopoint',V_Rejected_Sample_Range);
clear V_Rejected_Sample_Range;
Save the resultant file as an EEGLab .set
EEG.filename = [V_Participant '_bp03_40r_ica_in'];
EEG.filepath = [V_Folder_EEGLabData, V_Participant];
EEG.comments = char([V_Participant, '_bp03_40r_ica_in'], '; Sampling Rate: 500 Hz; BPF: 0.3-40 Hz; ReRef: Linked Mastoids;');
pop_saveset(EEG, 'filename', EEG.filename, 'filepath', EEG.filepath);
close all;
end;
The dataset ABxx_bp03_40r_ica_in.set is the one that will be used in the next step!