Skip to content

Commit

Permalink
Update bids.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Sep 8, 2023
1 parent b96be01 commit cb3e312
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions xcp_d/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,23 @@ def collect_data(

temp_bold_query = queries["bold"].copy()
temp_bold_query["extension"] = ".nii.gz"

temp_xfm_query = queries["anat_to_template_xfm"].copy()

for volspace in allowed_spaces:
temp_bold_query["space"] = volspace
bold_data = layout.get(**temp_bold_query)
if bold_data:
temp_xfm_query["to"] = volspace
transform_files = layout.get(**temp_xfm_query)

if bold_data and transform_files:
# will leave the best available space in the query
break

temp_xfm_query = queries["anat_to_template_xfm"].copy()
temp_xfm_query["to"] = volspace
transform_files = layout.get(**temp_xfm_query)
if not transform_files:
raise FileNotFoundError(f"No nifti transforms found to allowed space ({volspace})")
if not bold_data or not transform_files:
raise FileNotFoundError(
f"No BOLD NIfTI or transforms found to allowed space ({volspace})"
)

queries["anat_to_template_xfm"]["to"] = volspace
queries["template_to_anat_xfm"]["from"] = volspace
Expand Down

0 comments on commit cb3e312

Please sign in to comment.