Skip to main content

M/EEG denoising in Python

Project description

tests docs codecov Binder DOI Bluesky

MEEGkit

Denoising tools for M/EEG processing in Python 3.8+.

meegkit-ERP

Disclaimer: The project mostly consists of development code, although some modules and functions are already working. Bugs and performance problems are to be expected, so use at your own risk. More tests and improvements will be added in the future. Comments and suggestions are welcome.

Documentation

Automatic documentation is available online.

This code can also be tested directly from your browser using Binder, by clicking on the binder badge above.

Installation

This package can be installed easily using pip:

pip install meegkit

Or you can clone this repository and run the following commands inside the python-meegkit directory:

pip install -r requirements.txt
pip install .

Note : Use developer mode with the -e flag (pip install -e .) to be able to modify the sources even after install.

Advanced installation instructions

Some ASR variants require additional dependencies such as pymanopt. To install meegkit with these optional packages, use:

pip install -e '.[extra]'

or:

pip install meegkit[extra]

Other available options are [docs] (which installs dependencies required to build the documentation), or [tests] (which install dependencies to run unit tests).

References

If you use this code, you should cite the relevant methods from the original articles.

1. CCA, STAR, SNS, DSS, ZapLine, and Robust Detrending

This is mostly a translation of Matlab code from the NoiseTools toolbox by Alain de Cheveigné. It builds on an initial python implementation by Pedro Alcocer.

Only CCA, SNS, DSS, STAR, ZapLine and robust detrending have been properly tested so far. TSCPA may give inaccurate results due to insufficient testing (contributions welcome!)

[1] de Cheveigné, A. (2019). ZapLine: A simple and effective method to remove power line 
    artifacts. NeuroImage, 116356. https://doi.org/10.1016/j.neuroimage.2019.116356
[2] de Cheveigné, A. et al. (2019). Multiway canonical correlation analysis of brain 
    data. NeuroImage, 186, 728740. https://doi.org/10.1016/j.neuroimage.2018.11.026
[3] de Cheveigné, A. et al. (2018). Decoding the auditory brain with canonical component 
    analysis. NeuroImage, 172, 206216. https://doi.org/10.1016/j.neuroimage.2018.01.033
[4] de Cheveigné, A. (2016). Sparse time artifact removal. Journal of Neuroscience 
    Methods, 262, 1420. https://doi.org/10.1016/j.jneumeth.2016.01.005
[5] de Cheveigné, A., & Parra, L. C. (2014). Joint decorrelation, a versatile tool for 
    multichannel data analysis. NeuroImage, 98, 487505. 
    https://doi.org/10.1016/j.neuroimage.2014.05.068
[6] de Cheveigné, A. (2012). Quadratic component analysis. NeuroImage, 59(4), 38383844. 
    https://doi.org/10.1016/j.neuroimage.2011.10.084
[7] de Cheveigné, A. (2010). Time-shift denoising source separation. Journal of 
    Neuroscience Methods, 189(1), 113120. https://doi.org/10.1016/j.jneumeth.2010.03.002
[8] de Cheveigné, A., & Simon, J. Z. (2008a). Denoising based on spatial filtering.
    Journal of Neuroscience Methods, 171(2), 331339. 
    https://doi.org/10.1016/j.jneumeth.2008.03.015
[9] de Cheveigné, A., & Simon, J. Z. (2008b). Sensor noise suppression. Journal of 
    Neuroscience Methods, 168(1), 195202. https://doi.org/10.1016/j.jneumeth.2007.09.012
[10] de Cheveigné, A., & Simon, J. Z. (2007). Denoising based on time-shift PCA.
     Journal of Neuroscience Methods, 165(2), 297305. 
     https://doi.org/10.1016/j.jneumeth.2007.06.003

2. Artifact Subspace Reconstruction (ASR)

The base code is inspired from the original EEGLAB inplementation [1], while the Riemannian variant [2] was adapted from the rASR toolbox by Sarah Blum.

[1] Mullen, T. R., Kothe, C. A. E., Chi, Y. M., Ojeda, A., Kerth, T., Makeig, S., 
    et al. (2015). Real-time neuroimaging and cognitive monitoring using wearable dry 
    EEG. IEEE Trans. Bio-Med. Eng. 62, 25532567. 
    https://doi.org/10.1109/TBME.2015.2481482
