`plot_isi_distribution` adds the per-segment densities with several segments
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 83/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- matplotlib, numpy, python
- Domain
- data-visualization
Research direction
Start with widgets/isi_distribution.py and inspect the loop that computes and combines each segment’s histogram. The issue suggests adding counts with density=False and normalizing once after the loop; use the two supplied examples to check that the total area is 1 and that a one-spike segment leaves the bars finite. The reporter offers to add a test, but no test file is named.
Written by the indexing model from the issue text.
Description
I found this while reading widgets/isi_distribution.py, not in my own analyses, so this is a "for the sake of improvement" report.
With several segments, the histogram of each segment is computed with density=True and the densities are added (there is a TODO about this in the loop). The area is then the number of segments, and a segment with 10 spikes weighs as much as one with 5000, without an error. If one segment has a single spike, all the bars of the unit are NaN.
import matplotlib
matplotlib.use("Agg")
import numpy as np
from spikeinterface.core import NumpySorting
from spikeinterface.widgets import plot_isi_distribution
rng = np.random.default_rng(0)
seg0 = np.cumsum(rng.integers(150, 600, 5000)) # 5000 spikes, ISI 5-20 ms
seg1 = np.cumsum(rng.integers(2100, 2700, 10)) # 10 spikes, ISI 70-90 ms
sorting = NumpySorting.from_unit_dict([{0: seg0}, {0: seg1}], sampling_frequency=30000.0)
w = plot_isi_distribution(sorting, window_ms=100.0, bin_ms=1.0)
heights = np.array([bar.get_height() for bar in w.axes.flatten()[0].patches])
print("area:", heights.sum() * 1.0)
# area: 2.0 expected 1.0
print("fraction of ISI in 70-90 ms:", heights[70:90].sum() / heights.sum())
# fraction of ISI in 70-90 ms: 0.5 expected about 0.002 (9 of 5008 intervals)
sorting = NumpySorting.from_unit_dict([{0: seg0}, {0: seg1[:1]}], sampling_frequency=30000.0)
w = plot_isi_distribution(sorting, window_ms=100.0, bin_ms=1.0)
heights = np.array([bar.get_height() for bar in w.axes.flatten()[0].patches])
print("finite bars:", np.isfinite(heights).sum(), "of", heights.size)
# finite bars: 0 of 99 expected 99 of 99
Fix: add the counts of all segments with density=False and normalize once after the loop.
I can open a PR with a test if you agree.
- Dominant language
- Python
- Stars
- 883
- Forks
- 291
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 40
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SpikeInterface/spikeinterface
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
SpikeInterface/spikeinterface#5007 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
SpikeInterface/spikeinterface#5006 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
SpikeInterface/spikeinterface#5005 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
SpikeInterface/spikeinterface#5004 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
SpikeInterface/spikeinterface#5003 ·
Maintainers usually reply within 2 days
All issues in SpikeInterface/spikeinterface
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
available bug good first issue tooling
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Nixitov/Riptide-Native#816 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
teng-lin/notebooklm-py#2593 ·
Maintainers usually reply within 1 day
-
claimed-by:collie role:small-fix status:running
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Beovulfo/herd-sdlc#325 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 94/100
omarelshamy25x/shamy-arabic-nlp#267 ·
Maintainers usually reply within 1 day