Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] fix(write.py): throw warning instead of error on conflicting bids versions #1147

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mne_bids/tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def test_make_dataset_description(tmp_path, monkeypatch):
make_dataset_description(path=tmp_path, name="tst", source_datasets=s_ds)

monkeypatch.setattr(write, "BIDS_VERSION", "old")
with pytest.raises(ValueError, match="Previous BIDS version used"):
with pytest.warns(UserWarning, match="Conflicting BIDSVersion found*"):
make_dataset_description(path=tmp_path, name="tst")


Expand Down
11 changes: 7 additions & 4 deletions mne_bids/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from datetime import datetime, timezone, timedelta
import shutil
from collections import defaultdict, OrderedDict
import warnings

from pkg_resources import parse_version

Expand Down Expand Up @@ -1324,11 +1325,13 @@ def make_dataset_description(
with open(fname, "r", encoding="utf-8-sig") as fin:
orig_cols = json.load(fin)
if "BIDSVersion" in orig_cols and orig_cols["BIDSVersion"] != BIDS_VERSION:
raise ValueError(
"Previous BIDS version used, please redo the "
"conversion to BIDS in a new directory "
"after ensuring all software is updated"
warnings.warn(
"Conflicting BIDSVersion found in dataset_description.json! "
"Consider setting BIDS root to a new directory and redo "
"conversion after ensuring all software has been updated. "
"Original dataset description will not be overwritten."
)
overwrite = False
for key in description:
if description[key] is None or not overwrite:
description[key] = orig_cols.get(key, None)
Expand Down