@@ -342,6 +342,7 @@ def init_syn_preprocessing_wf(
342
342
debug = False ,
343
343
name = "syn_preprocessing_wf" ,
344
344
omp_nthreads = 1 ,
345
+ coregister = True ,
345
346
auto_bold_nss = False ,
346
347
t1w_inversion = None ,
347
348
sd_prior = True ,
@@ -365,6 +366,9 @@ def init_syn_preprocessing_wf(
365
366
Name for this workflow
366
367
omp_nthreads : :obj:`int`
367
368
Parallelize internal tasks across the number of CPUs given by this option.
369
+ coregister: :class:`bool`
370
+ Run BOLD-to-Anat coregistration. If set to ``False``, ``epi2anat_xfm`` must be
371
+ provided.
368
372
auto_bold_nss : :obj:`bool`
369
373
Set up the reference workflow to automatically execute nonsteady states detection
370
374
of BOLD images.
@@ -434,6 +438,7 @@ def init_syn_preprocessing_wf(
434
438
"in_anat" ,
435
439
"mask_anat" ,
436
440
"std2anat_xfm" ,
441
+ "epi2anat_xfm" ,
437
442
]
438
443
),
439
444
name = "inputnode" ,
@@ -481,28 +486,44 @@ def init_syn_preprocessing_wf(
481
486
DenoiseImage (copy_header = True ), name = "ref_anat" , n_procs = omp_nthreads
482
487
)
483
488
484
- epi2anat = pe .Node (
485
- Registration (from_file = data .load ("affine.json" )),
486
- name = "epi2anat" ,
487
- n_procs = omp_nthreads ,
488
- )
489
- epi2anat .inputs .output_warped_image = debug
490
- epi2anat .inputs .output_inverse_warped_image = debug
491
- if debug :
492
- epi2anat .inputs .args = "--write-interval-volumes 5"
493
-
494
- def _remove_first_mask (in_file ):
495
- if not isinstance (in_file , list ):
496
- in_file = [in_file ]
497
-
498
- in_file .insert (0 , "NULL" )
499
- return in_file
500
-
501
489
anat_dilmsk = pe .Node (BinaryDilation (), name = "anat_dilmsk" )
502
490
epi_dilmsk = pe .Node (BinaryDilation (), name = "epi_dilmsk" )
503
491
504
492
sampling_ref = pe .Node (GenerateSamplingReference (), name = "sampling_ref" )
505
493
494
+ if coregister :
495
+ epi2anat = pe .Node (
496
+ Registration (from_file = data .load ("affine.json" )),
497
+ name = "epi2anat" ,
498
+ n_procs = omp_nthreads ,
499
+ )
500
+ epi2anat .inputs .output_warped_image = debug
501
+ epi2anat .inputs .output_inverse_warped_image = debug
502
+ if debug :
503
+ epi2anat .inputs .args = "--write-interval-volumes 5"
504
+
505
+ def _remove_first_mask (in_file ):
506
+ if not isinstance (in_file , list ):
507
+ in_file = [in_file ]
508
+
509
+ in_file .insert (0 , "NULL" )
510
+ return in_file
511
+
512
+ workflow .connect ([
513
+ (ref_anat , epi2anat , [("output_image" , "fixed_image" )]),
514
+ (anat_dilmsk , epi2anat , [("out_file" , "fixed_image_masks" )]),
515
+ (deob_epi , epi2anat , [("out_file" , "moving_image" )]),
516
+ (epi_dilmsk , epi2anat , [
517
+ (("out_file" , _remove_first_mask ), "moving_image_masks" )]),
518
+ (epi2anat , anat2epi , [("forward_transforms" , "transforms" )]),
519
+ (epi2anat , mask2epi , [("forward_transforms" , "transforms" )]),
520
+ ]) # fmt:skip
521
+ else :
522
+ workflow .connect ([
523
+ (inputnode , anat2epi , [("epi2anat_xfm" , "transforms" )]),
524
+ (inputnode , mask2epi , [("epi2anat_xfm" , "transforms" )]),
525
+ ])
526
+
506
527
if sd_prior :
507
528
# Mapping & preparing prior knowledge
508
529
# Concatenate transform files:
@@ -528,12 +549,20 @@ def _remove_first_mask(in_file):
528
549
529
550
workflow .connect ([
530
551
(inputnode , transform_list , [("std2anat_xfm" , "in2" )]),
531
- (epi2anat , transform_list , [("forward_transforms" , "in1" )]),
532
552
(transform_list , prior2epi , [("out" , "transforms" )]),
533
553
(sampling_ref , prior2epi , [("out_file" , "reference_image" )]),
534
554
(prior2epi , outputnode , [("output_image" , "sd_prior" )]),
535
555
]) # fmt:skip
536
556
557
+ if coregister :
558
+ workflow .connect ([
559
+ (epi2anat , transform_list , [("forward_transforms" , "in1" )]),
560
+ ]) # fmt:skip
561
+ else :
562
+ workflow .connect ([
563
+ (inputnode , transform_list , [("epi2anat_xfm" , "in1" )]),
564
+ ])
565
+
537
566
else :
538
567
# no prior to be used
539
568
# MG: Future goal is to allow using alternative mappings
@@ -553,16 +582,9 @@ def _remove_first_mask(in_file):
553
582
(clip_anat , ref_anat , [("out_file" , "input_image" )]),
554
583
(deob_epi , epi_brain , [("out_file" , "in_file" )]),
555
584
(epi_brain , epi_dilmsk , [("out_mask" , "in_file" )]),
556
- (ref_anat , epi2anat , [("output_image" , "fixed_image" )]),
557
- (anat_dilmsk , epi2anat , [("out_file" , "fixed_image_masks" )]),
558
- (deob_epi , epi2anat , [("out_file" , "moving_image" )]),
559
- (epi_dilmsk , epi2anat , [
560
- (("out_file" , _remove_first_mask ), "moving_image_masks" )]),
561
585
(deob_epi , sampling_ref , [("out_file" , "fixed_image" )]),
562
586
(ref_anat , anat2epi , [("output_image" , "input_image" )]),
563
- (epi2anat , anat2epi , [("forward_transforms" , "transforms" )]),
564
587
(sampling_ref , anat2epi , [("out_file" , "reference_image" )]),
565
- (epi2anat , mask2epi , [("forward_transforms" , "transforms" )]),
566
588
(sampling_ref , mask2epi , [("out_file" , "reference_image" )]),
567
589
(mask2epi , mask_dtype , [("output_image" , "in_file" )]),
568
590
(anat2epi , outputnode , [("output_image" , "anat_ref" )]),
0 commit comments