Skip to content

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

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

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

This branch has not been deployed

No deployments
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

1 participant