Skip to main content

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.

pyRiemann's core utility functions support both NumPy and PyTorch backends transparently through the Python Array API, enabling optional GPU acceleration and autograd when PyTorch tensors are passed in directly.

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:

conda install -c conda-forge pyriemann

From sources

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

pip install .

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

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:

import pyriemann
from sklearn.model_selection import cross_val_score

# load your data
X = ... # EEG data, in format n_epochs x n_channels 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 = cross_val_score(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]:

from pyriemann.estimation import Covariances
from pyriemann.tangentspace import TangentSpace
from sklearn.pipeline import make_pipeline
from sklearn.model_selection import cross_val_score
from sklearn.svm import SVC

# load your data
X = ... # EEG data, in format n_epochs x n_channels x n_times
y = ... # labels

# build your pipeline
clf = make_pipeline(
    Covariances(),
    TangentSpace(),
    SVC(kernel="linear"),
)

# cross validation
accuracy = cross_val_score(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

@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        = july,
  year         = 2026,
  version      = {v0.12},
  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

Metadata

Release files for pyriemann 0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyriemann 0.12
File Size Uploaded
pyriemann-0.12.tar.gz 173.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyriemann 0.12
File Interpreter ABI Platform
pyriemann-0.12-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 327.0 kB

Release files / pyriemann-0.12.tar.gz

Download URL pyriemann-0.12.tar.gz
Size 173.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a1450307bf3360fafe4e2e11a5db81889245f34b0042094bf8b59b7fe2bdeb9f
BLAKE2b-256 checksum
How to use checksums
aba9849d09dae8b9746958ffe65ca9609b7f16e45ea69b16057a1929b16c8726
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / pyriemann-0.12-py2.py3-none-any.whl

Download URL pyriemann-0.12-py2.py3-none-any.whl
Size 153.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
74a90b2ef0938c94fe9bf90b6506991fc19da55850aae5fdf992026b3845d43a
BLAKE2b-256 checksum
How to use checksums
575ce788ad2f904c633520d9f283785e6177a66096b2efa356b46b4647a3240f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.12 This release

2 release files

0.11

2 release files

0.10

2 release files

0.9

2 release files

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2.7

1 release file

0.2.6

2 release files

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.1

1 release file

0.2

1 release file

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page