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 and a Python version >=3.5 To install autoreject, you first need to install its dependencies:

$ conda install numpy matplotlib scipy scikit-learn
$ pip install -U mne

An optional dependency is tqdm if you want to use the verbosity flags ‘tqdm’ or ‘tqdm_notebook’ for nice progressbars. In case you want to be able to read and write autoreject objects using the HDF5 format, you may also want to install h5py.

Then install the latest release of autoreject use:

$ pip install -U autoreject

If you want to install the latest version of the code (nightly) use:

$ pip install https://api.github.com/repos/autoreject/autoreject/zipball/master

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 AutoReject
>>> ar = AutoReject()
>>> 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