Skip to main content

natMEEG - Naturalistic M/EEG data analysis

PyPI version DOI

Latest released version: v2.0.0 (2026-08-24).

Formerly named pyEEG

natMEEG is a library for processing M/EEG data built mostly on top of MNE-Python and scikit-learn. It is designed for data collected with naturalistic stimuli, so it works with continuous recordings rather than trial-based designs. It supports analysis of continuous M/EEG and generation of temporal response functions from continuous signals or real-valued events (for example, word-level or phoneme-level features).

You can find the documentation here.

⚠️Note:

  • This code repository is actively maintained as part of the natMEEG project. The library provides tools for computing TRFs (Temporal Response Functions) with the TRFEstimator class in pyeeg/models/, which implements memory-efficient and accelerated computation for handling multiple epochs or multiple subjects.
  • The library is suitable for both research and production use.
  • The project was formerly known as pyEEG and has been rebranded to natMEEG to better reflect its focus on naturalistic M/EEG data analysis.

Installation

Dependencies

natMEEG requires:

  • Python (>= 3.10)
  • psutil
  • tqdm
  • NumPy
  • SciPy
  • scikit-learn
  • matplotlib
  • h5py
  • pandas
  • mne (>= 0.16) [optional]

To generate the doc, Python package sphinx (>= 1.1.0), sphinx_rtd_theme and nbsphinx are required.

User Installation

From PyPI

You can install the package from PyPI using pip:

pip install natmeeg

If you want to install docs building dependencies, you can do:

pip install natmeeg[docs]

If you want to install the package with all dependencies (including MNE), you can do:

pip install natmeeg[full]

From Source

If you prefer to install the package from source, you can clone the repository or download release archive or also use the source distribution (.tar.gz file from PyPi) and build it locally. There is a C-extension that needs to compile, so you need to have a C compiler installed on your machine.

From terminal, cd in root directory of the library after cloning this repository (directory containing pyproject.toml file).

To get the package installed only through symbolic links, namely so that you can modify the source code and use modified versions at will when importing the package in your python scripts do:

pip install -e .

Otherwise, for a standard installation, you can run:

pip install .

Windows Users

There are C-extensions in the library, so you need to have a C compiler installed on your machine. If the default compiler does not work, you can try to install Visual Studio Build Tools and try again.

Optionally try with MinGW, making sure after instalation of it to add the path to mingw/bin in your PATH environment variable. You can check if it is correctly installed by running the following command in your terminal:

gcc --version

If this build tool is available it should be detected during build process (running pip install ., pip install -e . or python -m build).

Usage

The most common usage of the library is to compute temporal response functions (TRF) from continuous M/EEG data. The library provides a TRFEstimator class that allows you to fit a TRF model to your data. The TRF model can be used to predict the M/EEG signal from a stimulus signal (e.g. a continuous audio signal or a sequence of word features):

from pyeeg import TRFEstimator

trf = TRFEstimator(tmin=-0.2, tmax=0.5, srate=fs, alpha=100.0) # TRF between -200ms and 500ms, regularization parameter alpha=100.0
trf.fit(X, y) # assuming data loaded: X is the stimulus signal, y is the M/EEG signal, they must have the same number of samples (rows)
print(trf.score(X, y)) # Normally you would use a separate test set for scoring
trf.plot() # plot the TRF

Choosing a Solver

The TRFEstimator auto-selects an appropriate solver by default (SVD-based ridge for regularized fits, ordinary least squares otherwise). For advanced use cases, any Solver subclass can be injected via the solver= parameter:

from pyeeg.solvers import SVDSolver, ConjugateGradientSolver, IRLSSolver

# Fast iterative solver (same results as SVD, often 10-50x faster)
trf = TRFEstimator(tmin=-0.2, tmax=0.5, srate=fs, alpha=100.0,
                   solver=ConjugateGradientSolver())

# Robust fitting with Cauchy loss (downweights outliers)
trf = TRFEstimator(tmin=-0.2, tmax=0.5, srate=fs, alpha=100.0,
                   solver=IRLSSolver(max_iter=50))

See scripts/examples/solver_showcase.py for a full comparison of all solvers.

Examples

See files in examples/.

Computing Envelope TRF and spatial map from CCA

See examples/CCA_envelope.ipynb

Computing Word-feature TRF

See examples/TRF_wordonsets.ipynb

Working with Word vectors

See examples/import_WordVectors.ipynb

Documentation

You can generate an offline HTML version, or a PDF file of all the docs by following the following instructions (HTML pages are easier to navigate in and prettier than the PDF thanks to the nice theme brought by sphinx_rtd_theme).

Generate the documentation

To generate the documentation you will need sphinx to be installed in your Python environment, as well as the extension nbsphinx (for Jupyter Notebook integration) and the theme package sphinx_rtd_theme. Install those with:

pip install natMEEG[docs]

You can access the doc as HTML or PDF format. First get the source documentation files by cloning the repository or downloading the release archive. The documentation is located in the docs folder. To generate the documentation HTML pages, type in a terminal:

For Unix environment (from root directory, as it uses the Makefile):

make doc

For Windows environment (from docs folder, where make.bat is located):

cd docs
make.bat html

Then you can open the docs/build/html/index.html page in your favourite browser.

And for PDF version, simply use docpdf instead of doc above. Then open docs/build/latex/natMEEG.pdf in a PDF viewer.

Note: The PDF documentation can only be generated if latex and latxmk are present on the machine

To clean files created during build process (can be necessary to re-build the documentation):

