← WritingsBA44

Sequential Change-Point Detection for Chronic Neural Interfaces using Adaptive Thresholds Under an Electrode Degradation Model

May 2026

Abbreviations

AbbreviationDefinition
ARLAverage run length
ARL₀ARL under the null hypothesis
CUSUMCumulative sum
EMAExponential moving average
FPFalse positive
H₀, H₁Null and alternative hypotheses
KLKullback–Leibler
LFPLocal field potential
LLRLog-likelihood ratio
MCMonte Carlo
RNSResponsive neurostimulation
SNRSignal-to-noise ratio
SPRTSequential probability ratio test
SRShiryaev–Roberts
TLETemporal lobe epilepsy

Introduction

Background and Motivation

Drug-resistant temporal lobe epilepsy (TLE) affects roughly one-third of the 50 million people worldwide living with epilepsy [1]. The NeuroPace responsive neurostimulation (RNS) system is the current clinical standard; however, it monitors only two anatomical targets via eight contact electrode arrays, with stimulation latencies exceeding 1 second [2,3]. TLE seizures are network-scale events with onset in the hippocampus and propagation through the amygdala, thalamus, and temporal cortex within seconds. Since the seizure onset time is unknown a priori, the detection problem can be framed as a quickest change-point detection problem, as described by Wald [4], Lorden [5], and Shiryaev [6].

Stochasticity is present across all levels: seizure onset time can be modeled as a random variable (RV); local field potential (LFP) recordings are ridden with Brownian-motion-type noise with long-term shifts in variance and attenuation in signal-to-noise ratio due to immune response and glial encapsulation of electrodes [7]; and seizure propagation delays across network nodes are RVs drawn from patient-specific anatomy and connectivity. A stochastic framework for data processing is thus required. Prior work has demonstrated that cumulative-sum (CUSUM)-based seizure detectors can outperform fixed-window classifiers for both scalp and intracranial EEG recordings in terms of detection latency, while maintaining comparable false-positive rates, motivating a deeper look into sequential methods and their robustness to the chronic signal degradation inherent in implanted interfaces [8, 9].

This project provides (1) a chronic degradation model capturing both signal attenuation and noise increases, (2) Monte Carlo validation of analytically derived performance bounds for three sequential detectors, and (3) a 6-month simulation to compare both fixed and adaptive thresholds.

Central Hypothesis

I hypothesize that adaptive-threshold sequential change-point detectors (SPRT, CUSUM, Shiryaev–Roberts), applied to a hidden Markov observation model of seizure dynamics with Gaussian diffusion observations, will maintain clinically viable detection performance over a simulated six-month chronic period despite impedance-driven SNR degradation from glial encapsulation, whereas fixed-threshold detectors will exhibit measurable deterioration in both detection delay and false positive rate over the same period.

Mathematical Background

The Log-Likelihood Ratio

Most sequential detection procedures monitor a constant stream of observations and, stepwise, ask whether the distribution has changed. The standard feature used as evidence is the log-likelihood ratio (LLR). Given a sequence of observations E1,E2,E_1, E_2, \ldots drawn independently from one of two distributions, under the null hypothesis H0H_0 each observation has density f0f_0, and under H1H_1 each has density f1f_1. The log-likelihood ratio for any one observation is thus:

λn=log(f1(En)f0(En))(1)\lambda_n = \log\left(\frac{f_1(E_n)}{f_0(E_n)}\right) \tag{1}

This ratio is positive when EnE_n is more likely under H1H_1 than under H0H_0, and negative otherwise. For this study, given a shift in the mean θ\theta, the Gaussian distributions that result are H0N(0,σ2)H_0 \sim \mathcal{N}(0,\sigma^2) and H1N(θ,σ2)H_1 \sim \mathcal{N}(\theta,\sigma^2) for θ>0\theta > 0. In this case, the LLR reduces to:

λn=θσ2Enθ22σ2(2)\lambda_n = \frac{\theta}{\sigma^2} E_n - \frac{\theta^2}{2\sigma^2} \tag{2}

