# How to average epochs excluding a list of channels?

**URL:** <https://mne.discourse.group/t/how-to-average-epochs-excluding-a-list-of-channels/2301>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [August 28, 2020, 6:15am UTC](https://mne.discourse.group/t/how-to-average-epochs-excluding-a-list-of-channels/2301 "2020-08-28T06:15:17Z")\
**Posts on this page:** 2\
**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:** [August 28, 2020, 6:15am UTC](https://mne.discourse.group/t/how-to-average-epochs-excluding-a-list-of-channels/2301/1 "2020-08-28T06:15:17Z")

</div>

External Email - Use Caution

Hi Group,

I would like to calculate the epochs average. There a list of channels that  
I would like exclude when calculating the average.

Despite assigning these channel as 'bads', it seem they were averaged  
together when run the line epochs.average().

May I know if there is any setting that I am not aware of.

Also, is it possible to avoid assigning these channel as 'bads' when  
calculating the epochs.average, as I would like to use them for other  
processing down the line later.

The code is as below

Thanks for any hint.

Regards

Rodney

Code:

raw = mne.io.read\_raw\_fif(fname\_raw, preload=True)  
outer\_ch = ['E43', 'E48','E49', 'E56', 'E63', 'E68', 'E73', 'E81', 'E88',  
'E94', 'E99',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'E107', 'E113', 'E119', 'E120','E125', 'E126', 'E127',  
'E128']  
raw.info['bads'] =outer\_ch # is there any approach rather than assign these  
channel as bad?  
event\_id = 1  
duration = 30  
events = mne.make\_fixed\_length\_events(raw, event\_id, duration=duration)  
epochs = mne.Epochs(raw, events=events, event\_id=event\_id, baseline=None,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;verbose=False, tmin=0, tmax=duration, preload=True)

evoked = epochs.average() # How to calculate average excluding the outer\_ch

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200828/2acc15ac/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200828/2acc15ac/attachment.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:** [August 28, 2020, 7:29am UTC](https://mne.discourse.group/t/how-to-average-epochs-excluding-a-list-of-channels/2301/2 "2020-08-28T07:29:44Z")

</div>

External Email - Use Caution

hi,

you can pass picks to Epochs eg obtained with pick\_types that does  
exclude='bads'  
by default.

you can also use the .pick methods of raw, epochs or evoked to drop channels  
at any step of your pipeline.

HTH  
Alex
