|
10 | 10 | In this example we will use MNE-BIDS to organize the MNE sample data according
|
11 | 11 | to the BIDS standard.
|
12 | 12 | 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 |
14 | 17 |
|
15 | 18 | # Authors: Mainak Jas <[email protected]>
|
16 | 19 | # Alexandre Gramfort <[email protected]>
|
|
24 | 27 | # First we import some basic Python libraries, followed by MNE-Python and its
|
25 | 28 | # sample data, and then finally the MNE-BIDS functions we need for this example
|
26 | 29 |
|
| 30 | +import json |
27 | 31 | import os.path as op
|
| 32 | +from pprint import pprint |
28 | 33 | import shutil
|
29 | 34 |
|
30 | 35 | import mne
|
31 | 36 | from mne.datasets import sample
|
32 | 37 |
|
33 | 38 | 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) |
35 | 41 | from mne_bids.stats import count_events
|
36 | 42 |
|
37 | 43 | # %%
|
|
82 | 88 | raw.info['line_freq'] = 60
|
83 | 89 | raw_er.info['line_freq'] = 60
|
84 | 90 |
|
| 91 | +task = 'audiovisual' |
85 | 92 | bids_path = BIDSPath(
|
86 | 93 | subject='01',
|
87 | 94 | session='01',
|
88 |
| - task='audiovisual', |
| 95 | + task=task, |
89 | 96 | run='1',
|
90 | 97 | root=output_path
|
91 | 98 | )
|
|
170 | 177 | with open(readme, 'r', encoding='utf-8-sig') as fid:
|
171 | 178 | text = fid.read()
|
172 | 179 | 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`_! |
0 commit comments