Speed up collision-aware amplitude scaling - #4786
Open
JESUSROYETH wants to merge 1 commit into
Open
JESUSROYETH wants to merge 1 commit into
JESUSROYETH wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Collision-aware amplitude scaling scans the whole chunk again for every selected spike, just to recover a position that's already known once the non-margin subset is built. So this bookkeeping step ends up quadratic in the number of spikes per chunk.
Changes
The fix keeps those flat indices and passes them to
find_collisions(), building each collision group once instead of concatenating it over and over. The existing helper call still works as is, the fitting arithmetic doesn't change.Validation
I ran two seven-pair fresh-process sweeps after one warm-up, on 100-unit, 64-channel generated recordings, through the public
analyzer.compute("amplitude_scalings", handle_collisions=True)path with one worker and 1 s chunks. Times below are complete extension calls: 20 s at 4 Hz and 10 s at 20 Hz.At high density this saves 118-166 ms per chunk, and 17,375 of the 19,954 spikes need a collision fit. All before/after ranges are separated, and all 42 measured pairs came back with identical arrays and collision counts. The public MEARec fixture also matched exactly. The complete module passes its 6 tests across sparse/dense analyzers, two segments, and memory/binary/zarr formats; Black is clean.