Here, the first term is directly proportional to the observation, so large values of EnE_n provide stronger evidence for H1H_1. The second term accounts for the size of the shift. Under H0H_0, the expected increment is E0[λn]=θ2/(2σ2)<0\mathbb{E}_0[\lambda_n] = -\theta^2/(2\sigma^2) < 0, so the accumulated evidence drifts toward H0H_0. Under H1H_1, the sign is reversed and the LLR drifts toward H1H_1.

When the variances differ between the hypotheses, H0N(0,σ02)H_0 \sim \mathcal{N}(0,\sigma_0^2) versus H1N(θ,σ12)H_1 \sim \mathcal{N}(\theta,\sigma_1^2), the LLR becomes:

λn=logσ0σ1(Enθ)22σ12+En22σ02(3)\lambda_n = \log\frac{\sigma_0}{\sigma_1} - \frac{(E_n-\theta)^2}{2\sigma_1^2} + \frac{E_n^2}{2\sigma_0^2} \tag{3}

This is quadratically related to EnE_n (unlike the equal-variance case).

The Sequential Probability Ratio Test

Wald’s Sequential Probability Ratio Test (SPRT) [4] accumulates the LLR over time and stops when a boundary is reached:

ΛN=n=1Nλn,T=inf{N:ΛN(A,B)}(4)\Lambda_N = \sum_{n=1}^{N} \lambda_n, \qquad T = \inf\{N : \Lambda_N \notin (A,B)\} \tag{4}

where A<0<BA < 0 < B. If ΛN>B\Lambda_N > B, decide H1H_1; if ΛN<A\Lambda_N < A, decide H0H_0. In this study, when H0H_0 is declared the SPRT is reset and rerun continuously.

Per Wald, with false-positive probability α\alpha and false-negative probability β\beta:

Alogβ1α,Blog1βα(5)A \approx \log\frac{\beta}{1-\alpha}, \qquad B \approx \log\frac{1-\beta}{\alpha} \tag{5}

For α=β=0.01\alpha = \beta = 0.01, this yields A=4.6A = -4.6 and B=4.6B = 4.6. Expected sample sizes under each hypothesis are:

E0[T](1α)A+αBE0[λ],E1[T](1β)B+βAE1[λ](6)\mathbb{E}_0[T] \approx \frac{(1-\alpha)A + \alpha B}{\mathbb{E}_0[\lambda]}, \qquad \mathbb{E}_1[T] \approx \frac{(1-\beta)B + \beta A}{\mathbb{E}_1[\lambda]} \tag{6}

Cumulative Sum

SPRT assumes the distribution lies at either H0H_0 or H1H_1 from the start. For seizure detection, the distribution starts at H0H_0 and transitions to H1H_1 at an unknown time ν\nu. Page’s CUSUM [2] discards evidence favoring H0H_0:

Wn=max(0,Wn1+λn),W0=0(7)W_n = \max(0,\, W_{n-1} + \lambda_n), \quad W_0 = 0 \tag{7} T=inf{n:Wn>h}for a threshold h>0(8)T = \inf\{n : W_n > h\} \quad\text{for a threshold } h > 0 \tag{8}

The detection delay under H1H_1 is approximately:

E1[delay]hE1[λ](9)\mathbb{E}_1[\mathrm{delay}] \approx \frac{h}{\mathbb{E}_1[\lambda]} \tag{9}

and the average run length under H0H_0 satisfies an exponential bound of the form

ARL0eζhζE0[λeζλ](10)\mathrm{ARL}_0 \approx \frac{e^{\zeta h}}{\zeta\,\mathbb{E}_0[\lambda e^{\zeta\lambda}]} \tag{10}

where ζ\zeta is the positive root of E0[eζλ]=1\mathbb{E}_0[e^{\zeta\lambda}] = 1 (for equal variances, ζ=1\zeta = 1).

The Shiryaev–Roberts Procedure

The Shiryaev–Roberts (SR) procedure [7, 11] aggregates evidence that a change occurred at some past time:

Rn=k=1nj=knf1(Ej)f0(Ej)(11)R_n = \sum_{k=1}^{n} \prod_{j=k}^{n} \frac{f_1(E_j)}{f_0(E_j)} \tag{11}

or recursively:

