Diff for "AnalyzingData/MNE_MRI_processing" - Meg Wiki
location: Diff for "AnalyzingData/MNE_MRI_processing"
Differences between revisions 9 and 11 (spanning 2 versions)
Revision 9 as of 2010-06-09 14:54:23
Size: 3425
Editor: YaaraErez
Comment:
Revision 11 as of 2010-06-09 15:25:28
Size: 1488
Editor: YaaraErez
Comment:
Deletions are marked like this. Additions are marked like this.
Line 39: Line 39:

= Forward Solution =

{{{
#!/bin/sh
#

## 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
subj_pre=(\
 'meg10_0001' \
 'meg10_0002' \
 'meg10_0003' \
 )

# MEG subdirectories
subj_dir=(\
  '100001' \
  '100002' \
  '100003' \
 )
 
dirbem='subject'


## Processing:

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


# REPORT number of files to be processed:

for m in `seq 0 ${lastsubj}`
do
  echo " "
  echo " Computing forward & inverse solution for SUBJECT ${subjects[m]}"
  echo " "
  
  subject=Subject${subjects[m]}


## setup model 3 layers (EEG+MEG)
mne_setup_forward_model --overwrite --subject ${subject} --surf --ico 4
 
mne_do_forward_solution \
                        --overwrite \
                        --subject ${subject} \
                        --mindist 5 \
                        --spacing 5 \
                        --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



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

mne_do_forward_solution \
                        --overwrite \
                        --subject ${subject} \
                        --mindist 5 \
                        --spacing 5 \
                        --megonly \
                        --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



done # subject loop
}}}
You should now realign the MRI and MEG coordinate systems, otherwise the following analyses (forward solution, inverse operator etc.) won't make sense. The procedure is described in the MNE manual, e.g. chapter 12.11. (sample data set).

Head Model and Source Space Creation in MNE

Make sure you've typed

  • mne_setup_2.6.0

and

  • setenv SUBJECTS_DIR </myMRIdirectory/>

in your Linux command window.

Then run the following scripts.

SUBJECTS_DIR='</myMRIdirectory/>'


for SUBJECT in Subject1 Subject2Subject3  # use your subject names here
do 

        cd ${SUBJECTS_DIR}

        # creates surfaces necessary for BEM head models
        mne_watershed_bem --overwrite --subject $SUBJECT

        ln -s $SUBJECTS_DIR/$SUBJECT/bem/watershed/$SUBJECT'_inner_skull_surface' $SUBJECTS_DIR/$SUBJECT/bem/inner_skull.surf
        ln -s $SUBJECTS_DIR/$SUBJECT/bem/watershed/$SUBJECT'_outer_skull_surface' $SUBJECTS_DIR/$SUBJECT/bem/outer_skull.surf
        ln -s $SUBJECTS_DIR/$SUBJECT/bem/watershed/$SUBJECT'_outer_skin_surface'  $SUBJECTS_DIR/$SUBJECT/bem/outer_skin.surf
        ln -s $SUBJECTS_DIR/$SUBJECT/bem/watershed/$SUBJECT'_brain_surface'       $SUBJECTS_DIR/$SUBJECT/bem/brain_surface.surf

        # creates fiff-files for MNE describing MRI data
        mne_setup_mri --overwrite --subject $SUBJECT

        # create a source space from the cortical surface created in Freesurfer
        mne_setup_source_space --spacing 5 --overwrite --subject $SUBJECT

done

You should now realign the MRI and MEG coordinate systems, otherwise the following analyses (forward solution, inverse operator etc.) won't make sense. The procedure is described in the MNE manual, e.g. chapter 12.11. (sample data set).

CbuMeg: AnalyzingData/MNE_MRI_processing (last edited 2024-04-10 14:27:41 by OlafHauk)