make clean

License

This project is licensed under the terms of the GPL-3.0 license. See the LICENSE file for details.

Citation

DOI

Weissbart, H. Natmeeg - M/EEG Data Analysis in Naturalistic Context. 1.7.1, Zenodo, 24 Aug. 2026, https://doi.org/10.5281/zenodo.22081524.

Download files

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

Source Distribution

natmeeg-2.1.1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distributions

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

natmeeg-2.1.1-cp313-cp313-win_amd64.whl (894.0 kB view details)

Uploaded CPython 3.13Windows x86-64

natmeeg-2.1.1-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl (913.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.5+ x86-64

natmeeg-2.1.1-cp313-cp313-macosx_10_13_universal2.whl (894.2 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

natmeeg-2.1.1-cp312-cp312-win_amd64.whl (894.0 kB view details)

Uploaded CPython 3.12Windows x86-64

natmeeg-2.1.1-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl (913.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ x86-64

natmeeg-2.1.1-cp312-cp312-macosx_10_13_universal2.whl (894.2 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

natmeeg-2.1.1-cp310-cp310-win_amd64.whl (894.0 kB view details)

Uploaded CPython 3.10Windows x86-64

natmeeg-2.1.1-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl (912.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ x86-64

natmeeg-2.1.1-cp310-cp310-macosx_10_9_universal2.whl (894.1 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file natmeeg-2.1.1.tar.gz.

File metadata

  • Download URL: natmeeg-2.1.1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for natmeeg-2.1.1.tar.gz
Algorithm Hash digest
SHA256 e004c18a0399f93b190778b2d85f22e0467dc06bfd4ad681345b27c092d5c980
MD5 2e2aefc3b3706b3a7055b27666702101
BLAKE2b-256 550fca8690f574fd9b2997dd98a40c81fb8ea967ed76ff65ef64b48323b2416a

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: natmeeg-2.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 894.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for natmeeg-2.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2d82ae3af12d9e73586d713b8624d3299c9a7e6d4cd1503a43c21f8fe5239cec
MD5 07174b713004ab58997507d2925722c5
BLAKE2b-256 a92089b7cb0d8d5ec5b0aefad2b069c89c44446ce0e14a6ba9b25165f60e26a1

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for natmeeg-2.1.1-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 a65843c1a8464d4854881631b9cc9f72afc861bdc3bb9dca32c1cc73b09136f6
MD5 965eedc7056644aed4851fc0c20ff51b
BLAKE2b-256 fefdb59ed8c8f21d0d3fefb60dbf89f5492f289c119d514523304f0044ad6d98

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for natmeeg-2.1.1-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 8f7cbdb0f74866c32bb9560afd9c1cffdb17b1d3b5f134781960e444cba38478
MD5 f9ce5d200bddce765260669b77c4e5b3
BLAKE2b-256 d3607ee77dece76ef28b02e820e1bd97e4f345a8feba8c6264db40f531bb9492

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: natmeeg-2.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 894.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for natmeeg-2.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 87816f5bdfb16510a918bb07d64b01d79806791b5d64635623df7adbd6b3fd6e
MD5 2e53cfea832e9988bfe931cf4dd35c56
BLAKE2b-256 100e83252bb2e61c2bc576b3ee8806bd6813c9dbd4c8592cf37199bcd3c57dde

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for natmeeg-2.1.1-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 90ef123680bccf1ed03326fd23f02ed322d8d5b43263e01ef2efdd068e4debc8
MD5 873a4a2be52e9c45eefac9b763d1a871
BLAKE2b-256 3ee53a0484ec54f2258a64fbfa719df2cdb3c6f113c35aa5ab1b0db0ed48b8e2

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for natmeeg-2.1.1-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 18503bb8b324b8c2d4d005be2980f1977d1237cabeed371209c6b0f044a9c44f
MD5 d81ed6057f0df581d0a03d4387b2f660
BLAKE2b-256 52a042335339fab018b37221018ca329e4235660b9cfd0dc1d4414c2864e0115

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: natmeeg-2.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 894.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for natmeeg-2.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b3c17e5560f07c1ad0e97f7f473a8e2d7f82ee1cd65360a84e0111fde884bee7
MD5 60670e0f8c694c3aafd2da8e0a6a7975
BLAKE2b-256 14d7437a70a57dfa38454e807ad683e6587f35e09e1112f5412155a39a8ba335

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for natmeeg-2.1.1-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 d8450234658f80d02bd5fea7b011eeb9a731a078fd4a2fcf419099b168e2d9a6
MD5 00cd025472b926ac759bcdff3839d434
BLAKE2b-256 91c11e0153e0907087c3bc77465c4b1664e44ced6889b608ecf722a7329a3229

See more details on using hashes here.

File details

Details for the file natmeeg-2.1.1-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for natmeeg-2.1.1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 326b62427be9b4174472bc861a70f17cfc64de008b1ea4b5c753ee24400c4cb6
MD5 559553b34457a7edffd74711d187cc63
BLAKE2b-256 c6298c748a02a068e7ecedfae6d67c98ca2b2c198798b30fad00d903a8af32f6

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.0

10 files

2.1.3

10 files

2.1.2

10 files

This release

2.1.1 This release

10 files

2.1.0

10 files

2.0.2

10 files

2.0.1

10 files

2.0.0

10 files

1.7.1

10 files

1.7.0

9 files

1.6.10

10 files

1.6.8

10 files

1.6.5

4 files

1.6.4

4 files

1.6.0

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page