@@ -2829,33 +2829,59 @@ def coregistration(wf, cfg, strat_pool, pipe_num, opt=None):
28292829 cfg .registration_workflows ['functional_registration' ][
28302830 'coregistration' ]['boundary_based_registration' ][
28312831 'bbr_wm_mask_args' ]
2832- bbreg_guardrail = registration_guardrail_node ('bbreg_guardrail_'
2833- f'{ pipe_num } ' )
2832+ bbreg_guardrail = registration_guardrail_node (
2833+ f'bbreg{ bbreg_status } _guardrail_{ pipe_num } ' )
2834+ if opt is True :
2835+ # Retry once on failure
2836+ retry_node = create_bbregister_func_to_anat (diff_complete ,
2837+ f'retry_func_to_anat_'
2838+ f'bbreg_{ pipe_num } ' ,
2839+ retry = True )
2840+ retry_node .inputs .inputspec .bbr_schedule = cfg [
2841+ 'registration_workflows' , 'functional_registration' ,
2842+ 'coregistration' , 'boundary_based_registration' ,
2843+ 'bbr_schedule' ]
2844+ retry_node .inputs .inputspec .bbr_wm_mask_args = cfg [
2845+ 'registration_workflows' , 'functional_registration' ,
2846+ 'coregistration' , 'boundary_based_registration' ,
2847+ 'bbr_wm_mask_args' ]
2848+ retry_guardrail = registration_guardrail_node (
2849+ f'retry_bbreg_guardrail_{ pipe_num } ' )
28342850
28352851 node , out = strat_pool .get_data ('desc-reginput_bold' )
28362852 wf .connect (node , out , func_to_anat_bbreg , 'inputspec.func' )
2853+ if opt is True :
2854+ wf .connect (node , out , retry_node , 'inputspec.func' )
28372855
28382856 if cfg .registration_workflows ['functional_registration' ][
28392857 'coregistration' ]['boundary_based_registration' ][
28402858 'reference' ] == 'whole-head' :
28412859 node , out = strat_pool .get_data ('T1w' )
28422860 wf .connect (node , out , func_to_anat_bbreg , 'inputspec.anat' )
28432861 wf .connect (node , out , bbreg_guardrail , 'reference' )
2862+ if opt is True :
2863+ wf .connect (node , out , retry_node , 'inputspec.anat' )
2864+ wf .connect (node , out , retry_guardrail , 'reference' )
28442865
28452866 elif cfg .registration_workflows ['functional_registration' ][
28462867 'coregistration' ]['boundary_based_registration' ][
28472868 'reference' ] == 'brain' :
28482869 node , out = strat_pool .get_data ('desc-brain_T1w' )
28492870 wf .connect (node , out , func_to_anat_bbreg , 'inputspec.anat' )
28502871 wf .connect (node , out , bbreg_guardrail , 'reference' )
2872+ if opt is True :
2873+ wf .connect (node , out , retry_node , 'inputspec.anat' )
2874+ wf .connect (node , out , retry_guardrail , 'reference' )
28512875
28522876 wf .connect (func_to_anat , 'outputspec.func_to_anat_linear_xfm_nobbreg' ,
28532877 func_to_anat_bbreg , 'inputspec.linear_reg_matrix' )
2878+ if opt is True :
2879+ wf .connect (func_to_anat ,
2880+ 'outputspec.func_to_anat_linear_xfm_nobbreg' ,
2881+ retry_node , 'inputspec.linear_reg_matrix' )
28542882
28552883 if strat_pool .check_rpool ('space-bold_label-WM_mask' ):
28562884 node , out = strat_pool .get_data (["space-bold_label-WM_mask" ])
2857- wf .connect (node , out ,
2858- func_to_anat_bbreg , 'inputspec.anat_wm_segmentation' )
28592885 else :
28602886 if cfg ['registration_workflows' , 'functional_registration' ,
28612887 'coregistration' , 'boundary_based_registration' ,
@@ -2867,56 +2893,62 @@ def coregistration(wf, cfg, strat_pool, pipe_num, opt=None):
28672893 'bbr_wm_map' ] == 'partial_volume_map' :
28682894 node , out = strat_pool .get_data (["label-WM_pveseg" ,
28692895 "label-WM_mask" ])
2870- wf .connect (node , out ,
2871- func_to_anat_bbreg , 'inputspec.anat_wm_segmentation' )
2896+ wf .connect (node , out ,
2897+ func_to_anat_bbreg , 'inputspec.anat_wm_segmentation' )
2898+ if opt is True :
2899+ wf .connect (node , out , retry_node , 'inputspec.anat_wm_segmentation' )
28722900
28732901 if diff_complete :
28742902 node , out = strat_pool .get_data ('effectiveEchoSpacing' )
28752903 wf .connect (node , out ,
28762904 func_to_anat_bbreg , 'echospacing_input.echospacing' )
2905+ if opt is True :
2906+ wf .connect (node , out ,
2907+ retry_node , 'echospacing_input.echospacing' )
28772908
28782909 node , out = strat_pool .get_data ('diffphase-pedir' )
28792910 wf .connect (node , out , func_to_anat_bbreg , 'pedir_input.pedir' )
2911+ if opt is True :
2912+ wf .connect (node , out , retry_node , 'pedir_input.pedir' )
28802913
28812914 node , out = strat_pool .get_data ("despiked-fieldmap" )
28822915 wf .connect (node , out , func_to_anat_bbreg , 'inputspec.fieldmap' )
2916+ if opt is True :
2917+ wf .connect (node , out , retry_node , 'inputspec.fieldmap' )
28832918
28842919 node , out = strat_pool .get_data ("fieldmap-mask" )
28852920 wf .connect (node , out ,
28862921 func_to_anat_bbreg , 'inputspec.fieldmapmask' )
2922+ if opt is True :
2923+ wf .connect (node , out , retry_node , 'inputspec.fieldmapmask' )
28872924
28882925 wf .connect (func_to_anat_bbreg , 'outputspec.anat_func' ,
28892926 bbreg_guardrail , 'registered' )
2927+ if opt is True :
2928+ wf .connect (func_to_anat_bbreg , 'outputspec.anat_func' ,
2929+ retry_guardrail , 'registered' )
28902930
28912931 mean_bolds = pe .Node (Merge (2 ), run_without_submitting = True ,
2892- name = f'bbreg_mean_bold_choices_{ pipe_num } ' )
2932+ name = f'bbreg_mean_bold_choices_{ pipe_num } ' )
28932933 xfms = pe .Node (Merge (2 ), run_without_submitting = True ,
2894- name = f'bbreg_xfm_choices_{ pipe_num } ' )
2934+ name = f'bbreg_xfm_choices_{ pipe_num } ' )
28952935 fallback_mean_bolds = pe .Node (Select , run_without_submitting = True ,
2896- name = 'bbreg_choose_mean_bold_'
2897- f' { pipe_num } ' )
2936+ name = f 'bbreg_choose_mean_bold_{ pipe_num } '
2937+ )
28982938 fallback_xfms = pe .Node (Select , run_without_submitting = True ,
28992939 name = f'bbreg_choose_xfm_{ pipe_num } ' )
29002940 if opt is True :
2901- # Retry once on failure
2902- retry_node = create_bbregister_func_to_anat (diff_complete ,
2903- f'retry_func_to_anat_'
2904- f'bbreg_{ pipe_num } ' ,
2905- retry = True )
29062941 wf .connect ([
2907- (func_to_anat_bbreg , mean_bolds , ['outputspec.anat_func' ,
2908- 'in1' ]),
2909- (retry_node , mean_bolds , ['outputspec.anat_func_nobbreg' ,
2910- 'in1' ]),
2942+ (bbreg_guardrail , mean_bolds , ['registered' , 'in1' ]),
2943+ (retry_guardrail , mean_bolds , ['registered' , 'in1' ]),
29112944 (func_to_anat_bbreg , xfms , [
29122945 'outputspec.func_to_anat_linear_xfm' , 'in2' ]),
29132946 (retry_node , xfms , [
29142947 'outputspec.func_to_anat_linear_xfm_nobbreg' , 'in2' ])])
29152948 else :
29162949 # Fall back to no-BBReg
29172950 wf .connect ([
2918- (func_to_anat_bbreg , mean_bolds , ['outputspec.anat_func' ,
2919- 'in1' ]),
2951+ (bbreg_guardrail , mean_bolds , ['registered' , 'in1' ]),
29202952 (func_to_anat , mean_bolds , ['outputspec.anat_func_nobbreg' ,
29212953 'in1' ]),
29222954 (func_to_anat_bbreg , xfms , [
@@ -2932,8 +2964,6 @@ def coregistration(wf, cfg, strat_pool, pipe_num, opt=None):
29322964 'space-T1w_desc-mean_bold' : (fallback_mean_bolds , 'out' ),
29332965 'from-bold_to-T1w_mode-image_desc-linear_xfm' : (fallback_xfms ,
29342966 'out' )}
2935- print (2938 )
2936- print (outputs )
29372967 return wf , outputs
29382968
29392969
0 commit comments