Brainstorm Tutorial - sEEG Localization
TianLab Access Only
Contributor: Hao Zhu (hao.zhu@nyu.edu)
Create Date: 2024/01/08
This tutorial is based on:
- Ubuntu 22.04.3 LTS 64-bit
- MATLAB R2023b
- Brainstorm 03-Nov-2023
- FreeSurfer 7.4.1
- dcm2niiX v1.0.20220505
Update History:
- Hao Zhu - 2024/01/16:
- With Brainstorm 03-Jan-2024. Right click
subject
, you can directly import CT. - Add Extras section
- With Brainstorm 03-Jan-2024. Right click
Introduction
This tutorial is designed to walk through the fundamental steps of sEEG electrode localization. The process includes merging pre-operative MRI with post-operative CT scans (co-registration), standardizing the data (normalization), marking the positions of the electrodes on the co-registered CT (manual electrode localization), identifying anatomical structures (atlas labeling), and visualization.
Table of Contents
- Installation
- Data preparation
- Getting Started
- Import Anatomy
- Electrode Localization
- Atlas Labeling
- Visualization
- Conclusion
- Extras
Installation
Follow the official installation guide for detailed instructions.
Data preparation
In this tutorial, I use a sample datasets from a real subject (sz14) collected from Shenzhen Second People’s Hospital.
- pre-operative MRI
-
dataset/NifTi/sz14-mriT1.nii.gz
- post-operative CT
-
dataset/NifTi/sz14-ct.nii
- Co-registered images (Done and provided by neurosurgeons)
-
dataset/coreg_map/
-
Inside the folder, there are subfolders named under the labels of implanted electrodes (eg.
dataset/coreg_map/A/
). In each of the subfolder, there are images displaying the position of the contact demonstrated by MRI and CT scans overlay (eg.dataset/coreg_map/A/A(1).png
). -
Addition to the images, there is a slide file (
dataset/coreg_map/summary.pptx
) that describes the electrode implantation in both hemisphere.
- FreeSurfer reconstruction
dataset/sz14/
- The open-source software FreeSurfer can be used to extract the cortical envelope from a T1/T2 MRI and register it to an atlas.
- Files that are used by brainstorm:
dataset/sz14/mri/T1.mgz
(T1 MRI volume) + optional /mri/T2.mgzdataset/sz14/mri/*aseg.mgz
(volume parcellations)dataset/sz14/surf/?h.pial
(grey/csf interface)dataset/sz14/surf/?h.white
(grey/white matter interface)dataset/sz14/surf/?h.sphere.reg
(registered parametrized sphere, for subject co-registration)dataset/sz14/label/?h.*.annot
(cortical surface-based atlases)dataset/sz14/surf/?h.thickness
(cortical thickness map)
Above four files are needed for this tutorial and successful electrode localization.
Getting Started
-
Launch brainstorm (Guide)
-
Select the menu
File
>New protocol
. Name it and select the options:
- No, use individual anatomy
-
No, use one channel file per acquisition run
Import Anatomy
Import neuroimages into Brainstorm.
- Create subject
-
Right-click on the protocol folder >
New subject
>sz14
. Keep the default options you defined for the protocol.
- import FreeSurfer anatomy folder
-
Right-click on the subject
sz14
>import anatomy folder
>dataset/sz14/
. Files of type should remain FreeSurfer + Volume atlases. -
Use default Number of vertices on the cortex surface: 15000
-
The MRI viewer opens automatically. The positions of all the anatomical fiducials are not defined. It will be defined in the next step.
-
Click on
Click here to compute MNI normalization
, select optionsegment
. It computes a non-linear transformation between the subject space and the MNI ICBM152 space. It takes a while for this computation and the fiducials will be automatically defined after this computation. -
Check fiducials, follow this instruction. Click
Save
to finish. -
The files you can see in the database explorer:
- MRI: The T1 MRI of the subject
- ASEG/DKT/Desikan-Killiany/Destrieux/tissues_segment: Volume parcellations, recommand to use Destrieux.
- head mask: Scalp surface generated by Brainstorm. The numbers in the filename indicate the parameters that were used for this head: vertices=10000, erode factor=0, fill holes=2, background threshold=detected.
- cortex_249462V: High-resolution pial surface that was generated by FreeSurfer, that contains usually between 200,000 and 300,000 vertices.
- cortex_15000V: Low-resolution pial surface, downsampled using the reducepatch function from Matlab. It is used as the default by the processes that require a cortex surface.
- white_249462V: High-resolution white matter envelope from FreeSurfer
- white_15000V: Low-resolution white matter, processed with reducepatch
- mid_*V: Mid-cortex surfaces (average of the pial + white surfaces vertex by vertex)
-
subcortical: Atlas of subcortical regions imported as labelled surfaces
- import CT scan
-
Right-click on the subject
sz14
>import MRI
>dataset/NifTi/sz14-ct.nii
. -
Click
Yes
to all pop-up windows (1st, 2nd, and 4th) andSPM
for co-registration window (3rd). -
Check co-registration result, close the Viewer window.
-
[optional] Right click the
sz14-ct_spm_reslice
>File
>Rename
>CT
The import step is finished. MRI and CT are co-registered and normalized.
Electrode Localization
Identify and mark the positions of the electrodes on the co-registered CT scan.
- Create implantation.
-
Right-click on the subject
sz14
>SEEG/ECOG implantation
-
Close the pop-up MRIViewer, we don’t do this on MRI.
-
In functional data section, right-click on the
sz14-implantation-SEEG/ECOG(0)
>MRI registration
>Edit... (MRI Viewer: CT)
-
Do not close the Viewer! It’s needed for the whole process of localization.
- Start localization
-
In the right panel of the brainstorm UI, under the
iEEG
tab. Click+
to add an electrode (click-
to delete). The electrode naming convention is:- electrode are named alphabetically by the neurosurgeons.
- electrode on the right hemisphere is named with a ‘ at the end, for example, X’. In brainstorm, symbols or numbers are not accepted. Use p to represent ‘, for example, name X’ as Xp in brainstorm.
- electrode with number in its name, for example, M-1. Use English word of the corresponding number to represent digits, for example, name M-1 as Mone in brainstorm.
-
On the left hemisphere, just take the electrode original name.
-
Let’s start with Xp.
- The order matters, my recommendation is start with the hemisphere that has smaller number of electrodes, move from anterior to posterior. Value coronal image since most electrodes are implanted from left/right side of the brain.
-
Select electrode parameter to be
Huake-Hengsheng SDE-08-S16
. ChangeNumber of contacts
according to how many contactsdataset/coreg_map/X'/
folder shows. If the number of contacts exceeds 16, changeElectrode length
to 70/80 mm to adapt. -
Check the Viewer window of the CT scan. Find the tip of the Xp electrode, put the cross at the tip. Use zoom in/out for help, and take images in
dataset/coreg_map/X'/
anddataset/coreg_map/summary.pptx
for reference. -
Go back to the brainstorm UI, click
Set tip
. -
Again, check the Viewer window of the CT scan and find the skull entry of the Xp electrode, put the cross at it. Make sure the point selected is outside of the skull.
-
Go back to the brainstorm UI, click
Set skull entry
. -
Check the Viewer window of the CT scan. Scroll around, you can see the electrode Xp has been localized.
- Repeat the Step 2 for the rest electrodes.
- Once finished localization, click
Save
on the right corner of the Viewer window. - Click
Yes
for the pop-up Channel editor window.
Atlas labeling
After electrode localization, we have the correct coordinates of each of contact. We can identify contact’s anatomical location in either native space (Destrieux atlas) or MNI space (AAL3 atlas). To identify the correct anatomical location of a contact, combine both labeling results and compare to actual neural signal.
- Native space
-
In functional data section, right-click on the subject
sz14-implantation-SEEG/ECOG(145)
>iEEG atlas labels
. Select directory you wish to export, and name itsz14.tsv
. ClickOK
andYes
for the rest pop-up window. The generated file will open. -
This file contains contact’s coordinates and anatomical labeling in different atlases and corresponding probability. I recommend to use Destrieux.
- MNI space
-
In functional data section, right-click on the subject
sz14-implantation-SEEG/ECOG(145)
>Project to default anatomy
. -
In functional data section, right-click on the subject
Group_channels-sz14-SEEG/ECOG(145)
>iEEG atlas labels
. Select directory you wish to export, and name itsz14_mni.tsv
. ClickOK
andYes
for the rest pop-up window. The generated file will open. -
This file also contains contact’s coordinates and anatomical labeling in different atlases and corresponding probability. But note it’s all in MNI space. I recommend to use AAL3.
Visualization
Visualize results using Brainstorm’s built-in tools and other toolboxes. I do not recommend mayavi
and pysurfer
.
- brainstorm
-
Native space. In functional data section, right-click on the subject
sz14-implantation-SEEG/ECOG(145)
>Display sensors
>SEEG (cortex)
. Adjust level of transparency of the cortex under theSurface
tab. Display atlas labels and contours under theScout
tab >Atlas
>From subject anatomy
>Destrieux
. To generate movie, in the 3D view window, right-click, selectSnapshot
>Movie (horizontal/vertical)
. -
MNI space. In functional data section, right-click on the subject
Group_channels-sz14-SEEG/ECOG(145)
>Display sensors
>SEEG (cortex)
.
- PyVista
- Brainstorm so far does not support group level electrode visualization (there is a walk-around by putting all electrodes coordinates in one pseudo-subject and plot them in MNI space).
PyVista
is a powerful 3D visualization toolkit inPython
that enables researchers to easily create complex and interactive 3D models. It is particularly notable for its capabilities in brain visualization, allowing for the detailed and interactive rendering of brain structures and data in a 3D space.MNE-python
currently implement PyVista as brain plot backend.- Extract the MNI coordinates computed from brainstorm and read it to
numpy
arrays. -
Use
FreeSurfer
fsaverage as template.
Conclusion
Congratulations! You’ve completed this Brainstorm Tutorial designed for sEEG electrode localization. This is just the beginning—continue exploring advanced features and analyses to enhance your sEEG research.
Feel free to check the official tutorial for more in-depth information and advanced topics.
Happy brain mapping!
Extras
-
Convert DICOM images to NifTi file.
dcm2niix -o __output_file_path__ -f %i_%n_%p_%s_%t -z y __image_folder_path__ o: output directory z y: output compressed = .nii.gz f: output name %i: patient id %n: subject name %p: protocol name %s: series %t: session date and time
-
Run FreeSurfer reconstruction.
-
Set up FreeSurfer environment
export FREESURFER_HOME=/INSTALL_PATH/freesurfer export SUBJECTS_DIR=/INSTALL_PATH/freesurfer/subjects source /INSTALL_PATH/freesurfer/SetUpFreeSurfer.sh
-
Run recon-all. Approx 6-8 hours on TianLab server, 2 hours on 14600K, 1.2-1.5 hours on 13900K.
recon-all -i __NII_FILE_PATH__ -subjid __SUBJECT_ID__ -all
-
Check MRI/CT NifTI file, use Freeview that is installed alone with FreeSurfer.
freeview