Fix edges of 2d-histogram in UnitWaveformDensityMapWidget #4283
+5
−11
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.
Currently,

sw.plot_unit_waveforms_density_map(analyzer, unit_ids=[0], use_max_channel=True)produces this:The density map has some spurious high values on the very first row (more visible near the peaks) and also on the bottom although less visible in this example.
The issue comes from the clipping in
spikeinterface/src/spikeinterface/widgets/unit_waveforms_density_map.py
Line 129 in 5a58beb
that counts any value with amplitude less than bin_min as belonging to the first bin and any value above bin_max as belonging to the last bin of the histogram, thus producing those lines on the plot.
This PR uses equal-sized bins from bin_min to bin_max and uses np.histogram to count occurrences. It produces:

without any artifacts. (Also tested it with multiple channels and multiple units)
Granted, it looks uglier but it's more correct. And it will look better for nicer data, this is a 2-minute recording just for testing.