General Overview
You will find below a short and very simple framework of analysis of a MEG experiment with the tools available at CENIR. Just for clarity, these commands were used to analyze a very simple somesthesic experiment with 300 right median nerve stimuli and 300 left median nerve stimuli. Our goal was to obtain an evoked potential for each stimulus with the same location of sensors.
Pre processing
Mean Head Position Computation
This first step uses dataHandler to compute a mean head position by averaging the initial had position of each run. This mean head position is then displayed using megDraw.
Code Block |
---|
|
## Compute mean head position by averaging initial head positions in run01 and run02
dataHandler_dev -r -avg run01.fif run02.fif -hp mean -time 0 -.1 meanhp.fif
## Generate *.hc files for each run
dataHandler_dev -r -hc run*.fif meanhp.fif
## Visualize each initial head position and computed mean position
megDraw *.hc
|
:hcfig.png?250|Head positions example
SSS Computation
We used maxfilter to correct for all the main non biological artifacts arising during the recording. maxfilter is configured here to check for bad channels on the entire dataset thanks to the duration computed with dataHandler. The head position for each run is transformed to the above computed mean head position and the MEG signals are recomputed accordingly. If needed you can add manualy bad channels with -bad option.
Code Block |
---|
|
Foreach run (run*.fif)
set log = `echo $run | sed "s/.fif/_sss.log/"`
set duration=`dataHandler -header $run | grep Duration | cut -d " " -f 2 `
@ half=$duration / 2
@ half++
maxfilter -gui -autobad $half -trans meanhp.fif -f $run > $log
## In case of bad channels not detected
## maxfilter -gui -bad 0121 -autobad $half -trans meanhp.fif -f $run > $log
end
|
Triggers Generation
You have to check the quality of the MaxFilter output before going further in your analysis.
First, we use dataHandler to generate the trigger list and add a new marker named "BAD". This marker will be used to mark artifacts and others part of the signals we do not want to use in the analysis.
Then you will use muse to double check the MaxFilter output.
Code Block |
---|
|
dataHandler -touchmarker BAD run*trans_sss.fif
muse_dev run01_trans_sss.fif
|
:badexample.png?500|
Blink Detection
Once your MaxFilter processing is good, you can run the blink detection using dataHandler. Check the results, if not enough blink is detected decrease maxvar option, if too many blinks are detected lower it and rerun the command. Of course your vertical EOG should be on BIO002 (standard location) and it should be reasonably clean (without artifacts bigger than the blinks amplitudes).
Code Block |
---|
|
dataHandler -tm BLINK maxvar -5 -ch BIO002 -time -.15 .6 -r run*trans_sss.fif > blinks.log
|
:blinkdetection.png?500|
QRS detection
Same thing for cardiac artifact, you should have a number of artifacts more or less equivalent to the number of seconds in your recordings (check the cardio.log file! you should find a line similar to this one: ExtractTemplate: corrected correlation: total points = 670 — we had a 10 minutes run so 670 fits well).
Code Block |
---|
|
dataHandler -r -tm CARDIO1 auto -.65 -time 0 .1 -ch BIO003 -alltrials run*trans_sss.fif > cardio.log
|
:cardioexample.png?500|
QRS Artifact correction
Once the cardiac artifacts are detected (please check the output of the previous dataHandler command!), run the following call to dataHandler to correct the cardiac artifacts. The output will be stored in cardiocor_run*.fif files.
Code Block |
---|
|
dataHandler -r -undo -pcavg CARDIO1 2 -meg -time 0 .7 *trans_sss.fif -new cardiocor_ > corrcardio.log
|
Basic Triggers manipulation & Basic Averaging
You can then start averaging steps to obtain your evoked potentials:
Code Block |
---|
|
foreach file_sss in (cardiocor_*sss.fif)
root=`echo $file_sss | sed "s/.fif//"`
## Here we generate clear name markers for our LEFT and RIGHT stimulation only when no BAD markers are found between -.2 second before and 0.5 second after a given occurrence of the marker
dataHandler -r -adm "LEFT_OK=STI101_01[-.2 0.7]&BAD~" ${file_sss}
dataHandler -r -adm "RIGHT_OK=STI101_02[-.2 0.7]&BAD~" ${file_sss}
## We then compute the evoked potentials between -.1s to .3s for each condition while removing the baseline computed between -.1 second and the occurrence of the marker.
dataHandler -r -rbm LEFT_OK -0.1 0.1 -avg ${file_sss} -sync STI101_01 -time -0.1 0.4 MOYENNES/${root}_LEFT_OK.fif
dataHandler -r -rbm RIGHT_OK -0.1 0.1 -avg ${file_sss} -sync STI101_01 -time -0.1 0.4 MOYENNES/${root}_RIGHT_OK.fif
end
|
...