# average reference projection for noise covariance matrix

**URL:** <https://mne.discourse.group/t/average-reference-projection-for-noise-covariance-matrix/5789>\
**Category:** Support & Discussions\
**Tags:** eeg\
**Created:** [October 22, 2022, 3:02pm UTC](https://mne.discourse.group/t/average-reference-projection-for-noise-covariance-matrix/5789 "2022-10-22T15:02:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rethinking\_eeg](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@rethinking\_eeg](https://mne.discourse.group/u/rethinking_eeg)\
**Post date:** [October 22, 2022, 3:02pm UTC](https://mne.discourse.group/t/average-reference-projection-for-noise-covariance-matrix/5789/1 "2022-10-22T15:02:21Z")

</div>

Hi  
thanks for the great library and its through documentation

currently i am working on a dataset that is referenced on average mastoid electrodes; but hadn’t include them in the dataset. so i don’t think it is a good idea to try average referencing other electrodes without knowing the initial reference electrodes values. is my assumption correct?

so when i wanted to apply “mne.minimum\_norm.apply\_inverse\_epochs” i get the warning that “RuntimeWarning: No average EEG reference present in info[“projs”], covariance may be adversely affected. Consider recomputing covariance using with an average eeg reference projector added.”

so i was wondering what should be the approach here?

thanks so much for your attention in advance.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 22, 2022, 3:39pm UTC](https://mne.discourse.group/t/average-reference-projection-for-noise-covariance-matrix/5789/2 "2022-10-22T15:39:32Z")

</div>

> [@rethinking\_eeg](#):
>
> so i was wondering what should be the approach here?
> 
> thanks so much for your attention in advance.

Hello @rethinking_eeg,

I think you could just add back a reference channel (which would represent the averaged mastoids) by doing something like

```python
raw.add_reference_channels('Ref')

```

This will add a channel named `Ref` with all-zero data.

After that, you can apply an average reference projection.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![rethinking\_eeg](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@rethinking\_eeg](https://mne.discourse.group/u/rethinking_eeg)\
**Post date:** [October 23, 2022, 7:06am UTC](https://mne.discourse.group/t/average-reference-projection-for-noise-covariance-matrix/5789/3 "2022-10-23T07:06:20Z")

</div>

@richard thank you so much for your prompt response  
as i think about it, your solution sounds so brilliant.  
i want to make sure that i got it right, so you suggest that i add a channel as a reference which at first will be just zeros (cause it is reference) and then by changing the reference to average, kind of interpolate the initial values of the average mastoids, is that correct?

after doing so would the noise covariance matrix be adversely affected if i set the reference to REST?

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 23, 2022, 12:14pm UTC](https://mne.discourse.group/t/average-reference-projection-for-noise-covariance-matrix/5789/4 "2022-10-23T12:14:51Z")

</div>

Hello,

the underlying idea is that, if all signals are measured relative to a reference electrode, by definition the signal at that reference is “zero” across all time points. Now in many electrode cap layouts, one uses one of the electrodes on the scalp as a reference (e.g., Cz). But many recording software packages then don’t include this electrode in the data, because its values are all-zero anyway. To ensure one can work with the “full” set of channels, one can use the `add_reference_channel()` method. It usually only makes sense to apply this if one re-references afterwards, or else you’ll end up with a channel that’s zero across all times.

But let’s assume you add back the “averaged mastoids” reference channel with all zeros, then you can safely calculate the average reference.

The problem with the averaged mastoids is that you don’t have their individual signals. So even if you use `add_reference_channels()`, it’s unclear which **location** you’ll want to assign to that new channel because it’s essentially a virtual channel that didn’t exist physically / doesn’t correspond to any electrode placed on the participant’s head.

I think you could simply **not** add the reference channel and **still** apply the average reference. Since the average reference subtracts the average of all channels from each individual channel, and since a reference channel is always zero, the only problem you’ll have is that the signal amplitude gets slightly inflated because, for each time point, you subtract

\frac{1}{N-1} \sum\_{i=1}^{N}{x}\_i

instead of

\frac{1}{N} \sum\_{i=1}^{N}{x}\_i

(remember that the sum term yields the same results with and without reference, as the reference value is zero).

But if you only look at relative differences or calculate e.g. the GFP, I don’t see a problem here.

As for REST, I’m not familiar with that kind of reference, so I don’t dare to give any advice here.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![rethinking\_eeg](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@rethinking\_eeg](https://mne.discourse.group/u/rethinking_eeg)\
**Post date:** [October 23, 2022, 11:31pm UTC](https://mne.discourse.group/t/average-reference-projection-for-noise-covariance-matrix/5789/5 "2022-10-23T23:31:15Z")

</div>

thank you so much richard for your thorough and detailed explanation  
it is much appreciated.
