`interpolate_motion` loses `interpolation_time_bin_size_s` when the recording is rebuilt from its kwargs
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
从sortingcomponents/motion/motion_interpolation.py开始,检查InterpolateMotionRecording从_kwargs重建时如何存储和使用插值时间 bin 设置。使用提供的示例,为clone()和并行save()添加回归测试;当提供 bin 大小和边界时,两个重建后的记录都返回与原始记录完全相同的 trace,即为完成。
由索引模型根据 Issue 内容生成。
描述
I found this while reading sortingcomponents/motion/motion_interpolation.py, not in my own analyses, so this is a "for the sake of improvement" report.
InterpolateMotionRecording._kwargs does not store interpolation_time_bin_size_s, and the stored interpolation_time_bin_centers_s is None in that case. A recording rebuilt from _kwargs (clone(), or the workers of save(n_jobs=2) on Windows, where they are started with spawn) therefore returns different traces, without an error. Reading the code, it falls back to the time bins of the motion.
import tempfile
import numpy as np
from spikeinterface.core import generate_recording
from spikeinterface.core.motion import Motion
from spikeinterface.sortingcomponents.motion import interpolate_motion
if __name__ == "__main__":
recording = generate_recording(num_channels=32, durations=[10.0], seed=0)
motion = Motion([np.linspace(0, 100, 5)[:, None]], [np.arange(5) * 2.0 + 1.0], np.array([100.0]))
corrected = interpolate_motion(
recording, motion, border_mode="force_extrapolate", interpolation_time_bin_size_s=0.1
)
traces = corrected.get_traces()
print("in _kwargs:", "interpolation_time_bin_size_s" in corrected._kwargs)
print("signal std:", traces.std())
print("clone, max abs diff:", np.abs(corrected.clone().get_traces() - traces).max())
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as folder:
saved = corrected.save(folder=folder + "/saved", n_jobs=2, chunk_duration="1s", progress_bar=False)
print("save(n_jobs=2), max abs diff:", np.abs(saved.get_traces() - traces).max())
del saved
# Output on current main (Windows):
# in _kwargs: False
# signal std: 0.8311724
# clone, max abs diff: 4.6557436
# save(n_jobs=2), max abs diff: 4.6557436
# Expected: both differences equal to 0
Fix: store interpolation_time_bin_size_s and interpolation_time_bin_edges_s in _kwargs, with the values given by the user. Reading the code, interpolation_time_bin_edges_s has the same problem: only the centers are stored and the edges are recomputed from them.
I can open a PR with a test if you agree.
- 主要语言
- Python
- 星标
- 883
- 派生
- 291
- 平均合并
- 3 天 17 小时
- 30 天内合并 PR
- 40
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SpikeInterface/spikeinterface 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 83/100
SpikeInterface/spikeinterface#5008 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
SpikeInterface/spikeinterface#5007 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
SpikeInterface/spikeinterface#5006 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
SpikeInterface/spikeinterface#5005 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
SpikeInterface/spikeinterface#5004 ·
维护者通常 2 天内回复
查看 SpikeInterface/spikeinterface 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 69/100
daniel-ospina/tortoise#15308 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
difficulty:easy prio:low type:bug
难度 2/5 1-3 小时 新手友好度 72/100
NatronGitHub/Natron#2405 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
Jstar269/nakagawa-recomp#3746 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复