Skip to content

Avoid materializing entire time vector from zarr for time_to_sample_index#4620

Open
grahamfindlay wants to merge 1 commit into
SpikeInterface:mainfrom
grahamfindlay:perf/lazy_time_to_sample_index
Open

Avoid materializing entire time vector from zarr for time_to_sample_index#4620
grahamfindlay wants to merge 1 commit into
SpikeInterface:mainfrom
grahamfindlay:perf/lazy_time_to_sample_index

Conversation

@grahamfindlay

Copy link
Copy Markdown
Contributor

np.searchsorted is fine for mem-maps, but for out-of-core arrays (zarr) it reads the whole time vector (even if a zarr.Array) into memory. Bisecting instead reads O(log N) elements, which saves an order of magnitude of RAM for long recordings.

…ndex

`np.searchsorted` is fine for mem-maps, but for out-of-core arrays (zarr) it reads
the whole time vector (even if a `zarr.Array`) into memory. Bisecting instead reads
O(log N) elements, which saves an order of magnitude of RAM for long recordings.
"""
grahamfindlay added a commit to grahamfindlay/spikeinterface that referenced this pull request Jun 16, 2026
@alejoe91

Copy link
Copy Markdown
Member

Stumbled upon the same issue yesterday!!

Elegant solution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants