Remove `segment_index` from the spike vector(s)

Đang mở
#4,816 2 bình luận 1 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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
32/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
numpy, python
Lĩnh vực
data, performance

Hướng nghiên cứu

Start with to_spike_vector(return_slices=True) in waveform_tools.py and review the linked usages in analyzer_extension_core.py and numpyextractors.py. Trace the repeated np.searchsorted calls across waveform_tools.py, basesorting.py, zarrextractors.py, sorting_tools.py, and remove_excess_spikes.py. Done means the segment index is removed, slices are used instead, and a compatibility path remains for saved sortings that contain the field.

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

Mô tả

core discussion

I am reviewing #4809 (optimize SpikeRetriever and RAM usage for extensions) and I want to bring back the topic of simplifying the spike vector (time ordered and unit ordered) data model. A lot of the memory cost on @alejoe91's benchmark is the spike vector itself and of that 1/3 is the segment index and the segment index is unnecessary. This is an edge case (most recordings are not multi-segment) and the field is only a convenience, syntactic sugar. These are the main places where we use it:

  1. To find the boundaries of a segment (the sorting already caches them as segment_slices, see to_spike_vector(return_slices=True)):
    https://github.com/SpikeInterface/spikeinterface/blob/93c612f51cca09ecafe2c23a283132cf0ad57869/src/spikeinterface/core/waveform_tools.py#L357
    The same np.searchsorted is repeated three more times in waveform_tools.py and in basesorting.py, zarrextractors.py, sorting_tools.py and remove_excess_spikes.py.

  2. To mask the spikes of one unit in one segment (this could be a slice of the segment plus a mask on unit_index):
    https://github.com/SpikeInterface/spikeinterface/blob/93c612f51cca09ecafe2c23a283132cf0ad57869/src/spikeinterface/core/analyzer_extension_core.py#L131-L133

  3. As a sort key when building a sorting from peaks (the slices could be computed once at construction instead):
    https://github.com/SpikeInterface/spikeinterface/blob/93c612f51cca09ecafe2c23a283132cf0ad57869/src/spikeinterface/core/numpyextractors.py#L498

As a side effect this would remove the branching for the mono-segment case, like the special cases that #4809 adds to SpikeRetriever, PeakRetriever and _get_spike_vector_segment_slices.

The cost is a big refactor: using the slices wherever we rely on np.searchsorted (which I also think would be more efficient) and a compatibility path for the sortings that were saved with the field.

What do you think? Is there something I am missing?

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.