From 9b3a4d38a252e8e26980135229f68ca90d0fe359 Mon Sep 17 00:00:00 2001 From: Daniel Tse Date: Thu, 20 Jul 2023 01:08:29 +0800 Subject: [PATCH] ENH: add microsecond format support in read_raw_snirf (#11804) Co-authored-by: Daniel McCloy --- doc/changes/latest.inc | 1 + doc/changes/names.inc | 2 ++ mne/io/snirf/_snirf.py | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/changes/latest.inc b/doc/changes/latest.inc index 8b8c7f65f81..a08fdaab4b2 100644 --- a/doc/changes/latest.inc +++ b/doc/changes/latest.inc @@ -42,6 +42,7 @@ Bugs - Fix bug that required curv.*h files to create Brain object (:gh:`11704` by :newcontrib:`Aaron Earle-Richardson`) - Extended test to highlight bug in :func:`mne.stats.permutation_t_test` (:gh:`11575` by :newcontrib:`Joshua Calder-Travis`) - Fix bug that used wrong indices for line/label styles (sometimes causing an ``IndexError``) in :meth:`mne.preprocessing.ICA.plot_sources` under certain conditions (:gh:`11808` by :newcontrib:`Joshua Calder-Travis`) +- Fix bug with :func:`~mne.io.read_raw_snirf` to handle files with measurement time containing milliseconds (:gh:`11804` by :newcontrib:`Daniel Tse`) - Fix bug where :meth:`mne.viz.Brain.add_volume_labels` used an incorrect orientation (:gh:`11730` by `Alex Rockhill`_) - Fix bug with :func:`mne.forward.restrict_forward_to_label` where cortical patch information was not adjusted (:gh:`11694` by `Eric Larson`_) - Fix bug with PySide6 compatibility (:gh:`11721` by `Eric Larson`_) diff --git a/doc/changes/names.inc b/doc/changes/names.inc index 9c6301cc211..ce9de035581 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -106,6 +106,8 @@ .. _Daniel Strohmeier: https://github.com/joewalter +.. _Daniel Tse: https://github.com/Xiezhibin + .. _Darin Erat Sleiter: https://github.com/dsleiter .. _David Haslacher: https://github.com/davidhaslacher diff --git a/mne/io/snirf/_snirf.py b/mne/io/snirf/_snirf.py index 2bde9fcf263..d21c860c7a6 100644 --- a/mne/io/snirf/_snirf.py +++ b/mne/io/snirf/_snirf.py @@ -419,7 +419,12 @@ def natural_keys(text): str_datetime = str_date + str_time # Several formats have been observed so we try each in turn - for dt_code in ["%Y-%m-%d%H:%M:%SZ", "%Y-%m-%d%H:%M:%S"]: + for dt_code in [ + "%Y-%m-%d%H:%M:%SZ", + "%Y-%m-%d%H:%M:%S", + "%Y-%m-%d%H:%M:%S.%f", + "%Y-%m-%d%H:%M:%S.%f%z", + ]: try: meas_date = datetime.datetime.strptime(str_datetime, dt_code) except ValueError: