Skip to content

Commit

Permalink
Fix ingression of standard-space mesh files (#1309)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo authored Oct 31, 2024
1 parent 9275de8 commit f927f34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 10 additions & 1 deletion xcp_d/tests/test_utils_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,25 @@ def test_collect_mesh_data(datasets, tmp_path_factory):
"sub-1648798153_ses-PNC1_hemi-L_space-fsLR_den-32k_white.surf.gii",
"sub-1648798153_ses-PNC1_hemi-R_space-fsLR_den-32k_pial.surf.gii",
"sub-1648798153_ses-PNC1_hemi-R_space-fsLR_den-32k_white.surf.gii",
"sub-1648798153_ses-PNC1_hemi-L_pial.surf.gii",
"sub-1648798153_ses-PNC1_hemi-L_white.surf.gii",
"sub-1648798153_ses-PNC1_hemi-R_pial.surf.gii",
"sub-1648798153_ses-PNC1_hemi-R_white.surf.gii",
]
for f in files:
(std_mesh_dir / "sub-1648798153/ses-PNC1/anat").joinpath(f).touch()

layout = BIDSLayout(std_mesh_dir, validate=False)
mesh_available, standard_space_mesh, _, _ = xbids.collect_mesh_data(
mesh_available, standard_space_mesh, _, mesh_files = xbids.collect_mesh_data(
layout, "1648798153", bids_filters={}
)
assert mesh_available is True
assert standard_space_mesh is True
order = ["lh_pial_surf", "lh_wm_surf", "rh_pial_surf", "rh_wm_surf"]
for i, k in enumerate(order):
assert mesh_files[k] == str(
(std_mesh_dir / "sub-1648798153/ses-PNC1/anat").joinpath(files[i])
)

# Dataset with multiple files matching each query (raises an error)
bad_mesh_dir = tmp_path_factory.mktemp("standard_mesh")
Expand Down
7 changes: 4 additions & 3 deletions xcp_d/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,11 @@ def collect_mesh_data(layout, participant_label, bids_filters):
LOGGER.info("No standard-space surfaces found.")

# Now that we know if there are standard-space surfaces available, we can grab the files.
query_extras = {}
if not standard_space_mesh:
query_extras = {"space": None}
if standard_space_mesh:
query_extras = {
"space": None,
"space": "fsLR",
"den": "32k",
}

initial_mesh_files = {}
Expand Down

0 comments on commit f927f34

Please sign in to comment.