Including bad channels in autoreject

Hi all,

I use autoreject to find optimal peak-to-peak rejection thresholds on my MEG data. Before running autoreject (local), I exclude bad channels that are notoriously bad. For some parts, autoreject seems to respect this exclusion (there is a warning, that these bad channels will be ignored, and in the progress bars, the reduced number of good channels are shown).
However, when I plot the channels x epoch rejection matrix (good, bad, interpolated), Two of the channels that I had marked as bad, are consistently shown in blue across all epochs, ie. they are interpolated (see figure below).

What is happening here? Is this just a problem with the illustration or are these channels used after all in the determination of the thresholds, which channels are interpolated, etc?

Thanks,
Eduard

Hello,

Could you share some code snippet to look at, and the output of the .info attribute on the objects passed to autoreject?

Mathieu

Hi Eduard,

I would suggest starting with one of the examples and the sample dataset. Do you observe this problem also there? If yes, we might have a bug or compatibility issue with newer MNE versions. Sharing a short code snippet as Mathieu suggested would also help in pinpointing the issue.

Mainak

Hi both of you,

Here the code snippet that produced the plot from my starting post:

# set parameters for autoreject
n_interpolates = np.array((1, 2, 3, 5, 7, 9))
consensus_percs = np.linspace(0.2, 0.7, 11)

# init autoreject object, picks are grads or mags respectively
rej = AutoReject(n_interpolates, consensus_percs, picks=picks,
                    thresh_method='bayesian_optimization')

# run the autoreject (local) algorithm
rej.fit(epochs)

# extract the log file
rej_log = rej.get_reject_log(epochs)

# plot
xlabels = reject_log.ch_names
image = reject_log.labels
image[image == 2] = 0.5  # move interp to 0.5
legend_label = {0: 'good', 0.5: 'interpolated', 1: 'bad'}
cmap = colors.ListedColormap(['white', 'blue', 'red'])
img = axes.imshow(image.T, cmap=cmap, vmin=0, vmax=1, interpolation='none')
plt.setp(axes, yticks=range(0, len(xlabels)), yticklabels=xlabels)
plt.setp(axes.get_yticklabels(), fontsize=2)
#add red box around rejected epochs
for idx in np.where(reject_log.bad_epochs)[0]:
    axes.add_patch(patches.Rectangle((idx - 0.5, -0.5), 1, len(xlabels),
                 linewidth=1, edgecolor='r', facecolor='none'))

The output of info I shall provide in about 2 weeks, as I am out of office for the next 2 weeks.

Eduard

Hi Eduard,

Can you see this: https://github.com/autoreject/autoreject/issues/309

looks like someone hit the same issue as you but didn’t get around to making a pull request. If you have bandwidth, any help would be welcome.

Mainak