Advanced Neurofeedback Toolbox
Real-time M/EEG neurofeedback for research and clinical use
ANT is an open-source Python package for real-time closed-loop M/EEG neurofeedback. Built on MNE-Python and the Lab Streaming Layer (LSL), it covers the full pipeline — from amplifier to 3D brain display — in a single, researcher-friendly API.
| Feature | Details |
|---|---|
| 14+ NF modalities | Alpha power, ERD/ERS, laterality, Hjorth, spectral centroid, CFC, graph metrics, source power … |
| Sensor & source space | Full MNE inverse-operator pipeline for source-level NF |
| Real-time artifact correction | ORICA (online ICA), adaptive LMS, GEDAI (GED-based spatial filters) |
| Three parallel windows | Raw stream viewer · NF signal monitor · 3D brain activation |
| OSC output | Send feedback values to Max/MSP, SuperCollider, Pure Data |
| CLI | ANT demo, ANT baseline, ANT run — no Python required |
| Mock mode | Works without hardware using bundled sample EEG data |
pip install ANT # core package (OSC output included)
pip install "ANT[full]" # all extras (viz, dev, docs)Other installation methods
uv (fast Rust-based installer):
uv pip install ANTconda / mamba:
conda env create -f environment.yml
conda activate antDevelopment install from source:
git clone https://github.com/payamsash/ANT.git
cd ANT
pip install -e ".[dev]"Verify the installation:
ANT info # print versions of ANT and all key dependencies
ANT demo # run a 60-second mock neurofeedback sessionfrom ant import NFRealtime
# 1 — Create a session object
nf = NFRealtime(
subject_id="sub01",
visit=1,
session="main",
subjects_dir="/data/subjects",
montage="easycap-M1",
)
# 2 — Connect to a live LSL stream (or a mock replay)
nf.connect_to_lsl(mock_lsl=True)
# 3 — Record a resting-state baseline (computes inverse operator)
nf.record_baseline(baseline_duration=120)
# 4 — Run the closed-loop NF session
nf.record_main(
duration=300,
modality=["sensor_power", "erd_ers", "laterality"],
show_nf_signal=True,
show_brain_activation=True,
)Click to open the interactive diagram
The acquisition loop runs in a background daemon thread; all three visualisation windows share a Qt event loop on the main thread, updated at ~30 fps via a pump timer.
| Key | Description |
|---|---|
sensor_power |
Mean band power across channels |
band_ratio |
Power ratio between two bands (e.g. θ/β) |
erd_ers |
Event-related de/synchronisation (baseline-normalised) |
laterality |
Log power asymmetry right vs. left hemisphere |
hjorth |
Hjorth activity, mobility, complexity |
spectral_centroid |
Frequency-weighted spectral centroid |
entropy |
Spectral / approximate / sample entropy |
argmax_freq |
Dominant frequency peak |
individual_peak_power |
Power at the individual spectral peak |
cfc_sensor |
Cross-frequency coupling (sensor space) |
sensor_connectivity |
Functional connectivity (PLI, correlation) |
sensor_graph |
Graph Laplacian from sensor connectivity |
source_power |
Source-space band power |
source_connectivity |
Source-space functional connectivity |
source_graph |
Graph Laplacian from source connectivity |
# Quick demo — no amplifier needed
ANT demo --duration 60 --modality sensor_power band_ratio
# Record a resting-state baseline
ANT baseline --subject sub01 --subjects-dir /data --duration 120 --mock
# Run a full NF session with OSC output
ANT run --subject sub01 --subjects-dir /data --duration 600 \
--modality sensor_power erd_ers \
--osc-host 127.0.0.1 --osc-port 9000Full documentation, API reference, and gallery examples:
payamsash.github.io/ANT
If you use ANT, please cite:
@inproceedings{shabestari2025advances,
title = {Advances on Real Time M/EEG Neural Feature Extraction},
author = {Shabestari, Payam S and Ribes, Delphine and D{\'e}fayes, Lara
and Cai, Danpeng and Groves, Emily and Behjat, Harry H
and Van de Ville, Dimitri and Kleinjung, Tobias
and Naas, Adrian and Henchoz, Nicolas and others},
booktitle = {2025 IEEE 38th International Symposium on Computer-Based
Medical Systems (CBMS)},
pages = {337--338},
year = {2025},
organization = {IEEE}
}Development was supported by the Swiss National Science Foundation (grant number - 208164 — Advancing Neurofeedback in Tinnitus).
MIT License — © 2025 Payam S. Shabestari