Set amplitude scalings equal zero for zero template units#4455
Merged
alejoe91 merged 2 commits intoSpikeInterface:mainfrom Mar 18, 2026
Merged
Set amplitude scalings equal zero for zero template units#4455alejoe91 merged 2 commits intoSpikeInterface:mainfrom
alejoe91 merged 2 commits intoSpikeInterface:mainfrom
Conversation
alejoe91
approved these changes
Mar 17, 2026
Member
|
Oups, @chrishalcrow can you check tests? |
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.
In some edge cases*, templates can be arrays of zeros. When this is the case, the amplitude scalings compute throws an error as you can't linregress a constant y-vector.
This PR fixes this: if the template of a given unit is equal to an array of zeros, the amplitude scalings computation is skipped (with scalings set to zero)
*This is my edge case: take two recordings, concatenate them and sort. Then make an analyzer for each recording by splitting the sorting in two. The concatenation has caused a artifact at the boundary of the two recordings which leads to a unit with a single spike near the boundary. Spikes within
nbeforeof the boundary get given a waveform equal to an array of zeros (this is because we can't accurately compute a waveform, but want to keep the number of spikes inrandom_spikes,waveformsetc the same). Spikes withinnbeforeusually aren't selected byselect_random_spikesbut because it's the only spike in the unit, it is selected. This is then the only waveform which contributes to the unit template, meaning the template is an array of zeros.