# Noise covariance for source localisation (using "resting" epochs conditions as noise)

**URL:** <https://mne.discourse.group/t/noise-covariance-for-source-localisation-using-resting-epochs-conditions-as-noise/3544>\
**Category:** Support & Discussions\
**Tags:** ﻿source-localization, eeg, epochs\
**Created:** [August 13, 2021, 4:36pm UTC](https://mne.discourse.group/t/noise-covariance-for-source-localisation-using-resting-epochs-conditions-as-noise/3544 "2021-08-13T16:36:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![romybeaute](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/romybeaute/32/770_2.png) [@romybeaute](https://mne.discourse.group/u/romybeaute)\
**Post date:** [August 13, 2021, 4:36pm UTC](https://mne.discourse.group/t/noise-covariance-for-source-localisation-using-resting-epochs-conditions-as-noise/3544/1 "2021-08-13T16:36:04Z")

</div>

**If you have a question or issue with MNE-Python, please include the following info:**

- MNE-Python version: 0.23.0
- operating system: MAC M1

Dear all,

I am doing source localisation from EEG, and was having a methodological doubt about the correctness of the way I calculated the noise covariance matrix (from epochs).

My dataset is composed of reconstructed epochs from the segmentation of 10sec of EEG signal that follows verbal instructions of motor commands (5\*2sec epochs, the 1st epoch corresponding of the “offset” of the -verbal- stim). My epochs are therefore 2sec cropped and correspond to either “move” or “stop moving” (rest) instructions.

Considering this setup, 2 questions came up to my mind concerning the calculation of noise covariance :

1. given that I am trying to look for particular activations following « keep moving » instructions, is it correct (and recommended) to use “rest” epochs as noise, and therefore to calculate the noise covariance from these rest epochs? One precision, I calculate the inverse
2. Is it a problem if my epochs are cropped ? Should I instead construct new epochs (1_10sec instead of 5_2sec) so that I can use the baseline ? If there is another solution, I would prefer not to as I’ll use the 2sec cropped epochs for the source localisation.

For the moment I could obtain a source localisation, but using :

`noise_cov = mne.compute_covariance(epochs['stop'], method='auto')`

as my noise covariance, so that the « stop moving » (rest) epochs are considered as noise.

Following these questions about covariance, I calculated the forward and inverse solution for the whole set of epochs (move AND rest) to construct a global model of the task, but applied it to “move” epochs only. In this case, should I calculate everything based on ‘move’ epochs only?

Sorry for this long message, but I am not that confident about the correctness of doing it this way (methodologically as well as theorically), and wanted to make sure that I am not introducing any error.

Would you have any recommandations about this ?

Thanks a lot for your consideration, any comment would be of a huge help !

Kind regards,

Romy

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [August 15, 2021, 8:02am UTC](https://mne.discourse.group/t/noise-covariance-for-source-localisation-using-resting-epochs-conditions-as-noise/3544/2 "2021-08-15T08:02:17Z")

</div>

I did not get all the details but you should use as noise data for covariance estimation some segments  
of brain signals which do not contain any activity of interest.

HTH  
Alex

---

<div class="post-metadata">

**Author:** ![romybeaute](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/romybeaute/32/770_2.png) [@romybeaute](https://mne.discourse.group/u/romybeaute)\
**Post date:** [August 18, 2021, 12:14pm UTC](https://mne.discourse.group/t/noise-covariance-for-source-localisation-using-resting-epochs-conditions-as-noise/3544/3 "2021-08-18T12:14:21Z")

</div>

Thank you so much for your reply, I guess it confirmed what I did (to use resting epochs as noise segments).

Best regards,

Romy

---

<div class="post-metadata">

**Author:** ![romybeaute](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/romybeaute/32/770_2.png) [@romybeaute](https://mne.discourse.group/u/romybeaute)\
**Post date:** [August 18, 2021, 1:27pm UTC](https://mne.discourse.group/t/noise-covariance-for-source-localisation-using-resting-epochs-conditions-as-noise/3544/4 "2021-08-18T13:27:03Z")

</div>

One other question though, is it advised to compute the forward and inverse solution on evoked or on the epochs objects ?

---

<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:** [August 18, 2021, 3:24pm UTC](https://mne.discourse.group/t/noise-covariance-for-source-localisation-using-resting-epochs-conditions-as-noise/3544/5 "2021-08-18T15:24:47Z")

</div>

`make_forward_solution()` and `make_inverse_operator()` expect an `Info` object as the first parameter. The relevant information should be the same in both `Epochs.info` and `Evoked.info`. `apply_inverse()` accepts an `Evoked` object only.

---

<div class="post-metadata">

**Author:** ![romybeaute](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/romybeaute/32/770_2.png) [@romybeaute](https://mne.discourse.group/u/romybeaute)\
**Post date:** [August 18, 2021, 3:59pm UTC](https://mne.discourse.group/t/noise-covariance-for-source-localisation-using-resting-epochs-conditions-as-noise/3544/6 "2021-08-18T15:59:00Z")

</div>

Ok, thank you it is very much clear
