`directional_derivative` ignores `channel_indices` in `get_traces`

未关闭 适合新手
#4,997 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从 preprocessing/directional_derivative.py 开始,追踪 DirectionalDerivativeRecordingSegment.get_traces 如何使用 channel_indices 并计算导数。将其与 #3631 中针对 average_across_direction 的通道选择修复进行比较,然后检查通道顺序与位置顺序不同时导数的表现。为报告中的通道选择和排序情况添加测试;完成标准是返回的两个形状都与请求的通道相符,且导数值遵循位置。

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

描述

I found this while reading preprocessing/directional_derivative.py, not in my own analyses, so this is a "for the sake of improvement" report.

DirectionalDerivativeRecordingSegment.get_traces reads all parent channels and returns the derivative of all of them, ignoring channel_indices. So get_traces(channel_ids=...), and recordings built on top of it such as select_channels, return all channels instead of the requested ones.

from spikeinterface.core import generate_recording
from spikeinterface.preprocessing import directional_derivative

recording = generate_recording(num_channels=16, durations=[1.0], seed=0)
derivative = directional_derivative(recording)
channel_ids = derivative.channel_ids[[0, 3]]

print(derivative.get_traces(channel_ids=channel_ids, end_frame=100).shape)
print(derivative.select_channels(channel_ids).get_traces(end_frame=100).shape)

# Output on current main:
# (100, 16)
# (100, 16)
# Expected: (100, 2) twice

Fix: return derivative_traces[:, channel_indices], as #3631 did for average_across_direction. Also, reading the code, np.gradient follows the channel order rather than the position, so a column whose channels are not sorted along direction gets wrong values.

I can open a PR with a test if you agree.

主要语言
Python
星标
883
派生
291
平均合并
3 天 17 小时
30 天内合并 PR
40

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

SpikeInterface/spikeinterface 的其他 Issue

查看 SpikeInterface/spikeinterface 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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