@@ -342,6 +342,7 @@ def init_syn_preprocessing_wf(
342342 debug = False ,
343343 name = "syn_preprocessing_wf" ,
344344 omp_nthreads = 1 ,
345+ coregister = True ,
345346 auto_bold_nss = False ,
346347 t1w_inversion = None ,
347348 sd_prior = True ,
@@ -365,6 +366,9 @@ def init_syn_preprocessing_wf(
365366 Name for this workflow
366367 omp_nthreads : :obj:`int`
367368 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.
368372 auto_bold_nss : :obj:`bool`
369373 Set up the reference workflow to automatically execute nonsteady states detection
370374 of BOLD images.
@@ -434,6 +438,7 @@ def init_syn_preprocessing_wf(
434438 "in_anat" ,
435439 "mask_anat" ,
436440 "std2anat_xfm" ,
441+ "epi2anat_xfm" ,
437442 ]
438443 ),
439444 name = "inputnode" ,
@@ -481,28 +486,44 @@ def init_syn_preprocessing_wf(
481486 DenoiseImage (copy_header = True ), name = "ref_anat" , n_procs = omp_nthreads
482487 )
483488
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-
501489 anat_dilmsk = pe .Node (BinaryDilation (), name = "anat_dilmsk" )
502490 epi_dilmsk = pe .Node (BinaryDilation (), name = "epi_dilmsk" )
503491
504492 sampling_ref = pe .Node (GenerateSamplingReference (), name = "sampling_ref" )
505493
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+
506527 if sd_prior :
507528 # Mapping & preparing prior knowledge
508529 # Concatenate transform files:
@@ -528,12 +549,20 @@ def _remove_first_mask(in_file):
528549
529550 workflow .connect ([
530551 (inputnode , transform_list , [("std2anat_xfm" , "in2" )]),
531- (epi2anat , transform_list , [("forward_transforms" , "in1" )]),
532552 (transform_list , prior2epi , [("out" , "transforms" )]),
533553 (sampling_ref , prior2epi , [("out_file" , "reference_image" )]),
534554 (prior2epi , outputnode , [("output_image" , "sd_prior" )]),
535555 ]) # fmt:skip
536556
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+
537566 else :
538567 # no prior to be used
539568 # MG: Future goal is to allow using alternative mappings
@@ -553,16 +582,9 @@ def _remove_first_mask(in_file):
553582 (clip_anat , ref_anat , [("out_file" , "input_image" )]),
554583 (deob_epi , epi_brain , [("out_file" , "in_file" )]),
555584 (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" )]),
561585 (deob_epi , sampling_ref , [("out_file" , "fixed_image" )]),
562586 (ref_anat , anat2epi , [("output_image" , "input_image" )]),
563- (epi2anat , anat2epi , [("forward_transforms" , "transforms" )]),
564587 (sampling_ref , anat2epi , [("out_file" , "reference_image" )]),
565- (epi2anat , mask2epi , [("forward_transforms" , "transforms" )]),
566588 (sampling_ref , mask2epi , [("out_file" , "reference_image" )]),
567589 (mask2epi , mask_dtype , [("output_image" , "in_file" )]),
568590 (anat2epi , outputnode , [("output_image" , "anat_ref" )]),
0 commit comments