@@ -776,7 +776,6 @@ def init_atropos_wf(
776
776
(merge_tpms , copy_xform , [('out' , 'out_tpms' )]),
777
777
(atropos , sel_wm , [('posteriors' , 'inlist' )]),
778
778
(sel_wm , copy_xform_wm , [('out' , 'wm_map' )]),
779
- (copy_xform_wm , inu_n4_final , [('wm_map' , 'weight_image' )]),
780
779
(inu_n4_final , copy_xform , [('output_image' , 'bias_corrected' ),
781
780
('bias_image' , 'bias_image' )]),
782
781
(copy_xform , apply_mask , [('bias_corrected' , 'in_file' ),
@@ -808,9 +807,6 @@ def _argmax(in_dice):
808
807
809
808
apply_wm_prior = pe .Node (niu .Function (function = _improd ), name = 'apply_wm_prior' )
810
809
811
- wf .disconnect ([
812
- (copy_xform_wm , inu_n4_final , [('wm_map' , 'weight_image' )]),
813
- ]) # fmt:skip
814
810
wf .connect ([
815
811
(inputnode , apply_wm_prior , [('in_mask' , 'in_mask' ),
816
812
('wm_prior' , 'op2' )]),
@@ -822,6 +818,8 @@ def _argmax(in_dice):
822
818
(copy_xform_wm , apply_wm_prior , [('wm_map' , 'op1' )]),
823
819
(apply_wm_prior , inu_n4_final , [('out' , 'weight_image' )]),
824
820
]) # fmt:skip
821
+ else :
822
+ wf .connect ([(copy_xform_wm , inu_n4_final , [('wm_map' , 'weight_image' )])])
825
823
return wf
826
824
827
825
@@ -925,7 +923,7 @@ def init_n4_only_wf(
925
923
thr_brainmask = pe .Node (Binarize (thresh_low = 2 ), name = 'binarize' )
926
924
927
925
# INU correction
928
- inu_n4_final = pe .MapNode (
926
+ inu_n4 = pe .MapNode (
929
927
N4BiasFieldCorrection (
930
928
dimension = 3 ,
931
929
save_bias = True ,
@@ -936,31 +934,28 @@ def init_n4_only_wf(
936
934
bspline_fitting_distance = 200 ,
937
935
),
938
936
n_procs = omp_nthreads ,
939
- name = 'inu_n4_final ' ,
937
+ name = 'inu_n4 ' ,
940
938
iterfield = ['input_image' ],
941
939
)
942
940
943
941
# Check ANTs version
944
942
try :
945
- inu_n4_final .inputs .rescale_intensities = True
943
+ inu_n4 .inputs .rescale_intensities = True
946
944
except ValueError :
947
945
warn (
948
946
"N4BiasFieldCorrection's --rescale-intensities option was added in ANTS 2.1.0 "
949
- f'({ inu_n4_final .interface .version } found.) Please consider upgrading.' ,
947
+ f'({ inu_n4 .interface .version } found.) Please consider upgrading.' ,
950
948
UserWarning ,
951
949
stacklevel = 1 ,
952
950
)
953
951
954
952
wf .connect ([
955
- (inputnode , inu_n4_final , [('in_files' , 'input_image' )]),
953
+ (inputnode , inu_n4 , [('in_files' , 'input_image' )]),
956
954
(inputnode , thr_brainmask , [(('in_files' , _pop ), 'in_file' )]),
957
955
(thr_brainmask , outputnode , [('out_mask' , 'out_mask' )]),
958
- (inu_n4_final , outputnode , [('output_image' , 'out_file' ),
959
- ('output_image' , 'bias_corrected' ),
960
- ('bias_image' , 'bias_image' )]),
961
956
]) # fmt:skip
962
957
963
- # If atropos refine, do in4 twice
958
+ # If atropos refine, n4 is run a second time
964
959
if atropos_refine :
965
960
atropos_model = atropos_model or list (ATROPOS_MODELS [bids_suffix ].values ())
966
961
atropos_wf = init_atropos_wf (
@@ -970,14 +965,9 @@ def init_n4_only_wf(
970
965
in_segmentation_model = atropos_model ,
971
966
)
972
967
973
- wf .disconnect ([
974
- (inu_n4_final , outputnode , [('output_image' , 'out_file' ),
975
- ('output_image' , 'bias_corrected' ),
976
- ('bias_image' , 'bias_image' )]),
977
- ]) # fmt:skip
978
968
wf .connect ([
979
969
(inputnode , atropos_wf , [('in_files' , 'inputnode.in_files' )]),
980
- (inu_n4_final , atropos_wf , [('output_image' , 'inputnode.in_corrected' )]),
970
+ (inu_n4 , atropos_wf , [('output_image' , 'inputnode.in_corrected' )]),
981
971
(thr_brainmask , atropos_wf , [('out_mask' , 'inputnode.in_mask' )]),
982
972
(atropos_wf , outputnode , [
983
973
('outputnode.out_file' , 'out_file' ),
@@ -987,6 +977,12 @@ def init_n4_only_wf(
987
977
('outputnode.out_tpms' , 'out_tpms' ),
988
978
]),
989
979
]) # fmt:skip
980
+ else :
981
+ wf .connect ([
982
+ (inu_n4 , outputnode , [('output_image' , 'out_file' ),
983
+ ('output_image' , 'bias_corrected' ),
984
+ ('bias_image' , 'bias_image' )]),
985
+ ]) # fmt:skip
990
986
991
987
return wf
992
988
0 commit comments