From 64269beeec9a92c335c38d54c6e74960cfb09dd5 Mon Sep 17 00:00:00 2001 From: Patrick Sadil Date: Wed, 2 Oct 2024 10:59:07 -0400 Subject: [PATCH 1/3] let fieldmap_id be optional --- fmriprep/utils/bids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmriprep/utils/bids.py b/fmriprep/utils/bids.py index b2927547..3c12ff5d 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, ): From 0c2e1b58f9034fd33b01f632d4272d52401e5878 Mon Sep 17 00:00:00 2001 From: Patrick Sadil Date: Wed, 2 Oct 2024 11:00:23 -0400 Subject: [PATCH 2/3] override matched provided entities with baseline spec query --- fmriprep/utils/bids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmriprep/utils/bids.py b/fmriprep/utils/bids.py index 3c12ff5d..5ca78d91 100644 --- a/fmriprep/utils/bids.py +++ b/fmriprep/utils/bids.py @@ -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 From c568a7beb682dddb8e93a31ea1c9f9a73d72e20f Mon Sep 17 00:00:00 2001 From: Patrick Sadil Date: Wed, 2 Oct 2024 11:27:51 -0400 Subject: [PATCH 3/3] handle merge conflicts --- fmriprep/utils/tests/test_derivative_cache.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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'