@@ -554,7 +554,7 @@ def init_infant_anat_fit_wf(
554
554
workflow .connect ([
555
555
(t1w_buffer , ds_t1w_mask_wf , [('t1w_mask' , 'inputnode.mask_file' )]),
556
556
]) # fmt:skip
557
- else :
557
+ else : # T1w mask derivative has been found
558
558
LOGGER .info ('ANAT Found T1w brain mask' )
559
559
if reference_anat == 'T1w' :
560
560
desc += (
@@ -563,26 +563,19 @@ def init_infant_anat_fit_wf(
563
563
)
564
564
t1w_buffer .inputs .t1w_mask = t1w_mask
565
565
apply_t1w_mask .inputs .in_mask = t1w_mask
566
- workflow .connect (t1w_validate , 'out_file' , apply_t1w_mask , 'in_file ' )
566
+ workflow .connect (apply_t1w_mask , 'out_file' , t1w_buffer , 't1w_brain ' )
567
567
568
568
if not t1w_preproc :
569
569
LOGGER .info ('ANAT Skipping skull-strip, INU-correction only' )
570
- t1w_n4_only_wf = init_n4_only_wf (
571
- omp_nthreads = omp_nthreads ,
572
- atropos_use_random_seed = not skull_strip_fixed_seed ,
573
- bids_suffix = 'T1w' ,
574
- name = 't1w_n4_only_wf' ,
575
- )
570
+ t1w_n4_wf = init_anat_preproc_wf (name = 't1w_n4_wf' )
576
571
workflow .connect ([
577
- (apply_t1w_mask , t1w_n4_only_wf , [('out_file' , 'inputnode.in_files' )]),
578
- (t1w_n4_only_wf , t1w_buffer , [
579
- (('outputnode.bias_corrected' , pop_file ), 't1w_preproc' ),
580
- (('outputnode.out_file' , pop_file ), 't1w_brain' ),
581
- ]),
572
+ (t1w_validate , t1w_n4_wf , [('out_file' , 'inputnode.in_anat' )]),
573
+ (t1w_n4_wf , t1w_buffer , [('outputnode.anat_preproc' , 't1w_preproc' )]),
574
+ (t1w_n4_wf , apply_t1w_mask , [('outputnode.anat_preproc' , 'in_file' )]),
582
575
]) # fmt:skip
583
576
else :
584
577
LOGGER .info ('ANAT Skipping T1w masking' )
585
- workflow .connect (apply_t1w_mask , 'out_file' , t1w_buffer , 't1w_brain ' )
578
+ workflow .connect (t1w_validate , 'out_file' , apply_t1w_mask , 'in_file ' )
586
579
587
580
# T2w masking logic:
588
581
#
@@ -709,33 +702,24 @@ def init_infant_anat_fit_wf(
709
702
LOGGER .info ('ANAT Found T2w brain mask' )
710
703
if reference_anat == 'T2w' :
711
704
desc += (
712
- 'A pre-computed T1w brain mask was provided as input and used throughout the '
705
+ 'A pre-computed T2w brain mask was provided as input and used throughout the '
713
706
'workflow.'
714
707
)
715
708
t2w_buffer .inputs .t2w_mask = t2w_mask
716
709
apply_t2w_mask .inputs .in_mask = t2w_mask
717
- workflow .connect ([
718
- (t2w_validate , apply_t2w_mask , [('out_file' , 'in_file' )]),
719
- ]) # fmt:skip
710
+ workflow .connect (apply_t2w_mask , 'out_file' , t2w_buffer , 't2w_brain' )
720
711
721
712
if not t2w_preproc :
722
713
LOGGER .info ('ANAT Skipping skull-strip, INU-correction only' )
723
- t2w_n4_only_wf = init_n4_only_wf (
724
- omp_nthreads = omp_nthreads ,
725
- atropos_use_random_seed = not skull_strip_fixed_seed ,
726
- bids_suffix = 'T2w' ,
727
- name = 't2w_n4_only_wf' ,
728
- )
714
+ t2w_n4_wf = init_anat_preproc_wf (name = 't2w_n4_wf' )
729
715
workflow .connect ([
730
- (apply_t2w_mask , t2w_n4_only_wf , [('out_file' , 'inputnode.in_files' )]),
731
- (t2w_n4_only_wf , t2w_buffer , [
732
- (('outputnode.bias_corrected' , pop_file ), 't2w_preproc' ),
733
- (('outputnode.out_file' , pop_file ), 't2w_brain' ),
734
- ]),
716
+ (t2w_validate , t2w_n4_wf , [('out_file' , 'inputnode.in_anat' )]),
717
+ (t2w_n4_wf , t2w_buffer , [('outputnode.anat_preproc' , 't2w_preproc' )]),
718
+ (t2w_n4_wf , apply_t2w_mask , [('outputnode.anat_preproc' , 'in_file' )]),
735
719
]) # fmt:skip
736
720
else :
737
721
LOGGER .info ('ANAT Skipping T2w masking' )
738
- workflow .connect (apply_t2w_mask , 'out_file' , t2w_buffer , 't2w_brain ' )
722
+ workflow .connect (t2w_validate , 'out_file' , apply_t2w_mask , 'in_file ' )
739
723
740
724
# Stage 3: Coregistration
741
725
t1w2t2w_xfm = precomputed .get ('t1w2t2w_xfm' )
@@ -1643,28 +1627,19 @@ def init_infant_single_anat_fit_wf(
1643
1627
desc += 'A pre-computed brain mask was provided as input and used throughout the workflow.'
1644
1628
anat_buffer .inputs .anat_mask = anat_mask
1645
1629
apply_mask .inputs .in_mask = anat_mask
1646
- workflow .connect ([
1647
- (anat_validate , apply_mask , [('out_file' , 'in_file' )]),
1648
- ]) # fmt:skip
1630
+ workflow .connect (apply_mask , 'out_file' , anat_buffer , 'anat_brain' )
1649
1631
1650
1632
if not anat_preproc :
1651
1633
LOGGER .info ('ANAT Skipping skull-strip, INU-correction only' )
1652
- n4_only_wf = init_n4_only_wf (
1653
- omp_nthreads = omp_nthreads ,
1654
- atropos_use_random_seed = not skull_strip_fixed_seed ,
1655
- bids_suffix = reference_anat ,
1656
- name = 'n4_only_wf' ,
1657
- )
1634
+ anat_n4_wf = init_anat_preproc_wf (name = 'anat_n4_wf' )
1658
1635
workflow .connect ([
1659
- (apply_mask , n4_only_wf , [('out_file' , 'inputnode.in_files' )]),
1660
- (n4_only_wf , anat_buffer , [
1661
- (('outputnode.bias_corrected' , pop_file ), 'anat_preproc' ),
1662
- (('outputnode.out_file' , pop_file ), 'anat_brain' ),
1663
- ]),
1636
+ (anat_validate , anat_n4_wf , [('out_file' , 'inputnode.in_anat' )]),
1637
+ (anat_n4_wf , anat_buffer , [('outputnode.anat_preproc' , 'anat_preproc' )]),
1638
+ (anat_n4_wf , apply_mask , [('outputnode.anat_preproc' , 'in_file' )]),
1664
1639
]) # fmt:skip
1665
1640
else :
1666
- LOGGER .info ('ANAT Skipping T2w masking' )
1667
- workflow .connect (apply_mask , 'out_file' , anat_buffer , 'anat_brain ' )
1641
+ LOGGER .info (f 'ANAT Skipping { reference_anat } masking' )
1642
+ workflow .connect (anat_validate , 'out_file' , apply_mask , 'in_file ' )
1668
1643
1669
1644
# Stage 3: Segmentation
1670
1645
seg_method = 'jlf' if config .execution .segmentation_atlases_dir else 'fast'
0 commit comments