Manuscript Offprint

arXiv:2610.38558

REVBRAIN: Real-time Probabilistic EEG Forecasting Using Residual Vector Quantization

Hanna Pankka, Jaakko Lehtinen, Timo Roine

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Real-time forecasting of resting-state EEG signals is required by applications like brain-state-dependent stimulation, where computer generated actions are coupled with ongoing neural oscillations. Recently, the deep learning model WaveNet was proposed for the forecasting task. It shows superior accuracy compared to the prevailing method, the linear autoregressive (AR) model, and provides a built-in uncertainty measure due to its probabilistic modeling framework. However, inference using WaveNet is too slow for real-time use due to its sample-by-sample autoregressive operation: a single forecast requires evaluating the model tens or hundreds of times depending on the length of the prediction window.

In this paper, we present REVBRAIN, a probabilistic deep learning method that produces forecasts in real time by generating the forecast over the whole prediction horizon at once. This is achieved by tokenizing the output space using residual vector quantization (RVQ) and generating forecasts over the items in the tokenized space.

We tested REVBRAIN for forecasting 200 ms of EEG time series in the alpha-frequency band (8–13 Hz) and compared our results against WaveNet model. We found that REVBRAIN achieved real-time inference on a laptop GPU and an over 50× speedup compared to WaveNet, while reaching superior prediction accuracy.

By achieving real-time inference speed, REVBRAIN enables incorporating accurate and probabilistic EEG forecasting into BCI applications, opening up new ways for investigating the functioning of the human brain.

Our implementation is available at https://github.com/hpankka/revbrain.

REVBRAIN

1 Introduction

Ongoing neural oscillations are known to play a vital role in how the brain responds to presented sensory inputs and brain stimulation protocols. Examples of these include visual (Busch et al., 2009) and auditory stimuli (Harlow et al., 2024) as well as transcranial magnetic stimulation (Zrenner et al., 2018) and transcranial alternating current stimulation (Kasten & Herrmann, 2022). In recent years there has been rising interest in studying these relationships and utilizing them in therapeutic interventions by coupling stimuli to the neural oscillations in real time through a brain–computer interface (BCI). This has the potential to reveal new insights about the functions of the human brain and enhance individualized stimulation therapies. For example, Bressler et al. (2024) found delivering auditory stimulation during the trough phase of alpha oscillations to improve sleep onset insomnia symptoms. In many of these applications, information from a specific frequency band or about the phase of the oscillation is needed for timing the stimulus. Forecasting resting-state electroencephalography (EEG) signals is then required due to two factors: Firstly, band-pass filtering and algorithmic processing induce delays that need to be bridged with a forecast to pair the stimulus with the desired event. Secondly, calculating the signal's current phase necessitates knowing the direction in which the signal is propagating.

An ideal EEG forecasting algorithm is accurate and fast enough to be used in real time. Previously, only the linear autoregressive (AR) model has been employed for forecasting resting-state EEG signals in BCI applications (Chen et al., 2013; Zrenner et al., 2018). The AR model is fast, but its accuracy is known to fade quickly as longer sequences are forecast, hindering its usability in state estimation tasks. Recently, a probabilistic deep learning model, WaveNet, was proposed for the forecasting task (Pankka et al., 2025). This approach has two major advantages over the AR model. Firstly, deep learning models can achieve superior prediction accuracy compared to simpler linear models. Secondly, the probabilistic framework yields a measure of uncertainty, which can be essential in applications that require high precision. However, WaveNet is too slow to produce forecasts in real-time due to autoregressive sampling: the model predicts samples one at a time, feeding the whole signal generated thus far back through the model to produce the next sample. This major drawback prevents its use in BCI applications.

To solve this, we propose a model using REsidual Vector quantization for BCI compatible RApid INference (REVBRAIN). Our approach is to redefine the output space such that it allows generating a probabilistic forecast over the whole prediction window in a single pass instead of predicting time steps one by one. This is achieved by tokenizing the output time series with residual vector quantization (RVQ) and forming the forecast over the items in the tokenized space rather than over individual samples. REVBRAIN is the first probabilistic deep learning model developed for forecasting resting-state EEG signals in real-time.

In this article, we explain the modeling concept of REVBRAIN and show how it can be used to forecast EEG signals 200 milliseconds into the future in the alpha-

REVBRAIN

frequency band (8–13 Hz). We compare our results to the autoregressive WaveNet model and find that REVBRAIN achieves an over 50× speedup in inference time, while surpassing the forecasting accuracy of WaveNet. Moreover, we present a probabilistic phase detection algorithm that utilizes the uncertainty in the outputs of REVBRAIN to determine whether a phase should be estimated or not. Finally, we show that REVBRAIN could be used in a real-time experiment by proposing a realistic usage pipeline that demonstrate the expected full latency when using the model in a BCI setting.

References (44)