autoreject

This is a library to automatically reject bad trials and repair bad sensors in magneto-/electroencephalography (M/EEG) data.

Installation

We recommend the Anaconda Python distribution. To install autoreject, you first need to install its dependencies:

$ pip install numpy matplotlib scipy mne scikit-learn

An optional dependency is tqdm if you want to use the verbosity flags ‘tqdm’ or ‘tqdm_notebook’ for nice progressbars.

Then install autoreject:

$ pip install git+https://github.com/autoreject/autoreject.git#egg=autoreject

If you do not have admin privileges on the computer, use the --user flag with pip. To upgrade, use the --upgrade flag provided by pip.

To check if everything worked fine, you can do:

$ python -c 'import autoreject'

and it should not give any error messages.

Quickstart

The easiest way to get started is to copy the following three lines of code in your script:

>>> from autoreject import LocalAutoRejectCV
>>> ar = LocalAutoRejectCV()
>>> epochs_clean = ar.fit_transform(epochs)  

This will automatically clean an epochs object read in using MNE-Python. To get the rejection dictionary, simply do:

>>> from autoreject import get_rejection_threshold
>>> reject = get_rejection_threshold(epochs)

We also implement RANSAC from the PREP pipeline. The API is the same:

>>> from autoreject import Ransac
>>> rsc = Ransac()
>>> epochs_clean = rsc.fit_transform(epochs)  

For more details check out the example to automatically detect and repair bad epochs.

Bug reports

Use the github issue tracker to report bugs.

Cite

[1] Mainak Jas, Denis Engemann, Federico Raimondo, Yousra Bekhti, and Alexandre Gramfort, “Automated rejection and repair of bad trials in MEG/EEG.” In 6th International Workshop on Pattern Recognition in Neuroimaging (PRNI), 2016.

[2] Mainak Jas, Denis Engemann, Yousra Bekhti, Federico Raimondo, and Alexandre Gramfort. 2017. “Autoreject: Automated artifact rejection for MEG and EEG data”. NeuroImage, 159, 417-429.

Fork me on GitHub