# EEG processing pipeline with autoreject

**URL:** https://mne.discourse.group/t/eeg-processing-pipeline-with-autoreject/3443
**Category:** Support & Discussions
**Tags:** eeg, ica, autoreject, preprocessing, epochs
**Created:** [July 22, 2021, 7:33am UTC](https://mne.discourse.group/t/eeg-processing-pipeline-with-autoreject/3443 "2021-07-22T07:33:35Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)
#### Post date: [July 22, 2021, 5:29pm UTC](https://mne.discourse.group/t/eeg-processing-pipeline-with-autoreject/3443/2 "2021-07-22T17:29:59Z")

</div>

Hello @eduardo,

> [@eduardo](#):
>
> ```python
> reject = get_rejection_threshold(epochs, random_state = 100)
> 
> ```

This will include `eog` in the returned `reject` dictionary – which might not be what you want, as it will lead to the removal of epochs with blinks. You may wish to consider passing `ch_types='eeg'` to only retrieve a rejection threshold for EEG.

> [@eduardo](#):
>
> ica = mne.preprocessing.ICA(random\_state = 100).fit(epochs, reject = reject)

Note that `reject` is simply ignored if you pass epochs to `ICA.fit()`. This is a little bit hidden in the documentation (and a reminder for me that we should add a clear warning):

 ![Screen Shot 2021-07-22 at 19.13.21](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/26819d56ed5b42df5726f8a999be834337f140f9.png)

If you want to fit ICA on epochs with a peak-to-peak rejection threshold applied, you must drop the bad epochs **before** ICA, either by calling `Epochs.drop_bad()` or by passing `reject` to `Epochs()` on instantiation.

> [@eduardo](#):
>
> 1. Is it good practice to use AutoReject after applying ICA?

Yes, this is a good idea. In fact, it appears that using autoreject “local” before and after ICA is in fact a good choice – we were seeing some issues with autoreject “global” before ICA in EEG layouts with some electrodes placed close to the eyes, like Fp1/Fp2. The respective tutorial has been updated very recently by @mainakjas:

> <https://github.com/autoreject/autoreject/blob/master/examples/plot_autoreject_workflow.py>

I think it has not yet been deployed to the autoreject documentation website, therefore I’m linking to the file on GitHub.

> [@eduardo](#):
>
> 1. Should I use a fixed threshold (like 100 uV) instead of applying AutoReject?

That’s what we do in the MNE-BIDS-Pipeline before ICA. However, the problem with fixed thresholds is that … they’re fixed (surprise!), and the same thresholds might now work across all participants in your study. On the other hand, autoreject “global” led to problems in some of our datasets (see my comments above), and running auroreject “local” twice (before and after ICA) can be quite time-consuming. It’s a tradeoff, really.

> [@eduardo](#):
>
> 1. After all the processing, should I normalize my epochs prior to feature extraction?

Yes, depending on your data and specific analysis, you may want to use MNE-Python’s `Scaler` or scikit-learn’s `StandardScaler`, see [Decoding (MVPA) — MNE 1.7.0.dev15+gb107d92ec documentation](https://mne.tools/dev/auto_tutorials/machine-learning/50_decoding.html) for examples how to use them.

---

_[View the full topic](https://mne.discourse.group/t/eeg-processing-pipeline-with-autoreject/3443)._
