From b535b5f4ce2307f8a62cc9a14173ca78a59bd429 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Fri, 4 Oct 2024 16:00:35 -0400 Subject: [PATCH] Try @effigies' recommendation. --- sdcflows/utils/wrangler.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sdcflows/utils/wrangler.py b/sdcflows/utils/wrangler.py index 7efcaadc9a..eca0e4f8b6 100644 --- a/sdcflows/utils/wrangler.py +++ b/sdcflows/utils/wrangler.py @@ -540,6 +540,39 @@ def find_estimators( _log_debug_estimation(logger, e, layout.root) estimators.append(e) + medic_entities = {**base_entities, **{'part': 'mag', 'echo': Query.ANY}} + has_magnitude = tuple() + with suppress(ValueError): + has_magnitude = layout.get( + suffix='bold', + **medic_entities, + ) + + for mag_img in has_magnitude: + phase_img = layout.get(**{**mag_img.get_entities(), **{'part': 'phase'}}) + if not phase_img: + continue + + phase_img = phase_img[0] + try: + e = fm.FieldmapEstimation( + [ + fm.FieldmapFile(mag_img.path, metadata=mag_img.get_metadata()), + fm.FieldmapFile(phase_img.path, metadata=phase_img.get_metadata()), + ] + ) + except (ValueError, TypeError) as err: + _log_debug_estimator_fail( + logger, + "potential MEDIC fieldmap", + [mag_img, phase_img], + layout.root, + str(err), + ) + else: + _log_debug_estimation(logger, e, layout.root) + estimators.append(e) + if estimators and not force_fmapless: fmapless = False