Problem with get_cluster_spike_waveforms
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 430
- Forks
- 187
- Avg merge
- 2h 31m
- Merged PRs (30d)
- 2
Description
I passed a dataset through Kilosort3. In order to curate the data using Phy, I first ran this command:
phy extract-waveforms params.py
and this generated the following three files:
- _phy_spikes_subset.channels.npy
- _phy_spikes_subset.spikes.npy
- _phy_spikes_subset.waveforms.npy
I then ran phy template-gui params.py and was able to merge/split clusters and label then as "good", "mua", or "noise." So far so good.
I am now playing around with phylib's model class in Python. I load the model like this:
from phylib.io.model import load_model
model = load_model("params.py")
I tried running this command:
model.get_cluster_spike_waveforms(cluster_id=0)
But it breaks. As far as I can tell, model.get_cluster_spike_waveforms() calls model.get_waveforms(), which then has two options:
- If the spikes are pre-computed, it calls traces.get_spike_waveforms()
- If the spikes are not pre-computed, it loads the waveforms directly from the raw data, which is a lot slower, by calling traces.extract_spike_waveforms()
In my case, the spikes are pre-computed because of the 3 files I generated (all starting with "phy"). The break happens when traces.get_spike_waveforms() runs this command:
assert np.all(np.isin(spike_ids, spike_waveforms.spike_ids))
In other words, for some reason not all values in spike_ids are to be found in spike_waveforms.spike_ids. I am not sure why.
The problem goes away if I remove the three phy files -- it looks like traces.extract_spike_waveforms() is able to get the job done.
With that said, it would be nice to know if there is an easy fix to this, or if there is something wrong with my workflow.
Thank you :)
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
Reproduce the issue with params.py after generating the _phy_spikes_subset.channels.npy, _phy_spikes_subset.spikes.npy, and _phy_spikes_subset.waveforms.npy files. Start at phylib.io.model.load_model and trace get_cluster_spike_waveforms through get_waveforms and traces.get_spike_waveforms, focusing on the spike_ids assertion. Done means determining whether this workflow is supported and documenting or correcting the mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100