Skip to content

Commit

Permalink
[MAINT] Move to pyproject.toml (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbara authored May 10, 2023
1 parent 12c348c commit 501ef5c
Show file tree
Hide file tree
Showing 57 changed files with 1,077 additions and 863 deletions.
40 changes: 26 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,32 @@ pydocstyle:
@pydocstyle

pep:
@$(MAKE) -k flake pydocstyle codespell-error

flake:
@if command -v flake8 > /dev/null; then \
echo "Running flake8"; \
flake8 --count meegkit examples; \
else \
echo "flake8 not found, please install it!"; \
exit 1; \
fi;
@echo "flake8 passed"
@$(MAKE) -k ruff codespell

# Tests
ruff:
@ruff check $(CODESPELL_DIRS)

ruff-fix:
@ruff check $(CODESPELL_DIRS) --fix

# Build and install
# =============================================================================
# test:
# py.test tests
install-requirements:
@echo "Checking/Installing requirements..."
@pip install -q -r requirements.in

install:
@echo "Installing package..."
@pip install -q --no-deps .
@echo "\x1b[1m\x1b[32m * Package successfully installed! \x1b[0m"

install-dev:
@echo "Installing package in editable mode..."
@pip install -q -e ".[docs, tests]" --config-settings editable_mode=compat
@echo "\x1b[1m\x1b[32m * Package successfully installed! \x1b[0m"

# Tests
# =============================================================================
test: in
rm -f .coverage
$(PYTESTS) -m 'not ultraslowtest' meegkit
Expand All @@ -94,3 +103,6 @@ test-full: in
$(PYTESTS) meegkit

.PHONY: init test



126 changes: 69 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
[![DOI](https://zenodo.org/badge/117451752.svg)](https://zenodo.org/badge/latestdoi/117451752)
[![twitter](https://img.shields.io/twitter/follow/lebababa?style=flat&logo=Twitter)](https://twitter.com/intent/follow?screen_name=lebababa)

# MEEGkit
# `MEEGkit`

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

![meegkit-ERP](https://user-images.githubusercontent.com/10333715/176754293-eaa35071-94f8-40dd-a487-9f8103c92571.png)

> **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.
> **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](https://nbara.github.io/python-meegkit/).

This code can also be tested directly from your browser using [Binder](https://mybinder.org), by clicking on the binder badge above.
This code can also be tested directly from your browser using
[Binder](https://mybinder.org), by clicking on the binder badge above.

## Installation

Expand All @@ -27,18 +31,21 @@ 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:
Or you can clone this repository and run the following commands inside the
`python-meegkit` directory:

```bash
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.
*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:
Some ASR variants require additional dependencies such as `pymanopt`. To install meegkit
with these optional packages, use:

```bash
pip install -e '.[extra]'
Expand All @@ -50,90 +57,95 @@ 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).
Other available options are `[docs]` (which installs dependencies required to build the
documentation), or `[tests]` (which install dependencies to run unit tests).

## References

### 1. CCA, STAR, SNS, DSS, ZapLine, and Robust Detrending
If you use this code, you should cite the relevant methods from the original articles.

This is mostly a translation of Matlab code from the [NoiseTools toolbox](http://audition.ens.fr/adc/NoiseTools/) by Alain de Cheveigné. It builds on an initial python implementation by [Pedro Alcocer](https://github.com/pealco).
### 1. CCA, STAR, SNS, DSS, ZapLine, and Robust Detrending

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!)
This is mostly a translation of Matlab code from the
[NoiseTools toolbox](http://audition.ens.fr/adc/NoiseTools/) by Alain de Cheveigné.
It builds on an initial python implementation by
[Pedro Alcocer](https://github.com/pealco).

If you use this code, you should cite the relevant methods from the original articles:
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!)

```sql
[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
[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
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
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](https://github.com/sccn/clean_rawdata) [1], while the riemannian variant [2] was adapted from the [rASR toolbox](https://github.com/s4rify/rASRMatlab) by Sarah Blum.

If you use this code, you should cite the relevant methods from the original articles:
The base code is inspired from the original
[EEGLAB inplementation](https://github.com/sccn/clean_rawdata) [1], while the Riemannian
variant [2] was adapted from the [rASR toolbox](https://github.com/s4rify/rASRMatlab) by
Sarah Blum.

```sql
[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.
[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](https://mikexcohen.com/data/) [1]

If you use this, you should cite the following article:

```sql
[1] Cohen, M. X., & Gulbinaite, R. (2017). Rhythmic entrainment source separation: Optimizing analyses
of neural responses to rhythmic sensory stimulation. Neuroimage, 147, 43-56.
[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](https://github.com/mnakanishi/TRCA-SSVEP), and was adapted to python by [Giuseppe Ferraro](mailto:[email protected])

If you use this, you should cite the following articles:
This code is based on the [Matlab implementation from Masaki Nakanishi](https://github.com/mnakanishi/TRCA-SSVEP),
and was adapted to python by [Giuseppe Ferraro](mailto:[email protected])

```sql
[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.
"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)

If you use this, you should cite the following article:

```sql
[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
Expand Down
2 changes: 1 addition & 1 deletion citation.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
given-names: "Nicolas"
orcid: "https://orcid.org/0000-0003-1495-561X"
title: "MEEGkit"
version: 0.1.3
version: 0.1.4
doi: 10.5281/zenodo.5643659
date-released: 2021-10-15
url: "https://github.com/nbara/python-meegkit"
Binary file added doc/_static/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 38 additions & 32 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@
#
import os
import sys
import matplotlib
matplotlib.use('agg')

import matplotlib as mpl

mpl.use("agg")

curdir = os.path.dirname(__file__)
sys.path.append(os.path.abspath(os.path.join(curdir, '..')))
sys.path.append(os.path.abspath(os.path.join(curdir, '..', 'meegkit')))
sys.path.append(os.path.abspath(os.path.join(curdir, "..")))
sys.path.append(os.path.abspath(os.path.join(curdir, "..", "meegkit")))

import meegkit # noqa

# -- Project information -----------------------------------------------------

project = 'MEEGkit'
copyright = '2022, Nicolas Barascud'
author = 'Nicolas Barascud'
project = "MEEGkit"
copyright = "2023, Nicolas Barascud"
author = "Nicolas Barascud"
release = meegkit.__version__
version = meegkit.__version__

Expand All @@ -35,31 +37,31 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'numpydoc',
'jupyter_sphinx',
'sphinx_gallery.gen_gallery',
'sphinxemoji.sphinxemoji',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"numpydoc",
"jupyter_sphinx",
"sphinx_gallery.gen_gallery",
"sphinxemoji.sphinxemoji",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'config.py']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "config.py"]

# generate autosummary even if no references
# autosummary_generate = True
autodoc_default_options = {
'members': True,
'special-members': '__init__',
'undoc-members': True,
'show-inheritance': True,
'exclude-members': '__weakref__'
"members": True,
"special-members": "__init__",
"undoc-members": True,
"show-inheritance": True,
"exclude-members": "__weakref__"
}
numpydoc_show_class_members = True

Expand All @@ -75,15 +77,19 @@
# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages
html_theme = 'pydata_sphinx_theme'
html_theme = "pydata_sphinx_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

html_static_path = ["_static"]

html_theme_options = {
"logo": {
"image_light": "_static/logo.png",
"image_dark": "_static/logo-dark.png",
"text": "meegkit",
},
"show_toc_level": 1,
"external_links": [
{
Expand All @@ -95,12 +101,12 @@
{
"name": "GitHub",
"url": "https://github.com/nbara/python-meegkit",
"icon": "fab fa-github-square",
"icon": "fa-brands fa-github",
},
{
"name": "Twitter",
"url": "https://twitter.com/lebababa",
"icon": "fab fa-twitter-square",
"icon": "fa-brands fa-twitter",
},
],
"use_edit_page_button": True,
Expand All @@ -116,10 +122,10 @@
# -- Options for Sphinx-gallery HTML ------------------------------------------

sphinx_gallery_conf = {
'doc_module': ('meegkit',),
'examples_dirs': '../examples', # path to your example scripts
'gallery_dirs': 'auto_examples', # path to where to save gallery generated output
'filename_pattern': '/example_',
'ignore_pattern': 'config.py',
'run_stale_examples': False,
"doc_module": ("meegkit",),
"examples_dirs": "../examples", # path to your example scripts
"gallery_dirs": "auto_examples", # path to where to save gallery generated output
"filename_pattern": "/example_",
"ignore_pattern": "config.py",
"run_stale_examples": False,
}
Loading

0 comments on commit 501ef5c

Please sign in to comment.