Skip to content

Commit 47c947d

Browse files
committed
fix: ensure the ME pathway does not crash at workflow build-time
1 parent 215770c commit 47c947d

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

fmriprep/workflows/base.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,23 @@ def init_single_subject_wf(subject_id):
335335
config.loggers.workflow.error(message)
336336
raise ValueError(message)
337337

338-
config.loggers.workflow.debug(
339-
f"{len(fmap_estimators)} fieldmap estimators found: "
340-
f"{[e.method for e in fmap_estimators]}"
341-
)
342-
343-
if "fieldmaps" in config.workflow.ignore:
338+
if (
339+
"fieldmaps" in config.workflow.ignore
340+
and [f for f in fmap_estimators
341+
if f.method != fm.EstimatorType.ANAT]
342+
):
343+
config.loggers.workflow.info(
344+
'Option "--ignore fieldmaps" was set, but either "--use-syn-sdc" '
345+
'or "--force-syn" were given, so fieldmap-less estimation will be executed.'
346+
)
344347
fmap_estimators = [f for f in fmap_estimators
345348
if f.method == fm.EstimatorType.ANAT]
346-
config.loggers.workflow.debug(
347-
"Ignoring fieldmap scans, using anatomical estimators: "
348-
f"{[e.method for e in fmap_estimators]}"
349+
350+
if fmap_estimators:
351+
config.loggers.workflow.info(
352+
"B0 field inhomogeneity map will be estimated with "
353+
f" the following {len(fmap_estimators)} estimators: "
354+
f"{[e.method for e in fmap_estimators]}."
349355
)
350356

351357
# Append the functional section to the existing anatomical exerpt
@@ -426,6 +432,8 @@ def init_single_subject_wf(subject_id):
426432
config.loggers.workflow.info(f"""\
427433
Setting-up fieldmap "{estimator.bids_id}" ({estimator.method}) with \
428434
<{', '.join(s.path.name for s in estimator.sources)}>""")
435+
436+
# Mapped and phasediff can be connected internally by SDCFlows
429437
if estimator.method in (fm.EstimatorType.MAPPED, fm.EstimatorType.PHASEDIFF):
430438
continue
431439

fmriprep/workflows/bold/base.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,19 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
252252
from sdcflows.fieldmaps import get_identifier
253253

254254
# Fallback to IntendedFor
255-
bold_rel = re.sub(
256-
r"^sub-[a-zA-Z0-9]*/", "", str(Path(bold_file).relative_to(layout.root))
255+
intended_rel = re.sub(
256+
r"^sub-[a-zA-Z0-9]*/",
257+
"",
258+
str(Path(
259+
bold_file if not multiecho else bold_file[0]
260+
).relative_to(layout.root))
257261
)
258-
estimator_key = get_identifier(bold_rel)
262+
estimator_key = get_identifier(intended_rel)
259263

260264
if not estimator_key:
261265
has_fieldmap = False
262266
config.loggers.workflow.critical(
263-
f"None of the available B0 fieldmaps are associated to <{bold_rel}>"
267+
f"None of the available B0 fieldmaps are associated to <{bold_file}>"
264268
)
265269
else:
266270
config.loggers.workflow.info(f"Found usable B0 fieldmap <{estimator_key}>")

0 commit comments

Comments
 (0)