`plot_isi_distribution` adds the per-segment densities with several segments

Đang mở Phù hợp với người mới
#5,008 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
83/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
matplotlib, numpy, python
Lĩnh vực
data-visualization

Hướng nghiên cứu

Bắt đầu với widgets/isi_distribution.py và kiểm tra vòng lặp tính toán và kết hợp histogram của từng đoạn. Issue đề xuất cộng các số đếm với density=False rồi chuẩn hóa một lần sau vòng lặp; hãy dùng hai ví dụ được cung cấp để kiểm tra tổng diện tích bằng 1 và một đoạn chỉ có một spike vẫn cho các cột hữu hạn. Người báo cáo đề nghị thêm một bài kiểm thử, nhưng không nêu tên tệp kiểm thử nào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
883
Fork
291
Merge trung bình
3 ngày 17 giờ
Pull request đã merge (30 ngày)
40

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của SpikeInterface/spikeinterface

Tất cả issue của SpikeInterface/spikeinterface

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.