Skip to content

Fix basescatterview binning and limits#235

Merged
chrishalcrow merged 5 commits intoSpikeInterface:mainfrom
alejoe91:fix-amplitude-limits-bins
Feb 16, 2026
Merged

Fix basescatterview binning and limits#235
chrishalcrow merged 5 commits intoSpikeInterface:mainfrom
alejoe91:fix-amplitude-limits-bins

Conversation

@alejoe91
Copy link
Copy Markdown
Member

@alejoe91 alejoe91 commented Feb 12, 2026

With the default binning strategy, for real data with non float amplitudes, you get a lot of zig-zags in the scatter histogram.
In addition, the default borders to compute histograms and limits are min/max of the data, with an hard-coded margin of 50.

This PR makes the limits and binning more adaptive by:

  • using percentiles (2, 98 by default) to compute limits for histogram and plots (avoids massive outliers)
  • set margin based on actual limits
  • fixes x range in QT to always be the segment t_start/stop (otherwise the plot was focusing on the available spikes, even if covering just a portion of the duration)
  • also fixes an issue in QT where the visible toggle always triggered true

All in all it gives much better default limits for all scatters (amp scalings were super off with the 50 margin!)

Comment thread spikeinterface_gui/basescatterview.py Outdated
Comment on lines +319 to +321
margin = 0.2 * (np.max(ymaxs) - np.min(ymins))
ymin = np.min(ymins) - margin
ymax = np.max(ymaxs) + margin
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of the margin - it makes the histogram and the scatter plot feel out of sync.

With margin:
Image

Without margin:
Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also be ok with computing and plotting the histogram for the full range, then setting the the y-range after to match the percentiles + margin.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I tried and it's awful with outliers eheheh! I can remove margins, or should we have it as a setting?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote to remove margins

@alejoe91
Copy link
Copy Markdown
Member Author

Margins removed @chrishalcrow

Copy link
Copy Markdown
Member

@chrishalcrow chrishalcrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Think it improves the default view a lot!

@chrishalcrow chrishalcrow merged commit b6b3051 into SpikeInterface:main Feb 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants