Reinforcement Learning via Brain Feedback for real-time fMRI-based adaptive stimulus generation
Preprint
Abstract
Traditional fMRI studies rely on predefined task paradigms, where fixed stimulus designs limit the flexibility with which brain-stimulus relationships can be explored. Here, we introduce Reinforcement Learning via Brain Feedback (RLBF), a framework and open-source software package for adaptive stimulus optimization using real-time fMRI. RLBF reverses the conventional direction of inference by using neural responses to guide the exploration of stimulus spaces through reinforcement learning, enabling optimization of predefined brain targets such as regional activity or multivariate neural signatures. The accompanying Python-based software provides a modular framework integrating real-time fMRI data processing, reinforcement learning agents, adaptive stimulus generation, simulation-based testing, and experiment monitoring. Its flexible architecture allows researchers to customize preprocessing pipelines, reward functions, stimulus spaces, and RL strategies for diverse closed-loop neuroimaging applications. We validate the framework in a proof-of-concept study (N=10), demonstrating real-time optimization of a simple visual stimulus space by adapting checkerboard contrast and frequency to maximize primary visual cortex (V1) responses within a single 10-minute fMRI session. RLBF provides an extensible foundation for brain-guided stimulus optimization and enables new approaches for investigating neural specificity, individualized brain–stimulus relationships, and adaptive experimental design.Keywords
This publication has 40 references indexed in Scilit:
- From Brain Signals to Neuroadaptive Technology: BCIs for Human-Computer Interaction2026
- Self-orthogonalizing attractor neural networks emerging from the free energy principleNeurocomputing, 2026
- The cerebellum contributes to context-effects during fear extinction learning: A 7T fMRI studyNeuroImage, 2022
- The first step for neuroimaging data analysis: DICOM to NIfTI conversionJournal of Neuroscience Methods, 2016
- The Automatic Neuroscientist: A framework for optimizing experimental design with closed-loop real-time fMRINeuroImage, 2016
- Simultaneous multislice (SMS) imaging techniquesMagnetic Resonance in Medicine, 2015
- Real-time fMRI neurofeedback: Progress and challengesNeuroImage, 2013
- FSLNeuroImage, 2012
- Symmetric diffeomorphic image registration with cross-correlation: Evaluating automated labeling of elderly and neurodegenerative brainMedical Image Analysis, 2008
- Detecting Activations in PET and fMRI: Levels of Inference and PowerNeuroImage, 1996