Diff for "AnalyzingData/MNE_CovarianceMatrix" - Meg Wiki
location: Diff for "AnalyzingData/MNE_CovarianceMatrix"
Differences between revisions 1 and 17 (spanning 16 versions)
Revision 1 as of 2010-06-09 16:27:20
Size: 2015
Editor: YaaraErez
Comment:
Revision 17 as of 2010-11-09 14:29:33
Size: 3342
Editor: YaaraErez
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Computing the Noise Covariance Matrix =

The noise covariance matrix is needed for the computation of the inverse operator.

Ingredients for this script are

* raw MEG data files (e.g. those used for averaging, after maxfilter)

* a description file ([#covdescription see below])

The end result is a fiff-file containing the noise covariance matrix, which can be read into Matlab using mne_read_noise_cov.

Note: For some applications, for example [http://imaging.mrc-cbu.cam.ac.uk/meg/AnalyzingData/MNE_singletrial single-trial analysis], you should use a covariance matrix computed on empty-room data. Pre-processing for these data should be as similar as possible to the raw data files used for analysis.

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 [http://imaging.mrc-cbu.cam.ac.uk/imaging/ImagersInterestGroup discussions] with more experienced researchers.

{{{
Line 7: Line 24:
path='<myrawMEGdatapath>' # where your raw MEG fiff-files are datapath='<myrawMEGdatapath>' # root directory for your MEG data
Line 37: Line 54:
    --raw ${path}/${subj_pre[m]}/${subj_dir[m]}/lex_${subjects[m]}A_raw_ssstf_raw.fif \
    --raw ${path}/${subj_pre[m]}/${subj_dir[m]}/lex_${subjects[m]}B_raw_ssstf_raw.fif \
  --raw ${path}/${subj_pre[m]}/${subj_dir[m]}/sem_${subjects[m]}A_raw_ssstf_raw.fif \
  --raw ${path}/${subj_pre[m]}/${subj_dir[m]}/sem_${subjects[m]}B_raw_ssstf_raw.fif \
  --raw ${path}/${subj_pre[m]}/${subj_dir[m]}/freq_${subjects[m]}A_raw_ssstf_raw.fif \
  --raw ${path}/${subj_pre[m]}/${subj_dir[m]}/freq_${subjects[m]}B_raw_ssstf_raw.fif \
  --eventsout ${path}/${subj_pre[m]}/${subj_dir[m]}/lex_${subjects[m]}A_raw_ssstf_raw.txt \
  --eventsout ${path}/${subj_pre[m]}/${subj_dir[m]}/lex_${subjects[m]}B_raw_ssstf_raw.txt \
  --eventsout ${path}/${subj_pre[m]}/${subj_dir[m]}/sem_${subjects[m]}A_raw_ssstf_raw.txt \
  --eventsout ${path}/${subj_pre[m]}/${subj_dir[m]}/sem_${subjects[m]}B_raw_ssstf_raw.txt \
  --eventsout ${path}/${subj_pre[m]}/${subj_dir[m]}/freq_${subjects[m]}A_raw_ssstf_raw.txt \
  --eventsout ${path}/${subj_pre[m]}/${subj_dir[m]}/freq_${subjects[m]}B_raw_ssstf_raw.txt \
    --raw ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw1.fif \
    --raw ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw2.fif \
  --raw ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw3.fif \
  --eventsout ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw1-eve.txt \
  --eventsout ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw2-eve.txt \
  --eventsout ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw3-eve.txt \
Line 50: Line 61:
    --cov GNG.cov \     --cov cov_desc1.cov \
                --cov cov_desc2.cov \
                --cov cov_desc3.cov \
Line 52: Line 65:
    --gcov ${path}/${subj_pre[m]}/${subj_dir[m]}/covmat-cov.fif     --gcov ${datapath}/${subj_pre[m]}/${subj_dir[m]}/covmat-cov.fif
Line 55: Line 68:
done # subject loop done # subjects
}}}
Line 57: Line 71:
echo " "
echo "DONE"
echo " "
[[Anchor(covdescription)]]
where the covariance description files cov_desc?.cov are of the form
Line 61: Line 74:
# END OF SCRIPT
######################
{{{
Line 64: Line 76:
#--events ${eventpath}/${subjects[m]}_block2_use.eve cov {
 gradReject 1e-12 # artefact rejection thresholds
 magReject 3e-12
 eegReject 120e-6
 eogReject 150e-6
        logfile YourLogFileName.txt # logfile that will contain some useful information

 def {
  event 1 # trigger code
  tmin -0.2 # interval used for covariance computation
  tmax 0
  basemin -0.2 # interval used for baseline correction
  basemax 0.0
 }

        def {
  event 2
  tmin -0.2
  tmax 0
  basemin -0.2
  basemax 0.0
 }


        def {
  event 3
  tmin -0.2
  tmax 0
  basemin -0.2
  basemax 0.0
 }
 
}
}}}

If the parameters are the same for all input files, you only have to specify one description file. For more details and options see the MNE manual.

Computing the Noise Covariance Matrix

The noise covariance matrix is needed for the computation of the inverse operator.

Ingredients for this script are

* raw MEG data files (e.g. those used for averaging, after maxfilter)

* a description file ([#covdescription see below])

The end result is a fiff-file containing the noise covariance matrix, which can be read into Matlab using mne_read_noise_cov.

Note: For some applications, for example [http://imaging.mrc-cbu.cam.ac.uk/meg/AnalyzingData/MNE_singletrial single-trial analysis], you should use a covariance matrix computed on empty-room data. Pre-processing for these data should be as similar as possible to the raw data files used for analysis.

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 [http://imaging.mrc-cbu.cam.ac.uk/imaging/ImagersInterestGroup discussions] with more experienced researchers.

#


## Your variables:

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

# 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 covariance matrix for SUBJECT  ${subjects[m]}"
  echo " "

  mne_process_raw  \
                --raw ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw1.fif \
                --raw ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw2.fif \
                --raw ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw3.fif \
                --eventsout ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw1-eve.txt \
                --eventsout ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw2-eve.txt \
                --eventsout ${datapath}/${subj_pre[m]}/${subj_dir[m]}/rawMEGfile_raw3-eve.txt \         
                --projoff \
                --cov cov_desc1.cov \
                --cov cov_desc2.cov \
                --cov cov_desc3.cov \
                --savecovtag -cov \
                --gcov ${datapath}/${subj_pre[m]}/${subj_dir[m]}/covmat-cov.fif


done # subjects

Anchor(covdescription) where the covariance description files cov_desc?.cov are of the form

cov {
        gradReject      1e-12               # artefact rejection thresholds
        magReject       3e-12
        eegReject       120e-6
        eogReject       150e-6
        logfile         YourLogFileName.txt  # logfile that will contain some useful information

        def {
                event   1        # trigger code
                tmin    -0.2     # interval used for covariance computation
                tmax    0
                basemin -0.2     # interval used for baseline correction
                basemax 0.0
        }

        def {
                event   2
                tmin    -0.2
                tmax    0
                basemin -0.2
                basemax 0.0
        }


        def {
                event   3
                tmin    -0.2
                tmax    0
                basemin -0.2
                basemax 0.0
        }
        
}

If the parameters are the same for all input files, you only have to specify one description file. For more details and options see the MNE manual.

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