Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch ordering in initial pass misses half the sorted batches? #84

Closed
djoshea opened this issue Jul 3, 2019 · 2 comments · Fixed by #595
Closed

Batch ordering in initial pass misses half the sorted batches? #84

djoshea opened this issue Jul 3, 2019 · 2 comments · Fixed by #595

Comments

@djoshea
Copy link
Contributor

djoshea commented Jul 3, 2019

In looking through the main loop of learnAndSolve8b, I'm wondering whether the current traversal through sorted-batches is appropriate. From the how it works section, the first pass is for determining the waveforms, and the second for the final extraction. There's also a gradual annealing of the templates as you traverse over batches. It seems to me that the initial pass only looks at the second half of sorted batch space.

batch_ordering

These are all indices into isortbatches, so this is the traversal in sorted batch space. We start halfway in, work our way to the end and then back to the middle. Then we memorizeW and begin the final extraction pass. We work our way out from the middle to the beginning, then revertW back to the middle sorted-batch, and then go forward to the end. The problem, I think, is that the initial pass never looks at the first half of the sorted-batches. I could imagine this being an issue if there are waveforms in the first half of sorted batch space, no clusters will be created for them (via mexGetSpikes2).

Do I understand this correctly or I am misreading the code?

If this is a mistake, I'm not sure how to fix this while preserving continuity across batches in the pass, while also making sure we finish the initial pass on the middle batch. Here's one proposal, but it will make the main loop 25% slower:

batch_ordering_proposed

After traversing the sorted batches in order, we finish annealing (leave pm equal to its final value), and then head back to the middle batch, where we memorizeW and proceed into the final pass.

@marius10p
Copy link
Contributor

Think of the first pass as an initialization, rather than an optimization. The algorithm forgets at a pretty fast rate what the active templates are, so it won't really matter much to go through the other half of the data for initialization. Only the most recent few hundred spikes from each neuron matter. On data that I've tested, it didn't matter how many back and forth passes we did.

djoshea added a commit to djoshea/Kilosort2 that referenced this issue Jul 3, 2019
@marius10p
Copy link
Contributor

Issue has become inactive. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants