Skip to content

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

Merged
zm711 merged 5 commits into
NeuralEnsemble:masterfrom
h-mayorquin:axon_lack_of_date_bug
Jul 9, 2026
Merged

Don't crash parsing ABF files with an invalid acquisition date#1866
zm711 merged 5 commits 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 Outdated
@h-mayorquin h-mayorquin force-pushed the axon_lack_of_date_bug branch from 53de479 to 5c4e286 Compare July 9, 2026 15:34
Comment thread .gitignore
uv.lock
.venv No newline at end of file
.venv
.python-version No newline at end of file

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.

Interesting where did this come from?

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.

this is a uv thing.

@h-mayorquin

Copy link
Copy Markdown
Contributor Author

At the end:

For version 2 I replaced the try/except with an explicit check for the two "no date" sentinel values (0 and 0xFFFFFFFF) on uFileStartDate, falling back to rec_datetime = None only for those and letting any other out-of-range value raise as before.

For version 1 I did the equivalent, but on the time field rather than the date field. That path hardcodes the date to 1900 and only reads lFileStartTime, where 0xFFFFFFFF comes through as -1 and 0 is a legitimate midnight. So instead of matching the two literal values (which would wrongly reject a real midnight), I check that the value is a valid time-of-day (0 <= lFileStartTime < 86400). Same effect: the sentinel falls back to None, everything else builds normally, and there's no try/except.

Both are covered by a test asserting that invalid_date_abf1.abf and invalid_date_abf2.abf parse with rec_datetime = None.

@h-mayorquin

Copy link
Copy Markdown
Contributor Author

This should be ready.

@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.

Good by me.

@zm711 zm711 merged commit 4277f1a into NeuralEnsemble:master Jul 9, 2026
3 checks passed
@h-mayorquin h-mayorquin deleted the axon_lack_of_date_bug branch July 9, 2026 16:17
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