Skip to content

Don't crash parsing ABF files with an invalid acquisition date#1866

Open
h-mayorquin wants to merge 1 commit into
NeuralEnsemble:masterfrom
h-mayorquin:axon_lack_of_date_bug
Open

Don't crash parsing ABF files with an invalid acquisition date#1866
h-mayorquin wants to merge 1 commit into
NeuralEnsemble:masterfrom
h-mayorquin:axon_lack_of_date_bug

Conversation

@h-mayorquin

Copy link
Copy Markdown
Contributor

Some ABF files store a "no date" sentinel (all bits set) in their date header fields, and AxonRawIO currently raises while building the recording datetime from those values, which blocks reading the file entirely even though the date is non-essential annotation. Both the ABF v1 and ABF v2 paths produce out-of-range values from this sentinel, so parsing now falls back to a None recording datetime rather than failing, keeping the signal accessible.

@h-mayorquin h-mayorquin self-assigned this Jun 24, 2026

@zm711 zm711 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just one general question @h-mayorquin.

Comment thread neo/rawio/axonrawio.py
try:
header["rec_datetime"] = datetime.datetime(YY, MM, DD, hh, mm, ss, ms)
except (ValueError, OverflowError):
# Date/time header fields hold an out-of-range or "no date" sentinel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we warn people? I don't know this system well enough to know if warning a person that they didn't have an acquisition time is a marker of a "poor" acquisition or is something that the user should know they forgot to set up? What do you think? It's not actionable, but it might be valuable for the user to know. I just don't know the reader.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am honestly not sure a missing date is a real problem, so I would rather follow pyABF precedent here to just skip it. As far as I can tell it happens because the date field holds an unset/sentinel value (0xFFFFFFFF) that does not parse into a real date, and pyABF does not treat that as fatal either, it just falls back.

In addition, most users of neo do not really use this field so I don't think the warning will be useful for their purposes. Most of the datetime work was done to parse metadata for neuroconv where this is required and there it fails loudly so I think is Ok.

Btw, thanks for making me check this, I found another error that I will address.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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