Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

 [FIX] force_fmapless on top of self-correcting pepolar bold #465

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .git_archival.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
ref-names: $Format:%D$
2 changes: 1 addition & 1 deletion docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Examples
:maxdepth: 2
:caption: Contents:

notebooks/SDC - Theory and physics
notebooks/SDC - Theory and physics
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ sphinx >= 7.2.2
sphinx-argparse
sphinxcontrib-apidoc
templateflow
traits < 6.4
traits < 6.4
44 changes: 38 additions & 6 deletions sdcflows/utils/tests/test_wrangler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
8 changes: 6 additions & 2 deletions sdcflows/utils/wrangler.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def find_estimators(

Likewise in a more comprehensive dataset:

>>> fm.clear_registry()
>>> find_estimators(
... layout=layouts['ds001771'],
... subject="36",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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:
Expand Down
Loading