You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong computation of amplitude_cutoff in quality metrics #4352
is currently computing the cutoff happening on the left side of the amplitude distribution (see figure below, right) but amplitudes are negative (or forced to be negative in L.876-883) and the expected cutoff would be on the right side, low amplitude spikes near zero values (Fig., middle), thus the current computation is not doing what it was intended to do.
Here's the current output for a couple of amplitude distribution examples (with ~15% cutoff) to show the issue.
Spikeinterface documentation for the function does say (source):
To calculate the approximate fraction of missing spikes, we look at the height of the lowest amplitude bin, and count the number of spikes at the upper end of the distribution with amplitudes above a bin of similar height.
which correctly describes the current method (i.e, find the cutoff on the left/lower side).
Same with the documentation for noise_cutoff:
For a given unit, the metric supposes that the lower bin of the amplitudes distribution will be high, i.e. will exhibit a sharp cut-off
The works because IBL uses amplitudes "in absolute SI units" (perhaps from kilosort, akin to the amplitude_scalings in spikeinterface) which are positive only. This is why they also have a median(amplitude) > 50 threshold for "good" recordings (which again would not make sense if the amplitudes were negative).
If amplitudes are negative (e.g., -100 to -10 μV): low (most negative) values (e.g., -90 to -100 μV) are high absolute amplitude so most stable spikes and high (least negative) values (e.g., -20 to -10 μV) are low absolute amplitude, "small spikes", near zero. Original source (Hill et al., 2011) agrees with this intuition:
I propose, instead of modifying the methods which were designed to work for positive amplitudes (finding the cutoff on the left/lower side of the distribution), we invert negative amplitudes before sending them to these methods (Currently it is doing the opposite, see below, I presume, because SI uses mainly negative amplitudes by default):
Yes, historically this is ported from the allen SDK, which mostly used kilosort 2.5 amplitude output, which is more akin to amplitude scalings. And we were not careful enough in porting/testing. I don't mind which way we fix this. I think either is ok, as along as it's clear in the docstring of the function. @alejoe91 any thoughts on which way is a better way to fix this?
Activity
ecobost commentedon Jan 30, 2026
Delved deeper into this.
Spikeinterface documentation for the function does say (source):
which correctly describes the current method (i.e, find the cutoff on the left/lower side).
Same with the documentation for noise_cutoff:
(source)

(source)
The works because IBL uses amplitudes "in absolute SI units" (perhaps from kilosort, akin to the amplitude_scalings in spikeinterface) which are positive only. This is why they also have a median(amplitude) > 50 threshold for "good" recordings (which again would not make sense if the amplitudes were negative).
If amplitudes are negative (e.g., -100 to -10 μV): low (most negative) values (e.g., -90 to -100 μV) are high absolute amplitude so most stable spikes and high (least negative) values (e.g., -20 to -10 μV) are low absolute amplitude, "small spikes", near zero. Original source (Hill et al., 2011) agrees with this intuition:

I propose, instead of modifying the methods which were designed to work for positive amplitudes (finding the cutoff on the left/lower side of the distribution), we invert negative amplitudes before sending them to these methods (Currently it is doing the opposite, see below, I presume, because SI uses mainly negative amplitudes by default):
spikeinterface/src/spikeinterface/metrics/quality/misc_metrics.py
Lines 876 to 883 in f732780
chrishalcrow commentedon Jan 30, 2026
Yes, historically this is ported from the allen SDK, which mostly used kilosort 2.5 amplitude output, which is more akin to amplitude scalings. And we were not careful enough in porting/testing. I don't mind which way we fix this. I think either is ok, as along as it's clear in the docstring of the function. @alejoe91 any thoughts on which way is a better way to fix this?