Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2025 Jan 7.
Published in final edited form as: Proc Int Brain Comput Interface Conf. 2024 Sep;2024:425–431. doi: 10.3217/978-3-99161-014-4-075

AN ONLINE SPIKE DETECTION AND MONITORING FRAMEWORK IN IEEG RECORDED USING BRAIN INTERCHANGE DEVICE

Behrang Fazli Besheli 1, Amir Hossein Ayyoubi 1,2, Jhan L Okkabaz 1,2, Chandra Prakash Swamy 1, Michael M Quach 3, Kai J Miller 1, Gregory A Worrell 4, Nuri F Ince 1,2,5
PMCID: PMC11706362  NIHMSID: NIHMS2039045  PMID: 39777227

Abstract

In this study, we developed and validated an online analysis framework in MATLAB Simulink for recording and analysis of intracranial electroencephalography (iEEG). This framework aims to detect interictal spikes in patients with epilepsy as the data is being recorded. An online spike detection was performed over 10-minute interictal iEEG data recorded with Brain Interchange CorTec in three human subjects. A pool of detected spikes is then broadcasted using User Datagram Protocol (UDP) to an external graphical user interface for further post-processing and visualization. The real-time spike detector demonstrated a 99% similarity index with the previously published offline detector, identifying interictal spikes. Furthermore, our findings indicated that channels with highest spike rates, captured with Brain Interchange CorTec, were in the epileptogenic focus. By enabling the detection of interictal spikes in an online fashion, this work provides early feedback on the probable seizure onset zone (SOZ) and suggests a promising direction for enhancing SOZ localization accuracy to clinicians, which is crucial for the surgical treatment of epilepsy.

INTRODUCTION

Epilepsy is a neurological disease marked by recurrent, unprovoked seizures, affecting millions of individuals worldwide [1]. A significant subset of these individuals (around 30%) suffer from medically intractable epilepsy, where seizures are not able to be well-controlled by medication. The localization of the seizure onset zone (SOZ) — the brain area responsible for initiating seizures — is crucial for successful surgical intervention [2,3]. Intracranial electroencephalography (iEEG) has emerged as a fundamental tool in this endeavor, allowing for the precise monitoring of brain activity associated with epileptic discharges [4]. In recent years, interictal spiking activity, a brief transient event, has received considerable attention for SOZ localization. Although contradicting studies [5] were reported regarding the effect of interictal spikes and ictogenesis, these have been hypothesized by other studies as a potential biomarker for mapping the SOZ [6].

The recent development of implantable devices capable of both recording and stimulating the human brain via iEEG contacts has offered great opportunities for treating neurological diseases [7-8] and has opened a new frontier in the development of brain-computer interfaces (BCIs). In this scheme, we showed the feasibility of recording iEEG with the Brain Interchange (BIC) of CorTec [9-10]. In this study, we expanded the framework with a new feature that can capture interictal spikes in an online fashion while iEEG data is being recorded. Despite the pioneering works [11-12], and advanced machine learning techniques in identifying spikes with high accuracy, the challenge of online detection of these events in a clinical setting remained primarily as an important step.

This study introduces a novel MATLAB Simulink framework designed to automatically detect the spikes in an online fashion. By leveraging the robust recording capabilities of the BIC CorTec amplifier and online signal processing algorithms, our system provides a fully online analysis platform for iEEG data. Unlike previous offline frameworks [13-14] that may have required post-recording analysis, our framework detects interictal spikes as the data is being recorded. We send these detected spikes to an external application using user datagram protocol (UDP) for visualization of the morphology of these events, their spatio-temporal distributions, and further post-processing.

To evaluate this framework, we draw comparisons with a previously published offline spike detector [13], highlighting our framework's capability to achieve a high similarity index in spike detection. Furthermore, our analysis of spike detection rates within and outside the clinically defined SOZ offers compelling evidence of the system's utility in surgical planning.

