Skip to content

Commit

Permalink
simple fix: generate bids_id for fmapless
Browse files Browse the repository at this point in the history
  • Loading branch information
bpinsard committed Oct 9, 2024
1 parent c58fa62 commit 84553d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
33 changes: 22 additions & 11 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 @@ -477,19 +480,27 @@ def test_fieldmapless(tmp_path):
self_pepolar_metadata = {
**bold["metadata"],
"B0FieldIdentifier": "pepolar_fmap",
"B0FieldSource": "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-"])],
"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)
est = find_estimators(layout=layout, subject="01", fmapless=True, force_fmapless=True)
assert len(est) == 2
assert len(est[0].sources) == 2
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)
4 changes: 2 additions & 2 deletions sdcflows/utils/wrangler.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,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"fmapless{si}")
except (ValueError, TypeError) as err:
_log_debug_estimator_fail(logger, "ANAT", spec, layout.root, str(err))
else:
Expand Down

0 comments on commit 84553d9

Please sign in to comment.