Skip to content

Commit

Permalink
fix(write.py): throw warning instead of error on conflicting bids ver…
Browse files Browse the repository at this point in the history
…sions (#1147)

* fix(write.py): throw warning instead of error on conflicting bids versions in dataset description

* test(test_write.py): update verification test for make_dataset_description to check user warning

* update doc and citation page

* move citation info to correct authors section (software, not paper)

* fixing RST syntax

---------

Co-authored-by: Stefan Appelhoff <stefan.appelhoff@mailbox.org>
  • Loading branch information
fordmcdonald and sappelhoff committed Jul 24, 2023
1 parent c3eb2cf commit 884333b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ authors:
family-names: Vanhoecke
orcid: 'https://orcid.org/0000-0002-9857-1519'
affiliation: 'Movement Disorder and Neuromodulation Unit, Department of Neurology, Charité – Universitätsmedizin Berlin, Germany'
- given-names: Ford
family-names: McDonald
affiliation: 'Behavior and NeuroData Core, Brown University, Providence, RI, USA'
orcid: 'https://orcid.org/0009-0004-5099-7109'
- given-names: Pierre
family-names: Guetschel
orcid: 'https://orcid.org/0000-0002-8933-7640'
Expand Down
1 change: 1 addition & 0 deletions doc/authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@
.. _Moritz Gerster: http://moritz-gerster.com
.. _Laetitia Fesselier: https://github.com/laemtl
.. _Jonathan Vanhoecke: https://github.com/JonathanVHoecke
.. _Ford McDonald: https://github.com/fordmcdonald
.. _Pierre Guetschel: https://github.com/PierreGtch
2 changes: 2 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The following authors contributed for the first time. Thank you so much! 🤩

* `Laetitia Fesselier`_
* `Jonathan Vanhoecke`_
* `Ford McDonald`_
* `Pierre Guetschel`_

The following authors had contributed before. Thank you for sticking around! 🤘
Expand Down Expand Up @@ -63,6 +64,7 @@ Detailed list of changes
- Fix :func:`~mne_bids.copyfiles.copyfile_eeglab` to prevent data type conversion leading to an ``eeg_checkset`` failure when trying to load the file in EEGLAB, by `Laetitia Fesselier`_ (:gh:`1126`)
- Improve compatibility with latest MNE-Python, by `Eric Larson`_ (:gh:`1128`)
- Working with :class:`~mne_bids.BIDSPath` would sometimes inadvertently create new directories, contaminating the BIDS dataset, by `Richard Höchenberger`_ (:gh:`1139`)
- Fix thrown error if the ``BIDSVersion`` defined in ``dataset_description.json`` file does not match the MNE-BIDS compliant ``BIDSVersion``, ensuring backwards compatibility across BIDS complient tools, by `Ford McDonald`_ (:gh:`1147`)

:doc:`Find out what was new in previous releases <whats_new_previous_releases>`

Expand Down
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

0 comments on commit 884333b

Please sign in to comment.