{"id":23095234,"url":"https://github.com/weiglszonja/meeg-tools","last_synced_at":"2025-08-16T10:33:32.242Z","repository":{"id":40561736,"uuid":"336049719","full_name":"weiglszonja/meeg-tools","owner":"weiglszonja","description":"EEG/MEG data preprocessing and analyses framework","archived":false,"fork":false,"pushed_at":"2022-05-02T13:56:48.000Z","size":125314,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-02T12:42:50.965Z","etag":null,"topics":["connectivity-analysis","eeg-analysis","eeg-preprocessing","pipeline","preprocessing-data","time-frequency-analysis"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weiglszonja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-04T18:42:24.000Z","updated_at":"2024-08-04T14:43:11.000Z","dependencies_parsed_at":"2022-08-09T23:10:53.778Z","dependency_job_id":null,"html_url":"https://github.com/weiglszonja/meeg-tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiglszonja%2Fmeeg-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiglszonja%2Fmeeg-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiglszonja%2Fmeeg-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiglszonja%2Fmeeg-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weiglszonja","download_url":"https://codeload.github.com/weiglszonja/meeg-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230032843,"owners_count":18162521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connectivity-analysis","eeg-analysis","eeg-preprocessing","pipeline","preprocessing-data","time-frequency-analysis"],"created_at":"2024-12-16T22:20:10.572Z","updated_at":"2024-12-16T22:20:11.349Z","avatar_url":"https://github.com/weiglszonja.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Paper](https://github.com/weiglszonja/eeg-preprocessing/actions/workflows/paper.yml/badge.svg)](https://github.com/weiglszonja/eeg-preprocessing/actions/workflows/paper.yml)\n[![code-quality](https://github.com/weiglszonja/meeg-tools/actions/workflows/pylint.yml/badge.svg)](https://github.com/weiglszonja/meeg-tools/actions/workflows/pylint.yml)\n[![code-formatter](https://github.com/weiglszonja/meeg-tools/actions/workflows/black.yml/badge.svg)](https://github.com/weiglszonja/meeg-tools/actions/workflows/black.yml)\n[![Unittests](https://github.com/weiglszonja/eeg-preprocessing/actions/workflows/testing.yml/badge.svg)](https://github.com/weiglszonja/eeg-preprocessing/actions/workflows/testing.yml)\n[![PyPI version](https://badge.fury.io/py/meeg-tools.svg)](https://badge.fury.io/py/meeg-tools)\n[![GitHub license](https://img.shields.io/github/license/weiglszonja/eeg-preprocessing)](https://github.com/weiglszonja/eeg-preprocessing/blob/master/LICENSE)\n\n![Team Logo](tutorials/static/bml_équipememo.png) ![CRNL Logo](tutorials/static/crnl_logo.png)\n\nIn association with the Lyon Neuroscience Research Center (Lyon), Memo Team,\nPI: [Dezso Nemeth](https://www.memoteam.org).\n\n# meeg-tools\n\nEEG/MEG data preprocessing and analyses framework\n\n\n## Overview\n\nThe `meeg-tools` serves as a cookbook for preprocessing and analyzing EEG/MEG\nsignals in a semiautomatic and reproducible way. The general use-case of the\npackage is to use it from a Jupyter notebook. The\n`tutorials` folder contains notebooks that demonstrate data operations\nand transformations that are described in the Background section.\n\n## Installation\n\nInstall the latest version from PyPI into an existing environment:\n\n```bash\n$ pip install meeg_tools\n```\n\nSince this project is under development, I would recommend installing it from\nsource in editable mode with pip:\n\n```bash\n$ git clone https://github.com/weiglszonja/meeg-tools.git\n$ cd meeg-tools\n$ pip install -e .\n```\n\n## Background\n\n### Preprocessing\n\n![Pipeline diagram](tutorials/static/preprocessing_pipeline_diagram.svg)\n\n\nElectroencephalography (EEG) and magnetoencephalography (MEG) measures neural\nactivity of the brain. The signals that are recorded from multiple sensors are\ninherently contaminated by noise. Preprocessing aims to attenuate noise in the\nEEG/MEG data without removing meaningful signals in the process. Here, we\npresent a semiautomatic pipeline which can prepare the data for functional\nconnectivity or event related potential (ERP) analyses.\n\nThe meeg-tools package aims to serve as a semiautomatic and reproducible\nframework for preprocessing EEG/MEG signals prior to time-frequency-based\nanalyses. It minimizes the manual steps required to clean the data based on\nvisual inspection and reduces the number of choices that depend on the\nresearcher for rejecting segments of data or interpolation of electrodes. This\npackage utilizes modules from mne-Python (Gramfort et al., 2013), a popular\nopen-source Python package for working with neurophysiological data. For\nautomated rejection of bad data spans and interpolation of bad electrodes it\nuses the Autoreject (Jas et al., 2017) and the Random Sample Consensus (\nRANSAC) (Bigdely-Shamlo et al., 2015) packages.\n\nThe general use-case of the package is to use it from a Jupyter notebook.\nThe `tutorials` folder contains notebooks demonstrating data operations such as\nloading and writing the data along with the transformation steps that are\ndescribed below.\n\nIn order to remove high-frequency artefacts and low-frequency drifts, a\nzero-phase band-pass filter (0.5 - 45 Hz) is applied to the continuous data\nusing mne-Python. This temporal filter adapts the filter length and transition\nband size based on the cutoff frequencies. The lower and upper cutoff\nfrequencies can be changed in the configuration file (config.py) located at the\nutils folder.\n\nSubsequently, the filtered data is segmented into nonoverlapping segments (\nepochs) to facilitate analyses. The default duration of epochs is one seconds,\nhowever it can be changed in the configuration file.\n\nThe removal of bad data segments is done in three steps. First, epochs are\nrejected based on a global threshold on the z-score (\u003e 3) of the epoch variance\nand amplitude range. To further facilitate the signal-to-noise ratio,\nindependent components analysis (ICA) is applied to the epochs. ICA is a\nsource-separation technique that decomposes the data into a set of components\nthat are unique sources of variance in the data. The number of components and\nthe algorithm to use can be specified in the configuration file. The default\nmethod is the infomax algorithm that finds independent signals by maximizing\nentropy as described by (Bell \u0026 Sejnowski, 1995), (Nadal \u0026 Parga, 1999).\nComponents containing blink artefacts are automatically identified using\nmne-Python. The interactive visualization of ICA sources lets the user decide\nwhich components should be rejected based on their topographies and\ntime-courses. The number of components that were removed from the data are\ndocumented in the “description” field of the epochs instance “info” structure.\nThe final step of epoch rejection is to apply Autoreject (Jas et al., 2017) on\nthe ICA cleaned data. Autoreject uses unsupervised learning to estimate the\nrejection threshold for the epochs. In order to reduce computation time that\nincreases with the number of epochs and channels, it is possibe to fit autoreject\non a representative subset of epochs (25% of total epochs). Once the parameters\nare learned, the solution can be applied to any data that contains channels\nthat were used during fit.\n\nThe final step of preprocessing is to find and interpolate outlier channels.\nThe Random Sample Consensus (RANSAC) algorithm (Fischler \u0026 Bolles, 1981)\nselects a random subsample of good channels to make predictions of each channel\nin small non-overlapping 4 seconds long time windows. It uses a method of\nspherical splines (Perrin et al., 1989) to interpolate the bad sensors.\n\nAdditionally, the EEG/MEG reference can be changed to a “virtual reference”\nthat is the average of all channels using mne-Python.\n\n### Time-frequency analysis\n\nThe `tutorials` folder contains a jupyter notebook that demonstrates the usage\nof some functions available in mne-Python for time-frequency analysis.\n\n```bash\n$ jupyter notebook tutorials/time_frequency_analysis_tutorial.ipynb\n```\n\n## Usage\n\nThe `tutorials` folder contains a sample jupyter notebook that demonstrates the\npreprocessing pipeline.\nSee [this](https://mne.tools/stable/auto_tutorials/io/20_reading_eeg_data.html)\ndocumentation about supported file formats.\n\n```bash\n$ jupyter notebook tutorials/preprocessing_tutorial_without_triggers.ipynb\n```\n\n## Tests\n\nRun unittests from the terminal with:\n\n```bash\n$ python -m unittest\n```\n\n## Contribution\n\nThis project is under development; comments are all welcome and encouraged!\nSuggestions related to this project can be made with opening an\n[issue](https://github.com/weiglszonja/meeg-tools/issues/new)\nat the issue tracker of the project. Contributions and enhancements to the code\ncan be made by forking the project first; committing changes to the forked\nproject and then opening a pull request from the forked branch to the master\nbranch of meeg-tools.\n\n\n## References\n\nBell, A. J., \u0026 Sejnowski, T. J. (1995). An information-maximization approach to\nblind separation and blind deconvolution. Neural Computation, 7(6), 1129–1159.\nBigdely-Shamlo, N., Mullen, T., Kothe, C.,\n\nSu, K.-M., \u0026 Robbins, K. A. (2015). The PREP pipeline: standardized\npreprocessing for large-scale EEG analysis. In Frontiers in Neuroinformatics (\nVol. 9). https://doi.org/10.3389/fninf.2015.00016\n\nFischler, M. A., \u0026 Bolles, R. C. (1981). Random sample consensus. In\nCommunications of the ACM (Vol. 24, Issue 6, pp. 381–395)\n. https://doi.org/10.1145/358669.358692\n\nGramfort, A., Luessi, M., Larson, E., Engemann, D. A., Strohmeier, D.,\nBrodbeck, C., Goj, R., Jas, M., Brooks, T., Parkkonen, L., \u0026 Hämäläinen, M. (\n2013). MEG and EEG data analysis with MNE-Python. Frontiers in Neuroscience, 7,\n267.\n\nJas, M., Engemann, D. A., Bekhti, Y., Raimondo, F., \u0026 Gramfort, A. (2017).\nAutoreject: Automated artifact rejection for MEG and EEG data. NeuroImage, 159,\n417–429.\n\nNadal, J.-P., \u0026 Parga, N. (1999). SENSORY CODING: INFORMATION MAXIMIZATION AND\nREDUNDANCY REDUCTION. In Neuronal Information Processing (pp. 164–171)\n. https://doi.org/10.1142/9789812818041_0008\n\nPerrin, F., Pernier, J., Bertrand, O., \u0026 Echallier, J. F. (1989). Spherical\nsplines for scalp potential and current density mapping. Electroencephalography\nand Clinical Neurophysiology, 72(2), 184–187.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweiglszonja%2Fmeeg-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweiglszonja%2Fmeeg-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweiglszonja%2Fmeeg-tools/lists"}