scieee AI-readable full text Open interactive document viewer

Time series segmentation for recognition of epileptiform patterns recorded via microelectrode arrays in vitro

Galeote-Checa, Gabriel; Panuccio, Gabriella; Canal-Alonso, Ángel; Linares Barranco, Bernabé; Serrano Gotarredona, María Teresa

Abstract

Epilepsy is a prevalent neurological disorder that affects approximately 1% of the global population. Approximately 30-40% of patients respond poorly to antiepileptic medications, leading to a significant negative impact on their quality of life. Closed-loop deep brain stimulation (DBS) is a promising treatment for individuals who do not respond to medical therapy. To achieve effective seizure control, algorithms play an important role in identifying relevant electrographic biomarkers from local field potentials (LFPs) to determine the optimal stimulation timing. In this regard, the detection and classification of events from ongoing brain activity, while achieving low power consumption through computationally inexpensive implementations, represents a major challenge in the field. To address this challenge, we here present two algorithms, the ZdensityRODE and the AMPDE, for identifying relevant events from LFPs by utilizing time series segmentation (TSS), which involves extracting different levels of information from the LFP and relevant events from it. The algorithms were validated validated against epileptiform activity induced by 4-aminopyridine in mouse hippocampuscortex (CTX) slices and recorded via microelectrode array, as a case study. The ZdensityRODE algorithm showcased a precision and recall of 93% for ictal event detection and 42% precision for interictal event detection, while the AMPDE algorithm attained a precision of 96% and recall of 90% for ictal event detection and 54% precision for interictal event detection. While initially trained specifically for detecting ictal activity, these algorithms can be fine-tuned for improved interictal detection, aiming at seizure prediction. Our results suggest that these algorithms can effectively capture epileptiform activity, supporting seizure detection and, possibly, seizure prediction and control. This opens the opportunity to design new algorithms based on this approach for closed-loop stimulation devices using more elaborate decisions and more accurate clinical guidelines.

Full text

