%% Pre-processing pipeline pseudocode %% Everything run in MATLAB %% Necessary extensions - eeglab, preppipeline, AMICA, corrmap, CSD % Preprocessing read in data re-reference to average remove baseline insert channel locations 'MMN_ElectrodeCoords_MA2.ced)' High Pass Filter - 'pop_eegfiltnew( EEG, 1, [], [], [0], 0, 0, 0);' Run preppipeline intpChans = setxor(1:64, [5 27 38 60]); % which channels to use for interpolation; exclude EOG channels params = struct('name', [vhdr{1} 'snum' num2str(sx) '.' num2str(nf)], ... 'lineFrequencies', [60:60:300], ... % Line frequencies to remove 'referenceChannels', intpChans, ... % Channels to be used for re-referencing 'evaluationChannels', intpChans, ... % Channels to be used for interpolation 'rereferencedChannels', [1:64], ... % Channels to be linenoise removed and referenced 'detrendChannels', [1:64], ... % Channels to detrend 'lineNoiseChannels', [1:64], ... % Channels to remove line noise from 'ignoreBoundaryEvents', true, ... % ??? not sure why it doesn't work without 'detrendType', 'none', ... % Use high pass filter to detrend channels 'detrendCutoff', 1, ... % High pass filter frequency cut off 'referenceType', 'robust', ... % Robust reference 'meanEstimateType', 'median', ... % Use median for robust reference 'interpolationOrder', 'post-reference', ... % Interpolate channels after robust referencing 'keepFiltered', true); % Retain filtering? EEG = prepPipeline(EEG, params); Low Pass Filter - pop_eegfiltnew( EEG, [], 50, [], [0], 0, 0, 0); Epoch to -1.5 - 3 seconds around stimulus using these triggers [111:114 121:124 211:214 221:224] Remove large artifacts using pop_autorej pop_autorej(EEG, 'nogui','on','threshold',500, 'startprob',5,'maxrej',5); Downsample to 500 Hz pop_resample( EEG, 500 ); Run AMICA using the following [EEG.icaweights, EEG.icasphere, EEG.icamods] = runamica15(EEG.data(:,:), ... 'max_iter', 10000, 'writestep', 500, 'pcakeep', 42, 'do_reject', 1, ... 'max_threads', 12, 'rejsig', 4); Create eeglab 'STUDY' structure Precompute topography to extract EOG using STUDY std_precomp(STUDY, ALLEEG, 'components','allcomps','on','recompute','on','scalp','on'); Find prototypical VEOG artifact and run 'corrmap' to identify all VEOG components corrmap(STUDY, ALLEEG, indx, 1, 'ics',1,'pl', 'both','clname','VEOG','badcomps','no', 'resetclusters','on'); Reject epochs by trend and component spectra, exclude for VEOG artifact pop_rejtrend( EEG, 0, include, size(EEG.times,2), 5, 0.3, 0, 0, 0); pop_rejspec( EEG, 0, 'elecrange', include ,'threshold',[-50 45;-100 30],'freqlimits',[0 3;20 50],'eegplotcom','','eegplotplotallrej',0,'eegplotreject',0); EEG.reject.sum = (EEG.reject.icarejfreq + EEG.reject.icarejconst) > 0; pop_select( EEG, 'notrial', find(EEG.reject.sum)); Run second round ICA on cleaner data [EEG.icaweights, EEG.icasphere, EEG.icamods] = runamica15(EEG.data(:,:), ... 'max_iter', 10000, 'writestep', 500, 'pcakeep', 42, 'do_reject', 1, ... 'max_threads', 12, 'rejsig', 4); Identify VEM, HEOG and VEOG artifacts and run corrmap again to identify Subtract artifacts from EEG pop_subcomp( EEG, [VEM HEOG VEOG], 0); % Check this Final clean up - re-baseline correct to 100 ms epoch baseline and remove large noisy epochs pop_rmbase( EEG, [-100 0]); pop_eegthresh( EEG, 1, [1:64], -90, 90, -1.5, 3, 0, 1); Run CSD transformation Remove eye channels ConvertLocations ExtractMontage for CSD Check Montage (MapMontage(M)) Set CSD: [G,H] = GetGH(M, 4); Run CSD: CSD(EEG.data(:,:), G, H, 1.0e-5, 10); reshape(EEG.CSDdata, size(EEG.data));