Skip to main content

EEG preprocessing pipeline on Python

Project description

EEGPrep

EEGPrep is a Python package that reproduces the EEGLAB default preprocessing pipeline with numerical accuracy down to 1e-5 uV, including clean_rawdata and ICLabel, enabling MATLAB-to-Python equivalence for EEG analysis. It takes BIDS data as input and produces BIDS derivative dataset as output, which can then be reimported into other packages as needed (EEGLAB, Fieldtrip, Brainstorm, MNE). It does produce plots. The package will be fully documented for conversion, packaging, and testing workflows, with installation available via PyPI.

Pre-Release

EEGPrep is currently in a pre-release phase. It functions end-to-end (bids branch) but has not yet been tested with multiple BIDS datasets. The documentation is incomplete, and use is at your own risk. The planned release is scheduled for the end of 2025.

Install

To install the complete EEGPrep including the ICLabel classifier (which can pull in ~7GB of binaries on Linux), use the following line:

pip install eegprep[all]

To install the lean version:

pip install eegprep

You can then manually install a lightweight CPU-only version of PyTorch if desired by your operating system.

Comparing MATLAB and Python implementations

The MATLAB and Python implementations were compared using the first two subjects from the BIDS datasets ds003061 and ds002680 available on NEMAR. The observed differences were extremely small, with the largest (during HighpassFilter) below 0.002, indicating excellent numerical consistency between the two implementations.

Screenshot 2025-10-02 at 11 43 03

Docker (SCCN Power Users)

Build Docker

versioning

  • pyproject version (change version inside file)
  • main version (change version inside file)
  • git tag
  • docker version when building (see below)

building

docker build -t eegprep:0.2.3 -f DOCKERFILE .
docker tag eegprep:0.2.1 arnodelorme/eegprep:0.2.3
docker push arnodelorme/eegprep:0.2.3  

Mounted folder in /usr/src/project

PYPI Release Process (Maintainers Only)

Quick Release Workflow

Use the release script for streamlined releases:

python scripts/make_release.py

The script will:

  1. Check prerequisites (build, twine, git status)
  2. Confirm the version from pyproject.toml
  3. Let you choose: test release, production release, or both
  4. Build and upload the package (automatically uses eegprep_test name for TestPyPI)
  5. Create and push git tags for production releases

Note: The script automatically handles a TestPyPI naming conflict by building a package with the name eegprep_test for test releases.

Prerequisites

Install build tools:

pip install build twine

API Tokens

  • Get API token for PyPI and TestPyPI (both maintainers should have these)
  • Twine will prompt for them during upload
  • Store them in ~/.pypirc for convenience

Manual Release Process

Recommended: Use scripts/make_release.py instead to avoid manual errors with package naming.

If you need to release manually:

1. Update version in pyproject.toml

2. Test release (staging):

Note: A former maintainer owns the eegprep package name on TestPyPI, so you will not be able to post a package named eegprep there at this time. To work around this when performing the build manually (note the make_release.py script handles this for you), temporarily change the package name to eegprep_test in pyproject.toml before building. Remember to change it back to eegprep after uploading!

# In pyproject.toml, temporarily change: name = "eegprep" to name = "eegprep_test"
python -m build
python -m twine upload --repository testpypi dist/*
# Change name back to "eegprep" in pyproject.toml

# Test the installation:
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ eegprep_test==X.Y.Z
# (imports still work as 'import eegprep')

3. Production release:

python -m twine upload dist/*
git tag -a vX.Y.Z -m "Release version X.Y.Z"
git push origin vX.Y.Z
pip install eegprep==X.Y.Z

Documentation

https://packaging.python.org/en/latest/tutorials/packaging-projects/

Install Package

Packaging was done following the tutorial: https://packaging.python.org/en/latest/tutorials/packaging-projects/ with setuptools

To install the package with all optional dependencies, run:

pip install eegprep[all]

Running Tests

Install MATLAB interface pip install /your/path/to/matlab/extern/engines/python Use tests/main_compare.m

This project uses unittest. You can run tests from the project root via the command:

python -m unittest discover -s tests

...or use the unittest integration in your IDE (e.g., PyCharm, VS Code, or Cursor).

Core maintainers

  • Arnaud Delorme, UCSD, CA, USA
  • Christian Kothe, Intheon, CA, USA
  • Bruno Aristimunha Pinto, Inria, France

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eegprep-0.2.3.tar.gz (11.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eegprep-0.2.3-py3-none-any.whl (11.0 MB view details)

Uploaded Python 3

File details

Details for the file eegprep-0.2.3.tar.gz.

File metadata

  • Download URL: eegprep-0.2.3.tar.gz
  • Upload date:
  • Size: 11.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for eegprep-0.2.3.tar.gz
Algorithm Hash digest
SHA256 6593f2ab48e0ff92d1277e65e13888b4d01183f4592eb81c0abd0b0252ad9012
MD5 c9c482db4d820add9750c514183d316a
BLAKE2b-256 d4f18d03051662cb6e356d9202e00fe94d1ef282e321fc9d0bbcb1895d190d30

See more details on using hashes here.

File details

Details for the file eegprep-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: eegprep-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 11.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for eegprep-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 156d4c45f73e32e5708f44cc9f23f517ef175b3815199c0e7fa7a34b4d65a3cf
MD5 80b609bda2abdb96817474107625e0a3
BLAKE2b-256 e1dc0d79dd5e8dbf0c134b1fd4d41ec051bbb689380e0014bad8094cdf2bae39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page