CLI#

MNE-RT provides an mne-rt shell command with five sub-commands.

mne-rt --help
mne-rt --version
mne-rt info
mne-rt demo         [options]
mne-rt demo-erp     [options]
mne-rt baseline     --subject ID --subjects-dir DIR [options]
mne-rt run          --subject ID --subjects-dir DIR --duration N [options]

Global options:

Flag

Default

Description

--verbose, -v

WARNING

Logging verbosity level: DEBUG, INFO, WARNING, or ERROR

mne-rt info#

Print the installed MNE-RT version and all key dependency versions.

$ mne-rt info
MNE-RT — Real-Time M/EEG Analysis
──────────────────────────────────
  mne-rt version : 1.0.0
  Python         : 3.11.9
  mne            : 1.8.0
  ...

mne-rt demo#

Launch a full demo real-time session from simulated EEG (no amplifier needed). The real-time scalp topomap (δ/θ/α/β/γ) is shown by default. The 3-D brain display is enabled automatically when a FreeSurfer fsaverage5 directory is found (via FREESURFER_HOME or --subjects-fs-dir).

$ mne-rt demo
$ mne-rt demo --duration 120 --modality sensor_power erd_ers
$ mne-rt demo --no-topomap
$ mne-rt demo --no-brain

Options:

Flag

Default

Description

--duration

120

Session duration in seconds

--modality

sensor_power band_ratio entropy hjorth

Feature modality(ies) to demonstrate

--winsize

1.0

Analysis window length (s)

--no-nf

Disable the scrolling real-time NF signal plot (NFPlot)

--no-raw

Disable the scrolling raw M/EEG viewer (RawPlot)

--no-topomap

Disable the real-time scalp topomap (enabled by default)

--no-brain

Disable 3-D brain display (auto-enabled when FreeSurfer is found)

--subjects-fs-dir

FreeSurfer subjects directory (auto-detected from FREESURFER_HOME or SUBJECTS_DIR if not given)

--surf

inflated

Brain surface geometry (inflated, pial, or white)

--smoothing

0.25

EMA smoothing factor applied to each feature value (1.0 = no smoothing, 0.1 = heavy smoothing). Lower values produce smoother output at the cost of slower response to real changes in brain activity.

--no-save

Skip saving session data and report

mne-rt demo-erp#

Launch an ERP demo that streams MNE sample-dataset EEG through a mock LSL player, collects auditory epochs trial-by-trial via RTEpochs, and drives the four epoch visualisation windows. Downloads the MNE sample dataset on first run (~1.5 GB).

$ mne-rt demo-erp                          # all four plot windows
$ mne-rt demo-erp --n-trials 50            # stop after 50 trials
$ mne-rt demo-erp --no-tfr                 # skip the TFR heatmap
$ mne-rt demo-erp --no-compare --no-tfr    # TopoPlot + ButterflyPlot only

Options:

Flag

Default

Description

--n-trials

70

Number of EEG trials to collect before stopping

--no-topo

Disable the scalp-layout TopoPlot (ERP display)

--no-butterfly

Disable the ButterflyPlot (all-channel overlay)

--no-compare

Disable CompareEvoked (per-channel comparison)

--no-tfr

Disable the TFRPlot (Morlet wavelet heatmaps)

mne-rt baseline#

Record a resting-state baseline and compute the noise covariance and inverse operator needed for source-space modalities.

$ mne-rt baseline --subject sub01 --subjects-dir /data/subjects
$ mne-rt baseline --subject sub01 --subjects-dir /data --duration 180 --mock
$ mne-rt baseline --subject sub01 --subjects-dir /data --mock \
                  --fname /path/to/recording.fif

Required:

  • --subject ID — subject identifier string

  • --subjects-dir DIR — root directory with one folder per subject

Options:

Flag

Default

Description

--duration

120

Baseline duration in seconds

--session

01

BIDS session label (e.g. 01, pre, week1)

--mock

Use simulated data instead of live LSL

--fname

Any MNE-readable file (.fif, .vhdr, .edf, .bdf, .set, …) for --mock playback

--montage

easycap-M1

EEG montage name or .bvct path

--data-type

eeg

eeg or meg

--subjects-fs-dir

FreeSurfer subjects directory (required for source-space modalities)

mne-rt run#

Run a real-time M/EEG session with feature extraction, feedback protocols, and live visualisation.

$ mne-rt run --subject sub01 --subjects-dir /data --duration 600 \
             --modality sensor_power erd_ers

# With epoch plots (requires a stimulus channel in the recording)
$ mne-rt run --subject sub01 --subjects-dir /data --duration 600 \
             --modality sensor_power \
             --topo --tfr --stim-ch "STI 014" \
             --event-id left=1 right=2

# With topomap display
$ mne-rt run --subject sub01 --subjects-dir /data --duration 600 \
             --modality sensor_power --topomap