In summary, our work contributes to technological and clinical advancement in epilepsy research and treatment by providing an online, accurate, and reliable method. Moreover, we opened a new avenue for immediate clinical decision-making and intervention, ultimately aiming to improve the lives of those affected by medically intractable epilepsy.

MATERIALS AND METHODS

Patient’s demographic:

We recorded iEEG from three patients (two pediatric and one adult) diagnosed with pharmacoresistant epilepsy at Texas Children’s Hospital (TCH) of Baylor College of Medicine (BCM) and Mayo Clinic. This study was approved by the Institutional Review Boards (IRBs) of BCM and Mayo Clinic, ensuring that all experiments and methods were performed in accordance with relevant guidelines and regulations. Furthermore, informed consent was obtained from all participants and/or their legal guardians prior to incorporating their data into this study.

The recordings were acquired in the epilepsy monitoring unit (EMU) using the BIC unit (Fig. 1A), which consists of 32 channels at a sampling frequency of 1 kHz. A subset of these channels was selected based on the clinically defined SOZ, while the remaining channels were chosen from areas outside the SOZ to validate the model. A random 10-minute section of interictal data was selected for further analysis. The clinical team at the affiliated institutes provided relevant medical annotations, including information about the SOZ.

Figure 1:

Figure 1:

(A) The schematic representation of the BIC CorTec Evaluation Kit, illustrating the components, including the evaluation implant, the communication unit, and the Simulink model designed for efficient data acquisition and online spike detection. (B) The window-based amplitude threshold detector concept to capture interictal spikes in multichannel iEEG recordings. (C) The details of the Simulink model architecture, which includes the data acquisition model, monopolar to bipolar iEEG data conversion to preprocess the iEEG stream for enhanced spike detection accuracy, the spike detection algorithm, and a UDP data transfer block. This block facilitates the transmission of detected events to external software for further post-processing and visualization. (D) Showcases the external GUI developed for the post-processing and visualization of detected spikes. This interface receives the collected events, displays the spatial and temporal distribution of these events, and conducts additional post-processing to distinguish spikes with and without high-frequency oscillations (HFOs). (E) Provides examples of detected interictal spikes.

Data recording and Online analysis framework:

To duplicate a real-time rapid prototyping environment, we developed a Simulink model for the iEEG data acquisition. The previously recorded data was then fed back to the model at real-time speed (Fig. 1B) to simulate the real data acquisition.

Furthermore, spike detection was conducted on the band-pass filtered data within the spike band range (10-55 Hz), and the detected events pool was generated within the model (Fig. 1C). This pool was then sent to an external graphical user interface (GUI, Fig. 1D) for further post-processing and visualization using UDP. Additionally, spike detection was performed using an offline detector, and the obtained results were utilized as the ground truth to evaluate the performance of the online detection method. Examples of detected spikes are illustrated in Fig. 1E.

Wireless data transfer and missing packets recovery:

The BIC unit facilitates wireless data transfer, which is a process inherently susceptible to data loss [9]. In this study, we addressed this challenge by employing linear interpolation to recover missing packets, thereby maintaining signal integrity. It has been demonstrated that this technique effectively restores iEEG data with minimal packet loss (<5%), particularly for spike detection in the frequency band below 80 Hz [9]. The recovered signal is then applied to subsequent analyses.

Threshold calculation and spike detection:

To compute the adaptive threshold for spike detection, our model applied a second-order Butterworth high-pass filter at 1 Hz to remove the DC offset. Subsequently, the signal underwent band-pass filtering using a fourth-order Butterworth filter with cut-off frequencies of 10 Hz and 55 Hz. The filtered signal was buffered into 128 sample-long segments and the standard deviation (std) was estimated for each frame. The std values were further buffered into 40 segment-long frames, and the median within each frame was calculated as the estimated background activity of iEEG data for each channel. Finally, a multiplier (×7) was selected based on the previous work [9] to compute the adaptive threshold for the stream of data (Fig. 2A).

