SOURCE FILE / S0153
zh.md
本站安全派生阅读版;AIbci 不是原始发布者。下载原始文件
- 原文件 SHA-256
05641eb4d61d80811ecce637318853ef999773e09b36b11133eb7eb770bc1439- 派生内容 SHA-256
2f0ab1b7deea8fc090ed194a4000a8344858069756388f431b8870d4d15ee512- 转换时间
- 2026-07-28T00:00:00Z
- 净化器版本
- text-reader-1.0.0
- 质量状态
- normalized-text-readable
# pyRiemann 代码仓库与文档
> AI 辅助翻译,非官方版本。专业判断、引用和争议应以原文及其勘误为准。
- 来源 ID:S0153
- 原始来源:https://raw.githubusercontent.com/pyRiemann/pyRiemann/854804d34bc7b40b318323520be896d97d8aa859/README.md
- 许可:BSD-3-Clause
- 翻译方法:Independent manual review; SHA-256-pinned source and translation
- 审校状态:独立人工审校完成
## 原始文件映射
- [README.md](../original/README.md)
## 许可文件(保留原文)
- [github-license-api.json](../license/github-license-api.json):法律或许可证据原文未翻译
- [LICENSE](../license/LICENSE):法律或许可证据原文未翻译
## 原始文件:README.md
# pyRiemann
[](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue)
[](https://badge.fury.io/py/pyriemann)
[](https://github.com/pyRiemann/pyRiemann/actions)
[](https://codecov.io/gh/pyRiemann/pyRiemann)
[](http://pyriemann.readthedocs.io/en/latest/?badge=latest)
[](https://doi.org/10.5281/zenodo.593816)
[](https://pepy.tech/project/pyriemann)
pyRiemann 是一个基于 [scikit-learn](http://scikit-learn.org/stable/modules/classes.html) API 的
Python 机器学习软件包。它通过对称(相应地,厄米)[正定](https://en.wikipedia.org/wiki/Definite_matrix)
(SPD;相应地,HPD)矩阵的[黎曼几何](https://en.wikipedia.org/wiki/Riemannian_geometry),为实值
(相应地,复值)多变量数据的处理和分类提供高级接口。
文档位于 http://pyriemann.readthedocs.io/en/latest/
本代码采用 BSD 三条款许可证。
# 说明
pyRiemann 的目标是成为通用的多变量数据分析软件包,不过其设计重点是处理应用于
[脑机接口](https://en.wikipedia.org/wiki/Brain%E2%80%93computer_interface)(BCI)的
[生物信号](https://en.wikipedia.org/wiki/Biosignal)(如 EEG、MEG 或 EMG):从多通道时间序列
估计[协方差矩阵](https://en.wikipedia.org/wiki/Covariance_matrix),并用 SPD 矩阵的黎曼几何进行
分类 [[1]](#1)。
在 BCI 应用中,研究的范式包括运动想象 [[2]](#2) [[3]](#3)、事件相关电位(ERP)[[4]](#4)
和稳态视觉诱发电位(SSVEP)[[5]](#5)。利用扩展标签,API 支持跨会话或跨受试者的多源
[迁移学习](https://en.wikipedia.org/wiki/Transfer_learning) [[6]](#6)。
另一项应用是[遥感](https://en.wikipedia.org/wiki/Remote_sensing):通过滑动窗口估计雷达图像
空间坐标上的协方差矩阵,并使用 SPD 矩阵的黎曼几何处理
[高光谱](https://en.wikipedia.org/wiki/Hyperspectral_imaging)图像,或使用 HPD 矩阵处理
[合成孔径雷达](https://en.wikipedia.org/wiki/Synthetic-aperture_radar)(SAR)图像。
pyRiemann 的核心实用函数通过 [Python Array API](https://data-apis.org/array-api/) 透明支持
NumPy 和 PyTorch 后端。直接传入 PyTorch 张量时,可选择启用 GPU 加速和自动微分。
# 安装
#### 使用 PyPI
```
pip install pyriemann
```
也可使用 pip+git 安装最新代码版本:
```
pip install git+https://github.com/pyRiemann/pyRiemann
```
#### 使用 conda
该软件包通过 [conda-forge](https://conda-forge.org) 分发。可用以下命令将其安装到工作环境:
```shell
conda install -c conda-forge pyriemann
```
#### 从源代码安装
要安装最新版本,可以在源代码目录中使用 ``pip``:
```shell
pip install .
```
也可以采用可编辑模式,以便修改源代码:
```shell
pip install -e .
```
# 使用方法
大多数函数仿照 scikit-learn API,因此可以直接与 sklearn 配合使用。例如,使用 [[2]](#2)
所述 MDM 算法对 EEG 信号进行交叉验证分类,可以这样实现:
```python
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())
```
也可以使用 sklearn 流水线框架组合方法。例如,按 [[3]](#3) 所述,在切空间中使用 SVM
分类器对 EEG 信号进行分类:
```python
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())
```
更多示例请查看示例文件夹。
# 贡献指南
本软件包力求尽可能遵循 [scikit-learn](http://scikit-learn.org/stable/developers/contributing.html#contributing-code)
和 [MNE-Python](https://mne.tools/stable/install/contributing.html) 的约定。向本仓库贡献前,请先阅读
它们的贡献指南。
# 测试
如果进行了修改,请在提交拉取请求前运行测试套件:
```
pytest
```
# 引用方式
```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 = july,
year = 2026,
version = {v0.12},
publisher = {Zenodo},
doi = {10.5281/zenodo.593816},
url = {https://doi.org/10.5281/zenodo.593816}
}
```
# 参考文献
<a id="1">[1]</a>
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. [链接](https://hal.science/hal-01570120/document)
<a id="2">[2]</a>
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. [链接](https://hal.archives-ouvertes.fr/hal-00681328)
<a id="3">[3]</a>
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. [链接](https://hal.archives-ouvertes.fr/hal-00820475/)
<a id="4">[4]</a>
A. Barachant and M. Congedo, "A Plug&Play P300 BCI Using Information Geometry".
Research report, 2014. [链接](http://arxiv.org/abs/1409.0107)
<a id="5">[5]</a>
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. [链接](https://hal.science/hal-01351623/file/Kalunga-Chevallier-Barthelemy-Online%20SSVEP-based%20BCI%20using%20Riemannian%20Geometry-Neurocomputing-16.pdf)
<a id="6">[6]</a>
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. [链接](https://hal.archives-ouvertes.fr/hal-01971856)
## 原文 DOI 与数字核对索引
下列不变量从原始载荷自动提取,仅用于核对译文完整性,不构成额外证据摘要。
- `10.5281`
- `10.5281/zenodo.593816`
- `10.5281/zenodo.593816.svg`
- `00`
- `00681328`
- `00820475`
- `01351623`
- `01570120`
- `01971856`
- `1`
- `112`
- `12`
- `1409.0107`
- `155`
- `16`
- `172`
- `174`
- `178`
- `191`
- `2`
- `20%`
- `2012`
- `2013`
- `2014`
- `2017`
- `2018`
- `2026`
- `203.12%`
- `203.13`
- `2390`
- `2401`
- `3`
- `3.11%`
- `4`
- `4.3`
- `5`
- `55`
- `59`
- `593816`
- `6`
- `66`
- `68`
- `8`
- `80%`
- `9`
- `920`
- `928`