Skip to content

Commit

Permalink
FIX: Repair and test query for precalculated baseline/boldref files (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
psadil authored and effigies committed Oct 2, 2024
1 parent ce31460 commit 565d1a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fmriprep/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
def collect_derivatives(
derivatives_dir: Path,
entities: dict,
fieldmap_id: str | None,
fieldmap_id: str | None = None,
spec: dict | None = None,
patterns: list[str] | None = None,
):
Expand All @@ -62,7 +62,7 @@ def collect_derivatives(

# search for both boldrefs
for k, q in spec['baseline'].items():
query = {**q, **entities}
query = {**entities, **q}
item = layout.get(return_type='filename', **query)
if not item:
continue
Expand Down
22 changes: 22 additions & 0 deletions fmriprep/utils/tests/test_derivative_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
from fmriprep.utils import bids


@pytest.mark.parametrize('desc', ['hmc', 'coreg'])
def test_baseline_found_as_str(tmp_path: Path, desc: str):
subject = '0'
task = 'rest'

to_find = tmp_path.joinpath(
f'sub-{subject}', 'func', f'sub-{subject}_task-{task}_desc-{desc}_boldref.nii.gz'
)
to_find.parent.mkdir(parents=True)
to_find.touch()

entities = {
'subject': subject,
'task': task,
'suffix': 'bold',
'extension': '.nii.gz',
}

derivs = bids.collect_derivatives(derivatives_dir=tmp_path, entities=entities)
assert dict(derivs) == {f'{desc}_boldref': str(to_find), 'transforms': {}}


@pytest.mark.parametrize('xfm', ['boldref2fmap', 'boldref2anat', 'hmc'])
def test_transforms_found_as_str(tmp_path: Path, xfm: str):
subject = '0'
Expand Down

0 comments on commit 565d1a9

Please sign in to comment.