Figure 2:

Figure 2:

(A) The schematic of the real-time adaptive threshold calculation within the iEEG data analysis framework. Initially, filtered iEEG streams within the frequency range of 10-55 Hz are directed into a buffer block, which captures 128 ms of samples consecutively without overlap and calculates the standard deviation for each buffered segment. Subsequently, a second buffering stage accumulates 40 standard deviation samples without overlap, from which the median value is derived, serving as an estimation of background neural activity. The final step involves applying a multiplier to these median values, thereby generating an adaptive threshold for spike detection across each channel over intervals of 5.12 seconds. (B) The percentage thresholds difference between online and offline calculated across all channels and subjects.

In this study, we observed differences in the threshold calculations of the filtered iEEG stream between online and offline analyses. These differences are due to the distinct filters employed in each process. Specifically, for offline processing, we used zero-phase filtering. This non-causal, bidirectional method leverages access to the entire dataset, leading to threshold values that may slightly differ from those generated by the causal filters employed in online processing.

The adaptive threshold is initially computed at intervals of 128*40 milliseconds and then transformed into a continuous data stream. We utilized a rate transition block within our Simulink model to modify the sampling rate of the calculated threshold. Thus, aligning with the sampling rate of the iEEG data (1 millisecond). This adjustment ensures that the threshold applies to all iEEG samples and synchronizes with the temporal resolution of the data.

The filtered iEEG and threshold values were then buffered into intervals of 640 sample-long segments with 512 samples of overlap for spike detection using the corresponding estimated threshold. In each segment, we found the points crossing the threshold levels and grouped them as a single event if their distance was smaller than a predefined interval. Furthermore, to ensure accuracy and specificity in spike detection, we implemented a strategy to exclude polyspike components, as discussed in [13]. A spike event is selected for further analysis only if its peak value is positioned at the center of the frame, specifically at 128 samples into the 640-sample frame. An essential step in the detection process involves distinguishing distinct spike events to prevent redundancy. This criterion, aligned with the overlap size, helps in accurate event identification and isolates individual spikes.

The channel information, timestamps, and segments with identified spikes are aggregated into an event pool. This pool is then broadcasted to a secondary computer via UDP for further processing. The separation of initial data acquisition and spike detection from subsequent post-processing and visualization ensures that the recording and primary analysis continue uninterruptedly with minimal computational demand. By structuring the methodology in this manner, we maintain a seamless and efficient workflow, allowing for continuous data acquisition and spike detection, followed by detailed event and pool visualization on a separate system.

RESULTS

In this study, we compared the adaptive real-time threshold with its offline counterpart over all channels across three subjects. This comparison is shown as a shaded plot illustrating the percentage difference between the real-time and offline thresholds for all channels across all subjects (Fig. 2B). Remarkably, in every instance, the difference between these two thresholds remained under 1%, with the maximum difference observed in the last subject (P3) being 0.82±0.98%, indicating a negligible difference between real-time and offline threshold calculations.

Further analysis was conducted by deploying the online spike detector on these datasets and comparing its performance with those spikes detected offline (Fig. 3, left panel). This study focused on the rate and spatial distribution of spikes detected in both online and offline methods, as well as their occurrence in clinically defined SOZ across subjects. Our approach to comparing detected spikes involved two individual methods. Initially, we evaluated the cosine similarity between the spatial distributions of spikes detected, discovering the alignment in spike distributions across all channels, with similarity indices surpassing 0.99 and angular differences between the spatial distribution of spike vectors in online and offline analysis measuring 1.6°, 2.0°, and 1.8°, respectively (Fig. 3, middle panel). Additionally, we employed the Kolmogorov-Smirnov statistical test to compare the rate of detected spikes across all channels in both online and offline analyses. This statistical evaluation revealed no significant difference, with p-values of 0.93, 0.99, and 0.99 for subjects 1-3, respectively (Fig. 3, right panel).

