diff --git a/fmriprep/utils/bids.py b/fmriprep/utils/bids.py index b2927547..5ca78d91 100644 --- a/fmriprep/utils/bids.py +++ b/fmriprep/utils/bids.py @@ -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, ): @@ -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 diff --git a/fmriprep/utils/tests/test_derivative_cache.py b/fmriprep/utils/tests/test_derivative_cache.py index 1a2c59ac..87382f73 100644 --- a/fmriprep/utils/tests/test_derivative_cache.py +++ b/fmriprep/utils/tests/test_derivative_cache.py @@ -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'