# computing forward solutions separately for MEG and	EEG

**URL:** <https://mne.discourse.group/t/computing-forward-solutions-separately-for-meg-and-eeg/895>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [January 7, 2015, 2:22pm UTC](https://mne.discourse.group/t/computing-forward-solutions-separately-for-meg-and-eeg/895 "2015-01-07T14:22:28Z")\
**Posts on this page:** 2\
**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:** [January 7, 2015, 2:22pm UTC](https://mne.discourse.group/t/computing-forward-solutions-separately-for-meg-and-eeg/895/1 "2015-01-07T14:22:28Z")

</div>

Dear mne users,

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

Then, back to work 😉 :

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  
> &nbsp;&nbsp;&nbsp;&nbsp;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  
> &nbsp;&nbsp;&nbsp;&nbsp;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

---

<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:** [January 7, 2015, 5:13pm UTC](https://mne.discourse.group/t/computing-forward-solutions-separately-for-meg-and-eeg/895/2 "2015-01-07T17:13:52Z")

</div>

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
