epochs.plot_drop_log() - get channels list

Hi everyone,

I’m using the epochs.drop_plot_log() function to see if some of my epochs were dropped because of bad channels (and indeed they are).

epochs = mne.Epochs(reref, events=allevents, event_id=eventsdict, tmin=tmin, tmax=tmax, on_missing='warn', reject=reject_criteria, preload=True, baseline=None, reject_by_annotation=True)
epochs.plot_drop_log().savefig(os.path.join(epochsdir, f"epochs drop log {subject}.png"))

Then i used to enter the bad channels manually like so:

badsCHs = input("enter bad channels...").split(sep=',')
    if len(badsCHs[0]) > 0:

Actually this is slow, and i know that i just say that bad channels are the ones that caused at least 5% of my epochs to be removed. So i want to do it automatically, but i can’t figure out where is this info stored. The plot_crop_log() function obviously makes use of exactly this, but i don’t understand where it is and how to access it :thinking: I looked at the .drop_log, but then i guess i should do the stats myself? But surely in order to plot them, this is already available somewhere, i don’t need to compute them again…?

Your help/ advice much appreciated :sloth:

I don’t know the exact answer, but I had a quick glance at the source code, and perhaps you continue the search from here: mne-python/mne/viz/epochs.py at 959d2b64dd1f53b36eefb0e025110d01b92006ee · mne-tools/mne-python · GitHub

For example, try something like:

# "epochs" are your epochs
ch_names = [ch for d in epochs.drop_log for ch in d]