Skip to content

fix(neuralynx): handle unclosed files with unparseable TimeClosed - #1903

Closed
Yi-111-a wants to merge 1 commit into
NeuralEnsemble:masterfrom
Yi-111-a:fix/1901-patch
Closed

Yi-111-a wants to merge 1 commit into
NeuralEnsemble:masterfrom
Yi-111-a:fix/1901-patch

Conversation

@Yi-111-a

Copy link
Copy Markdown

Fixes #1901

Summary

When reading Neuralynx files that were not properly closed (such as following an acquisition crash or interruption), the header line -TimeClosed File was not properly closed is matched by _closeDatetime2_pat = re.compile(r'-TimeClosed (?P<date>\S+) (?P<time>\S+)') with date='File' and time='was', raising dateutil.parser.ParserError: Unknown string format: File was.

Solution

  • Wrap dateutil.parser.parse() in a try...except (ValueError, dateutil.parser.ParserError): pass block in _setTimeDate.
  • If parsing fails, recording_closed remains unset (hdr.get('recording_closed') returns None, consistent with datasets lacking close time), while hdr['TimeClosed'] preserves the raw string 'File was not properly closed'.
  • Added unit test test_unclosed_file_datetime in test_neuralynxrawio.py verifying header parsing.

Fixes #1901

@zm711

zm711 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

This looks like the same goal as #1902. Could you explain why you have two strategies?

@Yi-111-a

Yi-111-a commented Oct 4, 2026

Copy link
Copy Markdown
Author

@zm711 Good catch — they are the same goal (#1901), and having both open was an accident of two parallel attempts, not two intentional strategies.

Difference

Recommendation
Keep #1902 — you already said it looks fine once IO tests are green — and I will close this one as a duplicate. The sentinel guard is enough for the reported crash string; if a different malformed close line shows up later, a general parse guard can be a follow-up.

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.

Neuralynx DateTime incorrectly parsed

2 participants