Figure 3:

Figure 3:

(Left Panel) The comparison of the spike rates across channels, contrasting the performance of online and offline spike detection. (Middle Panel) Illustrates the cosine similarity index between the spatial distributions of spikes detected in online and those identified through offline analysis. It shows the degree of alignment between the two detection methods were more than 99% in all cases. (Right Panel) Presents spike rates obtained from online and offline analyses across channels for each subject. Statistical analysis reveals no significant differences in the rate of spikes detected through online and offline analyses across the subjects, with p-values of 0.93, 0.99, and 0.99, respectively.

Importantly, our observations highlighted that the rate of detected spikes was consistently higher within the SOZ than outside the SOZ across all three cases. Notably, the initial two contacts exhibiting the highest rate of spikes were identified within the SOZ for all subjects. While this finding confirms previous works [9], it underscores the efficacy of employing the BIC CorTec system for online spike detection and emphasizes its potential in accurately identifying probable SOZ sites. This insight not only reaffirms the precision of our spike detection framework but also demonstrates its utility in enhancing the accuracy of SOZ localization, offering significant implications for the future of epilepsy treatment and management.

DISCUSSION

The current work introduces a fully online framework designed for the detection of interictal spikes, capable of broadcasting detected events to external applications for subsequent postprocessing and visualization. The methodology is structured around three main components: first, a complete data acquisition module; second, an online spike detection module—both developed as level-2 MATLAB s-functions handling data acquisition and initial spike identification. The third component features a user-friendly GUI that receives and visualizes the detected events. All essential signal processing blocks have been implemented in Simulink MATLAB to better control the entire framework.

The entire processing pipeline was validated by randomly selecting 10-minute segment of BIC CorTec pre-recorded interictal iEEG from three human subjects streamed in real-time as data playback to illustrate the online spike detection concept. This approach allowed for a comparison with a previously established offline spike detector, revealing that channels with the highest spike rate were associated with the SOZ.

In recent years, there has been a growing interest in spike-guided surgical intervention, referred to as spike-tailored surgery [5-6]. Furthermore, a real-time spike detection is crucial for enabling closed-loop neuromodulation or BCI applications, where timely and accurate detection of neural activity allows for responsive and adaptive interactions between the brain and external devices. In response to these interests, and as a tool that is essential for the analysis of iEEG recordings, we implemented the online spike detector and added it to the main data acquisition setup. The developed Simulink model holds the potential for adapting to online spike detection from data streams recorded with various biomedical amplifiers, broadening its applicability in future research.

CONCLUSION

We have successfully demonstrated the feasibility of recording iEEG from human subjects using the BIC CorTec device in a basic rapid prototyping environment within Simulink. In addition, we have integrated a real-time scenario for detecting interictal spikes as a new feature on top of this framework. Our goal is to continue evolving this framework by incorporating additional functionalities that will allow for concurrent analysis of iEEG data during the recording process.

An important aspect of our approach is the concept of broadcasting initially detected events, i.e., interictal spikes, thus transforming the data acquisition computer into a host. The host then streams the detected events to various clients for further post-processing and visualization. This strategy, when augmented with enhanced functionalities in iEEG, has the potential for iEEG surgical planning in the future.

ACKNOWLEDGEMENTS

This study was supported by grants R01NS112497 and UH3NS117944 from the National Institutes of Health—National Institute of Neurological Disorders and Stroke. B.F.B. was supported by the Sundt fellowship of the Mayo Clinic Neurological Surgery Department.