# With OSC output to Max/MSP
$ mne-rt run --subject sub01 --subjects-dir /data --duration 600 \
             --modality sensor_power --osc-host 127.0.0.1 --osc-port 9000

# With LSL output (faster, same-machine integration)
$ mne-rt run --subject sub01 --subjects-dir /data --duration 600 \
             --modality sensor_power --lsl-output

# From a mock file with artifact correction
$ mne-rt run --subject sub01 --subjects-dir /data --duration 300 \
             --mock --fname /data/sub01/session.fif \
             --artifact-correction asr --topo

Options (inherits all baseline flags above, plus):

Flag

Default

Description

--duration

required

Session duration in seconds

--modality

sensor_power

One or more feature modalities (space-separated). See table below.

--winsize

1.0

Analysis window length (s)

--artifact-correction

lms, orica, gedai, asr, or maxwell (MEG only)

--no-nf

Disable the scrolling real-time NF signal plot (NFPlot)

--no-raw

Disable the scrolling raw M/EEG viewer (RawPlot)

--topomap

Enable real-time scalp topomap (δ/θ/α/β/γ bands)

--brain

Enable 3-D brain display (requires inverse operator)

--topo

Enable TopoPlot ERP display (requires --stim-ch)

--butterfly

Enable ButterflyPlot (requires --stim-ch)

--compare-evoked

Enable CompareEvoked (requires --stim-ch)

--tfr

Enable TFRPlot Morlet wavelet heatmap (requires --stim-ch)

--stim-ch

Stimulus/trigger channel name, e.g. STI 014 — required when any epoch plot flag is used

--tmin

-0.1

Epoch start relative to stimulus (s)

--tmax

0.5

Epoch end relative to stimulus (s)

--event-id

stimulus=1

Condition definitions as NAME=CODE pairs, e.g. --event-id left=1 right=2

--surf

inflated

Brain surface geometry

--osc-host

Enable OSC output; target hostname (e.g. 127.0.0.1)

--osc-port

9000

OSC destination port

--osc-prefix

/mne_rt

OSC address prefix

--lsl-output

Push feature values into an LSL stream outlet (faster than OSC for same-machine integration; readable by PsychoPy, Psychtoolbox, …)

--lsl-stream-name

MNE_RT

LSL stream name (only with --lsl-output)

--smoothing

0.25

EMA smoothing factor applied to each feature value (1.0 = no smoothing, 0.1 = heavy smoothing)

Available feature modalities#

Modality key

Description

sensor_power

Mean band power across channels

band_ratio

Power ratio between two frequency bands (e.g. θ/β)

erd_ers

Event-related de/synchronisation (baseline normalised)

laterality

Log power asymmetry between right and left hemispheres

laterality_erd_ers

ERD/ERS computed separately per hemisphere

hjorth

Hjorth activity, mobility, complexity (time-domain)

spectral_centroid

Frequency-weighted spectral centroid

entropy

Spectral, approximate, or sample entropy

argmax_freq

Dominant frequency peak

individual_peak_power

Power at the individualised spectral peak

cfc_sensor

Cross-frequency coupling (sensor space)

instantaneous_phase

Instantaneous phase and amplitude envelope via Hilbert analytic signal

scp

Slow cortical potential — low-pass mean amplitude shift (DC-coupled)

peak_alpha_freq

Real-time peak alpha frequency tracker with EMA smoothing

sensor_connectivity

Functional connectivity (coh, plv, pli, wpli, corr, …); method set in config

connectivity_ratio

Ratio of connectivity between two channel pairs (e.g. C3–C4 / F3–F4)

sensor_graph

Graph-Laplacian learning from sensor connectivity

source_power

Source-space band power (requires inverse operator)

source_connectivity

Source-space functional connectivity

source_graph

Graph-Laplacian learning from source connectivity

For the mathematical background of every modality, see Real-time Feature Modalities.

Real-time visualisation#

All eight plot windows are available as CLI flags and can be combined freely:

Flag

Plot class

--nf (default on)

NFPlot — scrolling multi-channel NF signal monitor

--raw (default on)

RawPlot — scrolling raw M/EEG channel viewer (bad-channel / bad-segment marking)

--epoch-plot

EpochPlot — scrolling raw viewer with trigger/epoch overlays (requires --stim-ch)

--topomap

TopomapPlot — live per-band scalp topography

--brain

BrainPlot — interactive 3-D cortical surface

--topo

TopoPlot — scalp-layout ERP with ±SEM shading

--butterfly

ButterflyPlot — all channels overlaid, region-coloured

--compare-evoked

CompareEvoked — per-channel comparison with SEM ribbons

--tfr

TFRPlot — Morlet wavelet TFR heatmaps

The first four (--nf, --raw, --topomap, --brain) work with continuous feature extraction (mne-rt run). The epoch-based windows (--epoch-plot, --erp, --butterfly, --compare-evoked, --tfr) require --stim-ch. Use mne-rt demo-erp to try them without a live recording.

See Visualisation for screenshots and feature descriptions of each plot.