RESEARCH ARTICLE Time series segmentation for recognition of epileptiform patterns recorded via microelectrode arrays in vitro Gabriel Galeote-ChecaID 1 , Gabriella PanuccioID 2,4‡ , Angel Canal-AlonsoID 3‡ , Bernabe Linares-BarrancoID 1‡ *, Teresa Serrano-Gotarredona 1‡ 1Instituto de Microelectro ´nica de Sevilla (IMSE-CNM), Consejo Superior de Investigaciones Cientı ´ficas (CSIC) and Universidad de Sevilla, Sevilla, Spain, 2Enhanced Regenerative Medicine Lab, Instituto Italiano di Tecnologia, Genoa, Italy, 3Instituto de Investigacio ´n Biome ´dica de Salamanca-IBSAL, Consejo Superior de Investigaciones Cientı ´ficas and University of Salamanca, Salamanca, Spain, 4Istituto Italiano di Tecnologia, Genoa, Italy ‡ GP, ACA, BLB and TSG contributed equally to this work in supervision and ideas. *[email protected] Abstract Epilepsy is a prevalent neurological disorder that affects approximately 1% of the global population. Approximately 30-40% of patients respond poorly to antiepileptic medications, leading to a significant negative impact on their quality of life. Closed-loop deep brain stimulation (DBS) is a promising treatment for individuals who do not respond to medical therapy. To achieve effective seizure control, algorithms play an important role in identifying relevant electrographic biomarkers from local field potentials (LFPs) to determine the optimal stimulation timing. In this regard, the detection and classification of events from ongoing brain activity, while achieving low power consumption through computationally inexpensive implementations, represents a major challenge in the field. To address this challenge, we here present two algorithms, the ZdensityRODE and the AMPDE, for identifying relevant events from LFPs by utilizing time series segmentation (TSS), which involves extracting different levels of information from the LFP and relevant events from it. The algorithms were validated validated against epileptiform activity induced by 4-aminopyridine in mouse hippocampuscortex (CTX) slices and recorded via microelectrode array, as a case study. The ZdensityRODE algorithm showcased a precision and recall of 93% for ictal event detection and 42% precision for interictal event detection, while the AMPDE algorithm attained a precision of 96% and recall of 90% for ictal event detection and 54% precision for interictal event detection. While initially trained specifically for detecting ictal activity, these algorithms can be fine-tuned for improved interictal detection, aiming at seizure prediction. Our results suggest that these algorithms can effectively capture epileptiform activity, supporting seizure detection and, possibly, seizure prediction and control. This opens the opportunity to design new algorithms based on this approach for closed-loop stimulation devices using more elaborate decisions and more accurate clinical guidelines. PLOS ONE PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 1 / 20 a1111111111 a1111111111 a1111111111 a1111111111 a1111111111 OPEN ACCESS Citation: Galeote-Checa G, Panuccio G, CanalAlonso A, Linares-Barranco B, SerranoGotarredona T (2025) Time series segmentation for recognition of epileptiform patterns recorded via microelectrode arrays in vitro. PLoS ONE 20(1): e0309550. https://doi.org/10.1371/journal. pone.0309550 Editor: Gennady S. Cymbalyuk, Georgia State University, UNITED STATES OF AMERICA Received: December 3, 2023 Accepted: August 9, 2024 Published: January 24, 2025 Copyright: ©2025 Galeote-Checa et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited. Data Availability Statement: The algorithm implementations and experimental results that support the findings of this study are openly available in Zenodo repository (https://doi.org/10. 5281/zenodo.10154332). Funding: This work was partially supported by the European Union (https://research-and-innovation. ec.europa.eu/index_en) through grants 824164 (HERMES, with Principal Investigators TSG and Introduction Epilepsy is a prevalent neurological disorder that affects approximately 1% of the global population [1]. The standard treatment of epilepsy relies on medical therapy; however, 30-40% of the patients respond poorly, if at all, to anti-seizure medications, falling into Drug-Resistant Epilepsy (DRE) patients. Surgical removal of the epileptic focus is the current gold standard for those DRE patients. However, the success of ablative surgery highly depends on the accurate identification of the seizure focus. Brain stimulation has emerged as a promising and less radical alternative to ablative neurosurgery. In recent years, there has been a rapid growth of brain implantable devices, driven by the recent contributions in wireless power transmission techniques [2–4], flexible electronics for implantable devices [3,5], and device design miniaturization [6–8]. Among the diverse devices under pre-clinical and clinical research, NeuroPace (Mountain View, CA), which is the first FDA-approved responsive neurostimulation system for focal epilepsy, offers a median seizure reduction range of 50-70% across different studies [9]. Given the promising results in seizure suppression by responsive brain stimulation and the latest advances in brain implantable devices, the growth of these devices for treating epilepsy is expected to accelerate in the next years. However, important aspects such as longterm viability, biocompatibility, power harvesting, and the need for more efficient and optimized algorithms make clinical results still improvable. To operate effectively, brain stimulation devices should detect relevant electrographic biomarkers to determine the optimal stimulation timing and pattern to suppress, or ideally prevent, the seizure. Typically, local field potential (LFP) recordings are used for this purpose. Various biomarkers of interest, such as high-frequency oscillations (HFOs) [10–12], can be detected using embedded algorithms in the implantable device, allowing low latency real-time seizure suppression. In essence, the identification of those different biomarkers in the LFP would help to create decision models for closed-loop brain stimulation. However, the identification of electrographic biomarkers remains challenging due to their diverse characteristics in terms of morphology, time/frequency features, and their correlation with seizure events [12]. To address this challenge, various algorithms have been proposed, such as principal component analysis [13], linear support vector machine [14], approximate entropy [15], K-nearest neighbor and naïve Bayes classification [14], feature extraction using support vector machines [16], or complex multi-feature-based decision models [17]. These algorithms are complex and computationally intensive, and as such their potential for real-time operation is limited. More power-efficient approaches such as phase synchronization in multichannel recordings [18], multilevel wavelet transform [19], Izhikevich neural networks [20], auto-ranging threshold detection [21], or the Wiener algorithm [22], have proven more effective real-time seizure detection in hardware implementations.; However, the main drawbacks are associated with energy and memory consumption, as well as reduced performance caused by simpler implementations due to hardware constraints. Designing efficient algorithms requires reducing three main aspects: computation, memory, and power consumption. By reducing the computational cost, we can also decrease power consumption. This involves: (i) reducing algorithm complexity by optimizing the number and type of operations performed by it, (ii) minimizing memory access, (iii) increasing parallelism, and (iv) optimizing hardware architecture. Following these principles, we propose two novel algorithms that focus on optimizing computation and memory. Based on the principles of optimization, we have developed two innovative algorithms that aim to reduce computational complexity by minimizing the number of operations required and lowering memory usage. Additionally, our algorithms address the issue of complex and recursive computations, which can be inefficient and time-consuming. By prioritizing efficiency and effectiveness, we hope to PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 2 / 20 GP) and 101070908 (CROSSBRAIN, with Principal Investigator BLB). Competing interests: The authors have declared that no competing interests exist. create algorithms that can be easily implemented and utilized in a variety of settings. A time series segmentation approach is used to detect and classify epileptiform events within LFPs. This method involves dividing a continuous signal into discrete segments that share common characteristics. The goal is to identify common patterns, states, or behaviors within the data, which will provide varying levels of information. [23,24]. In the scope of this work, time series segmentation can be used to divide LFPs into distinct categories such as spiking events, firing patterns, or different network states. This approach can help manage a large amount of data and facilitate the application of various algorithms to post-process these segments, such as seizure prediction or control. The objective of this work is to classify ictal and interictal events in LFP data based on their temporal and morphological characteristics. We also aim to determine the current state of the brain network in real time. The principal goal is to ensure that the algorithms we propose have low computational complexity, thereby making them suitable for hardware implementation. We have achieved this goal by developing two new algorithms and validating them through microelectrode array (MEA) recordings of epileptiform activity generated by mouse hippocampus-cortex (CTX) slices treated with the convulsant drug 4-aminopyridine (4AP). This model is widely used to study limbic ictogenesis in vitro. [25], as it offers several parallelisms with the most common type of DRE in humans, i.e., mesial temporal lobe epilepsy (MTLE), including the primary origin of ictal activity in the entorhinal cortex [26– 29]. The two algorithms use different approaches; the first (ZdensityRODE) utilizes an adaptive z-score method, which uses a short-term memory strategy to provide a smooth detection of the brain’s states. The second algorithm (AMPDE) uses scalogram-based peak detection and density estimation in the signal for extracting events of interest determined by their density of excitation. Both algorithms incorporate a post-processing technique with a cumulative lookforward time integration based on their density and can distinguish among ictal discharges, interictal events, and baseline. The ZdensityRODE algorithm was designed for faster computation and reduced operations, while the AMPDE was designed for better adaptability to longterm variations but at the cost of more complex computation. Materials and methods Microelectrode array recording of epileptiform activity generated by brain slices Horizontal hippocampus-cortex (CTX) slices (400 μm-thick) were obtained from 4-8 weeks old male CD1 mice. Epileptiform activity was acutely induced by treatment with 4-aminopyridine (4AP, 250 μM). Extracellular field potentials were acquired using a 6 ×10 planar MEA with TiN electrodes (diameter: 30 μm, inter-electrode distance: 500 μm) and a MEA1060 amplifier. Signals were sampled at 2 kHz, low-pass filtered at half the sampling frequency before digitization, and recorded to the computer’s hard drive via the McRack software. All recordings were performed at 32˚C. The full methodological details describing brain slice preparation and maintenance can be found in [30]. Animal procedures were conducted in accordance with the National Legislation (D.Lgs. 26/2014) and the European Directive 2010/ 63/EU, and approved by the Institutional Ethics Committee of Istituto Italiano di Tecnologia and by the Italian Ministry of Health (protocol code 860/215-PR, approval date 24/08/2015). Animals were monitored daily and euthanized under deep isoflurane anesthesia, verified as the lack of reflexes upon feet, paws, and tail pinch, compliant with FELASA standards. The equipment for MEA recording and temperature control was obtained from Multichannel Systems (MCS), Germany. Fig 1 highlights the electrode mapping relative to the brain slice position on the MEA, showing the different regions from where the LFP signals are recorded. PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 3 / 20 Dataset preparation A validation dataset was generated from 7 brain slices. Brain slices coupled to 60-channel MEAs provided 11 ±5 (mean ±SD) valid electrodes. A total of 68 records, each being 30 minutes long, were extracted and then annotated. Epileptiform events were identified through a semi-automated process. Namely, an automated wavelet-based algorithm was first used to detect the events; then, the marked events were visually inspected and confirmed or manually corrected as required. This is detailed in [31]. Overall, the used dataset comprises a total of 521 ictal events and 6318 interictal events. LFPs were labeled as ictal, interictal, and baseline, coded as 2, 1, and 0, respectively. To ensure the homogeneity of the dataset, we established the following inclusion criteria: i) uniform sampling rate of 2 kHz to standardize disparate sample rates and ensure consistent recording precision; ii) records from the electrodes within the parahippocampal cortex (See Fig 1). All data and metadata are publicly available via the zenodo repository (10.5281/zenodo.10154332). Experimental design: Parameter search and optimization procedure All records were maintained for training in different scenarios, similar to online operation, under low and high SNR conditions, to avoid a possible overfitting of the algorithm. Table 1 summarizes the dataset characteristics for this experiment. Algorithms were trained with an optimization matrix including variations for each of the parameters of the algorithms. The complete set of combinations is described in Table 2, where the parameter search frame is detailed. The experimental protocol devised for this study is depicted in Fig 2. The dataset is divided into 70-30 test-validation splits. After running the algorithms in the training dataset, the best 10 scores were averaged. This particular number was chosen heuristically to obtain a winning combination. For recordings with low Signal-to-Noise Ratios (SNR) (<20 dB), parameters were further fine-tuned before the validation stage, to improve the accuracy. Fig 1. Epileptiform patterns recorded from 4AP-treated hippocampus-CTX slices via MEA. (A) Mouse brain slice placed on a planar 6 x 10 MEA grid (grid separation of 500 μm). Electrodes are grouped by their position in the brain structures comprised within the brain slice preparation. (B) Representative MEA recordings from the electrodes marked as CTX in panel A. The epileptiform pattern comprises both interictal and ictal events. The inserts show representative instances of each event type at an expanded time scale. https://doi.org/10.1371/journal.pone.0309550.g001 PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 4 / 20 Z-score Density-based Robust Outlier Detection Estimation (ZDensityRODE) Since the LFP signal in the used dataset primarily consists of baseline activity, then we may presume that any deviation from the signal’s trend could indicate an interictal or ictal event. By analyzing the outlier’s temporal duration, proximity to other outliers, and magnitude, we could somewhat estimate the type of event it may represent. The ZdensityRODE algorithm utilizes the statistical Z-score test to determine outliers in data trends using the distribution’s historic mean and standard deviation. The Z-test is a reliable measure of variability that can be used to identify outliers. By using historical data, the algorithm can adjust to changes in amplitude caused by factors like electrode degradation. Once the outliers are identified through a zscore test, they are stored for later spike density analysis. The density of these events is evaluated using a lookup window that meets specific search criteria and then classified based on their temporal characteristics and density. This algorithm can be configured using four parameters lag (λ), threshold (τ), influence (ι), and delta (Δ). The lag parameter determines how many past samples are considered for computing the historic average and standard deviation. A longer lag provides stability against rapid changes but increases memory load, while a shorter lag enables quicker adaptation to new information but increased variability. The threshold parameter sets the z-score level at which a data point is deemed significant, allowing for more precise detections based on signal features like the SNR. The influence parameter (ranging from 0 to 1) controls the weight given to incoming samples when recalculating averages and standard deviations, with 0 disregarding new data and 1 providing high adaptability. Lastly, the delta parameter defines the refractory time between peaks, crucial for pattern classification during the post-processing analysis of peak candidates. This parameter regards the duration of events and their separation in time. The algorithm workflow is depicted in Fig 3. The pseudocode for this algorithm is also Table 2. Algorithm optimization experiment matrix. Optimization matrix for the two algorithms. Combinations for each of the parameters of the algorithm and experiments. Algorithm Optimization Parameters ZDensityRODE Threshold [σ]: 4, 5, 6 Delta convolutional filter [seconds]: 3, 4, 5 Lag [seconds]: 0.125, 0.25, 0.5 AMPD Threshold [σ]: 3, 4, 5, 6 Delta Time Integration [σ]: 1.5, 2, 2.5 https://doi.org/10.1371/journal.pone.0309550.t002 Table 1. Brain slice MEA electrophysiology dataset description. Parameter Value Total number of signals 68 Number of electrodes per brain slice 11 ±5 Number of ictal events per brain slice 5 ±1 Number of interictal events per brain slice 80 ±50 Brain region Parahippocampal cortex Sampling rate 2 kHz Total recording time (average) 1800 s Signal-to-noise ratio (SNR) from 20 ±10 dB https://doi.org/10.1371/journal.pone.0309550.t001 PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 5 / 20 provided in Code 1. The algorithm’s complexity was assessed, resulting in a O(n+m) complexity, where n is the input data size and m is the number of relevant outliers found in the signal. If the signal contains no outliers or those are very limited, the spike density classifier is much faster as there are fewer events to compare. Code 1.Pseudo code for Z-score Density-based Robust Outlier Detection Estimation algorithm. Algorithm 1 ZdensityRODE Peak Classification 1: Input: signal, lag (λ), influence (ι), threshold (τ), delta (Δ) 2: Output: classified regions 3: Define an intermediary signal for filtered input values: Y 4: for x i in signal do 5: if Training stage then update buffers μand σbuffers 6: else 7: if (x i −μ i−1 ) > threshold �σ i−1 then 8: x i is an outlier 9: Y ≔(ι�x i ) + ((1 − ι)*U i−1 ); Fig 2. Experiment design description. A) Compendium of MEA recording datasets. B) Annotated signals showing the three different patterns, highlighted in different colors: baseline (green), interictal (yellow) and ictal (red). C) Test/train split of the dataset. D) Experiment design block diagram with the sequence of stages chosen for the experimental stage. https://doi.org/10.1371/journal.pone.0309550.g002 PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 6 / 20 10: else U≔x i 11: end if 12: avg ≔average(Get Chunk of Y for last λ samples); 13: std ≔Standard deviation(Get Chunk of Y for last λ samples); 14: for peak stored in processed window do 15: Account number of peaks in a Δ window 16: if N peaks in Δ time-lapse �Threshold_Athen 17: Classify interval as A label 18: if Threshold_B�N peaks in Δ window �Threshold_Athen 19: Classify interval as B label The algorithm starts with a training stage, in which during the first λsamples, the algorithm does not provide any detection but fills the buffers and calculates the initial trend of the data. Only a notch filter at 50 Hz to remove powerline noise (here, 50 Hz) is used in the signal conditioning stage. During this stage, which lasts as long as the lag time parameter, initial mean (μ), and standard deviation (σ) buffers are filled (See Fig 3). Once the algorithm is trained, it starts the operation mode by processing each incoming sample in three steps: (i) a z-score test Fig 3. ZDensityRODE algorithm flowchart. Block diagram with the workflow of the Z-score Density-based Robust Outlier Detection Estimation algorithm. https://doi.org/10.1371/journal.pone.0309550.g003 PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 7 / 20 relative to μand σ, which are estimated values from previous samples in the signal (Eq 1); (ii) local maxima evaluation by first-derivative test (Eq 2); (iii) refractory period evaluation. z¼xnm sð1Þ xn1<xn�xnþ1<xnð2Þ Where x n is the current sample, μis the historic mean and σis the historic standard deviation. Both historic μand σare implemented as FIFO, storing the λlast samples and recalculating on each sample with the influence parameter depending on the evaluation of the z-score. the μ and σfilters are updated following the expression in Eq 3. When the z-score exceeds the threshold, it indicates a significant and prominent peak, thus, the historical data is updated based on the influence defined by ι. If the z-score test is negative, implying noise or irrelevant information, the filters μand σare updated without considering the influence parameter, that is providing less importance to the current sample. This removes the influence of this value on the adaptation of the threshold. xn i�xi ð1iÞ�xi1 n¼0;1;...;lð3Þ When detecting outliers, these are transformed into intervals by observing the density of spikes over a continuous period of time. The number of events is recorded with a timestamp, which will be used to determine the type of event. The time intervals are measured based on the event length, the up-spike and down-spike, and their proximity to the next peak, using a simple incremental counter. If there are one or more peaks that occur within the integration time interval Δ, the detection window is extended until the peaks are separated by a time greater than the refractory period. When this condition is not met, the integration is stopped and the interval is classified. Interval classification is determined by duration, amplitude, and spike density. These characteristics provide information about event frequency and intensity. Automatic multiscale-based peak detection (AMPDE) The scalogram technique has proven to be effective and reliable in identifying peaks, especially in scenarios with noise and various peak shapes [32]. This algorithm uses a multiscale decomposition based on scalograms and various windows, followed by peak identification in each row of the scalogram matrix. As demonstrated by Scholkmann et al. [33], this method shows remarkable performance in detecting relevant events. The algorithm comprises six stages: Signal Conditioning, calculation of Local Maxima Scalogram (LMS), determination of optimal scale, LMS rescaling, peak detection, and estimation of peak density for brain activity pattern classification. A comprehensive block diagram of the algorithm is provided in Fig 4, offering a Fig 4. AMPD enhanced algorithm flowchart. Block diagram with the workflow of the Automatic multiscale-based peak detection (AMPDE) algorithm. In the first stage, a bandpass filter between 0.5 and 50 Hz is set. Then an LMS calculation is performed for each window in the signal. A summation of each row in the LMS returns the vector γ, which after a rescaling obtains the final vector of peaks candidate, filtered with an evaluation method to identify the peaks on the vector. https://doi.org/10.1371/journal.pone.0309550.g004 PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 8 / 20 visual representation of each step within the processing pipeline and input/output (I/O) delineation. The algorithm’s pseudocode is also available in Code 2. Its complexity was evaluated, resulting in an O(n 2 ) time complexity. This is because of the nested loops used in the matrix operations that significantly increase the algorithm’s complexity. Code 2.Pseudo code for AMPDE algorithm. Algorithm 2 Automatic Multiscale-based Peak Detection Enhanced (AMPDE) 1: Input: Signal (x), Scale range (k), threshold (α), delta (Δ) 2: Output: Detected peaks p 3: Calculate Linear Detrended Signal x0by subtracting the leastsquares fit of a straight line 4: for kin 2 1 , 2 2 ,. . ., 2 L where L=dN/2e− 1 do 5: for iin k+ 2, k+ 3, . . .,N−k+ 1 do 6: if r+αwhere ris a number 2[0, 1] and α= 1 then 7: mk;i¼0;if xi1>xik1^xi1>xiþk1 rþa;otherwise ( 8: else 9: m k,i = 0 10: end if 11: end for 12: end for 13: Compute Local Maxima Scalogram (LMS) matrix Musing m k,i values 14: Row-wise summation to get gk¼PN i¼1mk;ifor each scale k 15: Find global minimum λ = argmin k γ k 16: Reshape matrix M r by removing elements m k,i for k> λ 17: for iin 1, 2, . . .,Ndo 18: for jin 1, 2, . . ., λ do 19: Calculate σ i using Eq (7) column-wise standard deviation formula 20: end for 21: end for 22: Detect peaks: p= {ijσ i = 0} 23: Peak sorting task 24: for each peak, count all consecutive peaks within a delta (Δ) time do 25: if next peak exceeds the integration (Δ) window then 26: if Number of peaks exceeds classification threshold for ictal then 27: Mark the event as Ictal 28: else 29: if Within interictal kind of events then 30: Mark the event as Interictal 31: end if 32: end if 33: end if 34: end for =0 Let us now consider a univariate signal, x(i), with N uniformly sampled points, 1 �i�N, containing periodic or quasi-periodic peaks. The first step involves preprocessing the input signal to remove the offset and eliminate the power line interference (here, 50 Hz) by applying a notch filter with a quality factor of 90. Then the LMS is computed by analyzing all input values (x=x 1 ,x 2 ,x 3 ,x 4 ,. . .,x n ) using a moving window approach. The LMS uses the scalogram for the detection of peaks in the time series. The scalogram is the signal’s frequency distribution over time, analogous to the spectrogram. This representation enables the extraction of significant features such as peaks, edges, and patterns. In this work, we are interested in the PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 9 / 20 represent the corresponding results for each dataset, while B) and D) depict the SNR ranges for each recording session. The performance of the algorithms indeed correlates with the SNR. This variability is akin to selecting the MEA channels based on their anatomical position and assessing signal quality for SNR threshold compliance. Despite this variability, the algorithm exhibits an outstanding overall performance. Besides, the correct choice of parameters highly determines the algorithm performance as illustrated in Fig 8E and 8F. Discussion We have proposed a novel methodology for detecting epileptiform activity, addressing the problem through time series segmentation utilizing the ZdensityRODE and AMPDE algorithms. The effectiveness of both algorithms was verified by testing them on epileptiform activity recorded from 4AP-treated rodent brain slices via MEA. Both algorithms demonstrated remarkable performance in detecting ictal activity. It should be noted that these algorithms are capable of detecting interictal events as well, as they perform a time series segmentation task. The detection and classification of ictal and interictal events is typically based on three primary approaches: (i) morphological features, such as maximum amplitude, spike slope, absolute mean of windowed events, and successive spike density [7,14,42,43]; (ii) spectral features, including power content across different frequency bands [7,15,18,43–45]; and (iii) statistical features, encompassing variations in median and variance [7,14,22], kurtosis, and skewness [42]. To improve epilepsy diagnosis and treatment, several seizure detection algorithms have been proposed. In [18], a magnitude and phase synchronization between electrodes could achieve a 66% true positive rate (TPR). Yoo et al [7], used SVM yielding a TPR of 82.7% for seizure classification. Shoeb et al [46] proposed a machine learning technique through a feature vector for the detection of seizures, achieving a 96% of sensitivity and a 2/24h FPR. Kurtosis, skewness, and coefficient of variation from decimate Discrete Wavelet Decomposition were proposed by [47], achieving a precision of 92.66%. Ronchini et al [38], uses entropyand-spectrum features for seizure detection algorithm, boasting an accuracy of 97.8%. In [44], seizure detection is done by decimating discrete wavelet decomposition and interquartile range and mean absolute deviation, obtaining a precision of 84.2%, a sensitivity of 98.5% and latency of 1.76 seconds. Table 4 summarizes the performance and algorithmic approaches for the works mentioned above in a comparative table. Many of those implementations were tailored around the single patient rather than being designed as patient-agnostic approaches. In this regard, there is a great debate on the advantages of one approach over the other [48]. On the one hand, personalized algorithms offer a broad range of adjustable parameters and involve a training process; on the other hand, patient-agnostic approaches employ a fixed-parameter detector without the need for additional training [48,49]. This decision requires a trade-off between detection accuracy, simplicity, and speed. Following any of those approaches determines the accuracy of the algorithm and its applicability to different patients and scenarios. In this study, we have prioritized the perspective development of a seizure detection method that is not patient-specific but, at the same time, implements minimum levels of customization for improved accuracy. The identification of relevant biomarkers in LFP signals poses a significant challenge in the epilepsy field, because of the complex dynamics and different morphologies of ictal and interictal events. Further, the SNR significantly influences the performance of event detection algorithms. In various applications, signal quality assessment techniques improve algorithm performance by preventing unnecessary processing under unfavorable conditions [50,51]. In PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 16 / 20 this work, a low SNR particularly challenged accurate detection by ZdensityRODE, whereas AMPDE proved robust to additive noise, excelling in analyzing frequency bursts. Conclusion We have introduced a TSS approach as a novel strategy for seizure detection, toward improved seizure control via closed-loop brain stimulation. The detection of pathological biomarkers in LFPs recorded from epileptic patients is fundamental for the timely detection (or better, prediction) of seizures to improve brain stimulation strategies for epilepsy treatment. Furthermore, such electrographic biomarkers can provide additional information to advance our understanding of brain states related to epilepsy. ZdensityRODE and AMPDE have proved efficient in biomarkers detection, while using minimal and straightforward computation, as opposed to complex algorithmic approaches, such as neural networks. We believe that these algorithms provide a novel perspective to the field and establish the foundation for a growing subset of algorithms for the classification of epileptiform events and the prediction of seizures. Author Contributions Conceptualization: Gabriel Galeote-Checa, Gabriella Panuccio, Angel Canal-Alonso, Bernabe Linares-Barranco, Teresa Serrano-Gotarredona. Data curation: Gabriel Galeote-Checa, Gabriella Panuccio. Formal analysis: Gabriel Galeote-Checa, Bernabe Linares-Barranco, Teresa SerranoGotarredona. Table 4. Comparative analysis of MEA event detection algorithms. Paper Year Algorithm approach Precision [%] Sensitivity [%] [39] 2016 NLSVM - 95.7 [18] 2011 CORDIC - 66 [7] 2013 SVM - 82.7% [15] 2018 Approximate Entropy + FFT 97.8 - [14] 2015 KNN, SVM, Naive Bayes, logistic regression 80 95.24 [16] 2020 SVM - 100 [36] 2018 CNN - 79.2 [38] 2022 STDP 97.8 85.4 [46] 2010 Feature vector extraction - 96 [47] 2012 Kurtosis, skewness and coefficient of variation from the decimate DWT - 100 [4] 2013 Single window count, Multiple window count, spectral entropy - 94 [44] 2014 Decimate DWT and interquartile range and mean absolute deviation 84.2 98.5 ZdensityRODE 2023 Z-score test with memory buffering strategy (ictal) 93, (interictal) 42 93 AMDPEC 2023 Multiscale peak detection through DWT (ictal) 96, (interictal) 54 90 NLSVM: Non-Linear support vector machines CORDIC: Coordinate rotation digital computer FFT: Fast Fourier transform SVM: Support vector machines STDP: Spike-Timing Dependent Plasticity DWT: Discrete wavelet transform CNN: Convolutional neural networks https://doi.org/10.1371/journal.pone.0309550.t004 PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 17 / 20 Methodology: Gabriel Galeote-Checa. Supervision: Gabriella Panuccio, Angel Canal-Alonso, Bernabe Linares-Barranco, Teresa Serrano-Gotarredona. Validation: Angel Canal-Alonso. Visualization: Gabriel Galeote-Checa. Writing – original draft: Gabriel Galeote-Checa. Writing – review & editing: Gabriel Galeote-Checa, Gabriella Panuccio, Bernabe Linares-Barranco, Teresa Serrano-Gotarredona. References 1. Falco-Walter J. Epilepsy–Definition, Classification, Pathophysiology, and Epidemiology. Seminars in neurology. 2020; 40(6):617–623. https://doi.org/10.1055/s-0040-1718719 PMID: 33155183 2. Galeote-Checa G, Nabaei V, Das R, Heidari H. Wirelessly powered and modular flexible implantable device. ICECS 2020—27th IEEE International Conference on Electronics, Circuits and Systems, Proceedings. 2020. 3. Ray TR, Choi J, Bandodkar AJ, Krishnan S, Gutruf P, Tian L, et al. Bio-integrated wearable systems: A comprehensive review. Chemical Reviews. 2019; 119:5461–5533. https://doi.org/10.1021/acs. chemrev.8b00573 PMID: 30689360 4. Ho JS, Kim S, Poon AS. Midfield wireless powering for implantable systems. Proceedings of the IEEE. 2013; 101(6):1369–1378. https://doi.org/10.1109/JPROC.2013.2251851 5. Galeote-Checa G, Panuccio G, Linares-Barranco B, Serrano-Gotarredona T. Baseline Features Extraction from Microelectrode Array Recordings in an in vitro model of Acute Seizures using Digital Signal Processing for Electronic Implementation. 2021 IEEE International Conference on Omni-Layer Intelligent Systems (COINS). 2021; p. 1–6. 6. Burton A, Obaid SN, Va ´zquez-Guardado A, Schmit MB, Stuart T, Cai L, et al. Wireless, battery-free subdermally implantable photometry systems for chronic recording of neural dynamics. Proceedings of the National Academy of Sciences of the United States of America. 2020; 117:2835–2845. https://doi. org/10.1073/pnas.1920073117 PMID: 31974306 7. Yoo J, Yan L, El-Damak D, Altaf MAB, Shoeb AH, Chandrakasan AP. An 8-Channel Scalable EEG Acquisition SoC With Patient-Specific Seizure Classification and Recording Processor. IEEE Journal of Solid-State Circuits. 2013; 48(1):214–228. https://doi.org/10.1109/JSSC.2012.2221220 8. McGlynn E, Nabaei V, Ren E, Galeote-Checa G, Das R, Curia G, et al. The Future of Neuroscience: Flexible and Wireless Implantable Neural Electronics. Advanced Science. 2021; 8. https://doi.org/10. 1002/advs.202002693 PMID: 34026431 9. Geller EB, Skarpaas TL, Gross RE, Goodman RR, Barkley GL, Bazil CW, et al. Brain-responsive neurostimulation in patients with medically intractable mesial temporal lobe epilepsy. Epilepsia. 2017; 58 (6):994–1004. https://doi.org/10.1111/epi.13740 PMID: 28398014 10. Zijlmans M, Jiruska P, Zelmann R, Leijten FS, Jefferys JG, Gotman J. High-Frequency Oscillations as a New Biomarker in Epilepsy. Annals of Neurology. 2012; 71(2):169–178. https://doi.org/10.1002/ana. 22548 PMID: 22367988 11. Fisher R, Salanova V, Witt T, Worth R, Henry T, Gross R, et al. Electrical stimulation of the anterior nucleus of thalamus for treatment of refractory epilepsy. Epilepsia. 2010; 51(5):899–908. https://doi. org/10.1111/j.1528-1167.2010.02536.x PMID: 20331461 12. Chvojka J, Kudlacek J, Chang WC, Novak O, Tomaska F, Otahal J, et al. The role of interictal discharges in ictogenesis—a dynamical perspective. Epilepsy & Behavior. 2021; 121:106591. https://doi. org/10.1016/j.yebeh.2019.106591 PMID: 31806490 13. Topalovic U, Barclay S, Ling C, et al. A Wearable Platform for Closed-Loop Stimulation and Recording of Single-Neuron and Local Field Potential Activity in Freely Moving Humans. Nature Neuroscience. 2023; 26:517–527. https://doi.org/10.1038/s41593-023-01260-4 PMID: 36804647 14. Page A, Sagedy C, Smith E, Attaran N, Oates T, Mohsenin T. A Flexible Multichannel EEG Feature Extractor and Classifier for Seizure Detection. IEEE Transactions on Circuits and Systems II: Express Briefs. 2015; 62(2):109–113. https://doi.org/10.1109/TCSII.2014.2385211 15. Cheng CH, Tsai PY, Yang TY, Cheng WH, Yen TY, Luo Z, et al. A Fully Integrated 16-Channel ClosedLoop Neural-Prosthetic CMOS SoC With Wireless Power and Bidirectional Data Telemetry for RealPLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 18 / 20 Time Efficient Human Epileptic Seizure Control. IEEE Journal of Solid-State Circuits. 2018; 53 (11):3314–3326. https://doi.org/10.1109/JSSC.2018.2867293 16. Park YS, Cosgrove GR, Madsen JR, Eskandar EN, Hochberg LR, Cash SS, et al. Early Detection of Human Epileptic Seizures Based on Intracortical Microelectrode Array Signals. IEEE Transactions on Biomedical Engineering. 2020; 67(3):817–831. https://doi.org/10.1109/TBME.2019.2921448 PMID: 31180831 17. Aarabi A, He B. Seizure prediction in patients with focal hippocampal epilepsy. Clinical Neurophysiology. 2017; 128(7):1299–1307. https://doi.org/10.1016/j.clinph.2017.04.026 PMID: 28554147 18. Abdelhalim K, Smolyakov V, Genov R. Phase-Synchronization Early Epileptic Seizure Detector VLSI Architecture. IEEE Transactions on Biomedical Circuits and Systems. 2011; 5(5):430–438. https://doi. org/10.1109/TBCAS.2011.2170686 PMID: 23852175 19. Imfeld K, Maccione A, Gandolfo M, Martinoia S, Farine PA, Koudelka-Hep M, et al. Real-time signal processing for high-density microelectrode array systems. Wiley Online Library. 2009; 23:983–998. https:// doi.org/10.1002/acs.1077 20. Ahmadi-Farsani J, Linares-Barranco B, Serrano-Gotarredona T. Digital-signal-processor realization of izhikevich neural network for real-time interaction with electrophysiology experiments. 2019 26th IEEE International Conference on Electronics, Circuits and Systems, ICECS 2019. 2019; p. 899–902. 21. Kim C, et al. Sub-μV rms-Noise Sub-μW/Channel ADC-Direct Neural Recording With 200-mV/ms Transient Recovery Through Predictive Digital Autoranging. IEEE Journal of Solid-State Circuits. 2018; 53(11):3101–3110. https://doi.org/10.1109/JSSC.2018.2870555 22. Rajdev P, Ward MP, Rickus J, Worth R, Irazoqui PP. Real-time seizure prediction from local field potentials using an adaptive Wiener algorithm. Computers in Biology and Medicine. 2010; 40(1):97–108. https://doi.org/10.1016/j.compbiomed.2009.11.006 PMID: 20022319 23. Carmona-Poyato A, Fernandez-Garcia NL, Madrid-Cuevas FJ, Duran-Rosal AM. A new approach for optimal time-series segmentation. Pattern Recognition Letters. 2020; 135:153–159. https://doi.org/10. 1016/j.patrec.2020.04.006 24. Chung FL, Fu TC, Ng V, Luk RWP. An evolutionary approach to pattern-based time series segmentation. IEEE Transactions on Evolutionary Computation. 2004; 8(5):471–489. https://doi.org/10.1109/ TEVC.2004.832863 25. Avoli M, D’antuono M, Louvel J, Ko ¨hling R, Biagini G, Pumain R, et al. Network and pharmacological mechanisms leading to epileptiform synchronization in the limbic system in vitro. Progress in Neurobiology. 2002; 68(3):167–207. https://doi.org/10.1016/S0301-0082(02)00077-1 PMID: 12450487 26. McIntyre DC, Gilby KL. Mapping seizure pathways in the temporal lobe. Epilepsia. 2008; 49:23–30. https://doi.org/10.1111/j.1528-1167.2008.01507.x PMID: 18304253 27. Bartolomei F, Khalil M, Wendling F, Sontheimer A, Re ´gis J, Ranjeva JP, et al. Entorhinal cortex involvement in human mesial temporal lobe epilepsy: an electrophysiologic and volumetric study. Epilepsia. 2005; 46(5):677–687. https://doi.org/10.1111/j.1528-1167.2005.43804.x PMID: 15857433 28. Bartolomei F, Chauvel P, Wendling F. Epileptogenicity of brain structures in human temporal lobe epilepsy: a quantified study from intracerebral EEG. Brain. 2008; 131(7):1818–1830. https://doi.org/10. 1093/brain/awn111 PMID: 18556663 29. Spencer SS, Spencer DD. Entorhinal-hippocampal interactions in medial temporal lobe epilepsy. Epilepsia. 1994; 35(4):721–727. https://doi.org/10.1111/j.1528-1157.1994.tb02502.x PMID: 8082614 30. Panuccio G, Colombi I, Chiappalone M. Recording and modulation of epileptiform activity in rodent brain slices coupled to microelectrode arrays. JoVE (Journal of Visualized Experiments). 2018;(135): e57548. https://doi.org/10.3791/57548 PMID: 29863681 31. Caron D, Canal-Alonso A, Panuccio G. Mimicking CA3 Temporal Dynamics Controls Limbic Ictogenesis. Biology. 2022; 11(3). https://doi.org/10.3390/biology11030371 PMID: 35336745 32. Bishop SM, Ercole A. Multi-Scale Peak and Trough Detection Optimised for Periodic and Quasi-Periodic Neuroscience Data. Acta Neurochir Suppl. 2018; 126:189–195. https://doi.org/10.1007/978-3-31965798-1_39 PMID: 29492559 33. Scholkmann F, Boss J, Wolf M. An Efficient Algorithm for Automatic Peak Detection in Noisy Periodic and Quasi-Periodic Signals. Algorithms. 2012; 5:588–603. https://doi.org/10.3390/a5040588 34. Chung NC, Miasojedow B, Startek M, Gambin A. Jaccard/Tanimoto similarity test and estimation methods for biological presence-absence data. BMC Bioinformatics. 2019; 20(Suppl 15):644. https://doi.org/ 10.1186/s12859-019-3118-5 PMID: 31874610 35. Gregg NM, Marks VS, Sladky V, Lundstrom BN, Klassen B, Messina SA, et al. Anterior nucleus of the thalamus seizure detection in ambulatory humans. Epilepsia. 2021; 62(10):e158–e164. https://doi.org/ 10.1111/epi.17047 PMID: 34418083 PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 19 / 20 36. Truong ND, Nguyen AD, Kuhlmann L, Bonyadi MR, Yang J, Ippolito S, et al. Convolutional neural networks for seizure prediction using intracranial and scalp electroencephalogram. Neural Networks. 2018; 105:104–111. https://doi.org/10.1016/j.neunet.2018.04.018 PMID: 29793128 37. Ronchini M, Zamani M, Huynh HA, Rezaeiyan Y, Panuccio G, Farkhani H, et al. A CMOS-based neuromorphic device for seizure detection from LFP signals. Journal of Physics D: Applied Physics. 2021; 55 (1):014001. https://doi.org/10.1088/1361-6463/ac28bb 38. Ronchini M, Rezaeiyan Y, Zamani M, Panuccio G, Moradi F. NET-TEN: a silicon neuromorphic network for low-latency detection of seizures in local field potentials. Journal of Neural Engineering. 2023; 20 (3):036002. https://doi.org/10.1088/1741-2552/acd029 39. Bin Altaf MA, Yoo J. A 1.83 μJ/Classification, 8-Channel, Patient-Specific Epileptic Seizure Classification SoC Using a Non-Linear Support Vector Machine. IEEE Transactions on Biomedical Circuits and Systems. 2016; 10(1):49–60. https://doi.org/10.1109/TBCAS.2014.2386891 PMID: 25700471 40. de Curtis M, Jefferys JG, Avoli M. Interictal epileptiform discharges in partial epilepsy. Jasper’s Basic Mechanisms of the Epilepsies [Internet] 4th edition. 2012;. 41. Staba RJ, Stead M, Worrell GA. Electrophysiological Biomarkers of Epilepsy. Neurotherapeutics. 2014; 11(2):334–46. https://doi.org/10.1007/s13311-014-0259-0 PMID: 24519238 42. Khan YU, Farooq O, Sharma P. Automatic detection of seizure onset in pediatric EEG. International Journal of Embedded Systems and Applications. 2012; 2(3):81–89. https://doi.org/10.5121/ijesa.2012. 2309 43. Shoaran M, Haghi BA, Taghavi M, Farivar M, Emami-Neyestanak A. Energy-Efficient Classification for Resource-Constrained Biomedical Applications. IEEE Journal on Emerging and Selected Topics in Circuits and Systems. 2018; 8(4):693–707. https://doi.org/10.1109/JETCAS.2018.2844733 44. Ahammad N, Fathima T, Joseph P, et al. Detection of epileptic seizure event and onset using EEG. BioMed research international. 2014; 2014. https://doi.org/10.1155/2014/450573 PMID: 24616892 45. Huang SA, Chang KC, Liou HH, Yang CH. A 1.9-mW SVM processor with on-chip active learning for epileptic seizure control. IEEE Journal of Solid-State Circuits. 2019; 55(2):452–464. https://doi.org/10. 1109/JSSC.2019.2954775 46. Shoeb AH, Guttag JV. Application of machine learning to epileptic seizure detection. In: Proceedings of the 27th international conference on machine learning (ICML-10); 2010. p. 975–982. 47. Das K, Daschakladar D, Roy PP, Chatterjee A, Saha SP. Epileptic seizure prediction by the detection of seizure waveform from the pre-ictal phase of EEG signal. Biomedical Signal Processing and Control. 2020; 57:101720. https://doi.org/10.1016/j.bspc.2019.101720 48. De Cooman T, Vandecasteele K, Varon C, Hunyadi B, Cleeren E, Van Paesschen W, et al. Personalizing heart rate-based seizure detection using supervised SVM transfer learning. Frontiers in Neurology. 2020; 11:145. https://doi.org/10.3389/fneur.2020.00145 PMID: 32161573 49. Birjandtalab J, Jarmale VN, Nourani M, Harvey J. Impact of Personalization on Epileptic Seizure Prediction. In: 2019 IEEE EMBS International Conference on Biomedical & Health Informatics (BHI); 2019. p. 1–4. 50. He J, Liu D, Chen X. Wearable exercise electrocardiograph signal quality assessment based on fuzzy comprehensive evaluation algorithm. Computer Communications. 2020; 151:86–97. https://doi.org/10. 1016/j.comcom.2019.12.051 51. Satija U, Ramkumar B, Manikandan MS. A Review of Signal Processing Techniques for Electrocardiogram Signal Quality Assessment. IEEE Reviews in Biomedical Engineering. 2018; 11:36–52. https:// doi.org/10.1109/RBME.2018.2810957 PMID: 29994590 PLOS ONE Time series segmentation of epileptiform in-vitro MEA recordings PLOS ONE | https://doi.org/10.1371/journal.pone.0309550 January 24, 2025 20 / 20