`interpolate_motion` loses `interpolation_time_bin_size_s` when the recording is rebuilt from its kwargs
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
sortingcomponents/motion/motion_interpolation.pyから始め、InterpolateMotionRecordingが_kwargsから再構築される際に、補間時間ビンの設定をどのように保存して使用するかを調べてください。提示された例を使って、clone()と並列のsave()の回帰テストを追加してください。ビンサイズと境界を指定したとき、再構築された両方の記録が元の記録と同一のトレースを返せば完了です。
索引モデルが 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時間
- マージ済み PR(30日)
- 40
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 日以内に返信