computing forward solutions separately for MEG and EEG

Dear mne users,

at first and before all: Happy New Year to the list!

Then, back to work :wink: :

I recently tried to compute separate forward models for MEG, EEG and
combined EEG/MEG with the mne suite and mne_do_forward_solution

here is the bash code I used for the MEG-only computations:

arr1=($ListSubj)

Dir=/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/

for i in {0..19}; do
    echo ${arr1[i]}

export SUBJECTS_DIR=/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/mri/
export SUBJECT=\{arr1\[i\]\} export MEG\_DIR=/neurospin/meg/meg\_tmp/MTT\_MEG\_Baptiste/MEG/{arr1[i]}/mne_python

# for MEG
mne_setup_source_space --ico 5 -overwrite
mne_setup_forward_model --homog --surf --ico 4

mne_do_forward_solution --mindist 5 --spacing ico-5 --mricoord
Dir{arr1[i]}/raw_sss/run3_DG_trans_sss-trans.fif --meas
Dir{arr1[i]}/raw_sss/run3_DG_trans_sss.fif --bem ${arr1[i]}-5120.fif
--megonly --overwrite --fwd $MEG_DIR/run3_ico-5_megonly_-fwd.fif

done

and it worked fine.

For EEG only, I modified the code to use a 3 layer BEM (remove --homog
option in mne_setup_forward_model) and use the --eegonly option in
mne-do-forward solution.

arr1=($ListSubj)

Dir=/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/

for i in {0..1}; do
    echo ${arr1[i]}

export SUBJECTS_DIR=/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/mri/
export SUBJECT=\{arr1\[i\]\} export MEG\_DIR=/neurospin/meg/meg\_tmp/MTT\_MEG\_Baptiste/MEG/{arr1[i]}/mne_python

# for EEG

mne_setup_source_space --ico 5 -overwrite
mne_setup_forward_model --surf --ico 4

mne_do_forward_solution --mindist 5 --spacing ico-5 --mricoord
Dir{arr1[i]}/raw_sss/run3_DG_trans_sss-trans.fif --meas
Dir{arr1[i]}/raw_sss/run3_DG_trans_sss.fif --bem ${arr1[i]}-5120.fif
--eegonly --overwrite --fwd $MEG_DIR/run3_ico-5_eegonly_-fwd.fif

done

Then I got this error:

Read 306 MEG channels from

/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/cb130477/raw_sss/run3_DG_trans_sss.fif
Read 61 EEG channels from
/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/cb130477/raw_sss/run3_DG_trans_sss.fif
MEG not requested. MEG channels omitted.
Some EEG channels do not have locations assigned.
Forward computation failed (see above)

As I understood, if EEG channel number >60, it could raise an error and
prevent mne to retrieve channel location.
So I tried the dedicated fix: mne_check_eeg_locations

mne_check_eeg_locations --file

Dir{arr1[i]}/raw_sss/run3_DG_trans_sss-trans.fif --fix

and got:

mne_check_eeg_locations version 1.2 compiled at Jan 5 2015 04:22:49

input file :
/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/sd130343/raw_sss/run3_DG_trans_sss-trans.fif
digitizer data file :
/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/wl130316/raw_sss/run3_DG.fif

Checking...
Could not find the channel information.

I suspect that the EEG064 reference is the problem so I try to modify
directly the EEG status of this channel with mne_rename_channels and the
following alias: "EEG064:MISC666:502" in a text file, trying to transform
this problematic channel into a harmless MISC.

mne_rename_channels --fif

Dir{arr1[i]}/raw_sss/run3_DG_trans_sss-trans.fif --alias
/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/SCRIPTS/define_aliases.txt

and got:

mne_rename_channels version 1.5 compiled at Jan 5 2015 04:17:51

fif file :
/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/sd130343/raw_sss/run3_DG_trans_sss-trans.fif
alias file :
/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/SCRIPTS/define_aliases.txt
1 aliases read from
/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/SCRIPTS/define_aliases.txt
0 changes done

So it appears that it didn't change anything.
I checked that this EEG064 is in the fiff file and I confirmed it exists
from fiedtrip header content of the same file.

I'm a bit stuck at this step and would appreciate any feedback on my
unlucky attempts :).

Best regards,

Baptiste

hi Baptiste,

it seems you did the right things in the right order.

are you sure the channel is called "EEG064" in the fif file? no space?
"EEG 064"?

otherwise to debug this please share the file or fire up a python
shell and inspect info obtained with

info = mne.io.read_info('fname_raw.fif')

HTH
Alex