pyOpenNFT: An Open-Source Python Framework for ML-Based Real-Time fMRI and EEG-fMRI Neurofeedback
摘要
Real-time functional magnetic resonance imaging (rt-fMRI) is a powerful neuroimaging tool for monitoring brain activity and neurofeedback (NF) applications with promising therapeutic potential in psychiatric and neurological disorders. However, technical implementation of NF using acquired real-time fMRI and/or predicted real-time fMRI signals based on electroencephalographic (EEG) records remains restrictive and often lacks reproducibility. Here, a fully Python-based pyOpenNFT framework was designed for greater flexibility, modularity, and real-time processing efficiency. Its functionality was also extended with a ML-based prediction server for the fMRI NF signal using processed EEG records. The framework streamlines fMRI data acquisition and/or EEG-based prediction, NF signal estimation, and quality assessment (rtQA) without necessarily requiring a GUI. The FastAPI-based implementation for an EEG-based predictor integrates a Lab Streaming Layer (LSL) interface for processed EEG records and delivers real-time predictions of fMRI time-series for target brain regions. The system supports the visualization of additional NF sources by querying a RESTful interface, facilitating interoperability with external applications. Efficient real-time processing is achieved through parallelized workflows, optimized data handling, and shared memory buffers for seamless exchange of brain volumes, time-series data, and rtQA metrics. With open-source code available on GitHub , pyOpenNFT advances multimodal real-time neuroimaging and extends the platform for scientific, clinical and educational applications.