# Autoreject 代码仓库

> AI 辅助翻译，非官方版本。专业判断、引用和争议应以原文及其勘误为准。

- 来源 ID：S0155
- 原始来源：https://raw.githubusercontent.com/autoreject/autoreject/97a735960955f6259bcf31dcebec2e2373ed5ef4/README.rst
- 许可：BSD-3-Clause
- 翻译方法：Independent manual review; SHA-256-pinned source and translation
- 审校状态：独立人工审校完成

## 原始文件映射

- [README.rst](../original/README.rst)

## 许可文件（保留原文）

- [github-license-api.json](../license/github-license-api.json)：法律或许可证据原文未翻译
- [LICENSE](../license/LICENSE)：法律或许可证据原文未翻译

## 原始文件：README.rst

autoreject
==========

|CircleCI|_ |GitHub Actions|_ |Codecov|_ |PyPI|_ |Conda-Forge|_

.. |CircleCI| image:: https://circleci.com/gh/autoreject/autoreject/tree/main.svg?style=shield&circle-token=:circle-token
.. _CircleCI: https://circleci.com/gh/autoreject/autoreject

.. |GitHub Actions| image:: https://github.com/autoreject/autoreject/actions/workflows/test.yml/badge.svg
.. _GitHub Actions: https://github.com/autoreject/autoreject/actions/workflows/test.yml

.. |Codecov| image:: http://codecov.io/github/autoreject/autoreject/coverage.svg?branch=main
.. _Codecov: http://codecov.io/github/autoreject/autoreject?branch=main

.. |PyPI| image:: https://badge.fury.io/py/autoreject.svg
.. _PyPI: https://badge.fury.io/py/autoreject

.. |Conda-Forge| image:: https://img.shields.io/conda/vn/conda-forge/autoreject.svg
.. _Conda-Forge: https://anaconda.org/conda-forge/autoreject/

这是一个自动剔除脑磁图和脑电图（M/EEG）数据中的不良试次并修复不良传感器的库。

.. image:: https://autoreject.github.io/stable/_images/sphx_glr_plot_auto_repair_001.png
   :width: 400


文档可通过以下链接访问：

- `稳定版本 <https://autoreject.github.io/stable/index.html>`_
- `最新开发版本 <https://autoreject.github.io/dev/index.html>`_

.. docs_readme_include_label

安装
------------

我们推荐使用 `Anaconda Python 发行版 <https://www.anaconda.com/>`_，并使用
**Python 3.10 或更高版本**。还建议把 ``autoreject`` 安装在隔离的 Python 环境中。
要获取 ``autoreject`` 的稳定版本，可使用 ``pip``::

    pip install -U autoreject

也可以使用 ``conda``::

    conda install -c conda-forge autoreject

如需 ``autoreject`` 的最新开发版本，请使用::

    pip install https://github.com/autoreject/autoreject/archive/refs/heads/main.zip

可用以下命令检查安装是否成功::

    python -c 'import autoreject'

运行后不应出现错误消息。

以下是 ``autoreject`` 的依赖项。安装 ``autoreject`` 时会自动安装所有必需依赖。

* ``mne`` (>=1.5.0)
* ``numpy`` (>=1.21.2)
* ``scipy`` (>=1.7.1)
* ``scikit-learn`` (>=1.0.0)
* ``joblib``
* ``matplotlib`` (>=3.5.0)

可选依赖为：

* ``openneuro-py``（>= 2021.10.1，用于从 `OpenNeuro.org <https://openneuro.org>`_ 获取数据）

快速开始
==========

最简便的入门方式是把下面三行代码复制到脚本中：

.. code:: python

	>>> from autoreject import AutoReject
	>>> ar = AutoReject()
	>>> epochs_clean = ar.fit_transform(epochs)  # doctest: +SKIP

这会自动清理由 MNE-Python 读取的 `epochs` 对象。要取得剔除字典，只需执行：

.. code:: python

	>>> from autoreject import get_rejection_threshold
	>>> reject = get_rejection_threshold(epochs)  # doctest: +SKIP

我们还实现了 `PREP 流水线 <https://doi.org/10.3389/fninf.2015.00016>`_ 中的 RANSAC
（完整的 PREP 流水线实现见 `PyPREP <https://github.com/sappelhoff/pyprep>`_）。其 API 相同：

.. code:: python

	>>> from autoreject import Ransac
	>>> rsc = Ransac()
	>>> epochs_clean = rsc.fit_transform(epochs)  # doctest: +SKIP

更多细节请查看 `自动检测并修复不良 epochs 的示例 <https://autoreject.github.io/stable/_images/sphx_glr_plot_auto_repair_001.png>`_。

错误报告
===========

请使用 `GitHub 议题跟踪器 <https://github.com/autoreject/autoreject/issues>`_ 报告错误。

引用
====

[1] Mainak Jas, Denis Engemann, Federico Raimondo, Yousra Bekhti, and Alexandre Gramfort, "`Automated rejection and repair of bad trials in MEG/EEG <https://hal.archives-ouvertes.fr/hal-01313458/document>`_."
In 6th International Workshop on Pattern Recognition in Neuroimaging (PRNI), 2016.

[2] Mainak Jas, Denis Engemann, Yousra Bekhti, Federico Raimondo, and Alexandre Gramfort. 2017.
"`Autoreject: Automated artifact rejection for MEG and EEG data <http://www.sciencedirect.com/science/article/pii/S1053811917305013>`_".
NeuroImage, 159, 417-429.

## 原文 DOI 与数字核对索引

下列不变量从原始载荷自动提取，仅用于核对译文完整性，不构成额外证据摘要。

- `10.3389`
- `10.3389/fninf.2015.00016`
- `001`
- `01313458`
- `053811917305013`
- `1`
- `1.0.0`
- `1.21.2`
- `1.5.0`
- `1.7.1`
- `159`
- `2`
- `2015.00016`
- `2016`
- `2017`
- `2021.10.1`
- `3.10`
- `3.5.0`
- `400`
- `417`
- `429`
