From cb3e312fe83b526fea8846f490bf088ad19acb88 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Fri, 8 Sep 2023 16:47:00 -0400 Subject: [PATCH] Update bids.py --- xcp_d/utils/bids.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/xcp_d/utils/bids.py b/xcp_d/utils/bids.py index 4274d4d65..cd0868426 100644 --- a/xcp_d/utils/bids.py +++ b/xcp_d/utils/bids.py @@ -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