SpikeInterface / SpikeInterface/spikeinterface
Bug in extract_waveforms_to_buffers()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 847
- Forks
- 280
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 29
Description
Using extract_waveforms_to_buffers() I noticed there is a mismatch between the number of expected waveforms and the actual number returned per unit, when the unit_ids not exactly like range(num_units).
It seems my issue is related to this piece of code in allocate_waveforms_buffers():
for unit_ind, unit_id in enumerate(unit_ids):
n_spikes = np.sum(spikes["unit_index"] == unit_ind)
Obviously, if unit_ids=[0,1,2,3,4] there is no issue, but if unit_ids=[0,1,13,91,101], for example, then there is an issue, because:
>>> unit_ids=[0,1,13,91,101]
>>> list(enumerate(unit_ids))
[(0, 0), (1, 1), (2, 13), (3, 91), (4, 101)]
I could be missing something about how extract_waveforms_to_buffers() is intended to be used, but to me this looks like it was a mistake.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start in src/spikeinterface/core/waveform_tools.py at allocate_waveforms_buffers(), especially the loop around line 183, and trace how unit_ids are used by extract_waveforms_to_buffers(). Reproduce the mismatch with non-contiguous IDs such as [0, 1, 13, 91, 101], then verify that the returned waveform count for each unit matches its actual spikes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100