@@ -324,9 +324,9 @@ def find_estimators(
324
324
for fmap in bare_ids + listed_ids
325
325
]
326
326
)
327
- except ValueError as err :
327
+ except ( ValueError , TypeError ) as err :
328
328
_log_debug_estimator_fail (
329
- logger , b0_id , listed_ids , layout .root , str (err )
329
+ logger , b0_id , bare_ids + listed_ids , layout .root , str (err )
330
330
)
331
331
else :
332
332
_log_debug_estimation (logger , e , layout .root )
@@ -363,14 +363,21 @@ def find_estimators(
363
363
)
364
364
dirs = layout .get_directions (** entities )
365
365
if len (dirs ) > 1 :
366
- e = fm .FieldmapEstimation (
367
- [
368
- fm .FieldmapFile (fmap .path , metadata = fmap .get_metadata ())
369
- for fmap in layout .get (** {** entities , ** {'direction' : dirs }})
370
- ]
371
- )
372
- _log_debug_estimation (logger , e , layout .root )
373
- estimators .append (e )
366
+ fieldmaps = layout .get (** {** entities , ** {"direction" : dirs }})
367
+ try :
368
+ e = fm .FieldmapEstimation (
369
+ [
370
+ fm .FieldmapFile (fmap .path , metadata = fmap .get_metadata ())
371
+ for fmap in fieldmaps
372
+ ]
373
+ )
374
+ except ValueError as err :
375
+ _log_debug_estimator_fail (
376
+ logger , "unnamed PEPOLAR" , fieldmaps , layout .root , str (err )
377
+ )
378
+ else :
379
+ _log_debug_estimation (logger , e , layout .root )
380
+ estimators .append (e )
374
381
375
382
# At this point, only single-PE _epi files WITH ``IntendedFor`` can
376
383
# be automatically processed.
@@ -400,21 +407,30 @@ def find_estimators(
400
407
for intent in listify (epi_base_md ["IntendedFor" ]):
401
408
target = layout .get_file (str (subject_root / intent ))
402
409
if target is None :
403
- logger .debug ("Single PE target %s not found" , target )
410
+ logger .debug ("Single PE target %s not found" , intent )
404
411
continue
405
412
406
413
logger .debug ("Found single PE target %s" , target .relpath )
407
414
# The new estimator is IntendedFor the individual targets,
408
415
# even if the EPI file is IntendedFor multiple
409
416
estimator_md = epi_base_md .copy ()
410
417
estimator_md ["IntendedFor" ] = [intent ]
411
- with suppress ( ValueError , TypeError , fm . MetadataError ) :
418
+ try :
412
419
e = fm .FieldmapEstimation (
413
420
[
414
421
fm .FieldmapFile (epi_fmap .path , metadata = estimator_md ),
415
422
fm .FieldmapFile (target .path , metadata = target .get_metadata ())
416
423
]
417
424
)
425
+ except (ValueError , TypeError ) as err :
426
+ _log_debug_estimator_fail (
427
+ logger ,
428
+ "unnamed PEPOLAR" ,
429
+ [epi_fmap , target ],
430
+ layout .root ,
431
+ str (err )
432
+ )
433
+ else :
418
434
_log_debug_estimation (logger , e , layout .root )
419
435
estimators .append (e )
420
436
@@ -490,7 +506,9 @@ def _log_debug_estimation(
490
506
"Found %s estimation from %d sources:\n - %s" ,
491
507
estimation .method .name ,
492
508
len (estimation .sources ),
493
- "\n - " .join ([str (s .path .relative_to (bids_root )) for s in estimation .sources ]),
509
+ "\n - " .join (
510
+ [str (Path (s .path ).relative_to (bids_root )) for s in estimation .sources ]
511
+ ),
494
512
)
495
513
496
514
@@ -506,6 +524,6 @@ def _log_debug_estimator_fail(
506
524
"Failed to construct %s estimation from %d sources:\n - %s\n Error: %s" ,
507
525
b0_id ,
508
526
len (files ),
509
- "\n - " .join ([str (s .path .relative_to (bids_root )) for s in files ]),
527
+ "\n - " .join ([str (Path ( s .path ) .relative_to (bids_root )) for s in files ]),
510
528
message ,
511
529
)
0 commit comments