Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to generate by for BIDS #870

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AFQ/api/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ def __init__(self,
pipeline_description = {
"Name": bids_description["Name"],
"BIDSVersion": bids_description["BIDSVersion"],
"PipelineDescription": {"Name": "pyAFQ",
"Version": pyafq_version}}
"GeneratedBy": [{
"Name": "pyAFQ",
"Version": pyafq_version}]}

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

Expand Down
10 changes: 6 additions & 4 deletions AFQ/data/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ def to_bids_description(path, fname='dataset_description.json',
BIDSVersion="1.4.0", **kwargs):
"""Dumps a dict into a bids description at the given location"""
kwargs.update({"BIDSVersion": BIDSVersion})
if "GeneratedBy" in kwargs and "DatasetType" not in kwargs:
kwargs["DatasetType"] = "derivative"
desc_file = op.join(path, fname)
with open(desc_file, 'w') as outfile:
json.dump(kwargs, outfile)
Expand Down Expand Up @@ -763,7 +765,7 @@ def organize_cfin_data(path=None):
to_bids_description(
dmriprep_folder,
**{"Name": "CFIN",
"PipelineDescription": {"Name": "dipy"}})
"GeneratedBy": [{"Name": "dipy"}]})


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


fetch_hcp_atlas_16_bundles = _make_reusable_fetcher(
Expand Down Expand Up @@ -1460,6 +1462,6 @@ def fetch_hcp(subjects,
to_bids_description(base_dir,
**{"Name": study,
"Acknowledgements": hcp_acknowledgements,
"PipelineDescription": {'Name': 'dmriprep'}})
"GeneratedBy": [{'Name': 'dmriprep'}]})

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

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

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

for subject in subjects:
for modality in ['anat', 'dwi']:
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_AFQ_missing_files():
"otherDeriv"),
**{
"Name": "Missing",
"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 +218,7 @@ def test_AFQ_missing_files():
afd.to_bids_description(
op.join(bids_path, "missingPipe"), **{
"Name": "Missing",
"PipelineDescription": {"Name": "missingPipe"}})
"GeneratedBy": [{"Name": "missingPipe"}]})
with pytest.raises(
ValueError,
match="No non-json files recognized by pyBIDS"
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_bids_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
afd.to_bids_description(
tractography_path,
**{"Name": "my_tractography",
"PipelineDescription": {"Name": "my_tractography"}})
"GeneratedBy": [{"Name": "my_tractography"}]})


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