Add IBL's "noise cutoff" quality metric#3984
Conversation
zm711
left a comment
There was a problem hiding this comment.
some initial comments, suggestions, questions :)
| sorting_analyzer=sorting_analyzer | ||
| high_quantile=0.25, | ||
| low_quantile=0.10, | ||
| n_bins=100, |
There was a problem hiding this comment.
There is no discussion of what number of bins means for this metric. Might be worth adding. Why not do 10, or 1000 bins?
There was a problem hiding this comment.
I have added a comment to the docs. This is also the default value used in IBL's implementation.
| if peak_sign == "both": | ||
| raise TypeError('peak_sign should either be "pos" or "neg"!') |
There was a problem hiding this comment.
Shouldn't this error occur right after peak sign so we don't waste time doing the _get_amplitudes_by_units function?
There was a problem hiding this comment.
Also how does a user know what the peak sign is? Where did it come from. I would consider making this note refer to the peak sign of the spike_amplitudes extension.
There was a problem hiding this comment.
I added a comment about where to change the peak_sign in the error message. I moved the error before _get_amplitudes_by_units.
|
From a profiling perspective is there any benefit to thinking about doing a numba/numpy dual strategy? It seems like |
| '`peak_sign` should either be "pos" or "neg". You can set `peak_sign` as an argument when you compute spike_amplitudes.' | ||
| ) | ||
|
|
||
| amplitudes_by_units = _get_amplitudes_by_units(sorting_analyzer, unit_ids, peak_sign) |
There was a problem hiding this comment.
lets have in mind that this _get_amplitudes_by_units is not efficient because it internal use mask on all units.
amplitude_extension.get_data(outputs="by_units") is really faster for this. We should use it here and also inside
_get_amplitudes_by_units the only pain is that amplitude will be splited over segments but concatenate is fast.
There was a problem hiding this comment.
We just tried to implement amplitude_extension.get_data(outputs="by_units") and then concatenated, but it became very complex. We propose that there should be another PR to make _get_amplitudes_by_units to use the approach suggested.
|
Thank you for this, this is really nice. |
related to this, I don't think I've ever got |
|
Hello @oliche @GaelleChapuis , @huizizhang949 has implemented a version of the IBL noise cutoff metric here in spikeinterface (docs: https://spikeinterface--3984.org.readthedocs.build/en/3984/modules/qualitymetrics/noise_cutoff.html). Hoping it will be a helpful tool here! If you have time to have a look at the implementation, we'd appreciate any feedback! The bulk of the code is in |
7545d18 to
0711dab
Compare
|
@huizizhang949 why did you close this? I think it was in very good shape! |
Add a new metric "noise cutoff" based on IBL https://figshare.com/articles/online_resource/Spike_sorting_pipeline_for_the_International_Brain_Laboratory/19705522?file=49783080 in a new function
compute_noise_cutoffs.The original implementation is here https://github.com/int-brain-lab/ibllib/blob/2e1f91c622ba8dbd04fc53946c185c99451ce5d6/brainbox/metrics/single_units.py.
The "noise cutoff" metric assesses whether a unit’s spike‐amplitude distribution is truncated
at the low-end, which may be due to the high amplitude detection threhold in the deconvolution step,
i.e., if low‐amplitude spikes were missed. It does not assume a Gaussian shape;
instead, it directly compares counts in the low‐amplitude bins to counts in high‐amplitude bins (
cutoff) and the peak bin (ratio).Here are examples with no truncation and truncation, which give low and high values (

cutoffandratio), respectively.I have added documentation and tests.