pyriemann

Machine learning for multivariate data through the Riemannian geometry of positive definite matrices in Python

https://github.com/pyriemann/pyriemann

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org, zenodo.org
  • Committers with academic emails
    1 of 37 committers (2.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.5%) to scientific vocabulary

Keywords

brain-computer-interface covariance-estimation covariance-matrix eeg hermitian-matrices image-processing machine-learning positive-definite-matrices python radar-image remote-sensing riemannian-geometry signal-processing statistics symmetric-matrices time-series

Keywords from Contributors

neuroscience electroencephalography magnetoencephalography meg neuroimaging ecog electrocorticography bci-benchmarks bci closember
Last synced: 6 months ago · JSON representation

Repository

Machine learning for multivariate data through the Riemannian geometry of positive definite matrices in Python

Basic Info
Statistics
  • Stars: 693
  • Watchers: 28
  • Forks: 172
  • Open Issues: 3
  • Releases: 11
Topics
brain-computer-interface covariance-estimation covariance-matrix eeg hermitian-matrices image-processing machine-learning positive-definite-matrices python radar-image remote-sensing riemannian-geometry signal-processing statistics symmetric-matrices time-series
Created almost 11 years ago · Last pushed 6 months ago
Metadata Files
Readme License

README.md

pyRiemann

Code PythonVersion PyPI version Build Status codecov Documentation Status DOI Downloads

pyRiemann is a Python machine learning package based on scikit-learn API. It provides a high-level interface for processing and classification of real (resp. complex)-valued multivariate data through the Riemannian geometry of symmetric (resp. Hermitian) positive definite (SPD) (resp. HPD) matrices.

The documentation is available on http://pyriemann.readthedocs.io/en/latest/

This code is BSD-licensed (3 clause).

Description

pyRiemann aims at being a generic package for multivariate data analysis but has been designed around biosignals (like EEG, MEG or EMG) manipulation applied to brain-computer interface (BCI), estimating covariance matrices from multichannel time series, and classifying them using the Riemannian geometry of SPD matrices [1].

For BCI applications, studied paradigms are motor imagery [2] [3], event-related potentials (ERP) [4] and steady-state visually evoked potentials (SSVEP) [5]. Using extended labels, API allows multisource transfer learning between sessions or subjects [6].

Another application is remote sensing, estimating covariance matrices over spatial coordinates of radar images using a sliding window, and processing them using the Riemannian geometry of SPD matrices for hyperspectral images, or HPD matrices for synthetic-aperture radar (SAR) images.

Installation

Using PyPI

pip install pyriemann or using pip+git for the latest version of the code:

pip install git+https://github.com/pyRiemann/pyRiemann

Using conda

The package is distributed via conda-forge. You could install it in your working environment, with the following command:

shell conda install -c conda-forge pyriemann

From sources

For the latest version, you can install the package from the sources using pip:

shell pip install .

or in editable mode to be able to modify the sources:

shell pip install -e .

How to use

Most of the functions mimic the scikit-learn API, and therefore can be directly used with sklearn. For example, for cross-validation classification of EEG signal using the MDM algorithm described in [2], it is easy as:

```python import pyriemann from sklearn.modelselection import crossval_score

load your data

X = ... # EEG data, in format nepochs x nchannels x n_times y = ... # labels

estimate covariance matrices

cov = pyriemann.estimation.Covariances().fit_transform(X)

build your classifier

mdm = pyriemann.classification.MDM()

cross validation

accuracy = crossvalscore(mdm, cov, y)

print(accuracy.mean())

```

You can also pipeline methods using sklearn pipeline framework. For example, to classify EEG signal using a SVM classifier in the tangent space, described in [3]:

```python from pyriemann.estimation import Covariances from pyriemann.tangentspace import TangentSpace from sklearn.pipeline import makepipeline from sklearn.modelselection import crossvalscore from sklearn.svm import SVC

load your data

X = ... # EEG data, in format nepochs x nchannels x n_times y = ... # labels

build your pipeline

clf = make_pipeline( Covariances(), TangentSpace(), SVC(kernel="linear"), )

cross validation

accuracy = crossvalscore(clf, X, y)

print(accuracy.mean())

```

