# problem in \_check\_reference // inverse module

**URL:** <https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [December 21, 2017, 9:30am UTC](https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386 "2017-12-21T09:30:16Z")\
**Posts on this page:** 7\
**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:** [December 21, 2017, 9:30am UTC](https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386/1 "2017-12-21T09:30:16Z")

</div>

Dear MNE users,

I want to perform source reconstruction on MEG data and  
I have this error

\*\*\* ValueError: EEG average reference is mandatory for inverse  
modeling, use set\_eeg\_reference method. \*\*\*

Looking at the code, I think the problem is in the \_check\_reference function  
of inverse.py module. This function calls \_needs\_eeg\_average\_ref\_proj that  
picks the eeg channels.

In my data eeg\_sel contains 'ECG', 'VEOG', 'HEOG', thus

(len(eeg\_sel) \> 0

This implies that I need to set a reference, but since the average  
reference throws an exception I got another error

\*\*\* ValueError: Custom EEG reference is not allowed for inverse modeling.\*\*\*

I think the problem is that these channels have not to be assumed as  
eeg channels.

Best,  
Annalisa

---

<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:** [December 21, 2017, 12:38pm UTC](https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386/2 "2017-12-21T12:38:53Z")

</div>

can you show me what

raw.info

prints for you? did you set channel types properly?

what you need is to set channel types properly and then use

raw.set\_eeg\_reference('average', projection=True)

see:

[https://martinos.org/mne/stable/auto\_examples/preprocessing/plot\_rereference\_eeg.html](https://martinos.org/mne/stable/auto_examples/preprocessing/plot_rereference_eeg.html)

HTH  
Alex

---

<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:** [December 21, 2017, 3:41pm UTC](https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386/3 "2017-12-21T15:41:58Z")

</div>

CIao Alex,

my question is...why do I have to set the reference if I have  
only MEG data?

It seems that the problem is that the ECG, and EOG channels are considered  
as EEG ones and thus is required an usefulness average reference.  
Indeed if I set

raw.set\_eeg\_reference('average')

I get this error

\*\*\* ValueError: Custom EEG reference is not allowed for inverse modeling.\*\*\*

Here the raw.info

\<Info | 23 non-empty fields  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bads : list | 0 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer\_size\_sec : float64 | 1.0  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ch\_names : list | SCLK01-177, BG1-4408, BG2-4408, BG3-4408, BP1-4408, ...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chs : list | 300 items (MISC: 1, REF\_MEG: 26, MAG: 270, EEG: 3)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comps : list | 5 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ctf\_head\_t : Transform | 3 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;custom\_ref\_applied : bool | False  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dev\_ctf\_t : Transform | 3 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dev\_head\_t : Transform | 3 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dig : list | 186 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;events : list | 0 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file\_id : dict | 4 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;highpass : float | 0.0 Hz  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hpi\_meas : list | 0 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hpi\_results : list | 1 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lowpass : float | 400.0 Hz  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;meas\_date : ndarray | 2017-12-15 14:22:01 GMT  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;meas\_id : dict | 4 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nchan : int | 300  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proc\_history : list | 0 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;projs : list | 0 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sfreq : float | 800.0 Hz  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subject\_info : dict | 1 items  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acq\_pars : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acq\_stim : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;description : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;experimenter : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gantry\_angle : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hpi\_subsystem : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kit\_system\_id : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line\_freq : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proj\_id : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proj\_name : NoneType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xplotter\_layout : NoneType

> 

Best,  
Annalisa

Alexandre Gramfort \<alexandre.gramfort at inria.fr\> ha scritto:

---

<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:** [December 21, 2017, 3:57pm UTC](https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386/4 "2017-12-21T15:57:41Z")

</div>

see it tells you that you have "EEG: 3" so 3 EEG channels.

change the type of these channels to EOG or MISC and it will work.

HTH  
Alex

---

<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:** [December 22, 2017, 9:05am UTC](https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386/5 "2017-12-22T09:05:31Z")

</div>

Ciao Alex,

thks. I thought about this solution but it doesn't seem to me  
the best one mainly if I have to run the pipeline for a group  
of sbjs.

In your opinion, is it not right to put some check on the  
\_check\_reference function?

Best,  
Annalisa

Alexandre Gramfort \<alexandre.gramfort at [inria.fr](http://inria.fr)\> ha scritto:

---

<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:** [December 22, 2017, 10:03am UTC](https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386/6 "2017-12-22T10:03:00Z")

</div>

hi,

you should really set properly the channel types of each of your file/subject  
just after reading.

I don't see any reason why you may want \*\*not\*\* to change the channel types.

with valid channel types many things (plots, artifact rejection etc.)  
work out of the box.

Alex

---

<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:** [December 22, 2017, 11:29am UTC](https://mne.discourse.group/t/problem-in-check-reference-inverse-module/1386/7 "2017-12-22T11:29:27Z")

</div>

ok!

Thanks!  
Annalisa  
Alexandre Gramfort \<alexandre.gramfort at [inria.fr](http://inria.fr)\> ha scritto:
