-
Notifications
You must be signed in to change notification settings - Fork 2
02. EEG analysis stream
NOTE: These are data processing scripts for the EEG concurrently recorded inside the MEG system, a Yokogawa system with 157 gradiometers, at Academia Sinica. The data were collected on April 10 2019 using an auditory odd-ball paradigm on a healthy subject. The working directory was /Users/fhlin/workspace/sinica_meg/041019/analysis
.
Brain Products EEG For analysis using data collected by Brain Products EEG, the working directory was /Users/fhlin/workspace/eegmri_emotion
.
[This script file] calculates the evoked potentials. It reads for files associated with the "aep_1" experiment (../EEG_data/aep_1.vhdr
, ../EEG_data/aep_1.vmrk
, and ../EEG_data/aep_1.eeg
). ERP associated with three triggers coded with 112, 116, and 120 were read. The EEG channels are between rows 1 and 32.
[This script file] shows the evoked potentials (from "erp_avg_outside.mat" with the third "120" trigger) at all EEG channels over a 2D plane. It calls etc_plotEF_kit.m
. It needs eeg_fwd_prep_042319.mat
to get the positions for each EEG sensor.
You can click each sub-plot to enable a separate and enlarged plot of the selected channel.
These are done with FreeSurfer and MNE. Remember to source the necessary FreeSurfer environment setup and set the environment variable $SUBJECTS_DIR accordingly first.
mne_setup_mri --subject 041019
mne_setup_source_space --subject 041019 --spacing 5
mne_watershed_bem --subject 041019
Then create links to surface files created by the watershed algorithm.
cd $SUBJECTS_DIR/041019/bem
ln -s watershed/041019_inner_skull_surface inner_skull.surf
ln -s watershed/041019_outer_skull_surface outer_skull.surf
ln -s watershed/041019_outer_skin_surface outer_skin.surf
A high-resolution head surface is useful in registering EEG electrodes. This surface can be created from T1 MRI with the following commands.
setenv SUBJECTS_DIR /Users/fhlin/workspace/eegmri_emotion/subjects/
mkheadsurf -subjid s015
A head surface will be created at /Users/fhlin/workspace/eegmri_emotion/subjects/surf/lh.seghead
. Then, convert this surface to be read by Matlab.
cd /Users/fhlin/workspace/eegmri_emotion/subjects/s015/surf
mris_convert lh.seghead lh.seghead.tri
- [This script file] uses the digitizer information setup at Sinica MEG to co-register between a head and EEG sensors.
- [This script file] uses the digitizer information setup at Sunnybrook to co-register between a head and EEG sensors.
- [This script file] uses the digitizer information setup at VGH Taipei to co-register between a head and EEG sensors.
- [This script file] uses the digitizer information setup at VGH Taipei (DAT format) to co-register between a head and EEG sensors.
These files all get the head shape from the outer-skin surface, calculated by the watershed algorithm using mne_watershed_bem in FreeSurfer/MNE. EEG sensor locations described in the files, where "file_elec_loc" (../digitizers/neuroscan/LJY.eps
) and "file_elec_name" (../digitizers/neuroscan/LJY.ela
) give the EEG sensor locations and names, respectively.
It creates a head model data file (eeg_fwd_prep_042319.mat
in this example) first.
You can click "k" to enable the manual registration GUI to move MEG sensors and HPI coils around the head.
Upon completing the registration, remember to export the relative positions of EEG sensors to the data file (eeg_fwd_prep_042319.mat
in this example) by clicking the "export..." button.
[This script file] displays the result of MRI-MEG sensor co-registration.
With a prepared head model, [This script file] shows the evoked response (from "erp_avg_outside.mat" with the third trigger "120") at all EEG sensors over a head. It calls etc_render_topo.m
. It needs the file (eeg_fwd_prep_042319.mat
) for the description of head model, EEG sensor names, and EEG sensor locations.
Prepare high-resolution head surface. Do the following with FreeSurfer
$ mkheadsurf -s s015
$ cd $SUBJECTS_DIR/s015/surf
$ mris_convert lh.seghead lh.seghead.tri
[This script file] uses the digitizer information setup at Sunnybrook to co-register between a high-resolution head surface and EEG sensors.
setenv SUBJECTS_DIR
cd /Users/fhlin/workspace/eegmri_emotion/subjects/s015/surf
Then, we decimate the surfaces into lower resolution in order to save subsequent computational time. Without doing this, the computation of the forward solution can take more than 12 hours.
mris_decimate -d 0.1 inner_skull.surf inner_skull_d10.surf
mris_decimate -d 0.1 outer_skull.surf outer_skull_d10.surf
mris_decimate -d 0.1 outer_skin.surf outer_skin_d10.surf
Use this script to read multiple surface files (in .surf format) by FreeSurfe read_surf.m
, reduce the complexity (the number of triangulation) using reducepatch
function in Matlab, and save the simplified surface by FreeSurfer write_surf.m
.
The image below shows results of keeping only 10% of the number of faces in the triangulation. Visually surfaces are indistinguishable.
[This script file] prepares files needed for forward calculation using OpenMEEG. It uses the files from FreeSurfer/MNE to generate source space description and geometries for inner skull, outer skull, and outer skin. EEG sensor locations are described in the file eeg_fwd_prep_042319.mat
as the variable "file_eeg_mat".
An image showing inner skull, outer skull, and outer skill geometries, as well as source points (in red) and EEG sensor locations (in blue) will be shown.
Generated files are:
- 041019_d10-{lh, rh}.dip: the dipole current source (3 orthogonal directions at each location)
- 041019_d10.eegsensors : locations of EEG sensors
- scalp.tri, skull.tri, cortex.tri: description on the geometry for skull and scalp boundaries.
- 041019_d10_bem.cond: the conductivity of materials between boundaries
- 041019_d10_bem.geom: a wrapper file for boundary geometries.
This is done by the OpenMEEG software. Use following commands to create a forward model.
#OPENMEEG routines
om_assemble -HeadMat 041019_d10_bem.geom 041019_d10_bem.cond 041019_d10.hm
om_assemble -DSM 041019_d10_bem.geom 041019_d10_bem.cond 041019_d10-lh.dip 041019_d10-lh.dsm brain
om_assemble -DSM 041019_d10_bem.geom 041019_d10_bem.cond 041019_d10-rh.dip 041019_d10-rh.dsm brain
om_assemble -h2em 041019_d10_bem.geom 041019_d10_bem.cond 041019_d10.eegsensors 041019_d10.h2em
om_minverser 041019_d10.hm 041019_d10.hm_inv
om_gain -EEG 041019_d10.hm_inv 041019_d10-lh.dsm 041019_d10.h2em eeg_lh_gain.mat
om_gain -EEG 041019_d10.hm_inv 041019_d10-rh.dsm 041019_d10.h2em eeg_rh_gain.mat
Successful calculation gives you two Matlab data files for the forward solution with the source space in left (eeg_lh_gain.mat) and right (eeg_rh_gain.mat) hemispheres.
[A Matlab script] wraps these OpenMEEG commands.
-
[This script file] prepares a Matlab data by combining the forward solution generated by OpenMEEG and other information, such as source locations, orientations, indices (used by FreeSurfer), and EEG sensors. You need to provide the following:
-
file_fwd: a cell array of the forward solution generated by OpenMEEG.
-
file_source_fif: the source space described by MNE (e.g., 041019-5-src.fif)
Successful preparation gives you a Matlab data files (e.g., eeg_fwd_042319.mat).
- [This script file] is the updated one to include EEG channel names and forward solution in the output file (eeg_fwd_052524.mat).
[This script file] calculates the minimum-norm estimates of the EEG data. It needs the following:
- file_fwd: the prepared forward solution Matlab data file (see step 8).
- file_erp: the evoked response file (see step 1).
Successful execution generates two STC files, each of which describes the significance of current dipole strength over time for left and right hemispheres, for each condition.
[This script file] calculates the minimum-norm estimates (MNEs) and dynamic statistical parametric maps (dSPMs) of the EEG data of both the evoked responses and time-frequency representation (TFR). This example specifically calculate the 15-Hz oscillatory signals because the experiment was a steady-state visual evoked potential design, where 7.5 Hz checkerboard flashing was shown and 15 Hz oscillations were expected.
[This script file] helps you examine the distribution and time courses of the significance of the estimated current over the cortex.
The figure below shows the 15-Hz SSVEP calculated in step #9. The 15-Hz dSPM file was loaded as the functional overlay.