Skip to content

Commit

Permalink
add "GeneratedBy"s in dataset_description.json
Browse files Browse the repository at this point in the history
Fixes #1018
  • Loading branch information
pierre-nedelec committed Sep 12, 2023
1 parent e9dfc21 commit 921fdbd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
4 changes: 3 additions & 1 deletion AFQ/api/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def __init__(self,
"Name": bids_description["Name"],
"BIDSVersion": bids_description["BIDSVersion"],
"PipelineDescription": {"Name": "pyAFQ",
"Version": pyafq_version}}
"Version": pyafq_version},
"GeneratedBy": [{"Name": op.basename(self.afq_path),
"Version": pyafq_version}]}

pl_desc_file = op.join(self.afq_path, 'dataset_description.json')

Expand Down
18 changes: 12 additions & 6 deletions AFQ/data/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,8 @@ def organize_cfin_data(path=None):
to_bids_description(
dmriprep_folder,
**{"Name": "CFIN",
"PipelineDescription": {"Name": "dipy"}})
"PipelineDescription": {"Name": "dipy"},
"GeneratedBy": [{"Name": "dipy"}]})


def organize_stanford_data(path=None, clear_previous_afq=None):
Expand Down Expand Up @@ -1120,10 +1121,12 @@ def organize_stanford_data(path=None, clear_previous_afq=None):
# And descriptions of the pipelines in the derivatives:
to_bids_description(dmriprep_folder,
**{"Name": "Stanford HARDI",
"PipelineDescription": {"Name": "vistasoft"}})
"PipelineDescription": {"Name": "vistasoft"},
"GeneratedBy": [{"Name": "vistasoft"}]})
to_bids_description(freesurfer_folder,
**{"Name": "Stanford HARDI",
"PipelineDescription": {"Name": "freesurfer"}})
"PipelineDescription": {"Name": "freesurfer"},
"GeneratedBy": [{"Name": "freesurfer"}]})


fetch_stanford_hardi_lv1 = _make_reusable_fetcher(
Expand Down Expand Up @@ -1750,7 +1753,8 @@ def fetch_hcp(subjects,
to_bids_description(base_dir,
**{"Name": study,
"Acknowledgements": hcp_acknowledgements,
"PipelineDescription": {'Name': 'dmriprep'}})
"PipelineDescription": {'Name': 'dmriprep'},
"GeneratedBy": [{'Name': 'dmriprep'}]})

return data_files, op.join(my_path, study)

Expand Down Expand Up @@ -1844,7 +1848,8 @@ def fetch_hbn_preproc(subjects, path=None):
to_bids_description(base_dir,
**{"Name": "HBN",
"Acknowledgements": hbn_acknowledgements,
"PipelineDescription": {'Name': 'qsiprep'}})
"PipelineDescription": {'Name': 'qsiprep'},
"GeneratedBy": [{'Name': 'qsiprep'}]})

return data_files, op.join(my_path, "HBN")

Expand Down Expand Up @@ -1941,6 +1946,7 @@ def fetch_hbn_afq(subjects, path=None):
# Create the BIDS derivatives description file text
to_bids_description(base_dir,
**{"Name": "HBN",
"PipelineDescription": {'Name': 'afq'}})
"PipelineDescription": {'Name': 'afq'},
"GeneratedBy": [{'Name': 'afq'}]})

return data_files, op.join(my_path, "HBN")
15 changes: 10 additions & 5 deletions AFQ/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def create_dummy_bids_path(n_subjects, n_sessions, share_sessions=True):
afd.to_bids_description(
dmriprep_dir,
**{"Name": "Dummy",
"PipelineDescription": {"Name": "synthetic"}})
"PipelineDescription": {"Name": "synthetic"},
"GeneratedBy": [{"Name": "synthetic"}]})

for subject in subjects:
for session in sessions:
Expand All @@ -140,7 +141,8 @@ def create_dummy_bids_path(n_subjects, n_sessions, share_sessions=True):
afd.to_bids_description(
dmriprep_dir,
**{"Name": "Dummy",
"PipelineDescription": {"Name": "synthetic"}})
"PipelineDescription": {"Name": "synthetic"},
"GeneratedBy": [{"Name": "synthetic"}]})

for d in range(n_subjects):
subject = subjects[d]
Expand All @@ -163,7 +165,8 @@ def create_dummy_bids_path(n_subjects, n_sessions, share_sessions=True):
afd.to_bids_description(
dmriprep_dir,
**{"Name": "Dummy",
"PipelineDescription": {"Name": "synthetic"}})
"PipelineDescription": {"Name": "synthetic"},
"GeneratedBy": [{"Name": "synthetic"}]})

for subject in subjects:
for modality in ['anat', 'dwi']:
Expand Down Expand Up @@ -205,7 +208,8 @@ def test_AFQ_missing_files():
"otherDeriv"),
**{
"Name": "Missing",
"PipelineDescription": {"Name": "otherDeriv"}})
"PipelineDescription": {"Name": "otherDeriv"},
"GeneratedBy": [{"Name": "otherDeriv"}]})
touch(op.join(subses_folder, "sub-01_ses-01_dwi.nii.gz"))

with pytest.raises(
Expand All @@ -218,7 +222,8 @@ def test_AFQ_missing_files():
afd.to_bids_description(
op.join(bids_path, "missingPipe"), **{
"Name": "Missing",
"PipelineDescription": {"Name": "missingPipe"}})
"PipelineDescription": {"Name": "missingPipe"},
"GeneratedBy": [{"Name": "missingPipe"}]})
with pytest.raises(
ValueError,
match="No non-json files recognized by pyBIDS"
Expand Down
3 changes: 2 additions & 1 deletion examples/tutorial_examples/plot_bids_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
afd.to_bids_description(
tractography_path,
**{"Name": "my_tractography",
"PipelineDescription": {"Name": "my_tractography"}})
"PipelineDescription": {"Name": "my_tractography"},
"GeneratedBy": [{"Name": "my_tractography"}]})


###########################################################################
Expand Down

0 comments on commit 921fdbd

Please sign in to comment.