REFERENCES

  • [1].Epilepsy [Internet]. World Health Organization; [cited 2024 Mar 13]. Available from: https://www.who.int/news-room/fact-sheets/detail/epilepsy [Google Scholar]
  • [2].Rummel C, Abela E, Andrzejak RG, Hauf M, Pollo C, Müller M, Weisstanner C, Wiest R, Schindler K. Resected brain tissue, seizure onset zone and quantitative EEG measures: towards prediction of post-surgical seizure control. PLoS One. 2015. Oct 29;10(10):e0141023. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [3].Vakharia VN, Duncan JS, Witt JA, Elger CE, Staba R, Engel J Jr. Getting the best outcomes from epilepsy surgery. Annals of neurology. 2018. Apr;83(4):676–90.. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [4].Schroeder GM, Karoly PJ, Maturana M, Taylor PN, Cook MJ, Wang Y. Chronic iEEG recordings and interictal spike rate reveal multiscale temporal modulations in seizure states. arXiv preprint arXiv:2201.11600. 2022. Jan 27. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [5].Marsh ED, Peltzer B, Brown MW III, Wusthoff C, Storm PB Jr, Litt B, Porter BE. Interictal EEG spikes identify the region of electrographic seizure onset in some, but not all, pediatric epilepsy patients. Epilepsia. 2010. Apr;51(4):592–601. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [6].Karoly PJ, Freestone DR, Boston R, Grayden DB, Himes D, Leyde K, Seneviratne U, Berkovic S, O’Brien T, Cook MJ. Interictal spikes and epileptic seizures: their relationship and underlying rhythmicity. Brain. 2016. Apr 1;139(4):1066–78. [DOI] [PubMed] [Google Scholar]
  • [7].Skarpaas TL, Jarosiewicz B, Morrell MJ. Brain-responsive neurostimulation for epilepsy (RNS® System). Epilepsy research. 2019. Jul 1;153:68–70. [DOI] [PubMed] [Google Scholar]
  • [8].Sun FT, Morrell MJ. Closed-loop neurostimulation: the clinical experience. Neurotherapeutics. 2014. Jul 1;11(3):553–63. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [9].Ayyoubi AH, Fazli Besheli B, Quach MM, Gavvala JR, Goldman AM, Swamy CP, Bartoli E, Curry DJ, Sheth SA, Francis DJ, Ince NF. Benchmarking signal quality and spatiotemporal distribution of interictal spikes in prolonged human iEEG recordings using CorTec wireless brain interchange. Scientific Reports. 2024. Feb 8;14(1):2652. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [10].Schalk G, Worrell S, Mivalt F, Belsten A, Kim I, Klassen BT, Staff NP, Brunner P, Worrell GA, Miller KJ. Toward a fully implantable ecosystem for adaptive neuromodulation in humans: Preliminary experience with the CorTec BrainInterchange device in a canine model. Frontiers in Neuroscience. 2022. Dec 19;16:932782. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [11].Edakawa K, Yanagisawa T, Kishima H, Fukuma R, Oshino S, Khoo HM, Kobayashi M, Tanaka M, Yoshimine T. Detection of epileptic seizures using phase–amplitude coupling in intracranial electroencephalography. Scientific reports. 2016. May 5;6(1):25422. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [12].Medvedev AV, Agoureeva GI, Murro AM. A long short-term memory neural network for the detection of epileptiform spikes and high frequency oscillations. Scientific reports. 2019. Dec 18;9(1):19374. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [13].Janca R, Jezdik P, Cmejla R, Tomasek M, Worrell GA, Stead M, Wagenaar J, Jefferys JG, Krsek P, Komarek V, Jiruska P. Detection of interictal epileptiform discharges using signal envelope distribution modelling: application to epileptic and non-epileptic intracranial recordings. Brain topography. 2015. Jan;28:172–83. [DOI] [PubMed] [Google Scholar]
  • [14].Brown MW III, Porter BE, Dlugos DJ, Keating J, Gardner AB, Storm PB Jr, Marsh ED. Comparison of novel computer detectors and human performance for spike detection in intracranial EEG. Clinical neurophysiology. 2007. Aug 1;118(8):1744–52. [DOI] [PubMed] [Google Scholar]

RESOURCES