Diff for "AnalyzingData/MNE_ForwardSolution" - Meg Wiki
location: Diff for "AnalyzingData/MNE_ForwardSolution"
Differences between revisions 3 and 11 (spanning 8 versions)
Revision 3 as of 2010-06-09 15:22:59
Size: 2467
Editor: YaaraErez
Comment:
Revision 11 as of 2010-06-09 15:50:07
Size: 3069
Editor: YaaraErez
Comment:
Deletions are marked like this. Additions are marked like this.
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 coregistered your MRIs with the MEG data. 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].
Line 5: Line 5:
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 BEM model (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)
Line 23: Line 33:
# MEG IDs # MEG IDs (your directory structure may differ)
Line 30: Line 40:
# MEG subdirectories # MEG subdirectories (your directory structure may differ)
Line 37: Line 47:
dirbem='subject'
Line 45: Line 53:

# REPORT number of files to be processed:
Line 51: Line 56:
  echo " Computing forward & inverse solution for SUBJECT ${subjects[m]}"   echo " Computing forward solution for SUBJECT ${subjects[m]}"
Line 54: Line 59:
  subject=Subject${subjects[m]}


## setup model 3 layers (EEG+MEG)
mne_setup_forward_model --overwrite --subject ${subject} --surf --ico 4
  ## setup model 3 layers (EEG+MEG)
  mne_setup_forward_model --overwrite --subject ${subjects[m}} --surf --ico 4
Line 60: Line 62:
mne_do_forward_solution \   mne_do_forward_solution \
Line 62: Line 64:
                        --subject ${subject} \                         --subject ${subjects[m}} \
Line 65: Line 67:
                        --bem ${MRIpath}/${subject}/bem/${subject}-5120-5120-5120-bem-sol.fif \
                        --src ${MRIpath}/${subject}/bem/${subject}-5-src.fif \
                        --meas ${path}/${subj_pre[m]}/${subj_dir[m]}/MEGfile.fif \
                        --fwd ${path}/${subj_pre[m]}/${subj_dir[m]}/lex_go_5-3L-EMEG-fwd.fif
                        --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
Line 72: Line 74:
## setup model 1 layer (MEG only)
mne_setup_forward_model --overwrite --subject ${subject} --surf --homog --ico 4
  ## setup model 1 layer (MEG only)
  mne_setup_forward_model --overwrite --subject ${subjects[m}} --surf --homog --ico 4
Line 75: Line 77:
mne_do_forward_solution \   mne_do_forward_solution \
Line 77: Line 79:
                        --subject ${subject} \                         --subject ${subjects[m}} \
Line 81: Line 83:
                        --bem ${MRIpath}/${subject}/bem/${subject}-5120-bem-sol.fif \
                        --src ${MRIpath}/${subject}/bem/${subject}-5-src.fif \
                        --meas ${path}/${subj_pre[m]}/${subj_dir[m]}/MEGfile.fif \
                        --fwd ${path}/${subj_pre[m]}/${subj_dir[m]}/lex_go_5-1L-MEG-fwd.fif
                        --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
Line 86: Line 88:


done # subject loop
done # subjects

Forward Solution

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 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 BEM model (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)

#

## Your variables:

path='<myMEGdatapath>'    # where your MEG fiff-files are
MRIpath='/myMRIdirectory/'    # where your MRI subdirectories are

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

# 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/${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



  ## 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/${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

done # subjects

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