Skip to content

Default missing firstSample to 0 in SpikeGLX reader#1832

Merged
h-mayorquin merged 7 commits intoNeuralEnsemble:masterfrom
h-mayorquin:spikeglx_fix_lack_of_first_sample
Apr 21, 2026
Merged

Default missing firstSample to 0 in SpikeGLX reader#1832
h-mayorquin merged 7 commits intoNeuralEnsemble:masterfrom
h-mayorquin:spikeglx_fix_lack_of_first_sample

Conversation

@h-mayorquin
Copy link
Copy Markdown
Contributor

Closes #1819. Some SpikeGLX .meta files do not carry firstSample, even though it is documented in every phase. The reader accesses it directly in _parse_header and crashes with a bare KeyError. This PR makes the read defensive and defaults to 0.0 with a UserWarning naming the file. Zero is the correct fallback: firstSample exists to offset t_start for files that represent a trimmed slice of a longer run, and files that never had it written are not trimmed.

I have lifted the read into a new pre-dict step, _add_first_sample, that follows the pattern of _add_segment_order: it enriches each info dict with info["first_sample"] before signals_info_dict is built, and the timing loop then reads the prepared field instead of touching the raw meta.

@h-mayorquin h-mayorquin merged commit 71df66e into NeuralEnsemble:master Apr 21, 2026
3 checks passed
@h-mayorquin h-mayorquin deleted the spikeglx_fix_lack_of_first_sample branch April 21, 2026 20:13
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.

Support for SpikeGLX files with missing firstSample in meta

2 participants