Skip to content

Fix saving a recording when only some segments have a t_start - #4922

Merged
alejoe91 merged 3 commits into
SpikeInterface:mainfrom
AxelNoun:fix-mixed-t-starts
Nov 10, 2026
Merged

alejoe91 merged 3 commits into
SpikeInterface:mainfrom
AxelNoun:fix-mixed-t-starts

Conversation

@AxelNoun

@AxelNoun AxelNoun commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4914.

When only some segments have a t_start, for example after append_recordings or shift_times(..., segment_index=1), get_segment_t_starts returns a list such as [None, 100.0]. NumpyRecording, SharedMemoryRecording and BinaryRecordingExtractor called float() on every entry, so save raised a TypeError for the binary and memory formats.

This PR keeps the None entries in these three constructors, rather than replacing them with 0.0, so that "no start time" stays distinct from "starts at 0", as zarr already does with NaN. It also covers the two smaller points of the issue:

  • SharedMemoryRecording no longer raises AttributeError in __del__ after a failed constructor. With main_shm_owner=True, it now releases the buffers it had attached.
  • ZarrRecordingExtractor returns t_start as a float instead of a 0-d array.

Not addressed: the binary save with a time vector on only some segments (#4923), and save silently ignoring unknown keywords such as shared_memory.

Claude helped me with this PR.

get_segment_t_starts returns a mixed list such as [None, 100.0] when only
some segments have a start time, and three constructors called float() on
every entry. Keep None in these constructors.

Also set shms and main_shm_owner first in SharedMemoryRecording, so that
__del__ is safe after a failed constructor, and return a float instead of
a 0-d array from ZarrRecordingExtractor.

Claude helped me with this change.
@alejoe91

alejoe91 commented Nov 9, 2026

Copy link
Copy Markdown
Member

Thanks @AxelNoun

Could you shorten the PR message? You can drop "Changes" and just keep an overview of what changed. We also don't need all the Tests details.

Always keep in mind that humans will need to read it, and we all have a limited amount of time! Thanks in advance!

@alejoe91 alejoe91 added the core Changes to core module label Nov 9, 2026
@AxelNoun

AxelNoun commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @alejoe91, I shortened the description.

@alejoe91 alejoe91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AxelNoun

Can you remove the added test that is unrelated to the change?

Requested in review: the test is unrelated to the t_starts fix.

@alejoe91 alejoe91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@alejoe91
alejoe91 merged commit 21f7fcb into SpikeInterface:main Nov 10, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saving a multi-segment recording fails when only some segments have a t_start

2 participants