Skip to content

Set num_histogram_bins in amplitude_cutoff (back) to 100 - #4415

Merged
alejoe91 merged 3 commits into
SpikeInterface:mainfrom
ecobost:amp_cutoff
Mar 3, 2026
Merged

alejoe91 merged 3 commits into
SpikeInterface:mainfrom
ecobost:amp_cutoff

Conversation

@ecobost

@ecobost ecobost commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor

#4353 changed the default num_histogram_bins in AmplitudeCutoff from 100 to 200 to get a more granular histogram/estimate.

But given the default amplitudes_bins_min_ratio=5, any cell with less than 1000 spikes will return amplitude_cutoff = NaN. That is (I think?) too big a hurdle (a unit with 0.1Hz firing rate will require 2.8 hours to spike 1000 times).

Assuming 500 spikes are enough to model the amplitude distribution, I change it back to 100 here. I also change the default value on the low-level amplitude_cutoff()to match this default.

EDIT: Even if we don't think 500 spikes are enough to model the distribution, the right parameter to change would be amplitudes_bins_min_ratio and not num_histogram_bins as we would rather have more samples per bin (lower variance)

@alejoe91 alejoe91 added the metrics Related to metrics module label Feb 27, 2026
@zm711

zm711 commented Feb 28, 2026 •

Copy link
Copy Markdown
Member

If we go messing with AmplitudeCutoff and I don't get all NaN's I'll have no way to know my code is working :P

Isn't our default for random_spikes 500 see here. So if 500 is enough sample for a distribution for the core of the analyzer then I would agree with you that 500 should be enough here too!

@alejoe91

alejoe91 commented Mar 3, 2026

Copy link
Copy Markdown
Member

If we go messing with AmplitudeCutoff and I don't get all NaN's I'll have no way to know my code is working :P

Isn't our default for random_spikes 500 see here. So if 500 is enough sample for a distribution for the core of the analyzer then I would agree with you that 500 should be enough here too!

Agreed! But on a related note we should maybe increase random spikes to get better estimates of templates #4389

@alejoe91
alejoe91 merged commit 81e89fd into SpikeInterface:main Mar 3, 2026
13 checks passed
@ecobost

ecobost commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

For what is worth, I use:

sa.create_sorting_analyzer(...,    num_spikes_for_sparsity=500) # default=100
analyzer.compute('random_spikes', max_spikes_per_unit=1000) # default 500
analyzer.compute('quality_metrics',  metric_params={
     'amplitude_cutoff': {'amplitudes_bins_min_ratio': 7.5}}) #i.e., 750 spikes, default is 5

Increasing the random_spikes to 1000 by default seems reasonable.

@ecobost
ecobost deleted the amp_cutoff branch March 3, 2026 23:41
SID-6921 added a commit to SID-6921/spikeinterface that referenced this pull request Nov 18, 2026
SpikeInterface#4415 fixed amplitude_cutoff()'s and AmplitudeCutoff.metric_params's
num_histogram_bins default back to 100 after a regression, but didn't touch
compute_amplitude_cutoffs()'s own signature default, which stayed at 500 even
though its own docstring still said 100.

With amplitudes_bins_min_ratio=5, that mismatch silently raises the spike
count a unit needs before its amplitude_cutoff stops being NaN from 500 to
2500 whenever compute_amplitude_cutoffs() is called directly without an
explicit num_histogram_bins override. Confirmed with a 2317-spike unit:
num_histogram_bins=500 returns NaN, num_histogram_bins=100 returns a real
value (0.23).

Set compute_amplitude_cutoffs()'s default to 100, matching its own docstring,
AmplitudeCutoff.metric_params, and the amplitude_cutoff() helper it wraps.
Also fixed amplitude_cutoff()'s docstring, which still claimed "default: 500"
after SpikeInterface#4415 changed the actual default to 100.
alejoe91 pushed a commit to alejoe91/spikeinterface that referenced this pull request Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metrics Related to metrics module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants