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.3.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.3-cp313-cp313-win_amd64.whl (895.7 kB view details)

Uploaded CPython 3.13Windows x86-64

natmeeg-2.1.3-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl (914.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.5+ x86-64

natmeeg-2.1.3-cp313-cp313-macosx_10_13_universal2.whl (895.9 kB view details)

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

natmeeg-2.1.3-cp312-cp312-win_amd64.whl (895.7 kB view details)

Uploaded CPython 3.12Windows x86-64

natmeeg-2.1.3-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl (914.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ x86-64

natmeeg-2.1.3-cp312-cp312-macosx_10_13_universal2.whl (895.9 kB view details)

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

natmeeg-2.1.3-cp310-cp310-win_amd64.whl (895.7 kB view details)

Uploaded CPython 3.10Windows x86-64

natmeeg-2.1.3-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl (914.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ x86-64

natmeeg-2.1.3-cp310-cp310-macosx_10_9_universal2.whl (895.8 kB view details)

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

File details

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

File metadata

  • Download URL: natmeeg-2.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 bc437ca219a9bbe068583c0b9bb2634b4803bf37eeefc665160eac1ac06c8ca7
MD5 ed3cfc37747bbcd88f0573f03ad5db81
BLAKE2b-256 7f26576b42000ddfd1eacca55555da9a1a836b1d2ba0798ec0902348fd5c9f9b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: natmeeg-2.1.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 895.7 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7c024be0c2f6b15d82efd4b4f36f1b0277cadabffd29f3378239b2c5b9bdad68
MD5 14647b6d786e310c5b46e63732960c2f
BLAKE2b-256 60d88f215e5cf4fdbc9f60030aceba5f1dbe2a6fa972fce3406cdc35238ed97f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-2.1.3-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 a8aecc3ec6db7eea69861c0e95655dfb6b604faa3533433cb793e75711abfa2f
MD5 6b96054a9055d90c5ea46d45eb29296c
BLAKE2b-256 ccae6746b3c695705343d0b8e28183e73d1ed2203f76145498335255cc0b4ed6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-2.1.3-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 27574ad9b3f0ba3aa44c1a0929376549d03d2ae59fd0e8e4b10b9f3146dc0836
MD5 162e14ce7e0002ca9a79c1bcc4f911b6
BLAKE2b-256 4f3dfbdcebeea6a32d194ebbc3bca5182006acf64ba9bd7de3d8a245def74d0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: natmeeg-2.1.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 895.7 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9f070f6eaa3897d8016b589c1eccee7b87d912460733ab3e941eae2a3ab6f140
MD5 96573f7cc066795555234df3d7d84e3a
BLAKE2b-256 043e5cda84e68c63f2fc08db678a1a023cff1f496759b92dc00f6818dfbc0602

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-2.1.3-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0a98070bd4e9e6325f467accf82af656e96458c7b8b02f94adae586306d55041
MD5 4e9c3c227455916ce6180acdd126c962
BLAKE2b-256 dc96de8d7a3d1453afa4e9598c2999dd4a41c6a101a4d2c7f91abf8b0e328193

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-2.1.3-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 5f3f332a6ae029b149a82c9606ca4a1266232321069b20f48f466fc3e9a3f9b3
MD5 6f737f14a7bbbc74f8494c571c18a3d5
BLAKE2b-256 a4b0e303c54f07f3581b17d5adb7e68f04a6af997700eae03ef52af93c79eebd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: natmeeg-2.1.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 895.7 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 da3f3ccde3b612292dbafe3e03d9fee0268b7ff84aefb0a84759e928e42b06ce
MD5 5cd6b99c50cbfec857d55762b130af51
BLAKE2b-256 5fedab2754e01359094721587a3efc0914382cf698ea02fe60a8e06fdfefd4c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-2.1.3-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3fb452fa9f772bd85adc1c0ff2481020f7e673f37fa9643754c3f6217162c8d8
MD5 e0625ee0ae4d48ed3a39b89f936ecb96
BLAKE2b-256 1b7363908441db11a3229efe1cfe3f82756b58e5e520657b680ed131430db894

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-2.1.3-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 6cda10ccb457c8cb7f2145bdf732235679b4154b3d29c48999e912b80abcacc1
MD5 6ba6f0eba0a0091718084c1e17e4a4db
BLAKE2b-256 7a4af86e4d4f76c148b02877d2ecb5666a3ab6f4a9b4b151c8bce2e64a67ac7f

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.0

10 files

This release

2.1.3 This release

10 files

2.1.2

10 files

2.1.1

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