SafeLens: A Statistically Controlled Nonlinear Machine Learning Framework for Characterizing Hidden Dynamics in Event-Locked Neural Activity

Read the full article See related articles

Listed in

This article is not in any list yet, why not save it to one of your lists.
Log in to save this article

Abstract

Machine learning has advanced rapidly over the past decade, yet event-locked neural activity is still analyzed predominantly with traditional statistics and linear models. While traditional linear methods provide computationally tractable statistical control for pre-selected features or trial-averaged waveforms, they miss subtle nonlinear and trial-varying neural dynamics. Nonlinear models can capture these complex patterns, but their feature reliance is opaque and notoriously difficult to threshold statistically. We introduce SafeLens (Searchlight Analysis of Fluctuation Events, Leveraging Extensive Null Sampling) to combine the power of nonlinear machine learning with the rigorous false-positive control of traditional statistical inference. At each position of a sliding window, a random forest learns to discriminate event-locked activity from interleaved resting-state neural activity using multiscale temporal derivatives. Randomized feature ablation inverts slope polarity in held-out trials to map the random forest models’ reliance on specific rising versus falling excursions across the time-frequency space. SafeLens then establishes an empirical null by running the same pipeline on separate resting-state recordings, training forests to discriminate rest from rest. This empirical null translates each channel’s complex nonlinear resting dynamics into a model-matched noise floor on the map’s linear reliance scale, allowing a single threshold to control the family-wise error rate against the channel’s own background structure rather than a summary statistic of its baseline. When we injected simulated cortico-cortical evoked potentials (CCEPs) into resting intracranial EEG recordings, SafeLens recovered ~2.5 times as many polarity-resolved deflections as trial-average thresholding and the closest data-driven method, maintaining its advantage under trial-to-trial variability while yielding ~5–11 times fewer false components, ~2–5 times lower mean boundary error, and superior single-trial latency tracking as a timing prior. In eight patients, CCEPs remained detectable above chance until 1,040 ms after stimulation, compared with 570 and 455 ms for those benchmarks. Together, these findings establish SafeLens as a novel solution for enabling nonlinear models to uncover subtle, trial-varying neural dynamics under strict statistical control.

Author Summary

Much of what we know about brain function comes from measuring how neural activity responds to specific events, from sensory stimuli and cognitive demands to targeted pulses of brain stimulation. Tracking these responses is fundamental for mapping how brain networks communicate in health and disease and for guiding interventions that modulate neural circuits. Because each response is buried in ongoing background activity and changes across repetitions, isolating it is difficult. Existing methods average repetitions inside short, hand-picked time windows, restricting researchers to seeing only the earliest, most stereotyped part of a response while leaving later, fluctuating activity invisible. Here, we introduce a new approach that combines the pattern-finding sensitivity of modern machine learning with the strict false-positive control of traditional statistics. Our method searches the period after each event without a preset window, using recordings of the brain at rest both to learn how a response differs from normal background activity and to measure what the model detects by chance alone. Using this tool, we show that human brain responses to electrical stimulation last over twice as long as previously recognized, revealing that brief perturbations trigger a longer cascade of neural activity than previously thought.

Article activity feed

  1. SafeLens: A Statistically Controlled Nonlinear Machine Learning Framework for Characterizing Hidden Dynamics in Event-Locked Neural Activity #NeuroDegeneration 🧪🧠 https://www.biorxiv.org/content/10.64898/2026.10.31.763367v1

  2. SafeLens: A Statistically Controlled Nonlinear Machine Learning Framework for Characterizing Hidden Dynamics in Event-Locked Neural Activity https://www.biorxiv.org/content/10.64898/2026.10.31.763367v1

  3. SafeLens: A Statistically Controlled Nonlinear Machine Learning Framework for Characterizing Hidden Dynamics in Event-Locked Neural Activity https://www.biorxiv.org/content/10.64898/2026.10.31.763367v1