diff --git a/.git_archival.txt b/.git_archival.txt index b1a286bbb6..8fb235d704 100644 --- a/.git_archival.txt +++ b/.git_archival.txt @@ -1,4 +1,4 @@ node: $Format:%H$ node-date: $Format:%cI$ describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ -ref-names: $Format:%D$ \ No newline at end of file +ref-names: $Format:%D$ diff --git a/docs/examples.rst b/docs/examples.rst index 4efb78ab02..af6f58b215 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -5,4 +5,4 @@ Examples :maxdepth: 2 :caption: Contents: - notebooks/SDC - Theory and physics \ No newline at end of file + notebooks/SDC - Theory and physics diff --git a/docs/requirements.txt b/docs/requirements.txt index bb636713a2..dad96f7142 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -18,4 +18,4 @@ sphinx >= 7.2.2 sphinx-argparse sphinxcontrib-apidoc templateflow -traits < 6.4 \ No newline at end of file +traits < 6.4 diff --git a/sdcflows/utils/tests/test_wrangler.py b/sdcflows/utils/tests/test_wrangler.py index f5e7c6cdd5..65c0f86ff9 100644 --- a/sdcflows/utils/tests/test_wrangler.py +++ b/sdcflows/utils/tests/test_wrangler.py @@ -326,12 +326,15 @@ def test_wrangler_filter(tmpdir, name, skeleton, estimations): ('phasediff', phasediff, 3), ], ) -@pytest.mark.parametrize("session, estimations", [ - ("01", 1), - ("02", 1), - ("03", 1), - (None, None), -]) +@pytest.mark.parametrize( + "session, estimations", + [ + ("01", 1), + ("02", 1), + ("03", 1), + (None, None), + ], +) def test_wrangler_URIs(tmpdir, name, skeleton, session, estimations, total_estimations): bids_dir = str(tmpdir / name) generate_bids_skeleton(bids_dir, skeleton) @@ -472,3 +475,32 @@ def test_fieldmapless(tmp_path): assert len(est[0].sources) == 2 clear_registry() rmtree(bids_dir) + + # force fmapless on top of self-pepolar + self_pepolar_metadata = { + **bold["metadata"], + "B0FieldIdentifier": "pepolar_fmap", + "B0FieldSource": "pepolar_fmap", + } + + spec = { + "01": { + "anat": [T1w], + "func": [ + { + "run": i, + **bold, + "metadata": {**self_pepolar_metadata, "PhaseEncodingDirection": pedir}, + } + for i, pedir in zip(range(1, 3), ["j", "j-"]) + ], + }, + } + generate_bids_skeleton(bids_dir, spec) + layout = gen_layout(bids_dir) + ests = find_estimators(layout=layout, subject="01", fmapless=True, force_fmapless=True) + assert len(ests) == 3 + for est in ests: + assert len(est.sources) == 2 + clear_registry() + rmtree(bids_dir) diff --git a/sdcflows/utils/wrangler.py b/sdcflows/utils/wrangler.py index 67743b496d..c0b7d28d9e 100644 --- a/sdcflows/utils/wrangler.py +++ b/sdcflows/utils/wrangler.py @@ -231,6 +231,7 @@ def find_estimators( Likewise in a more comprehensive dataset: + >>> fm.clear_registry() >>> find_estimators( ... layout=layouts['ds001771'], ... subject="36", @@ -259,6 +260,7 @@ def find_estimators( heuristics come back empty (BOLD and DWI files are missing the mandatory ``PhaseEncodingDirection``, in this case): + >>> fm.clear_registry() >>> find_estimators( ... layout=layouts['dsA'], ... subject="01", @@ -277,6 +279,7 @@ def find_estimators( This function should also correctly investigate multi-session datasets: + >>> fm.clear_registry() >>> find_estimators( ... layout=layouts['ds000206'], ... subject="05", @@ -309,6 +312,7 @@ def find_estimators( The only exception to the priority of ``B0FieldIdentifier`` is when fieldmaps are searched with the ``force_fmapless`` argument on: + >>> fm.clear_registry() >>> fm.clear_registry() # Necessary as `pepolar4pe` is not changing. >>> find_estimators( ... layout=layouts['dsC'], @@ -550,9 +554,9 @@ def find_estimators( base_entities=base_entities, suffixes=fmapless, ) - for spec in estimator_specs: + for si, spec in enumerate(estimator_specs): try: - estimator = fm.FieldmapEstimation(spec) + estimator = fm.FieldmapEstimation(spec, bids_id=f"auto_fmapless_{si}") except (ValueError, TypeError) as err: _log_debug_estimator_fail(logger, "ANAT", spec, layout.root, str(err)) else: