BrainQuake: An Open-Source Python Toolbox for the Stereoelectroencephalography Spatiotemporal Analysis

Fang Cai, Kang Wang, Tong Zhao, Haixiang Wang, Wenjing Zhou, Bo HongFrontiers Neuroinformatics 2021 · DOI

Introduction

Stereoelectroencephalography (SEEG) is a critical diagnostic procedure for patients with drug-resistant epilepsy, involving the implantation of depth electrodes to identify the seizure onset zone (SOZ). However, the post-processing workflow—integrating preoperative MRI, postoperative CT, and extensive EEG recordings—is traditionally fragmented, manual, and time-intensive. BrainQuake is an open-source Python toolbox designed to automate this complex workflow through a unified, GUI-driven platform, significantly reducing the manual labor required for presurgical evaluations.

Methodology

BrainQuake provides an end-to-end pipeline that handles brain surface reconstruction, electrode localization, and SOZ prediction. The architecture utilizes a client-server model to bridge the gap between high-performance Linux-based neuroimaging tools (like FreeSurfer) and standard clinical workstations, allowing clinicians to interact with a simple Python GUI while heavy processing occurs on a dedicated server.

The BrainQuake pipeline integrating SEEG data, imaging, and predictive modules.

Key technical innovations in the methodology include:

  • Automated Electrode Localization: Utilizing a 3D Hough Transform to identify linear trajectories of electrode shafts in the CT point cloud, followed by Gaussian Mixture Models (GMM) for robust voxel clustering. This geometric prior avoids the "local optima" problems common in standard clustering approaches.
  • Center-of-Mass Convergence: An iterative algorithm that refines contact coordinates by "stepping" along the detected electrode axis and converging on the highest intensity CT voxels.
  • Dual-Mode SOZ Prediction: The toolbox calculates an Epileptogenicity Index (EI) for ictal (seizure) data based on high-gamma energy and a High-Frequency Events Index (HI) for interictal (between seizure) data, providing a vital cross-reference for clinical assessment.

Results and Validation

The toolbox was validated using clinical data from 8 patients (743 contacts) and open-access datasets. The integrated FastSurfer pipeline reduced surface reconstruction time from 3.5 hours to 30 minutes, while electrode localization was completed in approximately 30 seconds per subject.

Sample summary table of electrode contact locations generated by BrainQuake.

Predictive accuracy for the SOZ reached an average Area Under the Curve (AUC) of 0.83 for ictal data and 0.80 for interictal data. Statistical analysis confirmed that BrainQuake’s EI implementation significantly outperforms existing tools such as AnyWave (p < 0.01). Furthermore, 95% of detected contacts were within 0.1 mm of their estimated axes, demonstrating high geometric precision compared to physical reality.

Discussion and Future Work

BrainQuake addresses the practical hurdles of clinical research by automating labor-intensive tasks and providing a cross-platform solution. While the center-of-mass algorithm effectively handles most electrode placements, extreme electrode "bending" remains a challenge for linear regression models.

Future developments will focus on GPU-accelerated modules for interictal analysis to manage large datasets (often exceeding 50GB per patient) and the integration of neural networks for automated HFO detection. Despite high levels of automation, the authors emphasize that expert visual verification remains a necessary final step in the clinical decision-making process.

Summary updated

BibTeX
@article{cai2021brainquake,
  author = {Fang Cai and Kang Wang and Tong Zhao and Haixiang Wang and Wenjing Zhou and Bo Hong},
  title = {{BrainQuake: An Open-Source Python Toolbox for the Stereoelectroencephalography Spatiotemporal Analysis}},
  journal = {Frontiers Neuroinformatics},
  year = {2021},
  doi = {10.3389/fninf.2021.773890},
}
Figure