Skip to content

Commit 8e0ac92

Browse files
Merge branch 'main' into electrodes_dev
2 parents 1fab1e5 + 7c08e3b commit 8e0ac92

File tree

2 files changed

+65
-4
lines changed

2 files changed

+65
-4
lines changed

examples/convert_mne_sample.py

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
In this example we will use MNE-BIDS to organize the MNE sample data according
1111
to the BIDS standard.
1212
In a second step we will read the organized dataset using MNE-BIDS.
13-
""" # noqa: D400 D205
13+
14+
.. _BIDS dataset_description.json definition: https://bids-specification.readthedocs.io/en/stable/03-modality-agnostic-files.html#dataset-description
15+
.. _ds000248 dataset_description.json: https://github.com/sappelhoff/bids-examples/blob/master/ds000248/dataset_description.json
16+
""" # noqa: D400 D205 E501
1417

1518
# Authors: Mainak Jas <[email protected]>
1619
# Alexandre Gramfort <[email protected]>
@@ -24,14 +27,17 @@
2427
# First we import some basic Python libraries, followed by MNE-Python and its
2528
# sample data, and then finally the MNE-BIDS functions we need for this example
2629

30+
import json
2731
import os.path as op
32+
from pprint import pprint
2833
import shutil
2934

3035
import mne
3136
from mne.datasets import sample
3237

3338
from mne_bids import (write_raw_bids, read_raw_bids, write_meg_calibration,
34-
write_meg_crosstalk, BIDSPath, print_dir_tree)
39+
write_meg_crosstalk, BIDSPath, print_dir_tree,
40+
make_dataset_description)
3541
from mne_bids.stats import count_events
3642

3743
# %%
@@ -82,10 +88,11 @@
8288
raw.info['line_freq'] = 60
8389
raw_er.info['line_freq'] = 60
8490

91+
task = 'audiovisual'
8592
bids_path = BIDSPath(
8693
subject='01',
8794
session='01',
88-
task='audiovisual',
95+
task=task,
8996
run='1',
9097
root=output_path
9198
)
@@ -170,3 +177,57 @@
170177
with open(readme, 'r', encoding='utf-8-sig') as fid:
171178
text = fid.read()
172179
print(text)
180+
181+
# %%
182+
# It is also generally a good idea to add a description of your dataset,
183+
# see the `BIDS dataset_description.json definition`_ for more information.
184+
185+
how_to_acknowledge = """\
186+
If you reference this dataset in a publication, please acknowledge its \
187+
authors and cite MNE papers: A. Gramfort, M. Luessi, E. Larson, D. Engemann, \
188+
D. Strohmeier, C. Brodbeck, L. Parkkonen, M. Hämäläinen, \
189+
MNE software for processing MEG and EEG data, NeuroImage, Volume 86, \
190+
1 February 2014, Pages 446-460, ISSN 1053-8119 \
191+
and \
192+
A. Gramfort, M. Luessi, E. Larson, D. Engemann, D. Strohmeier, C. Brodbeck, \
193+
R. Goj, M. Jas, T. Brooks, L. Parkkonen, M. Hämäläinen, MEG and EEG data \
194+
analysis with MNE-Python, Frontiers in Neuroscience, Volume 7, 2013, \
195+
ISSN 1662-453X"""
196+
197+
make_dataset_description(
198+
path=bids_path.root,
199+
name=task,
200+
authors=["Alexandre Gramfort", "Matti Hämäläinen"],
201+
how_to_acknowledge=how_to_acknowledge,
202+
acknowledgements="""\
203+
Alexandre Gramfort, Mainak Jas, and Stefan Appelhoff prepared and updated the \
204+
data in BIDS format.""",
205+
data_license='CC0',
206+
ethics_approvals=['Human Subjects Division at the University of Washington'], # noqa: E501
207+
funding=[
208+
"NIH 5R01EB009048",
209+
"NIH 1R01EB009048",
210+
"NIH R01EB006385",
211+
"NIH 1R01HD40712",
212+
"NIH 1R01NS44319",
213+
"NIH 2R01NS37462",
214+
"NIH P41EB015896",
215+
"ANR-11-IDEX-0003-02",
216+
"ERC-StG-263584",
217+
"ERC-StG-676943",
218+
"ANR-14-NEUC-0002-01"
219+
],
220+
references_and_links=[
221+
"https://doi.org/10.1016/j.neuroimage.2014.02.017",
222+
"https://doi.org/10.3389/fnins.2013.00267",
223+
"https://mne.tools/stable/overview/datasets_index.html#sample"
224+
],
225+
doi="doi:10.18112/openneuro.ds000248.v1.2.4",
226+
overwrite=True
227+
)
228+
desc_json_path = bids_path.root / 'dataset_description.json'
229+
with open(desc_json_path, 'r', encoding='utf-8-sig') as fid:
230+
pprint(json.loads(fid.read()))
231+
232+
# %%
233+
# This should be very similar to the `ds000248 dataset_description.json`_!

mne_bids/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ def get_entity_vals(root, entity_key, *, ignore_subjects='emptyroom',
16221622
16231623
References
16241624
----------
1625-
.. [1] https://bids-specification.rtfd.io/en/latest/02-common-principles.html#file-name-structure # noqa: E501
1625+
.. [1] https://bids-specification.rtfd.io/en/latest/02-common-principles.html#entities # noqa: E501
16261626
16271627
"""
16281628
root = _check_fname(

0 commit comments

Comments
 (0)