# autoreject

**URL:** <https://mne.discourse.group/t/autoreject/1567>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [July 10, 2018, 9:47am UTC](https://mne.discourse.group/t/autoreject/1567 "2018-07-10T09:47:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [July 10, 2018, 9:47am UTC](https://mne.discourse.group/t/autoreject/1567/1 "2018-07-10T09:47:53Z")

</div>

External Email - Use Caution

Hi,

i am trying to explore a little the "autoreject" tools. specifically i am trying to apply following example:  
[https://autoreject.github.io/auto\_examples/plot\_auto\_repair.html#sphx-glr-auto-examples-plot-auto-repair-py](https://autoreject.github.io/auto_examples/plot_auto_repair.html#sphx-glr-auto-examples-plot-auto-repair-py)

to a dataset recorded in salzburg.

i adapted the code to chop out 2s epochs from the fif file. the rest should be the same as in the tutorial example (which works great btw). code below.

however i am getting an error message that is over the top of my head.

> > > (executing lines 34 to 36 of "\<tmp 1\>")

Running autoreject on ch\_type=grad  
Traceback (most recent call last):  
File "\<tmp 1\>", line 36, in \<module\>  
ar.fit(epochs)  
File "/Users/b1019548/anaconda3/lib/python3.6/site-packages/autoreject/autoreject.py", line 878, in fit  
self.consensus, self.verbose)  
File "/Users/b1019548/anaconda3/lib/python3.6/site-packages/autoreject/autoreject.py", line 683, in \_run\_local\_reject\_cv  
local\_reject.fit(epochs)  
File "/Users/b1019548/anaconda3/lib/python3.6/site-packages/autoreject/autoreject.py", line 600, in fit  
epochs.copy(), picks=self.picks\_, verbose=self.verbose)  
File "/Users/b1019548/anaconda3/lib/python3.6/site-packages/autoreject/autoreject.py", line 367, in compute\_thresholds  
verbose=verbose)  
File "/Users/b1019548/anaconda3/lib/python3.6/site-packages/autoreject/utils.py", line 231, in clean\_by\_interp  
interpolate\_bads(inst\_clean, picks=picks, reset\_bads=True, mode='fast')  
File "/Users/b1019548/anaconda3/lib/python3.6/site-packages/autoreject/utils.py", line 279, in interpolate\_bads  
\_interpolate\_bads\_meg\_fast(inst, picks=meg\_picks\_interp, mode=mode)  
File "/Users/b1019548/anaconda3/lib/python3.6/site-packages/autoreject/utils.py", line 392, in \_interpolate\_bads\_meg\_fast  
assert ch\_names\_a == ch\_names\_b  
AssertionError

this is likely due to my ignorance in the proper use of autoreject. but the error message makes it difficult for me to infer what the problem might be. i would appreciate any pointers.

best,  
nathan

> import numpy as np
> 
> n\_interpolates = np.array([1, 4, 32])  
> consensus\_percs = np.linspace(0, 1.0, 11)
> 
> ##
> 
> import mne # noqa  
> from mne.utils import check\_random\_state # noqa
> 
> from autoreject import (AutoReject, set\_matplotlib\_defaults) # noqa
> 
> check\_random\_state(42)
> 
> data\_path = '/Users/b1019548/Desktop/Data\_Sternberg/'  
> raw\_fname = data\_path + 'jens\_H.fif'  
> raw = mne.io.read\_raw\_fif(raw\_fname, preload=True)
> 
> events = mne.make\_fixed\_length\_events(raw, id=1, duration=2)
> 
> raw.info['bads'] =   
> picks = mne.pick\_types(raw.info, meg='grad', eeg=False, stim=False, eog=False, include=, exclude=)
> 
> raw.info['projs'] = list()
> 
> epochs = mne.Epochs(raw, events, tmin=0, tmax=2,  
> baseline=(None, 0), reject=None,  
> verbose=False, detrend=0, preload=True)
> 
> ##  
> ar = AutoReject(n\_interpolates, consensus\_percs, picks=picks,  
> thresh\_method='random\_search', random\_state=42)  
> ar.fit(epochs)  
> epochs\_clean = ar.transform(epochs)

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20180710/8163ca16/attachment-0001.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180710/8163ca16/attachment-0001.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [July 10, 2018, 1:45pm UTC](https://mne.discourse.group/t/autoreject/1567/2 "2018-07-10T13:45:48Z")

</div>

External Email - Use Caution

Hi Nathan,

It appears you do not have the latest version of autoreject. Could you try  
upgrading to the latest version from pip  
and trying again? Also what do you have in epochs.info['bads'] before you  
apply autoreject?

Mainak

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [July 10, 2018, 2:07pm UTC](https://mne.discourse.group/t/autoreject/1567/3 "2018-07-10T14:07:19Z")

</div>

External Email - Use Caution

Hi Mainak,

thanks for the reply.

i am indeed not experienced in python. i mindlessly copy-pasted instructions from here:  
[http://autoreject.github.io/&gt](http://autoreject.github.io/&gt);

> > > pip install -U autoreject

Requirement already up-to-date: autoreject in ./anaconda3/lib/python3.6/site-packages (0.1)

is this the most recent version?

regarding your other question:

> > > epochs.info['bads']

best,  
nathan

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [July 10, 2018, 2:27pm UTC](https://mne.discourse.group/t/autoreject/1567/4 "2018-07-10T14:27:44Z")

</div>

External Email - Use Caution

Hi Nathan,

The code and the version look good. I am wondering if there may be any  
Salzburg peculiarities with the fif file. Could you share some of the data  
with us? (also privately).

Best,  
Denis
