[Mne_analysis] Plot Epochs with Bad Epochs Selected in Red

Mainak Jas mainakjas at gmail.com
Mon Mar 4 22:12:04 EST 2019
Search archives:

        External Email - Use Caution        

Hi Alex,

I don’t think it’s possible in MNE. The reason is that the data that has
been dropped is not there any more.

However, there is a workaround that you could try using autoreject. Here’s
a code snippet to get you started:

import numpy as npfrom autoreject import RejectLog
epochs_orig = epochs.copy()
# now interactively mark the bad epochs
epochs.plot()

bad_idxs = [idx for idx, drop in enumerate(epochs.drop_log) if
            drop == ['USER']]

n_channels = epochs_orig.info['nchan']
n_epochs = len(epochs_orig)

bad_epochs = np.zeros((n_epochs,))
labels = np.zeros((n_epochs, n_channels))

bad_epochs[bad_idxs] = 1

reject = RejectLog(bad_epochs=bad_epochs, labels=labels,
                   ch_names=epochs.info['ch_names'])
reject.plot_epochs(epochs_orig)

Best,
Mainak

On Mon, Mar 4, 2019 at 1:47 PM Rockhill, Alexander P.
AROCKHILL at mgh.harvard.edu <http://mailto:AROCKHILL@mgh.harvard.edu> wrote:

Hi all,
>
>    I couldn't find a way to plot epochs with the epochs in the drop log
> plotted in red instead of not plotted at all. If anyone had any advice in
> regards to how to do that I would appreciate it.
>
> Thanks,
>
> Alex
>
> Translational NeuroEngineering Laboratory
> Division of Neurotherapeutics, Department of Psychiatry
> Massachusetts General Hospital, Martinos Center
> 149 13th St Charlestown #2301, Boston, MA 02129
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190304/d0f77f32/attachment-0001.html 


More information about the Mne_analysis mailing list