Check out the example folder for more examples.

Contribution Guidelines

The package aims at adopting the scikit-learn and MNE-Python conventions as much as possible. See their contribution guidelines before contributing to the repository.

Testing

If you make a modification, run the test suite before submitting a pull request

pytest

How to cite

bibtex @software{pyriemann, author = {Alexandre Barachant and Quentin Barthélemy and Jean-Rémi King and Alexandre Gramfort and Sylvain Chevallier and Pedro L. C. Rodrigues and Emanuele Olivetti and Vladislav Goncharenko and Gabriel Wagner vom Berg and Ghiles Reguig and Arthur Lebeurrier and Erik Bjäreholt and Maria Sayu Yamamoto and Pierre Clisson and Marie-Constance Corsi and Igor Carrara and Apolline Mellot and Bruna Junqueira Lopes and Brent Gaisford and Ammar Mian and Anton Andreev and Gregoire Cattan and Arthur Lebeurrier}, title = {pyRiemann}, month = jul, year = 2025, version = {v0.9}, publisher = {Zenodo}, doi = {10.5281/zenodo.593816}, url = {https://doi.org/10.5281/zenodo.593816} }

References

[1] M. Congedo, A. Barachant and R. Bhatia, "Riemannian geometry for EEG-based brain-computer interfaces; a primer and a review". Brain-Computer Interfaces, 4.3, pp. 155-174, 2017. link

[2] A. Barachant, S. Bonnet, M. Congedo and C. Jutten, "Multiclass Brain-Computer Interface Classification by Riemannian Geometry". IEEE Transactions on Biomedical Engineering, vol. 59, no. 4, pp. 920-928, 2012. link

[3] A. Barachant, S. Bonnet, M. Congedo and C. Jutten, "Classification of covariance matrices using a Riemannian-based kernel for BCI applications". Neurocomputing, 112, pp. 172-178, 2013. link

[4] A. Barachant and M. Congedo, "A Plug&Play P300 BCI Using Information Geometry". Research report, 2014. link

[5] EK. Kalunga, S. Chevallier, Q. Barthélemy, K. Djouani, E. Monacelli and Y. Hamam, "Online SSVEP-based BCI using Riemannian geometry". Neurocomputing, 191, pp. 55-68, 2014. link

[6] PLC. Rodrigues, C. Jutten and M. Congedo, "Riemannian Procrustes analysis: transfer learning for brain-computer interfaces". IEEE Transactions on Biomedical Engineering, vol. 66, no. 8, pp. 2390-2401, 2018. link

Owner

  • Name: pyRiemann
  • Login: pyRiemann
  • Kind: organization

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 614
  • Total Committers: 37
  • Avg Commits per committer: 16.595
  • Development Distribution Score (DDS): 0.596
Past Year
  • Commits: 58
  • Committers: 9
  • Avg Commits per committer: 6.444
  • Development Distribution Score (DDS): 0.276
Top Committers
Name Email Commits
Alexandre Barachant a****t@g****m 248
Quentin Barthélemy q****y@g****m 185
gabelstein d****h@w****e 39
Alexandre Gramfort a****t@m****g 33
kingjr j****b@g****m 27
Sylvain Chevallier s****r@u****r 17
Pedro Rodrigues p****1@g****m 11
brunalopes b****l@u****r 9
gcattan g****n@h****r 5
toncho11 t****1 3
maxdolle c****b@m****r 3
V G v****o@p****u 3
Emanuele Olivetti o****i@f****u 3
Dave d****y@g****m 3
Apolline Mellot 8****t 2
Maria Sayu Yamamoto 1****o 2
stevenmortier 5****r 1
Emanuele Olivetti e****e@r****m 1
Gabriel Wagner vom Berg g****l@b****e 1
AJ Keller p****c@g****m 1
mhurte 3****e 1
mccorsi 6****i 1
jona-sassenhagen j****n@g****m 1
jliersch 1****h 1
Tim Näher 6****r 1
Thibault de Surrel 6****l 1
Richard Höchenberger r****r@g****m 1
Pierre Clisson m****a 1
JJ 1****l 1
Igor Carrara 9****g 1
and 7 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 40
  • Total pull requests: 267
  • Average time to close issues: almost 2 years
  • Average time to close pull requests: 18 days
  • Total issue authors: 28
  • Total pull request authors: 25
  • Average comments per issue: 2.98
  • Average comments per pull request: 1.62
  • Merged pull requests: 234
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 6
  • Pull requests: 89
  • Average time to close issues: 5 days
  • Average time to close pull requests: 8 days
  • Issue authors: 6
  • Pull request authors: 8
  • Average comments per issue: 1.17
  • Average comments per pull request: 1.37
  • Merged pull requests: 71
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • alexandrebarachant (4)
  • agramfort (4)
  • qbarthelemy (3)
  • andrewjaykeller (3)
  • kingjr (2)
  • penguinpee (2)
  • dojeda (1)
  • charlespan110 (1)
  • DingkunLiu (1)
  • TanTingyi (1)
  • sylvchev (1)
  • hubert3102 (1)
  • musicinmybrain (1)
  • nkueper (1)
  • hoechenberger (1)
Pull Request Authors
  • qbarthelemy (186)
  • gabelstein (15)
  • gcattan (14)
  • toncho11 (8)
  • agramfort (8)
  • AmmarMian (5)
  • sylvchev (4)
  • msyamamoto (3)
  • timnaher (2)
  • plcrodrigues (2)
  • brentgaisford (2)
  • apmellot (2)
  • thibaultdesurrel (2)
  • carraraig (2)
  • brunaafl (2)
Top Labels
Issue Labels
enhancement (5) help wanted (2) easy (1) bug (1) duplicate (1) question (1)
Pull Request Labels
enhancement (4) documentation (1)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 111,404 last-month
  • Total dependent packages: 13
    (may contain duplicates)
  • Total dependent repositories: 68
    (may contain duplicates)
  • Total versions: 29
  • Total maintainers: 3
pypi.org: pyriemann

Machine learning for multivariate data with Riemannian geometry

  • Versions: 15
  • Dependent Packages: 12
  • Dependent Repositories: 67
  • Downloads: 111,404 Last month
Rankings
Dependent packages count: 1.1%
Downloads: 1.7%
Dependent repos count: 1.8%
Average: 2.3%
Stargazers count: 2.7%
Forks count: 4.0%
Last synced: 6 months ago
proxy.golang.org: github.com/pyriemann/pyriemann
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/pyRiemann/pyRiemann
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
conda-forge.org: pyriemann

pyRiemann aims at being a generic package for multivariate signal classification but has been designed around applications of biosignal (M/EEG, EMG, etc) classification.

  • Versions: 2
  • Dependent Packages: 1
  • Dependent Repositories: 1
Rankings
Forks count: 15.2%
Stargazers count: 17.9%
Average: 21.6%
Dependent repos count: 24.3%
Dependent packages count: 29.0%
Last synced: 6 months ago

Dependencies

.github/workflows/deploy_ghpages.yml actions
  • actions/checkout v2 composite
  • actions/upload-artifact v2 composite
  • ammaraskar/sphinx-action master composite
.github/workflows/testing.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
doc/requirements.txt pypi
  • ipython *
  • joblib *
  • mne >=0.24
  • numpydoc *
  • pandas *
  • scikit-learn *
  • seaborn *
  • sphinx-bootstrap_theme *
  • sphinx-gallery *
requirements.txt pypi
  • joblib *
  • numpy *
  • pandas *
  • scikit-learn >=0.22
  • scipy *
  • seaborn *
setup.py pypi
  • joblib *
  • numpy *
  • pandas *
  • scikit-learn *
  • scipy *