-
Notifications
You must be signed in to change notification settings - Fork 2
06. SEEG source modeling
NOTE: These are data processing scripts based on the SEEG data collected on subject "s031" using an audio-visual stimulation paradigm. The working directory is /Users/fhlin_admin/workspace/seeg/s031/analysis
.
[This script file] or [this script file] calculates the evoked responses. It reads two auxiliary files:["../epochs/seeg_channels.txt"] for channel names and ["../epochs/seeg_epoch_timepoints.txt"] for time points.
Two variables, 'erp_all' and 'C', are saved in the output file "erf_050719.mat".
'erp_all' is an object cell, each one of which contains the evoked response of one condition. It has the following fields:
- erf: c x t matrix with c contacts and t time points
- name: a string cell of c contact names
- trig_str: a string of condition
- timeVec: a vector of length t describing the time stamps
'C' is the noise covariance matrix, estimated from baseline (pre-stimulus) interval. 'C' is required for subsequent distributed source modeling.
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 s031
mne_setup_source_space --subject s031 --spacing 5
mne_watershed_bem --subject s031
Then create links to surface files created by the watershed algorithm.
cd $SUBJECTS_DIR/s031/bem
ln -s watershed/s031_inner_skull_surface inner_skull.surf
ln -s watershed/s031_outer_skull_surface outer_skull.surf
ln -s watershed/s031_outer_skin_surface outer_skin.surf
Then, we decimate the surfaces into lower resolution in order to save subsequent computational time.
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
NOTE: Steps above can be simplified with the following script by setting up the environment variable SUBJECT
denoting the subject folder.
setenv SUBJECT s031
ln -s watershed/"$SUBJECT"_inner_skull_surface inner_skull.surf
ln -s watershed/"$SUBJECT"_outer_skull_surface outer_skull.surf
ln -s watershed/"$SUBJECT"_outer_skin_surface outer_skin.surf
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
Follow the instruction [here] and [here] to register electrodes to pre-surgery MRI. The output of the registration is a Matlab MAT file.
[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. Three files are needed to get the locations of electrode contacts in pre-surgery MRI.
- file_seeg_contact_postMR: the Matlab data file describing location of electrodes in the post-surgery MRI (e.g., electrode_040119_085342.mat).
- file_xfm: a registration file to transform **post-surgery T1 ** to pre-surgery T1 (e.g., /Users/fhlin_admin/workspace/seeg/subjects/s031_post/tmp/register.dat').
NOTE: If the registration file is not available, you can try the following commands to create one.
cd $SUBJECTS_DIR/s031_post/tmp %go to the post-surgery MRI FreeSurfer recon.
bbregister --s s036 --mov ../mri/orig.mgz --init-best-rr --reg register.dat --t1
tkregisterfv --mov ../mri/orig.mgz --reg register.dat --surfs %examine the registration using FreeView
NOTE: If the registration file is not ideal, you can try the following command:
bbregister --s s036 --mov ../mri/orig.mgz --init-rr --reg register.dat --t1
- file_MRI_post: the "orig.mgz" file for post-surgery MRI (e.g., /Users/fhlin_admin/workspace/seeg/subjects/s031_post/mri/orig.mgz).
The file denoted by the variable file_seeg_contact_postMR
was the file for electrode locations. You may consult this page and this page for creating this file to locate elecctrode contacts.
[This script file] can be used to show the electrode contacts on the pre-surgery brain surface and volume. To show electrodes, you should enable the electrode window by clicking 'e' and then load the electrode locations file for the pre-surgery MRI, which will be prepared automatically from the electrode location files prepared over the post-surgery MRI, by clicking the "l" button in the electrode window.
[This script file] can be used to show the electrode contacts on the post-surgery brain surface and volume. To show electrodes, you should enable the electrode window by clicking 'e' and then load the electrode locations file for the post-surgery MRI.
An image showing inner skull, outer skull, and outer skill geometries, as well as source points (in red) and SEEG electrode contacts (in blue) will be shown.
Generated files are:
- s031_d10-{lh, rh}.dip: the dipole current source (3 orthogonal directions at each location)
- s031_d10.seeg: locations of SEEG contacts
- scalp.tri, skull.tri, cortex.tri: description on the geometry for skull and scalp boundaries.
- s031_d10_bem.cond: the conductivity of materials between boundaries
- s031_d10_bem.geom: a wrapper file for boundary geometries.
In the previous example, the "source space", the collection of tentative locations in the brain generating SEEG measurements, is restricted to the cortical surface. If you want to include deep brain structures, such as thalamus, you may use [this script file] to create the source space (*.dip files).
Green dots in the figure below shows the locations of deep brain structures, including thalamus, caudate, putamen, pallidum, hippocampus, amygdala, insula, operculum, accumbens, substancia nigra, and cerebellum. These structures were automatically segmented and labeled by FreeSurfer.
The deep brain structures in a typical FreeSurfer analysis are in 1-mm resolution. This may cause excessive computational load. The deep brain structures can be described in a coarser resolution. Here is [the script file] to describe deep brain structures in 2-mm isotropic resolution. See ### 5.1 for the related BEM preparation.
Use the following commands to generate the forward soluation for left and right hemispheres.
om_assemble -HeadMat s031_d10_bem.geom s031_d10_bem.cond s031_d10.hm
om_assemble -DSM s031_d10_bem.geom s031_d10_bem.cond s031_d10-lh.dip s031_d10-lh.dsm brain
om_assemble -DSM s031_d10_bem.geom s031_d10_bem.cond s031_d10-rh.dip s031_d10-rh.dsm brain
om_assemble -h2ipm s031_d10_bem.geom s031_d10_bem.cond s031_d10.seeg s031_d10.h2ipm
om_assemble -ds2ipm s031_d10_bem.geom s031_d10_bem.cond s031_d10-lh.dip s031_d10.seeg seeg-lh.ds2ipm
om_assemble -ds2ipm s031_d10_bem.geom s031_d10_bem.cond s031_d10-rh.dip s031_d10.seeg seeg-rh.ds2ipm
om_minverser s031_d10.hm s031_d10.hm_inv
om_gain -InternalPotential s031_d10.hm_inv s031_d10-lh.dsm s031_d10.h2ipm seeg-lh.ds2ipm s031_d10-lh.gain.mat
om_gain -InternalPotential s031_d10.hm_inv s031_d10-rh.dsm s031_d10.h2ipm seeg-rh.ds2ipm s031_d10-rh.gain.mat
Successful calculation gives you two Matlab data files for the forward solution with the source space in left (s031_d10-lh.gain.mat) and right (s031_d10-rh.gain.mat) hemispheres.
When running om_assemble -h2ipm
, you may encounter error messages like this:
Interface::contains_point(53.9479 -12.0381 69.5572) Error. Are you sure the interface "cortex" is closed? Solid angle: 9.92543e-17*PI.
Interface::contains_point(53.9479 -12.0381 69.5572) Error. Are you sure the interface "cortex" is closed? Solid angle: 9.92543e-17*PI.
Interface::contains_point(58.5024 -14.0257 69.0033) Error. Are you sure the interface "cortex" is closed? Solid angle: 3.52015e-16*PI.
Interface::contains_point(58.5024 -14.0257 69.0033) Error. Are you sure the interface "cortex" is closed? Solid angle: 3.52015e-16*PI.
Interface::contains_point(63.0568 -16.0133 68.4495) Error. Are you sure the interface "cortex" is closed? Solid angle: 2.13348e-16*PI.
Interface::contains_point(63.0568 -16.0133 68.4495) Error. Are you sure the interface "cortex" is closed? Solid angle: 2.13348e-16*PI.
This is because the SEEG contact locations may outside the cortex. You may remove lead fields of these SEEG contacts in the analysis.
[This matlab script file] calculates the forward solution by running 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 SEEG contact names. You need to provide the following:
- file_fwd: a cell array of the forward solution generated by OpenMEEG.
- file_seeg_contact_postMR: the Matlab data file describing location of electrodes in the post-surgery MRI (e.g., electrode_040119_085342.mat).
- file_source_fif: the source space described by MNE (e.g., s031-5-src.fif)
Successful preparation gives you a Matlab data file (e.g., seeg_fwd_050719.mat).
6.1 Prepare the forward solution for source modeling with deep brain structures in a coarse resolution
If using a source space with decimated resolution in sub-cortical structures, consider [this script file]. See ## 3.2 ## for the related BEM preparation.
For the SEEG source space including deep brain structure in a coarse resolution (see ### 4.2 ### ), use [this script file] to create the forward solution in Matlab.
[This script file] calculates the minimum-norm estimates of the SEEG data. It needs the following:
- file_fwd: the prepared forward solution Matlab data file (see step 4). We need this one to get the name of SEEG contacts in the calculated forward solutions.
- file_erf: the evoked response file (see ## 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.
For the SEEG source space including deep brain structure in a coarse resolution (see ### 4.2 ### and ### 6.1 ###), use [this script file] to create the forward solution in Matlab. Additional *vol.stc (dSPM) and *_mne-vol.stc (MNE) should be generated.
[This script file] helps you examine the distribution and time courses of the significance of the estimated current over the cortex.
[This script file] helps you examine the distribution and time courses of the significance of the estimated current over both the volume and the cortex.
[This script file] morphs the STC files from a source subject (e.g., s031
) to a target subject (e.g., fsaverage
). This allows you to do group-averaging or other 2nd-level analysis.
When using a source space including both cortical and sub-cortical neuronal current source locations, we will have the -vol.stc
files with the estimated neuronal current dynamics. Use [this script file] to morph these volumetric STC files between subjects.
As volumetric STC files include source estimates at both cortical and sub-cortical locations, we can use [this script file] to morph between subjects with cortical neuronal current estimates expanding cortical ribbon, instead of a thin cortical surface between, for example, gray and white matter.
[This script file] renders a movie of the source estimates on the cortical surface.
[This script file] renders a movie of the source estimates on brain cross-sectional images.
[This script file] calculates the sensitivity and SNR maps at both cortical and sub-cortical areas.
[This script file] morphs the sensitivity and SNR maps from individual subject to a template ('fsaverage' subject).