Skip to content

Commit d5f28cc

Browse files
Merge branch 'main' into fix-filelock
2 parents 5711ca3 + e7635a3 commit d5f28cc

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.14.2
3+
rev: v0.14.3
44
hooks:
55
- id: ruff
66
name: ruff mne_bids/

doc/Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,22 @@ help:
1818
# Catch-all target: route all unknown targets to Sphinx using the new
1919
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
2020
%: Makefile
21-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(O)
22+
23+
# Build without executing the example gallery (faster)
24+
html-noplot:
25+
@$(SPHINXBUILD) $(SPHINXOPTS) -D plot_gallery=0 $(SOURCEDIR) $(BUILDDIR)
2226

2327
# View the built documentation
28+
# If we build the example gallery, the index file is at _build/html/index.html
29+
# If we don't (e.g. html-noplot), then it is at _build/index.html
2430
view:
25-
@python -c "import webbrowser; webbrowser.open_new_tab('file://$(PWD)/_build/html/index.html')"
31+
@if [ -f "$(BUILDDIR)/html/index.html" ]; then \
32+
python -c "import webbrowser; webbrowser.open_new_tab('file://$(PWD)/$(BUILDDIR)/html/index.html')"; \
33+
elif [ -f "$(BUILDDIR)/index.html" ]; then \
34+
python -c "import webbrowser; webbrowser.open_new_tab('file://$(PWD)/$(BUILDDIR)/index.html')"; \
35+
else echo "No index.html file found to open. Did you build the docs?"; \
36+
fi
2637

2738
clean:
2839
-rm -rf _build auto_examples generated

doc/whats_new.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Detailed list of changes
5757
- Fixed a bug that modified the name and help message of some of the available commands, by `Alex Lopez Marquez`_ (:gh:`1441`)
5858
- 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`)
5959
- Made the lock helpers skip reference counting when the optional ``filelock`` dependency is missing, preventing spurious ``AttributeError`` crashes during reads, by `Bruno Aristimunha`_ (:gh:`1469`)
60-
60+
- 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`)
6161

6262
⚕️ Code health
6363
^^^^^^^^^^^^^^

mne_bids/read.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ def _handle_scans_reading(scans_fname, raw, bids_path):
420420
acq_time = acq_time.replace(tzinfo=timezone.utc)
421421
else:
422422
# Convert time offset to UTC
423+
if acq_time.tzinfo is None:
424+
# Windows needs an explicit local tz for naive, pre-epoch times.
425+
local_tz = datetime.now().astimezone().tzinfo or timezone.utc
426+
acq_time = acq_time.replace(tzinfo=local_tz)
423427
acq_time = acq_time.astimezone(timezone.utc)
424428

425429
logger.debug(f"Loaded {scans_fname} scans file to set acq_time as {acq_time}.")

mne_bids/tests/test_read.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,21 @@ def test_handle_scans_reading(tmp_path):
834834
new_acq_time = datetime.strptime(new_acq_time_str, date_format)
835835
assert raw_03.info["meas_date"] == new_acq_time.astimezone(timezone.utc)
836836

837+
# Regression for naive, pre-epoch acquisition times (Windows bug GH-1399)
838+
pre_epoch_str = "1950-06-15T13:45:30"
839+
scans_tsv["acq_time"][0] = pre_epoch_str
840+
_to_tsv(scans_tsv, scans_path)
841+
842+
raw_pre_epoch = read_raw_bids(bids_path)
843+
pre_epoch_naive = datetime.strptime(pre_epoch_str, "%Y-%m-%dT%H:%M:%S")
844+
local_tz = datetime.now().astimezone().tzinfo or timezone.utc
845+
expected_pre_epoch = pre_epoch_naive.replace(tzinfo=local_tz).astimezone(
846+
timezone.utc
847+
)
848+
assert raw_pre_epoch.info["meas_date"] == expected_pre_epoch
849+
if raw_pre_epoch.annotations.orig_time is not None:
850+
assert raw_pre_epoch.annotations.orig_time == expected_pre_epoch
851+
837852

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

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ doc = [
5858
"seaborn",
5959
"sphinx-copybutton",
6060
"sphinx>=7.4.7",
61-
"sphinx_gallery",
61+
"sphinx_gallery>=0.19.0",
6262
]
6363
# Dependencies for using all mne_bids features
6464
full = [

0 commit comments

Comments
 (0)