[2] Blum, S., Jacobsen, N., Bleichner, M. G., & Debener, S. (2019). A Riemannian 
    modification of artifact subspace reconstruction for EEG artifact handling. Frontiers 
    in human neuroscience, 13, 141.

3. Rhythmic Entrainment Source Separation (RESS)

The code is based on Matlab code from Mike X. Cohen [1]

[1] Cohen, M. X., & Gulbinaite, R. (2017). Rhythmic entrainment source separation: 
    Optimizing analyses of neural responses to rhythmic sensory stimulation. Neuroimage, 
    147, 43-56.

4. Task-Related Component Analysis (TRCA)

This code is based on the Matlab implementation from Masaki Nakanishi, and was adapted to python by Giuseppe Ferraro

[1] M. Nakanishi, Y. Wang, X. Chen, Y.-T. Wang, X. Gao, and T.-P. Jung,
    "Enhancing detection of SSVEPs for a high-speed brain speller using task-related 
    component analysis", IEEE Trans. Biomed. Eng, 65(1): 104-112, 2018.
[2] X. Chen, Y. Wang, S. Gao, T. -P. Jung and X. Gao, "Filter bank canonical correlation 
    analysis for implementing a high-speed SSVEP-based brain-computer interface", 
    J. Neural Eng., 12: 046008, 2015.
[3] X. Chen, Y. Wang, M. Nakanishi, X. Gao, T. -P. Jung, S. Gao, "High-speed spelling 
    with a noninvasive brain-computer interface", Proc. Int. Natl. Acad. Sci. U.S.A, 
    112(44): E6058-6067, 2015.

5. Local Outlier Factor (LOF)

[1] Breunig M, Kriegel HP, Ng RT, Sander J. 2000. LOF: identifying density-based 
    local outliers. SIGMOD Rec. 29, 2, 93-104. https://doi.org/10.1145/335191.335388
[2] Kumaravel VP, Buiatti M, Parise E, Farella E. 2022. Adaptable and Robust 
    EEG Bad Channel Detection Using Local Outlier Factor (LOF). Sensors (Basel). 
    2022 Sep 27;22(19):7314. https://doi.org/10.3390/s22197314.

6. Phase Estimation

The oscillator code is based on the Matlab implementation from Michael Rosenblum, and its corresponding paper [1]. The Endpoint Corrected Hilbert Transform (ECHT) method was adapted from [2].

[1] Rosenblum, M., Pikovsky, A., Kühn, A.A. et al. Real-time estimation of phase 
    and amplitude with application to neural data. Sci Rep 11, 18037 (2021). 
    https://doi.org/10.1038/s41598-021-97560-5
[2] Schreglmann, S. R., Wang, D., Peach, R. L., Li, J., Zhang, X., Latorre, A., 
    ... & Grossman, N. (2021). Non-invasive suppression of essential tremor via
    phase-locked disruption of its temporal coherence. Nature communications, 12(1), 363.

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

meegkit-0.1.9.tar.gz (25.2 MB view details)

Uploaded Source

Built Distribution

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

meegkit-0.1.9-py3-none-any.whl (90.8 kB view details)

Uploaded Python 3

File details

Details for the file meegkit-0.1.9.tar.gz.

File metadata

  • Download URL: meegkit-0.1.9.tar.gz
  • Upload date:
  • Size: 25.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for meegkit-0.1.9.tar.gz
Algorithm Hash digest
SHA256 5032dfaf10725f22c02bea5f4ec9ef150b0f11e9297eac8c5d56cac87da5d282
MD5 073551a7134b0fa39b6b44e954093683
BLAKE2b-256 cce1092a0d0ec78111b90c992868d85ff731b0377b4d73ace887e01fd3d52ed0

See more details on using hashes here.

File details

Details for the file meegkit-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: meegkit-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 90.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for meegkit-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5c9a8fa92f57f39dd6b7e121c4b1536589db880a1bcb4797427daf6df5e7f718
MD5 dee024551a0d883a863cefb14d588969
BLAKE2b-256 60de8239db31455ea73ddb54f409c3c82280167bbca2c2183798e09b7b799912

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