Skip to main content

natMEEG - Naturalistic M/EEG data analysis

PyPI version DOI (v1.6.10)

Latest released version: v1.6.10 (2025-04-15). The current branch is under development toward the next release.

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

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.6.10, Zenodo, 9 Sept. 2025, https://doi.org/10.5281/zenodo.17084930.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

natmeeg-1.7.0-cp313-cp313-win_amd64.whl (166.4 kB view details)

Uploaded CPython 3.13Windows x86-64

natmeeg-1.7.0-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl (185.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.5+ x86-64

natmeeg-1.7.0-cp313-cp313-macosx_10_13_universal2.whl (167.0 kB view details)

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

natmeeg-1.7.0-cp312-cp312-win_amd64.whl (166.4 kB view details)

Uploaded CPython 3.12Windows x86-64

natmeeg-1.7.0-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl (185.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ x86-64

natmeeg-1.7.0-cp312-cp312-macosx_10_13_universal2.whl (166.9 kB view details)

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

natmeeg-1.7.0-cp310-cp310-win_amd64.whl (166.4 kB view details)

Uploaded CPython 3.10Windows x86-64

natmeeg-1.7.0-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl (184.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ x86-64

natmeeg-1.7.0-cp310-cp310-macosx_10_9_universal2.whl (166.9 kB view details)

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

File details

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

File metadata

  • Download URL: natmeeg-1.7.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 166.4 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-1.7.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 578eefd5e944983540548f738e26316265917e75112fe5577870f002d271014d
MD5 db3c8109b4b20367839546e8f6628c0a
BLAKE2b-256 6ed34c7f9a744000bb22c4b1c10667a0be006a8a1e8dd1fd61a10b65459ba3dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-1.7.0-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0834f6cde14dbdec1b188c890484aed14f7c797e9f391b87108887f353c76630
MD5 bf0504b8be3df4d74897d215a6dd2ff9
BLAKE2b-256 b458175533cf67cd13de91e424dc3bca41c3959278cfff3cc180e84d74f544e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-1.7.0-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 95e3fdb11ceaad9e52a28f2146f9e38bb40bf922e38c775d70a24eee2d6c9a46
MD5 f19d9fc21f7315eaf19526b3e2cae55a
BLAKE2b-256 d3dfdbff0103786b292f2763d4df4fd86b14cdd75e2c3e03904eb2734e1ebea5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: natmeeg-1.7.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 166.4 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-1.7.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 275a0e05183c317deea52223cd748c24aca9502be0fd7685c4d02110d70bbe81
MD5 b09eebe1223611e3fb48e13dcf5e030b
BLAKE2b-256 cc8657e9288392cf5e870dde0224e658b3dd51205f627f35d285d40af3f274a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-1.7.0-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3e094fdbd76d04b55e76251a99ad27dc5bb248fc3a9a7c18b72372254ececf27
MD5 8fddda7f8307a8e19d34c25cb07cff05
BLAKE2b-256 560a898d4ce068bd88052d0904f364dac849c5ab87da210cd334f32d876fd8c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-1.7.0-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 04348e485843b9736c661868ee084b4d08f271cc58752773ce51431d4b639363
MD5 2cf76db7bc3375806057bad4cd3d301d
BLAKE2b-256 6b0a938b695c5690a8779973ac6f19d4feb546770c6caa5796053dbbf98a2152

See more details on using hashes here.

File details

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

File metadata

  • Download URL: natmeeg-1.7.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 166.4 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-1.7.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c5ce1948357c3d7528183bc6228ce7cde15a7809d49c8166be8eba30b7323eb0
MD5 46965b78c67af95e059303114b9133e4
BLAKE2b-256 1dde85f73909c14eaee4980dbdb6a0f314bba0f42bee29ea123f2c804bbde324

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-1.7.0-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 62b37313a9a7b69d8d92ff5abc93a64f1c7c9db1fca7479f5d7ee07b4498b591
MD5 a5feec9e2e29ed9e1d9848215669a231
BLAKE2b-256 970bea3f17d33ac0b11641d56fba08023dad12a4e9911c36d91ace5ed6e1549a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natmeeg-1.7.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 1b84f08207d23d0c4b1b110b7594732ee4bb38e72ade8043d041ad6dd1ab0249
MD5 c171c8fe7eca0a2b36de8b4acedd4148
BLAKE2b-256 42ff498f836189ca863c6bab7a852900b4f5d447c68d3f06e78fca231d78bf40

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

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

This release

1.7.0 This release

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