@@ -129,7 +129,9 @@ def find_estimators(
129
129
[FieldmapEstimation(sources=<2 files>, method=<EstimatorType.PHASEDIFF: 3>,
130
130
bids_id='auto_00006'),
131
131
FieldmapEstimation(sources=<2 files>, method=<EstimatorType.PEPOLAR: 2>,
132
- bids_id='auto_00007')]
132
+ bids_id='auto_00007'),
133
+ FieldmapEstimation(sources=<2 files>, method=<EstimatorType.PEPOLAR: 2>,
134
+ bids_id='auto_00008')]
133
135
134
136
Finally, *SDCFlows*' "*dataset A*" and "*dataset B*" contain BIDS structures
135
137
with zero-byte NIfTI files and some corresponding metadata:
@@ -399,23 +401,43 @@ def find_estimators(
399
401
logger .debug ("Found single PE fieldmap %s" , epi_fmap .relpath )
400
402
epi_base_md = epi_fmap .get_metadata ()
401
403
402
- # There are two possible interpretations of an IntendedFor list:
403
- # 1) The fieldmap and each intended target are combined separately
404
- # 2) The fieldmap and all intended targets are combined at once
405
- #
406
- # (1) has been the historical interpretation of NiPreps,
407
- # so construct a separate estimator for each target.
404
+ # Find existing IntendedFor targets and warn if missing
405
+ all_targets = []
408
406
for intent in listify (epi_base_md ["IntendedFor" ]):
409
407
target = layout .get_file (str (subject_root / intent ))
410
408
if target is None :
411
409
logger .debug ("Single PE target %s not found" , intent )
412
410
continue
411
+ all_targets .append (target )
412
+
413
+ # If sbrefs are targets, then the goal is generally to estimate with epi+sbref
414
+ # and correct bold/dwi
415
+ sbrefs = [
416
+ target for target in all_targets if target .entities ["suffix" ] == "sbref"
417
+ ]
418
+ if sbrefs :
419
+ targets = sbrefs
420
+ intent_map = []
421
+ for sbref in sbrefs :
422
+ ents = sbref .entities .copy ()
423
+ ents ["suffix" ] = ["bold" , "dwi" ]
424
+ intent_map .append (
425
+ [
426
+ target
427
+ for target in layout .get (** ents )
428
+ if target in all_targets
429
+ ]
430
+ )
431
+ else :
432
+ targets = all_targets
433
+ intent_map = [[target ] for target in all_targets ]
413
434
435
+ for target , intent in zip (targets , intent_map ):
414
436
logger .debug ("Found single PE target %s" , target .relpath )
415
437
# The new estimator is IntendedFor the individual targets,
416
438
# even if the EPI file is IntendedFor multiple
417
439
estimator_md = epi_base_md .copy ()
418
- estimator_md ["IntendedFor" ] = [ intent ]
440
+ estimator_md ["IntendedFor" ] = intent
419
441
try :
420
442
e = fm .FieldmapEstimation (
421
443
[
0 commit comments