Skip to content

Fix binary save when only some segments have a time vector - #4923

Merged
alejoe91 merged 3 commits into
SpikeInterface:mainfrom
AxelNoun:fix-binary-partial-times
Nov 10, 2026
Merged

alejoe91 merged 3 commits into
SpikeInterface:mainfrom
AxelNoun:fix-binary-partial-times

Conversation

@AxelNoun

@AxelNoun AxelNoun commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Found while fixing #4914, listed under "Not addressed" in #4922.

recording.save(format="binary", ...) raised FileNotFoundError when only some segments have a time vector, for example after recording.set_times(times, segment_index=0). write_recording listed a timestamps file for every segment, but only those with a time vector are written. The error came after all the traces were written.

This PR lists None for the segments without a time vector, and makes BinaryRecordingExtractor and recursive_path_modifier accept these entries. It also includes the t_starts lines of #4922, so that a time vector on one segment and a t_start on another works without depending on it. The two PRs merge without conflict in either order, and these lines drop out of this diff if #4922 goes in first.

binary.json can now contain null in file_timestamps_paths. Older versions cannot load these folders, but could not create them either, and the output is unchanged when no segment or every segment has a time vector. I also considered ignoring a missing timestamps file when loading, but a lost file would then silently reset the times to 0.

Claude helped me with this PR.

write_recording listed a timestamps path for every segment, write_binary
only wrote those with a time vector, and BinaryRecordingSegment opened all
of them, so save raised FileNotFoundError after writing the traces. List
None for the segments without a time vector, and keep None in the
constructor, its kwargs and recursive_path_modifier.

Also keep None in t_starts, with the same lines as SpikeInterface#4922. Otherwise a time
vector on one segment and a t_start on another still raises a TypeError.

Claude helped me with this change.
@alejoe91 alejoe91 added the core Changes to core module label Nov 9, 2026
@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!

@AxelNoun

AxelNoun commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @alejoe91, I shortened the description.

Co-authored-by: Alessio Buccino <alejoe9187@gmail.com>
@alejoe91
alejoe91 merged commit 56ec52e 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.

2 participants