Repository navigation
Speed up select_periods and get_data(periods=...) by finding each period's spikes with searchsorted - #4940
Open
grahamfindlay wants to merge 1 commit into
Conversation
select_sorting_periods_mask
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.
select_sorting_periods_maskcompares every period against all of its unit's spikes. With many periods per unit this is slow. On one of our 48 h sortings (~140 M spikes, ~3,700 periods), a single call takes 88 s. Multiple this the number of quality metrics that all call it repeatedly (to build the same mask -- a bit inefficient), and it blows up. Of the ~45 minutes that it took to compute 14 quality metrics on these data, around a third of it (15 min) was spent just inselect_sorting_periods_mask.The good news: Since each unit's spike train is sorted, the spikes inside a period form one contiguous slice. With binary search (
np.searchsorted), it is fast and easy to find the slice borders.I haven't re-run the quality metrics on the 48 h sorting, but I did a test to get a rough sense of the timing improvement. With 50 units at 50 Hz for 1 h (9 M spikes) and 74 periods per unit,
select_periodsdrops from 2.3 s to 0.27 s. So on the 48 h I expect it to cut >13 min off the quality metric computation time.