`plot_unit_presence` shows bin indices on the `Time (s)` axis when `time_range` is not given

Đang mở Phù hợp với người mới
#5,006 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
82/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, python
Lĩnh vực
data-visualization

Hướng nghiên cứu

Bắt đầu với widgets/unit_presence.py, nơi plot_unit_presence tính số lượng bin và gọi imshow. Dùng hai ví dụ trong issue để kiểm tra giới hạn trục khi bỏ qua time_range và lỗi IndexError ở tần số lấy mẫu 24414.0625 Hz. Hoàn thành khi trục hiển thị giây và việc đếm bin sử dụng độ rộng mẫu nhất quán mà không gây ra lỗi chỉ mục.

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/unit_presence.py, not in my own analyses, so this is a "for the sake of improvement" report.

Without time_range, no extent is passed to imshow, so the x axis shows bin indices while it is labelled "Time (s)". With the default 0.05 s bins, the times are 20 times too large, without an error. Also, the bin width in samples is truncated with int(bin_duration_s * fs) while the number of bins is computed in seconds, so some sampling frequencies raise an IndexError.

import matplotlib

matplotlib.use("Agg")
from spikeinterface.core import generate_sorting
from spikeinterface.widgets import plot_unit_presence

sorting = generate_sorting(num_units=4, durations=[10.0], sampling_frequency=30000.0, seed=0)
w = plot_unit_presence(sorting)
print(w.ax.get_xlabel(), [float(x) for x in w.ax.get_xlim()])
# Time (s) [-0.5, 198.5]  expected about [0, 10]

sorting = generate_sorting(num_units=4, durations=[60.0], sampling_frequency=24414.0625, seed=0)
plot_unit_presence(sorting)
# IndexError: index 1200 is out of bounds for axis 1 with size 1200

Fix: always pass an extent in seconds to imshow, and compute the number of bins and the bin indices with the same bin width in samples.

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.