BeMoBIL-MNE#

BeMoBIL-MNE is a Python library for EEG and multimodal Mobile Brain/Body Imaging (MoBI) data processing, developed at the Biopsychology & Neuroergonomics department at TU Berlin.

It provides a full analysis stack built on top of MNE-Python:

  • Multimodal loading - read XDF recordings and align auxiliary streams (ECG, gaze, EMG, EDA) to a common time grid using the XDFLoader.

  • EEG preprocessing pipeline - ZapLine line-noise removal → bad channel detection → bandpass filter → optional ASR → AMICA/ICA → ICLabel classification → dipole fitting, all in one EEGPreprocessor call with full provenance tracking.

  • BIDS export - write cleaned datasets to the BIDS standard via export_to_bids().

  • Motion capture - rigid-body kinematics from XDF motion streams via find_rigid_bodies().

  • Visualization - ERP, PSD, TFR, and topomap plots built on MNE and matplotlib.

The pipeline is designed to replicate and extend the MATLAB-based BeMoBIL pipeline in Python, sharing the same preprocessing defaults where meaningful. See Comparison with the BeMoBIL pipeline for a full comparison and migration example.


Installation#

git clone https://github.com/BeMoBIL/bemobil-mne.git
cd bemobil-mne
pip install -e .

Quick start#

from bemobil_mne.io import XDFLoader
from bemobil_mne.preproc import EEGPreprocessor

# 1. Load a multimodal XDF recording
loader = XDFLoader(
    montage="standard_1020",
    target_sfreq=250.0,
)
recording = loader.load("sub-01_task-walk_run-01.xdf")
raw = recording.raw          # mne.io.Raw with EEG + aux channels merged

# 2. Run the full preprocessing pipeline
preprocessor = EEGPreprocessor(
    loader=loader,
    line_noise_freq="europe",   # 50 Hz + harmonics up to Nyquist
    zapline_method="adaptive",  # ZapLine-Plus before filtering
)
raw_clean, report, metadata = preprocessor.run_raw(raw, fname_out="sub-01_clean.fif.gz")

# raw_clean : ICA-cleaned, average-referenced, bad channels interpolated
# report    : mne.Report HTML summary (saved alongside output)
# metadata  : dict with raw_minimal, raw_asr, ica, ic_labels, bad_ch_dict, …