@@ -340,8 +340,6 @@ def init_func_preproc_wf(bold_file):
340340 # apply BOLD registration to T1w
341341 bold_t1_trans_wf = init_bold_t1_trans_wf (name = 'bold_t1_trans_wf' ,
342342 freesurfer = freesurfer ,
343- use_fieldwarp = bool (fmaps ),
344- multiecho = multiecho ,
345343 mem_gb = mem_gb ['resampled' ],
346344 omp_nthreads = omp_nthreads ,
347345 use_compression = False )
@@ -398,10 +396,12 @@ def init_func_preproc_wf(bold_file):
398396 debug = config .execution .debug )
399397
400398 # MULTI-ECHO EPI DATA #############################################
401- if multiecho :
399+ if multiecho : # instantiate relevant interfaces, imports
402400 from niworkflows .func .util import init_skullstrip_bold_wf
403401 skullstrip_bold_wf = init_skullstrip_bold_wf (name = 'skullstrip_bold_wf' )
404402
403+ split_opt_comb = bold_split .clone (name = 'split_opt_comb' )
404+
405405 inputnode .inputs .bold_file = ref_file # Replace reference w first echo
406406
407407 join_echos = pe .JoinNode (niu .IdentityInterface (fields = ['bold_files' ]),
@@ -415,13 +415,6 @@ def init_func_preproc_wf(bold_file):
415415 omp_nthreads = omp_nthreads ,
416416 name = 'bold_t2smap_wf' )
417417
418- workflow .connect ([
419- (skullstrip_bold_wf , join_echos , [
420- ('outputnode.skull_stripped_file' , 'bold_files' )]),
421- (join_echos , bold_t2s_wf , [
422- ('bold_files' , 'inputnode.bold_file' )]),
423- ])
424-
425418 # MAIN WORKFLOW STRUCTURE #######################################################
426419 workflow .connect ([
427420 (inputnode , t1w_brain , [('t1w_preproc' , 'in_file' ),
@@ -450,8 +443,6 @@ def init_func_preproc_wf(bold_file):
450443 ('t1w_aparc' , 'inputnode.t1w_aparc' )]),
451444 (t1w_brain , bold_t1_trans_wf , [
452445 ('out_file' , 'inputnode.t1w_brain' )]),
453- # unused if multiecho, but this is safe
454- (bold_hmc_wf , bold_t1_trans_wf , [('outputnode.xforms' , 'inputnode.hmc_xforms' )]),
455446 (bold_reg_wf , outputnode , [
456447 ('outputnode.itk_bold_to_t1' , 'bold2anat_xfm' ),
457448 ('outputnode.itk_t1_to_bold' , 'anat2bold_xfm' )]),
@@ -470,7 +461,6 @@ def init_func_preproc_wf(bold_file):
470461 ('outputnode.ref_image_brain' , 'inputnode.epi_brain' ),
471462 ('outputnode.bold_mask' , 'inputnode.epi_mask' )]),
472463 (bold_sdc_wf , bold_t1_trans_wf , [
473- ('outputnode.out_warp' , 'inputnode.fieldwarp' ),
474464 ('outputnode.epi_mask' , 'inputnode.ref_bold_mask' ),
475465 ('outputnode.epi_brain' , 'inputnode.ref_bold_brain' )]),
476466 (bold_sdc_wf , bold_bold_trans_wf , [
@@ -516,20 +506,34 @@ def init_func_preproc_wf(bold_file):
516506 ('outputnode.bold' , 'inputnode.bold' )]),
517507 (bold_split , bold_t1_trans_wf , [
518508 ('out_files' , 'inputnode.bold_split' )]),
509+ (bold_hmc_wf , bold_t1_trans_wf , [
510+ ('outputnode.xforms' , 'inputnode.hmc_xforms' )]),
511+ (bold_sdc_wf , bold_t1_trans_wf , [
512+ ('outputnode.out_warp' , 'inputnode.fieldwarp' )])
519513 ])
520- else : # for meepi, create and use optimal combination
514+ else : # for meepi, use optimal combination
521515 workflow .connect ([
522516 # update name source for optimal combination
523517 (inputnode , func_derivatives_wf , [
524518 (('bold_file' , combine_meepi_source ), 'inputnode.source_file' )]),
525519 (bold_bold_trans_wf , skullstrip_bold_wf , [
526520 ('outputnode.bold' , 'inputnode.in_file' )]),
521+ (skullstrip_bold_wf , join_echos , [
522+ ('outputnode.skull_stripped_file' , 'bold_files' )]),
523+ (join_echos , bold_t2s_wf , [
524+ ('bold_files' , 'inputnode.bold_file' )]),
527525 (bold_t2s_wf , bold_confounds_wf , [
528526 ('outputnode.bold' , 'inputnode.bold' )]),
529- (bold_t2s_wf , bold_t1_trans_wf , [
530- ('outputnode.bold' , 'inputnode.bold_split' )]),
527+ (bold_t2s_wf , split_opt_comb , [
528+ ('outputnode.bold' , 'in_file' )]),
529+ (split_opt_comb , bold_t1_trans_wf , [
530+ ('out_files' , 'inputnode.bold_split' )]),
531531 ])
532532
533+ # Already applied in bold_bold_trans_wf, which inputs to bold_t2s_wf
534+ bold_t1_trans_wf .inputs .inputnode .fieldwarp = 'identity'
535+ bold_t1_trans_wf .inputs .inputnode .hmc_xforms = 'identity'
536+
533537 if fmaps :
534538 from sdcflows .workflows .outputs import init_sdc_unwarp_report_wf
535539 # Report on BOLD correction
@@ -628,7 +632,6 @@ def init_func_preproc_wf(bold_file):
628632 spaces = spaces ,
629633 name = 'bold_std_trans_wf' ,
630634 use_compression = not config .execution .low_mem ,
631- use_fieldwarp = bool (fmaps ),
632635 )
633636 workflow .connect ([
634637 (inputnode , bold_std_trans_wf , [
@@ -637,14 +640,10 @@ def init_func_preproc_wf(bold_file):
637640 ('bold_file' , 'inputnode.name_source' ),
638641 ('t1w_aseg' , 'inputnode.bold_aseg' ),
639642 ('t1w_aparc' , 'inputnode.bold_aparc' )]),
640- (bold_hmc_wf , bold_std_trans_wf , [
641- ('outputnode.xforms' , 'inputnode.hmc_xforms' )]),
642643 (bold_reg_wf , bold_std_trans_wf , [
643644 ('outputnode.itk_bold_to_t1' , 'inputnode.itk_bold_to_t1' )]),
644645 (bold_bold_trans_wf , bold_std_trans_wf , [
645646 ('outputnode.bold_mask' , 'inputnode.bold_mask' )]),
646- (bold_sdc_wf , bold_std_trans_wf , [
647- ('outputnode.out_warp' , 'inputnode.fieldwarp' )]),
648647 (bold_std_trans_wf , outputnode , [('outputnode.bold_std' , 'bold_std' ),
649648 ('outputnode.bold_std_ref' , 'bold_std_ref' ),
650649 ('outputnode.bold_mask_std' , 'bold_mask_std' )]),
@@ -664,18 +663,22 @@ def init_func_preproc_wf(bold_file):
664663 if not multiecho :
665664 workflow .connect ([
666665 (bold_split , bold_std_trans_wf , [
667- ('out_files' , 'inputnode.bold_split' )])
666+ ('out_files' , 'inputnode.bold_split' )]),
667+ (bold_sdc_wf , bold_std_trans_wf , [
668+ ('outputnode.out_warp' , 'inputnode.fieldwarp' )]),
669+ (bold_hmc_wf , bold_std_trans_wf , [
670+ ('outputnode.xforms' , 'inputnode.hmc_xforms' )]),
668671 ])
669672 else :
670- split_opt_comb = bold_split .clone (name = 'split_opt_comb' )
671673 workflow .connect ([
672- (bold_t2s_wf , split_opt_comb , [
673- ('outputnode.bold' , 'in_file' )]),
674674 (split_opt_comb , bold_std_trans_wf , [
675- ('out_files' , 'inputnode.bold_split' )
676- ])
675+ ('out_files' , 'inputnode.bold_split' )])
677676 ])
678677
678+ # Already applied in bold_bold_trans_wf, which inputs to bold_t2s_wf
679+ bold_std_trans_wf .inputs .inputnode .fieldwarp = 'identity'
680+ bold_std_trans_wf .inputs .inputnode .hmc_xforms = 'identity'
681+
679682 # func_derivatives_wf internally parametrizes over snapshotted spaces.
680683 workflow .connect ([
681684 (bold_std_trans_wf , func_derivatives_wf , [
@@ -693,7 +696,6 @@ def init_func_preproc_wf(bold_file):
693696 mem_gb = mem_gb ['resampled' ],
694697 metadata = metadata ,
695698 omp_nthreads = omp_nthreads ,
696- use_fieldwarp = bool (fmaps ),
697699 err_on_aroma_warn = config .workflow .aroma_err_on_warn ,
698700 aroma_melodic_dim = config .workflow .aroma_melodic_dim ,
699701 name = 'ica_aroma_wf' )
0 commit comments