Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Detailed list of changes

- Fixed a bug that modified the name and help message of some of the available commands, by `Alex Lopez Marquez`_ (:gh:`1441`)
- Updated MEG/iEEG writers to satisfy the stricter checks in the latest BIDS validator releases: BTi/4D run folders now retain their ``.pdf`` suffix (falling back to the legacy naming when an older validator is detected), KIT marker files encode the run via the ``acq`` entity instead of ``run``, datasets lacking iEEG montages receive placeholder ``electrodes.tsv``/``coordsystem.json`` files, and the ``AssociatedEmptyRoom`` entry stores dataset-relative paths by `Bruno Aristimunha`_ (:gh:`1449`)
- Fixed a bug in :func:`mne_bids.read_raw_bids` that caused it to fail when reading BIDS datasets where the acquisition time was specified in local time rather than UTC only in Windows, by `Bruno Aristimunha`_ (:gh:`1452`)

⚕️ Code health
^^^^^^^^^^^^^^
Expand Down
4 changes: 4 additions & 0 deletions mne_bids/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ def _handle_scans_reading(scans_fname, raw, bids_path):
acq_time = acq_time.replace(tzinfo=timezone.utc)
else:
# Convert time offset to UTC
if acq_time.tzinfo is None:
# Windows needs an explicit local tz for naive, pre-epoch times.
local_tz = datetime.now().astimezone().tzinfo or timezone.utc
acq_time = acq_time.replace(tzinfo=local_tz)
acq_time = acq_time.astimezone(timezone.utc)

logger.debug(f"Loaded {scans_fname} scans file to set acq_time as {acq_time}.")
Expand Down
15 changes: 15 additions & 0 deletions mne_bids/tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,21 @@ def test_handle_scans_reading(tmp_path):
new_acq_time = datetime.strptime(new_acq_time_str, date_format)
assert raw_03.info["meas_date"] == new_acq_time.astimezone(timezone.utc)

# Regression for naive, pre-epoch acquisition times (Windows bug GH-1399)
pre_epoch_str = "1950-06-15T13:45:30"
scans_tsv["acq_time"][0] = pre_epoch_str
_to_tsv(scans_tsv, scans_path)

raw_pre_epoch = read_raw_bids(bids_path)
pre_epoch_naive = datetime.strptime(pre_epoch_str, "%Y-%m-%dT%H:%M:%S")
local_tz = datetime.now().astimezone().tzinfo or timezone.utc
expected_pre_epoch = pre_epoch_naive.replace(tzinfo=local_tz).astimezone(
timezone.utc
)
assert raw_pre_epoch.info["meas_date"] == expected_pre_epoch
if raw_pre_epoch.annotations.orig_time is not None:
assert raw_pre_epoch.annotations.orig_time == expected_pre_epoch


@pytest.mark.filterwarnings(warning_str["channel_unit_changed"])
def test_handle_scans_reading_brainvision(tmp_path):
Expand Down