how to drop epochs per channel?

Hi,
I have a recording with multiple channels where a timespan is annotated as “bad” for only one channel. When I generate epochs from this annotated recording with reject_by_annotation=True the whole epoch over all channels gets dropped. Since the data in the channels that are not marked as bad is valuable to us, I would like to drop the epoch only for that one specific channel. How can I achieve that?

Hello, you could try using autoreject, which would interpolate bad channels so no epochs would get lost. See this example:

https://autoreject.github.io/stable/auto_examples/plot_auto_repair.html

Best wishes
Richard

1 Like

Thank you for the reply. In essence, we just want to gain access to the information of how many epochs were affected by / overlap with the annotation “bad” in each channel! If I use interpolate_bads can I somehow see how many epochs per channel were affected by interpolation?

I hope you can follow me :sweat_smile:

Hey @librethinker!

I do not think mne currently supports annotations that affect only one channel. I could be wrong though. So I think if you used reject_by_annotation it would apply to all the channels.

Hello,

This issue might be relevant to the discussion channel-specific epoch removal. Unfortunately, I can’t work on it yet, but I hope I can spare some hours next week.

Do you think such a feature might help you @librethinker ?

Best,

Carina

3 Likes

Hi @CarinaFo,
this feature would be really helpful to us! Would it also be possible to see which epochs in which channels got dropped/replaced by NaN, for example in drop_log?

Greetings from Dresden,
Richard

1 Like

Hello Richard,
yes, the idea would be to include the information about which epoch in which channel got dropped in drop_log.

Best from Berlin,

Carina

2 Likes

Hi @CarinaFo
I saw on Github that you have already been working on this feature for the last couple of days. Thank you very much! I have a rather specific question to plan our workflow for once the feature will be available: will it be possible to use reject_by_annotation to drop an epoch for the specific channel the annotation is located in?

Have a nice weekend!
Richard

Hi Richard,
so far I have implemented a method for epochs called set_bad_epochs_to_NaN(), that takes a list of indices per channel as input and simply sets the bad epochs to NaN. This way the user can decide how to define bad epochs and write her/his function. If you want to know the number of bad epochs per channel, you can then run sum(np.isnan) per channel. I am still thinking about where to store this information in the mne epochs object, probably something similar to nave but per channel. If you would like to check the code PR 12219.

All the best,

Carina