Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

BUG: fNIRS `interpolate_bads` copies wrong channel when positions are missing

未关闭
#14,415 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@kalomak 已经在做这个了。

开始于 2026年10月14日。

  • #14416 来自 @kalomak —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
data

调研方向

Start in _interpolate_bads_nirs, where the nearest good channel is chosen with np.argmin over distances; the reproduction script in the issue shows the wrong copy. Check the open pull request #14416 first, since it already targets this fix. Done means bad channels without positions become NaN, good channels without positions are never chosen as neighbours, and a ValueError is raised when a positioned bad channel has no good neighbour left.

由索引模型根据 Issue 内容生成。

描述

For bad channels without positions (NaN or all zero), interpolate_bads warns that their values "will be all NaN". _interpolate_bads_nirs instead picks the nearest channel with np.argmin over the distances, which returns the first NaN index for NaN positions, so the bad channel gets data from an arbitrary channel. All-zero positions give the same result.

import mne
import numpy as np

names = [f"S{i}_D{i} {w}" for i in (1, 2, 3) for w in (760, 850)]
info = mne.create_info(names, 10.0, "fnirs_cw_amplitude")
for ch in info["chs"]:
    ch["loc"][:] = np.nan
    ch["loc"][9] = 760 if ch["ch_name"].endswith("760") else 850
raw = mne.io.RawArray(np.arange(1, 7)[:, None] * np.ones((6, 5)), info)
raw.info["bads"] = ["S3_D3 760", "S3_D3 850"]
raw.interpolate_bads(origin=(0, 0, 0))
# RuntimeWarning: ... The values of these channels will be all NaN.
print(raw.get_data()[4:, 0])  # [1. 2.]: S1_D1 copied, not NaN

Proposed fix, in _interpolate_bads_nirs:

  1. Set bad channels without positions to NaN, as the warning says.
  2. Never pick good channels without positions.
  3. Raise ValueError when a bad channel with a position has no good neighbor left.
主要语言
Python
星标
3.5k
派生
1.6k
平均合并
1 天 3 小时
30 天内合并 PR
74

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

mne-tools/mne-python 的其他 Issue

查看 mne-tools/mne-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。