Diff for "AnalyzingData/MNE_ForwardSolution" - Meg Wiki
location: Diff for "AnalyzingData/MNE_ForwardSolution"
Differences between revisions 11 and 27 (spanning 16 versions)
Revision 11 as of 2010-06-09 15:50:07
Size: 3069
Editor: YaaraErez
Comment:
Revision 27 as of 2012-04-16 16:56:44
Size: 4068
Editor: YaaraErez
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Forward Solution = = Forward Solution and BEM =
Line 3: Line 3:
The following script creates the forward model, from which the inverse operator will be computed. It is essential that you have created the [http://imaging.mrc-cbu.cam.ac.uk/meg/AnalyzingData/MNE_MRI_processing source space and BEM model, and realigned your MRI and MEG coordinate systems]. The following script creates the forward model and BEM, from which the inverse operator will be computed. It is essential that you have created the [wiki:CbuMeg:AnalyzingData/MNE_MRI_processing source space and head surfaces, and realigned your MRI and MEG coordinate systems].
Line 10: Line 10:
* the BEM model (surfaces describing boundaries of different electrical conductivity) * the head surfaces (describing boundaries of different electrical conductivity)
Line 14: Line 14:
The end product will be the forward solution file (something ending in *fwd.fif) The end product will be the forward solution file (something ending in *fwd.fif), which can be read into Matlab using mne_read_forward_solution. The BEM surfaces can be read using mne_read_bem_surfaces.

If using EEG, you may need to apply mne_check_eeg_locations to your measurement file YourMEGfile.fif.

It is possible that the creation of a 3-shell BEM model fails because the inner and out skull surfaces are intersecting. In that case, you may use a script to [http://imaging.mrc-cbu.cam.ac.uk/meg/AnalyzingData/MNE_ForwardSolution_ShrinkSkull modify the skull surfaces] (CBU only).

It's a good idea to '''[wiki:CbuMeg:AnalyzingData/MNE_CheckBEM check your BEM surfaces]'''.

The parameters below are reasonable choices for standard analyses. However, these Wiki pages are not supposed to substitute the [http://www.nmr.mgh.harvard.edu/meg/manuals/MNE-manual-2.6.pdf MNE manual], [http://imaging.mrc-cbu.cam.ac.uk/meg/MEGpapers reading papers], and [wiki:CbuImaging:ImagersInterestGroup discussions] with more experienced researchers.
Line 23: Line 31:
path='<myMEGdatapath>' # where your MEG fiff-files are datapath='<myMEGdatapath>' # root directory for your MEG data
Line 29: Line 38:
 'Subject1' \
 'Subject1' \
 'Subject2' \
 'Subject3' \
Line 60: Line 69:
  mne_setup_forward_model --overwrite --subject ${subjects[m}} --surf --ico 4   mne_setup_forward_model --overwrite --subject ${subjects[m]} --surf --ico 4
Line 64: Line 73:
                        --subject ${subjects[m}} \                         --subject ${subjects[m]} \
Line 67: Line 76:
                        --bem ${MRIpath}/${subjects[m}}/bem/${subject}-5120-5120-5120-bem-sol.fif \
                        --src ${MRIpath}/${subjects[m}}/bem/${subject}-5-src.fif \
                        --meas ${path}/${subj_pre[m]}/${subj_dir[m]}/YourMEGfile.fif \
                        --fwd ${path}/${subj_pre[m]}/${subj_dir[m]}/YourName_5-3L-EMEG-fwd.fif
                        --bem ${MRIpath}/${subjects[m]}/bem/${subjects[m]}-5120-5120-5120-bem-sol.fif \
                        --src ${MRIpath}/${subjects[m]}/bem/${subjects[m]}-5-src.fif \
                        --meas ${datapath}/${subj_pre[m]}/${subj_dir[m]}/YourMEGfile.fif \
                        --fwd ${datapath}/${subj_pre[m]}/${subj_dir[m]}/YourName_5-3L-EMEG-fwd.fif
Line 75: Line 84:
  mne_setup_forward_model --overwrite --subject ${subjects[m}} --surf --homog --ico 4   mne_setup_forward_model --overwrite --subject ${subjects[m]} --surf --homog --ico 4
Line 79: Line 88:
                        --subject ${subjects[m}} \                         --subject ${subjects[m]} \
Line 83: Line 92:
                        --bem ${MRIpath}/${subjects[m}}/bem/${subject}-5120-bem-sol.fif \
                        --src ${MRIpath}/${subjects[m}}/bem/${subject}-5-src.fif \
                        --meas ${path}/${subj_pre[m]}/${subj_dir[m]}/YourMEGfile.fif \
                        --fwd ${path}/${subj_pre[m]}/${subj_dir[m]}/YourName_5-1L-MEG-fwd.fif
                        --bem ${MRIpath}/${subjects[m]}/bem/${subjects[m]}-5120-bem-sol.fif \
                        --src ${MRIpath}/${subjects[m]}/bem/${subjects[m]}-5-src.fif \
                        --meas ${datapath}/${subj_pre[m]}/${subj_dir[m]}/YourMEGfile.fif \
                        --fwd ${datapath}/${subj_pre[m]}/${subj_dir[m]}/YourName_5-1L-MEG-fwd.fif

Forward Solution and BEM

The following script creates the forward model and BEM, from which the inverse operator will be computed. It is essential that you have created the [wiki:AnalyzingData/MNE_MRI_processing source space and head surfaces, and realigned your MRI and MEG coordinate systems].

The script creates two forward solutions: One for MEG only (using only the inner skull surface), and one for combined EEG and MEG analysis (using inner skull, out skull and skin surfaces). If you only have MEG data, you can skip the latter. The main ingredients for this step are

* the source space (cortical surface)

* the head surfaces (describing boundaries of different electrical conductivity)

* the MEG data (at this stage only sensor/electrode positions and MRI-MEG realignment)

The end product will be the forward solution file (something ending in *fwd.fif), which can be read into Matlab using mne_read_forward_solution. The BEM surfaces can be read using mne_read_bem_surfaces.

If using EEG, you may need to apply mne_check_eeg_locations to your measurement file YourMEGfile.fif.

It is possible that the creation of a 3-shell BEM model fails because the inner and out skull surfaces are intersecting. In that case, you may use a script to [http://imaging.mrc-cbu.cam.ac.uk/meg/AnalyzingData/MNE_ForwardSolution_ShrinkSkull modify the skull surfaces] (CBU only).

It's a good idea to [wiki:AnalyzingData/MNE_CheckBEM check your BEM surfaces].

The parameters below are reasonable choices for standard analyses. However, these Wiki pages are not supposed to substitute the [http://www.nmr.mgh.harvard.edu/meg/manuals/MNE-manual-2.6.pdf MNE manual], [http://imaging.mrc-cbu.cam.ac.uk/meg/MEGpapers reading papers], and [wiki:ImagersInterestGroup discussions] with more experienced researchers.

#

## Your variables:

datapath='<myMEGdatapath>'    # root directory for your MEG data

MRIpath='/myMRIdirectory/'    # where your MRI subdirectories are

# subjects names used for MRI data
subjects=(\
        'Subject1' \
        'Subject2' \
        'Subject3' \
)

# MEG IDs (your directory structure may differ)
subj_pre=(\
        'meg10_0001' \
        'meg10_0002' \
        'meg10_0003' \
        )

# MEG subdirectories (your directory structure may differ)      
subj_dir=(\
         '100001' \
         '100002' \
         '100003' \
        )
        

## Processing:

nsubjects=${#subjects[*]}
lastsubj=`expr $nsubjects - 1`

for m in `seq 0 ${lastsubj}`
do
  echo " "
  echo " Computing forward solution for SUBJECT  ${subjects[m]}"
  echo " "
  
  ## setup model 3 layers (EEG+MEG)
  mne_setup_forward_model --overwrite  --subject ${subjects[m]} --surf --ico 4
 
  mne_do_forward_solution \
                        --overwrite \
                        --subject ${subjects[m]} \
                        --mindist 5 \
                        --spacing 5 \
                        --bem ${MRIpath}/${subjects[m]}/bem/${subjects[m]}-5120-5120-5120-bem-sol.fif \
                        --src ${MRIpath}/${subjects[m]}/bem/${subjects[m]}-5-src.fif \
                        --meas ${datapath}/${subj_pre[m]}/${subj_dir[m]}/YourMEGfile.fif  \
                        --fwd ${datapath}/${subj_pre[m]}/${subj_dir[m]}/YourName_5-3L-EMEG-fwd.fif



  ## setup model 1 layer (MEG only)
  mne_setup_forward_model --overwrite  --subject ${subjects[m]} --surf --homog --ico 4

  mne_do_forward_solution \
                        --overwrite \
                        --subject ${subjects[m]} \
                        --mindist 5 \
                        --spacing 5 \
                        --megonly \
                        --bem ${MRIpath}/${subjects[m]}/bem/${subjects[m]}-5120-bem-sol.fif \
                        --src ${MRIpath}/${subjects[m]}/bem/${subjects[m]}-5-src.fif \
                        --meas ${datapath}/${subj_pre[m]}/${subj_dir[m]}/YourMEGfile.fif \
                        --fwd ${datapath}/${subj_pre[m]}/${subj_dir[m]}/YourName_5-1L-MEG-fwd.fif

done # subjects

CbuMeg: AnalyzingData/MNE_ForwardSolution (last edited 2013-03-08 10:02:43 by localhost)