Skip to content

Commit 0626ef5

Browse files
committed
RF: Update dataset_description.json generator to conform to BIDS 1.4.0
1 parent e0b83d3 commit 0626ef5

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

fmriprep/utils/bids.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ def write_bidsignore(deriv_dir):
2222

2323

2424
def write_derivative_description(bids_dir, deriv_dir):
25-
from ..__about__ import __version__, __url__, DOWNLOAD_URL
25+
from ..__about__ import __version__, DOWNLOAD_URL
2626

2727
bids_dir = Path(bids_dir)
2828
deriv_dir = Path(deriv_dir)
2929
desc = {
3030
'Name': 'fMRIPrep - fMRI PREProcessing workflow',
31-
'BIDSVersion': '1.1.1',
32-
'PipelineDescription': {
31+
'BIDSVersion': '1.4.0',
32+
'DatasetType': 'derivative',
33+
'GeneratedBy': [{
3334
'Name': 'fMRIPrep',
3435
'Version': __version__,
3536
'CodeURL': DOWNLOAD_URL,
36-
},
37-
'CodeURL': __url__,
37+
}],
3838
'HowToAcknowledge':
3939
'Please cite our paper (https://doi.org/10.1038/s41592-018-0235-4), '
4040
'and include the generated citation boilerplate within the Methods '
@@ -43,30 +43,31 @@ def write_derivative_description(bids_dir, deriv_dir):
4343

4444
# Keys that can only be set by environment
4545
if 'FMRIPREP_DOCKER_TAG' in os.environ:
46-
desc['DockerHubContainerTag'] = os.environ['FMRIPREP_DOCKER_TAG']
46+
desc['GeneratedBy'][0]['Container'] = {
47+
"Type": "docker",
48+
"Tag": f"poldracklab/fmriprep:{os.environ['FMRIPREP_DOCKER_TAG']}"
49+
}
4750
if 'FMRIPREP_SINGULARITY_URL' in os.environ:
48-
singularity_url = os.environ['FMRIPREP_SINGULARITY_URL']
49-
desc['SingularityContainerURL'] = singularity_url
50-
51-
singularity_md5 = _get_shub_version(singularity_url)
52-
if singularity_md5 and singularity_md5 is not NotImplemented:
53-
desc['SingularityContainerMD5'] = _get_shub_version(singularity_url)
51+
desc['GeneratedBy'][0]['Container'] = {
52+
"Type": "singularity",
53+
"URI": os.environ['FMRIPREP_SINGULARITY_URL']
54+
}
5455

5556
# Keys deriving from source dataset
5657
orig_desc = {}
5758
fname = bids_dir / 'dataset_description.json'
5859
if fname.exists():
59-
with fname.open() as fobj:
60-
orig_desc = json.load(fobj)
60+
orig_desc = json.loads(fname.read_text())
6161

6262
if 'DatasetDOI' in orig_desc:
63-
desc['SourceDatasetsURLs'] = ['https://doi.org/{}'.format(
64-
orig_desc['DatasetDOI'])]
63+
desc['SourceDatasets'] = [{
64+
'URL': 'https://doi.org/{}'.format(orig_desc['DatasetDOI']),
65+
'DOI': orig_desc['DatasetDOI']
66+
}]
6567
if 'License' in orig_desc:
6668
desc['License'] = orig_desc['License']
6769

68-
with (deriv_dir / 'dataset_description.json').open('w') as fobj:
69-
json.dump(desc, fobj, indent=4)
70+
Path.write_text(deriv_dir / 'dataset_description.json', json.dumps(desc, indent=4))
7071

7172

7273
def validate_input_dir(exec_env, bids_dir, participant_label):
@@ -154,7 +155,3 @@ def validate_input_dir(exec_env, bids_dir, participant_label):
154155
subprocess.check_call(['bids-validator', bids_dir, '-c', temp.name])
155156
except FileNotFoundError:
156157
print("bids-validator does not appear to be installed", file=sys.stderr)
157-
158-
159-
def _get_shub_version(singularity_url):
160-
return NotImplemented

0 commit comments

Comments
 (0)