natMEEG - Naturalistic M/EEG data analysis
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
TRFEstimatorclass inpyeeg/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
pyEEGand has been rebranded tonatMEEGto 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
latexandlatxmkare 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
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 Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file natmeeg-1.7.1.tar.gz.
File metadata
- Download URL: natmeeg-1.7.1.tar.gz
- Upload date:
- Size: 423.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d261e3d1e9c2edc85ffac48eb13d6ed793f1112db219eea2461a0f3176cd252
|
|
| MD5 |
cddf590d37505358030c68adca8eb12f
|
|
| BLAKE2b-256 |
908dc9850532cc307b9e20a908fbebf7f916b4019661dc92c086f7dce21108f9
|
File details
Details for the file natmeeg-1.7.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: natmeeg-1.7.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd4eca20d44991d51f52f99ccb90e963987052207abd6e77f3caeffe1a92b6c3
|
|
| MD5 |
24d619650bc00260d5056226bdf91cc3
|
|
| BLAKE2b-256 |
1c686ada8304942da2f0ff9c2328dd184937738ef5e23bafc76fe37b37259966
|
File details
Details for the file natmeeg-1.7.1-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: natmeeg-1.7.1-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 185.3 kB
- Tags: CPython 3.13, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68c9e44d06c96ebb29405a84dcdae83e188d4f8452cf1022b63d416bb4c7eca5
|
|
| MD5 |
fb7357abc1f8c30aaf56dfeb69c21347
|
|
| BLAKE2b-256 |
026c2e150fa1d6c9034a754303380441f889c3b335e450be02262434273f7753
|
File details
Details for the file natmeeg-1.7.1-cp313-cp313-macosx_10_13_universal2.whl.
File metadata
- Download URL: natmeeg-1.7.1-cp313-cp313-macosx_10_13_universal2.whl
- Upload date:
- Size: 166.7 kB
- Tags: CPython 3.13, macOS 10.13+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
debc637e3d226b1d6f107c0c43754a2ac39025ffbd4d529349cd4e1806aee731
|
|
| MD5 |
19f3e1a313a266028c84532537bf2fd4
|
|
| BLAKE2b-256 |
e8b55b1288fbbc2554e218fe63d1bbe181f2c60ccd5a5f577c44b76bd8d0d6fe
|
File details
Details for the file natmeeg-1.7.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: natmeeg-1.7.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ebdfe156b1af5d6a938e00b07c3816302b737d12422e5c4872b62872cad5b59
|
|
| MD5 |
90ab17ce7424d1261085883504aa4325
|
|
| BLAKE2b-256 |
549895189d73a90056ebab9e61643ce0e4bd5fdda64b9079cbdfa42e8fd03a39
|
File details
Details for the file natmeeg-1.7.1-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: natmeeg-1.7.1-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 185.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00a2ccf18fc39071b410cc05acee1375a848787042ac3e5019470262a0b582ec
|
|
| MD5 |
7c52cc034163545efc140dc97cec3f42
|
|
| BLAKE2b-256 |
39c448ede0c217f9d22940ce45fef96faf7630dc89e2345ef38ca6fcceb864fc
|
File details
Details for the file natmeeg-1.7.1-cp312-cp312-macosx_10_13_universal2.whl.
File metadata
- Download URL: natmeeg-1.7.1-cp312-cp312-macosx_10_13_universal2.whl
- Upload date:
- Size: 166.7 kB
- Tags: CPython 3.12, macOS 10.13+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6213fff3bf9e7540b374647f42b045540a9d952fdfdf9f44c3206b19ff5861d4
|
|
| MD5 |
4ea97f71bca71b20598f70ee7c4dcb9a
|
|
| BLAKE2b-256 |
140255131124728b4b29f1f509de6ff610e31a336526c3a03349d29c9cdcf0fc
|
File details
Details for the file natmeeg-1.7.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: natmeeg-1.7.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3298360dfd5d6e2ff27ceaf90a0b70bc14d965d90e95f2a002bb1ce68f778925
|
|
| MD5 |
778185d63ea97009cf4678d85f3afeb3
|
|
| BLAKE2b-256 |
34f07eb3858307072db222e6ad3675198998a8a7195bd36fdbb0c48a2f80e44c
|
File details
Details for the file natmeeg-1.7.1-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: natmeeg-1.7.1-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 184.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
617613f863167a2c9cabf7a4bef91dc09ee5b418dd6311d1e266e961cb615735
|
|
| MD5 |
4a96937eb711dde33fba787ee51d7515
|
|
| BLAKE2b-256 |
a4d5f269c01143ec5f701728bc8ac1213dd0141655cb8b9df2098cfcd7161ee9
|
File details
Details for the file natmeeg-1.7.1-cp310-cp310-macosx_10_9_universal2.whl.
File metadata
- Download URL: natmeeg-1.7.1-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 166.6 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17ca958607d53abbf0f83cd9ff3ade92aaed47b5c6e784cd27fd27af95eef244
|
|
| MD5 |
100de4b82d56c6ab9764a6176751b014
|
|
| BLAKE2b-256 |
b7f393107f91eecf959dc94cbbf3ce3353a62d4d4f329f714d2fc794bddfc64a
|