Rn=(1+Rn1)f1(En)f0(En),R0=0(12)R_n = \left(1 + R_{n-1}\right)\frac{f_1(E_n)}{f_0(E_n)}, \quad R_0 = 0 \tag{12}

with stopping time

T=inf{n:Rn>A}for a threshold A.(13)T = \inf\{n : R_n > A\} \quad\text{for a threshold } A. \tag{13}

The Pareto Frontier

For a sequential detection procedure, a trade-off exists between detection delay and false-positive rate. By sweeping detector thresholds and plotting operating points, relative efficiency can be compared. The Pareto frontier is the set of points at which no procedure achieves both shorter delay and lower false-positive rate.

Methods

State Process and Observation Model

The seizure state is modeled as a continuous-time process X(t){0,1}X(t)\in\{0,1\} where X=0X=0 is interictal and X=1X=1 is ictal. The change point ν\nu is the transition time from 0 to 1. Features used to compute the LLR are high-gamma band energy (70–150 Hz), computed across 100-ms windows at 10 Hz. The feature-level observation model is:

En    X={N(0,σ02)X=0N(θ,σ12)X=1(14)E_n \;\big|\; X = \begin{cases} \mathcal{N}(0,\sigma_0^2) & X=0 \\ \mathcal{N}(\theta,\sigma_1^2) & X=1 \end{cases} \tag{14}

where θ>0\theta>0 is the change in expected high-gamma activity at seizure onset, σ0\sigma_0 is the interictal noise standard deviation, and σ1\sigma_1 is the ictal noise standard deviation. The ratio r=σ1/σ0r=\sigma_1/\sigma_0 is a model parameter (default r=1.5r=1.5), swept over r{1.0,1.2,1.5,2.0}r\in\{1.0,1.2,1.5,2.0\}.

Dual Chronic Degradation Model

Glial scar encapsulation attenuates the recorded signal and raises the noise floor [7, 10]:

θ(t)=θ0(1β(1et/τg))(15)\theta(t) = \theta_0\bigl(1 - \beta(1 - e^{-t/\tau_g})\bigr) \tag{15} σ0(t)=σ0,init(1+α(1et/τg))(16)\sigma_0(t) = \sigma_{0,\mathrm{init}}\bigl(1 + \alpha(1 - e^{-t/\tau_g})\bigr) \tag{16}

with σ1(t)=rσ0(t)\sigma_1(t)=r\,\sigma_0(t). Default parameters: α=0.75\alpha=0.75, β=0.2\beta=0.2, τg=2.5\tau_g=2.5 months, r=1.5r=1.5.

Combined SNR Trajectory

SNR(t)=θ(t)σ0(t)=θ0(1β(1et/τg))σ0,init(1+α(1et/τg))(17)\mathrm{SNR}(t) = \frac{\theta(t)}{\sigma_0(t)} = \frac{\theta_0\bigl(1-\beta(1-e^{-t/\tau_g})\bigr)}{\sigma_{0,\mathrm{init}}\bigl(1+\alpha(1-e^{-t/\tau_g})\bigr)} \tag{17}

At month 6 with the parameters above, θ(6)0.82θ0\theta(6)\approx 0.82\,\theta_0 and σ0(6)1.68σ0,init\sigma_0(6)\approx 1.68\,\sigma_{0,\mathrm{init}}, giving SNR(6)0.49SNR(0)\mathrm{SNR}(6)\approx 0.49\,\mathrm{SNR}(0).

Detector Implementation and Adaptive Estimation

The three algorithms follow the recursions in Eqs. 4, 7–8, and 12–13 on LLR sequences from Eq. 3. Adaptive detectors track σ0\sigma_0 and θ\theta with two-timescale exponential moving averages and recalibrate thresholds daily (SPRT via Eq. 5; CUSUM/SR via target ARL0_0/delay). Monte Carlo evaluation uses 10,000 trials per acute condition and 100 six-month chronic simulations across nine algorithm ×\times threshold-mode combinations (fixed, adaptive-slow, adaptive-fast), plus robustness checks with Student-tt noise and variance-ratio sweeps.

Results

Observation Model and Degradation Dynamics

The full degradation model predicts a 51% drop in SNR after 6 months post-implantation vs a 41% drop for the model that only included variance degradation. This is due to the exclusion of the signal amplitude attenuation in the latter model. The majority of the degradation occurs during the first three months and is driven by τg=2.5\tau_g = 2.5 months (Fig. 1).

Fig. 1: Observation model and degradation dynamics. (A) Synthetic feature sequence with change point. (B) Dual chronic degradation in \theta and \sigma. (C) Combined SNR trajectory under full and variance-only degradation.
Fig. 1: Observation model and degradation dynamics. (A) Synthetic feature sequence with change point. (B) Dual chronic degradation in \theta and \sigma. (C) Combined SNR trajectory under full and variance-only degradation.

Detector Behavior on a Single Trial

All three detectors detect within 10–15 windows of the change point (1–1.5 seconds at 10 Hz). The SPRT demonstrates restarting behavior during the interictal period when boundary AA is reached. The CUSUM statistic remains near 0 during the interictal period due to the max operator. The SR statistic reflects interictal variation by incorporating possible past change points. After the change point, all three statistics show a positive drift and cross the detection boundaries.

Fig. 2: Detector statistic plots on a single trial (r=1.5, \alpha=\beta=0.01). Top: SPRT. Middle: CUSUM. Bottom: SR.
Fig. 2: Detector statistic plots on a single trial (r=1.5, \alpha=\beta=0.01). Top: SPRT. Middle: CUSUM. Bottom: SR.

Pareto Frontier

CUSUM and SR algorithms have shorter detection delays than SPRT at similar false positive rates. The CUSUM and SR empirical plots overlap substantially, whereas SPRT has a higher average false-positive rate for a given detection delay. Analytic predictions align with empirical trends for CUSUM and SR at smaller mean detection delays; the SPRT analytical prediction overestimates the false positive rate but matches the overall trend.

Fig. 3: Pareto frontier at \mathrm{SNR}=1.0 with r=1 for SPRT, CUSUM, and SR (empirical and analytical).
Fig. 3: Pareto frontier at \mathrm{SNR}=1.0 with r=1 for SPRT, CUSUM, and SR (empirical and analytical).

Analytic Validation Across SNR

All three detectors show monotonic behavior. Both ARL0\mathrm{ARL}_0 and detection delay decrease as SNR increases. Detection of H1H_1 occurs much faster than the average stopping time under H0H_0, as expected.

Fig. 4: Analytic vs empirical stopping times across an SNR sweep for SPRT, CUSUM, and SR.
Fig. 4: Analytic vs empirical stopping times across an SNR sweep for SPRT, CUSUM, and SR.

Chronic Detection Delay

Adaptive threshold detectors show clear but modest performance degradation over the six-month simulation (Figure 5). The SPRT exhibits the most severe deterioration, with mean delay increasing from approximately 8 windows at month 0 to approximately 21 windows by month 6. CUSUM and SR degrade less, from approximately 7 to 15 windows. Fixed thresholds demonstrate a steady decrease in detection delay as degradation increases false positives.

Fig. 5: Mean detection delay over 6 months for all 9 conditions (fixed, adaptive-slow, adaptive-fast).
Fig. 5: Mean detection delay over 6 months for all 9 conditions (fixed, adaptive-slow, adaptive-fast).

Chronic False Positive Rate

The fixed-threshold algorithms exhibit a severe increase in the false positive rate, from <20<20 false positives per hour to over 160 by month 2–3 (Fig. 6)—clinically unusable. Adaptive threshold models hover below 20 false positives per hour. This separation is the strongest evidence supporting the central hypothesis, alongside the modest delay increase in Fig. 5.

Fig. 6: False positive rate over 6 months for fixed vs adaptive thresholds across detectors.
Fig. 6: False positive rate over 6 months for fixed vs adaptive thresholds across detectors.

Adaptive Parameter Tracking

The two-timescale EMA estimation procedure can track the evolution of parameters (Fig. 7). Adaptive-fast and adaptive-slow models track the shift in variance; signal-shift estimates show greater discrepancy and tend to overestimate θ\theta. The recalibrated CUSUM threshold hh decreases over six months as parameters drift.

Fig. 7: Adaptive parameter tracking for CUSUM from one Monte Carlo trial.
Fig. 7: Adaptive parameter tracking for CUSUM from one Monte Carlo trial.

Sensitivity Analysis

As expected, detection delay decreases as rr increases from 1.0 to 2.0. Gaussian and Student-tt noise produce very similar false-positive rates under chronic drift, confirming that parameter drift dominates the noise-distribution choice for the conditions tested.

Fig. 8: Sensitivity analysis for variance ratio r and heavy-tailed noise.
Fig. 8: Sensitivity analysis for variance ratio r and heavy-tailed noise.

Conclusion

The central hypothesis predicted that adaptive-threshold detectors would outperform fixed-threshold detectors over the 6-month degradation period. The simulations confirm this: fixed-threshold detectors show decreasing mean detection delay only because false-positive rates explode, whereas adaptive detectors accept a modest delay increase of about 5–10 windows (0.50.511 second) while holding false-positive rates steady. CUSUM and SR outperform SPRT on the Pareto frontier and in chronic simulation; SPRT degrades fastest because its restarting mechanism is more sensitive to miscalibration. Among CUSUM and SR, performance is nearly identical, with CUSUM offering a slightly more practical implementation.

This study shows that quickest-detection algorithms applied to synthetic seizure features retain clinical utility under adaptive thresholds across a 6-month chronic degradation model. Future work may examine fusion across distributed recording nodes for closed-loop stimulation that better matches the network architecture of TLE.

AI Disclosure

I used Claude (Anthropic) to implement simulation infrastructure: the Monte Carlo engine, batch feature generation, figure formatting, and file I/O. I also used it for debugging code and vectorizing inner loops. All mathematical derivations were performed by hand, including the log-likelihood ratios, SPRT threshold algebra, CUSUM ARL0_0 bound, and the miscalibrated-drift analysis motivating adaptive detection. The detector algorithms and analytic bounds were coded from these derivations. Simulation design, analysis, interpretation, and all prose are my own work.

References

[1] Asadi-Pooya, A. A., Stewart, G. R., Abrams, D. J., & Sharan, A. (2017). Prevalence and Incidence of Drug-Resistant Mesial Temporal Lobe Epilepsy in the United States. World Neurosurgery, 99, 662–666.

[2] Nair, D. R. et al. (2020). Nine-year prospective efficacy and safety of brain-responsive neurostimulation for focal epilepsy. Neurology, 95(9), e1244–e1256.

[3] Fisher, R. et al. (2010). Electrical stimulation of the anterior nucleus of the thalamus for treatment of refractory epilepsy. Epilepsia, 51(5), 899–908.

[4] Wald, A. (1945). Sequential tests of statistical hypotheses. Annals of Mathematical Statistics, 16(2), 117–186.

[5] Lorden, G. (1971). Procedures for reacting to a change in distribution. Annals of Mathematical Statistics, 42(6), 1897–1908.

[6] Shiryaev, A. N. (1963). On optimum methods in quickest detection problems. Theory of Probability & Its Applications, 8(1), 22–46.

[7] Polikov, V. S. et al. (2005). Response of brain tissue to chronically implanted neural electrodes. Journal of Neuroscience Methods, 148(1), 1–18.

[8] Zandi, A. S. et al. (2010). Automated real-time epileptic seizure detection in scalp EEG recordings using an algorithm based on wavelet packet transform. IEEE Transactions on Biomedical Engineering, 57(7), 1639–1651.

[9] Osorio, I. et al. (2002). Performance reassessment of a real-time seizure-detection algorithm on long ECoG series. Epilepsia, 43(12), 1522–1535.

[10] Salatino, J. W. et al. (2017). Glial responses to implanted electrodes in the brain. Nature Biomedical Engineering, 1, 862–877.

[11] Pollak, M. (1985). Optimal detection of a change in distribution. Annals of Statistics, 13(1), 206–227.

[12] Tartakovsky, A., Nikiforov, I., & Basseville, M. (2014). Sequential Analysis: Hypothesis Testing and Changepoint Detection. CRC Press.