`interpolate_motion` loses `interpolation_time_bin_size_s` when the recording is rebuilt from its kwargs
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in sortingcomponents/motion/motion_interpolation.py and inspect how InterpolateMotionRecording stores and uses interpolation time bin settings when rebuilding from _kwargs. Add a regression test for clone() and parallel save() using the supplied example; done means both rebuilt recordings return traces identical to the original when bin size and edges are provided.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 883
- Forks
- 291
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 40
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SpikeInterface/spikeinterface
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
SpikeInterface/spikeinterface#5008 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
SpikeInterface/spikeinterface#5007 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
SpikeInterface/spikeinterface#5006 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
SpikeInterface/spikeinterface#5005 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
SpikeInterface/spikeinterface#5004 ·
Maintainers usually reply within 2 days
All issues in SpikeInterface/spikeinterface
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
available bug good first issue tooling
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Nixitov/Riptide-Native#816 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
teng-lin/notebooklm-py#2593 ·
Maintainers usually reply within 1 day
-
claimed-by:collie role:small-fix status:running
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Beovulfo/herd-sdlc#325 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 94/100
omarelshamy25x/shamy-arabic-nlp#267 ·
Maintainers usually reply within 1 day