@@ -325,6 +325,7 @@ def init_syn_preprocessing_wf(
325325 debug = False ,
326326 name = "syn_preprocessing_wf" ,
327327 omp_nthreads = 1 ,
328+ coregister = True ,
328329 auto_bold_nss = False ,
329330 t1w_inversion = None ,
330331 sd_prior = True ,
@@ -348,6 +349,9 @@ def init_syn_preprocessing_wf(
348349 Name for this workflow
349350 omp_nthreads : :obj:`int`
350351 Parallelize internal tasks across the number of CPUs given by this option.
352+ coregister: :class:`bool`
353+ Run BOLD-to-Anat coregistration. If set to ``False``, ``epi2anat_xfm`` must be
354+ provided.
351355 auto_bold_nss : :obj:`bool`
352356 Set up the reference workflow to automatically execute nonsteady states detection
353357 of BOLD images.
@@ -417,6 +421,7 @@ def init_syn_preprocessing_wf(
417421 "in_anat" ,
418422 "mask_anat" ,
419423 "std2anat_xfm" ,
424+ "epi2anat_xfm" ,
420425 ]
421426 ),
422427 name = "inputnode" ,
@@ -464,28 +469,44 @@ def init_syn_preprocessing_wf(
464469 DenoiseImage (copy_header = True ), name = "ref_anat" , n_procs = omp_nthreads
465470 )
466471
467- epi2anat = pe .Node (
468- Registration (from_file = data .load ("affine.json" )),
469- name = "epi2anat" ,
470- n_procs = omp_nthreads ,
471- )
472- epi2anat .inputs .output_warped_image = debug
473- epi2anat .inputs .output_inverse_warped_image = debug
474- if debug :
475- epi2anat .inputs .args = "--write-interval-volumes 5"
476-
477- def _remove_first_mask (in_file ):
478- if not isinstance (in_file , list ):
479- in_file = [in_file ]
480-
481- in_file .insert (0 , "NULL" )
482- return in_file
483-
484472 anat_dilmsk = pe .Node (BinaryDilation (), name = "anat_dilmsk" )
485473 epi_dilmsk = pe .Node (BinaryDilation (), name = "epi_dilmsk" )
486474
487475 sampling_ref = pe .Node (GenerateSamplingReference (), name = "sampling_ref" )
488476
477+ if coregister :
478+ epi2anat = pe .Node (
479+ Registration (from_file = data .load ("affine.json" )),
480+ name = "epi2anat" ,
481+ n_procs = omp_nthreads ,
482+ )
483+ epi2anat .inputs .output_warped_image = debug
484+ epi2anat .inputs .output_inverse_warped_image = debug
485+ if debug :
486+ epi2anat .inputs .args = "--write-interval-volumes 5"
487+
488+ def _remove_first_mask (in_file ):
489+ if not isinstance (in_file , list ):
490+ in_file = [in_file ]
491+
492+ in_file .insert (0 , "NULL" )
493+ return in_file
494+
495+ workflow .connect ([
496+ (ref_anat , epi2anat , [("output_image" , "fixed_image" )]),
497+ (anat_dilmsk , epi2anat , [("out_file" , "fixed_image_masks" )]),
498+ (deob_epi , epi2anat , [("out_file" , "moving_image" )]),
499+ (epi_dilmsk , epi2anat , [
500+ (("out_file" , _remove_first_mask ), "moving_image_masks" )]),
501+ (epi2anat , anat2epi , [("forward_transforms" , "transforms" )]),
502+ (epi2anat , mask2epi , [("forward_transforms" , "transforms" )]),
503+ ]) # fmt:skip
504+ else :
505+ workflow .connect ([
506+ (inputnode , anat2epi , [("epi2anat_xfm" , "transforms" )]),
507+ (inputnode , mask2epi , [("epi2anat_xfm" , "transforms" )]),
508+ ])
509+
489510 if sd_prior :
490511 # Mapping & preparing prior knowledge
491512 # Concatenate transform files:
@@ -511,12 +532,20 @@ def _remove_first_mask(in_file):
511532
512533 workflow .connect ([
513534 (inputnode , transform_list , [("std2anat_xfm" , "in2" )]),
514- (epi2anat , transform_list , [("forward_transforms" , "in1" )]),
515535 (transform_list , prior2epi , [("out" , "transforms" )]),
516536 (sampling_ref , prior2epi , [("out_file" , "reference_image" )]),
517537 (prior2epi , outputnode , [("output_image" , "sd_prior" )]),
518538 ]) # fmt:skip
519539
540+ if coregister :
541+ workflow .connect ([
542+ (epi2anat , transform_list , [("forward_transforms" , "in1" )]),
543+ ]) # fmt:skip
544+ else :
545+ workflow .connect ([
546+ (inputnode , transform_list , [("epi2anat_xfm" , "in1" )]),
547+ ])
548+
520549 else :
521550 # no prior to be used
522551 # MG: Future goal is to allow using alternative mappings
@@ -536,16 +565,9 @@ def _remove_first_mask(in_file):
536565 (clip_anat , ref_anat , [("out_file" , "input_image" )]),
537566 (deob_epi , epi_brain , [("out_file" , "in_file" )]),
538567 (epi_brain , epi_dilmsk , [("out_mask" , "in_file" )]),
539- (ref_anat , epi2anat , [("output_image" , "fixed_image" )]),
540- (anat_dilmsk , epi2anat , [("out_file" , "fixed_image_masks" )]),
541- (deob_epi , epi2anat , [("out_file" , "moving_image" )]),
542- (epi_dilmsk , epi2anat , [
543- (("out_file" , _remove_first_mask ), "moving_image_masks" )]),
544568 (deob_epi , sampling_ref , [("out_file" , "fixed_image" )]),
545569 (ref_anat , anat2epi , [("output_image" , "input_image" )]),
546- (epi2anat , anat2epi , [("forward_transforms" , "transforms" )]),
547570 (sampling_ref , anat2epi , [("out_file" , "reference_image" )]),
548- (epi2anat , mask2epi , [("forward_transforms" , "transforms" )]),
549571 (sampling_ref , mask2epi , [("out_file" , "reference_image" )]),
550572 (mask2epi , mask_dtype , [("output_image" , "in_file" )]),
551573 (anat2epi , outputnode , [("output_image" , "anat_ref" )]),
0 commit comments