problem in _check_reference // inverse module

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

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

HTH
Alex

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
     bads : list | 0 items
     buffer_size_sec : float64 | 1.0
     ch_names : list | SCLK01-177, BG1-4408, BG2-4408, BG3-4408, BP1-4408, ...
     chs : list | 300 items (MISC: 1, REF_MEG: 26, MAG: 270, EEG: 3)
     comps : list | 5 items
     ctf_head_t : Transform | 3 items
     custom_ref_applied : bool | False
     dev_ctf_t : Transform | 3 items
     dev_head_t : Transform | 3 items
     dig : list | 186 items
     events : list | 0 items
     file_id : dict | 4 items
     highpass : float | 0.0 Hz
     hpi_meas : list | 0 items
     hpi_results : list | 1 items
     lowpass : float | 400.0 Hz
     meas_date : ndarray | 2017-12-15 14:22:01 GMT
     meas_id : dict | 4 items
     nchan : int | 300
     proc_history : list | 0 items
     projs : list | 0 items
     sfreq : float | 800.0 Hz
     subject_info : dict | 1 items
     acq_pars : NoneType
     acq_stim : NoneType
     description : NoneType
     experimenter : NoneType
     gantry_angle : NoneType
     hpi_subsystem : NoneType
     kit_system_id : NoneType
     line_freq : NoneType
     proj_id : NoneType
     proj_name : NoneType
     xplotter_layout : NoneType

Best,
Annalisa

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

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

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> ha scritto:

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

ok!

Thanks!
Annalisa
Alexandre Gramfort <alexandre.gramfort at inria.fr> ha scritto: