1 Reject+ICA
eeglab;
subjectIDs = 'CT004.set';
for i=1:length(subjectIDs)
[~, name, ~] = fileparts(subjectIDs);
EEG = pop_loadset(subjectIDs); cd('Preprocess_Simplest')
EEG = pop_eegfiltnew(EEG, 'locutoff', 2, 'hicutoff', 48);
EEG = pop_resample(EEG, 125);
EEG = pop_clean_rawdata(EEG, 'FlatlineCriterion', 'off', 'ChannelCriterion', 'off', 'LineNoiseCriterion', 'off', 'BurstCriterion', 40, 'WindowCriterion', 0.5, 'BurstRejection', 'on');
eegplot(EEG.data, 'srate', EEG.srate, 'winlength', EEG.pnts/EEG.srate, 'spacing', 100, 'eloc_file', EEG.chanlocs, 'title', 'filter+ICA+Reject', 'position', [0 0 1 1]);
drawnow; set(gcf,'WindowState','maximized');
EEG = pop_runica(EEG, 'icatype', 'runica');
EEG = pop_iclabel(EEG, 'default');
EEG = pop_icflag(EEG, [NaN NaN; 0.9 1; 0.9 1; 0.9 1; 0.9 1; 0.9 1; 0.9 1]);
EEG = pop_subcomp(EEG, [], 0);
eegplot(EEG.data, 'srate', EEG.srate, 'winlength', EEG.pnts/EEG.srate, 'spacing', 100, 'eloc_file', EEG.chanlocs, 'title', 'filter+ICA+Reject+ICA', 'position', [0 0 1 1]);
drawnow; set(gcf,'WindowState','maximized');
end
2 ICA+reject+ICA Code
subjectIDs = 'CT004.set';
tic,mkdir('Preprocess_Simplest');
for i=1:length(subjectIDs)
[~, name, ~] = fileparts(subjectIDs{i});
EEG = pop_loadset(subjectIDs{i}); cd('Preprocess_Simplest')
EEG = pop_eegfiltnew(EEG, 'locutoff', 2, 'hicutoff', 48);
eegplot(EEG.data, 'srate', EEG.srate, 'winlength', EEG.pnts/EEG.srate, 'spacing', 100, 'eloc_file', EEG.chanlocs, 'title', 'filter', 'position', [0 0 1 1]);
drawnow; set(gcf,'WindowState','maximized'); saveas(gcf, [name '_filter.png']); pop_saveset(EEG, [name '_filter.set']);
EEG = pop_resample(EEG, 125);
EEG = pop_runica(EEG, 'icatype', 'runica');
EEG = pop_iclabel(EEG, 'default');
EEG = pop_icflag(EEG, [NaN NaN; 0.9 1; 0.9 1; 0.9 1; 0.9 1; 0.9 1; 0.9 1]);
EEG = pop_subcomp(EEG, [], 0);
eegplot(EEG.data, 'srate', EEG.srate, 'winlength', EEG.pnts/EEG.srate, 'spacing', 100, 'eloc_file', EEG.chanlocs, 'title', 'filter+ICA', 'position', [0 0 1 1]);
drawnow; set(gcf,'WindowState','maximized'); saveas(gcf, [name '_ICA.png']); pop_saveset(EEG, [name '_ICA.set']);
EEG = pop_clean_rawdata(EEG, 'FlatlineCriterion', 'off', 'ChannelCriterion', 'off', 'LineNoiseCriterion', 'off', 'BurstCriterion', 40, 'WindowCriterion', 0.5, 'BurstRejection', 'on');
eegplot(EEG.data, 'srate', EEG.srate, 'winlength', EEG.pnts/EEG.srate, 'spacing', 100, 'eloc_file', EEG.chanlocs, 'title', 'filter+ICA+Reject', 'position', [0 0 1 1]);
drawnow; set(gcf,'WindowState','maximized'); saveas(gcf, [name '_ICA_Rej.png']); pop_saveset(EEG, [name '_ICA_Rej.set']);
EEG = pop_runica(EEG, 'icatype', 'runica');
EEG = pop_iclabel(EEG, 'default');
EEG = pop_icflag(EEG, [NaN NaN; 0.9 1; 0.9 1; 0.9 1; 0.9 1; 0.9 1; 0.9 1]);
EEG = pop_subcomp(EEG, [], 0);
eegplot(EEG.data, 'srate', EEG.srate, 'winlength', EEG.pnts/EEG.srate, 'spacing', 100, 'eloc_file', EEG.chanlocs, 'title', 'filter+ICA+Reject+ICA', 'position', [0 0 1 1]);
drawnow; set(gcf,'WindowState','maximized'); saveas(gcf, [name '_ICA_Rej_ICA.png']); pop_saveset(EEG, [name '_ICA_Rej_ICA.set']);
end