Skip to content

Commit b208a8c

Browse files
authored
auto-gen a GeneratedBy dict (#1384)
* auto-gen a GeneratedBy dict * changelog
1 parent a36db9e commit b208a8c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

doc/whats_new.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Detailed list of changes
4343
🧐 API and behavior changes
4444
^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545

46-
- Nothing yet
46+
- :func:`mne_bids.make_dataset_description` will now auto-generate basic ``GeneratedBy`` fields if ``generated_by=None``. To suppress the auto-generated fields, pass an empty list. By `Daniel McCloy`_ (:gh:`1384`)
4747

4848
🛠 Requirements
4949
^^^^^^^^^^^^^^^

mne_bids/write.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
from mne_bids import (
3939
BIDSPath,
40+
__version__,
4041
get_anonymization_daysback,
4142
get_bids_path_from_fname,
4243
read_raw_bids,
@@ -1297,7 +1298,9 @@ def make_dataset_description(
12971298
doi:10.5281/zenodo.3686061).
12981299
generated_by : list of dict | None
12991300
Used to specify provenance of the dataset. See BIDS specification
1300-
for details.
1301+
for details. If ``None``, a basic description containing MNE-BIDS name, version,
1302+
and URL will be generated for you. To suppress this behavior, pass an empty
1303+
list.
13011304
source_datasets : list of dict | None
13021305
Used to specify the locations and relevant attributes of all source
13031306
datasets. Each dict in the list represents one source dataset and
@@ -1349,9 +1352,16 @@ def make_dataset_description(
13491352
)
13501353
if not set(i.keys()).issubset(generated_by_keys):
13511354
raise ValueError(msg_key.format(i.keys() - generated_by_keys))
1355+
elif generated_by is not None:
1356+
raise ValueError(msg_type.format("generated_by"))
13521357
else:
1353-
if generated_by is not None:
1354-
raise ValueError(msg_type.format("generated_by"))
1358+
generated_by = [
1359+
dict(
1360+
Name="MNE-BIDS",
1361+
Version=__version__,
1362+
CodeURL="https://mne.tools/mne-bids/",
1363+
)
1364+
]
13551365

13561366
source_ds_keys = set(["URL", "DOI", "Version"])
13571367
if isinstance(source_datasets, list):

0 commit comments

Comments
 (0)