@@ -1794,7 +1794,8 @@ def ANTs_registration_connector(wf_name, cfg, params, orig="T1w",
17941794 return (wf , outputs )
17951795
17961796
1797- def bold_to_T1template_xfm_connector (wf_name , cfg , reg_tool , symmetric = False ):
1797+ def bold_to_T1template_xfm_connector (wf_name , cfg , reg_tool , symmetric = False ,
1798+ blip = False ):
17981799
17991800 wf = pe .Workflow (name = wf_name )
18001801
@@ -1804,7 +1805,8 @@ def bold_to_T1template_xfm_connector(wf_name, cfg, reg_tool, symmetric=False):
18041805 'coreg_xfm' ,
18051806 'T1w-brain-template_funcreg' ,
18061807 'T1w_to_template_xfm' ,
1807- 'template_to_T1w_xfm' ]),
1808+ 'template_to_T1w_xfm' ,
1809+ 'blip_warp' ]),
18081810 name = 'inputspec' )
18091811
18101812 sym = ''
@@ -1856,11 +1858,18 @@ def bold_to_T1template_xfm_connector(wf_name, cfg, reg_tool, symmetric=False):
18561858 cfg .registration_workflows ['anatomical_registration' ][
18571859 'registration' ]['ANTs' ]['interpolation' ]
18581860
1859- collect_all_transforms = pe .Node (util .Merge (2 ),
1860- name = f'collect_all_transforms' )
1861+ if not blip :
1862+ collect_all_transforms = pe .Node (util .Merge (2 ),
1863+ name = 'collect_all_transforms' )
1864+ else :
1865+ collect_all_transforms = pe .Node (util .Merge (3 ),
1866+ name = 'collect_all_transforms' )
1867+
1868+ wf .connect (inputNode , 'blip_warp' ,
1869+ collect_all_transforms , 'in3' )
18611870
18621871 wf .connect (inputNode , 'T1w_to_template_xfm' ,
1863- collect_all_transforms , 'in1' )
1872+ collect_all_transforms , 'in1' )
18641873
18651874 wf .connect (change_transform , 'updated_affine_file' ,
18661875 collect_all_transforms , 'in2' )
@@ -1916,10 +1925,18 @@ def bold_to_T1template_xfm_connector(wf_name, cfg, reg_tool, symmetric=False):
19161925 wf .connect (inputNode , 'T1w-brain-template_funcreg' ,
19171926 write_composite_xfm , 'reference' )
19181927
1919- wf .connect (inputNode , 'coreg_xfm' , write_composite_xfm , 'premat' )
1920-
1921- wf .connect (inputNode , 'T1w_to_template_xfm' ,
1922- write_composite_xfm , 'warp1' )
1928+ if blip :
1929+ wf .connect (inputNode , 'coreg_xfm' ,
1930+ write_composite_xfm , 'postmat' )
1931+ wf .connect (inputNode , 'blip_warp' ,
1932+ write_composite_xfm , 'warp1' )
1933+ wf .connect (inputNode , 'T1w_to_template_xfm' ,
1934+ write_composite_xfm , 'warp2' )
1935+ else :
1936+ wf .connect (inputNode , 'coreg_xfm' ,
1937+ write_composite_xfm , 'premat' )
1938+ wf .connect (inputNode , 'T1w_to_template_xfm' ,
1939+ write_composite_xfm , 'warp1' )
19231940
19241941 outputs = {
19251942 f'from-bold_to-{ sym } template_mode-image_xfm' :
@@ -2935,7 +2952,9 @@ def create_func_to_T1template_xfm(wf, cfg, strat_pool, pipe_num, opt=None):
29352952 "option_key": ["target_template", "using"],
29362953 "option_val": "T1_template",
29372954 "inputs": [("sbref",
2938- "from-bold_to-T1w_mode-image_desc-linear_xfm"),
2955+ "from-bold_to-T1w_mode-image_desc-linear_xfm",
2956+ "ants-blip-warp",
2957+ "fsl-blip-warp"),
29392958 ("from-T1w_to-template_mode-image_xfm",
29402959 "from-template_to-T1w_mode-image_xfm",
29412960 "desc-brain_T1w"),
@@ -2974,6 +2993,21 @@ def create_func_to_T1template_xfm(wf, cfg, strat_pool, pipe_num, opt=None):
29742993 node , out = strat_pool .get_data ('from-template_to-T1w_mode-image_xfm' )
29752994 wf .connect (node , out , xfm , 'inputspec.template_to_T1w_xfm' )
29762995
2996+ if strat_pool .check_rpool ('ants-blip-warp' ):
2997+ if reg_tool == 'ants' :
2998+ node , out = strat_pool .get_data ('ants-blip-warp' )
2999+ wf .connect (node , out , xfm , 'inputspec.blip_warp' )
3000+ elif reg_tool == 'fsl' :
3001+ # apply the ants blip warp separately
3002+ pass
3003+ elif strat_pool .check_rpool ('fsl-blip-warp' ):
3004+ if reg_tool == 'fsl' :
3005+ node , out = strat_pool .get_data ('fsl-blip-warp' )
3006+ wf .connect (node , out , xfm , 'inputspec.blip_warp' )
3007+ elif reg_tool == 'ants' :
3008+ # apply the fsl blip warp separately
3009+ pass
3010+
29773011 return (wf , outputs )
29783012
29793013
@@ -3033,6 +3067,77 @@ def create_func_to_T1template_symmetric_xfm(wf, cfg, strat_pool, pipe_num,
30333067 return (wf , outputs )
30343068
30353069
3070+ def apply_blip_to_timeseries_separately (wf , cfg , strat_pool , pipe_num ,
3071+ opt = None ):
3072+ '''
3073+ Node Block:
3074+ {"name": "apply_blip_to_timeseries_separately",
3075+ "config": "None",
3076+ "switch": [["registration_workflows", "functional_registration",
3077+ "func_registration_to_template", "run"],
3078+ ["functional_preproc", "distortion_correction", "run"]],
3079+ "option_key": "None",
3080+ "option_val": "None",
3081+ "inputs": [("sbref",
3082+ "desc-preproc_bold",
3083+ "from-bold_to-template_mode-image_xfm",
3084+ "ants-blip-warp",
3085+ "fsl-blip-warp")],
3086+ "outputs": ["desc-preproc_bold"]}
3087+ '''
3088+
3089+ xfm_prov = strat_pool .get_cpac_provenance (
3090+ 'from-bold_to-template_mode-image_xfm' )
3091+ reg_tool = check_prov_for_regtool (xfm_prov )
3092+
3093+ if strat_pool .check_rpool ("ants-blip-warp" ):
3094+ if reg_tool == 'fsl' :
3095+ blip_node , blip_out = strat_pool .get_data ("ants-blip-warp" )
3096+ else :
3097+ outputs = {'desc-preproc_bold' : strat_pool .get_data ("desc-preproc_bold" )}
3098+ return (wf , outputs )
3099+ elif strat_pool .check_rpool ("fsl-blip-warp" ):
3100+ if reg_tool == 'ants' :
3101+ blip_node , blip_out = strat_pool .get_data ("fsl-blip-warp" )
3102+ else :
3103+ outputs = {'desc-preproc_bold' : strat_pool .get_data ("desc-preproc_bold" )}
3104+ return (wf , outputs )
3105+
3106+ num_cpus = cfg .pipeline_setup ['system_config' ][
3107+ 'max_cores_per_participant' ]
3108+
3109+ num_ants_cores = cfg .pipeline_setup ['system_config' ]['num_ants_threads' ]
3110+
3111+ apply_xfm = apply_transform (f'warp_ts_to_blip_sep_{ pipe_num } ' , reg_tool ,
3112+ time_series = True , num_cpus = num_cpus ,
3113+ num_ants_cores = num_ants_cores )
3114+
3115+ if reg_tool == 'ants' :
3116+ apply_xfm .inputs .inputspec .interpolation = cfg .registration_workflows [
3117+ 'functional_registration' ]['func_registration_to_template' ][
3118+ 'ANTs_pipelines' ]['interpolation' ]
3119+ elif reg_tool == 'fsl' :
3120+ apply_xfm .inputs .inputspec .interpolation = cfg .registration_workflows [
3121+ 'functional_registration' ]['func_registration_to_template' ][
3122+ 'FNIRT_pipelines' ]['interpolation' ]
3123+
3124+ connect = strat_pool .get_data ("desc-preproc_bold" )
3125+ node , out = connect
3126+ wf .connect (node , out , apply_xfm , 'inputspec.input_image' )
3127+
3128+ node , out = strat_pool .get_data ("sbref" )
3129+ wf .connect (node , out , apply_xfm , 'inputspec.reference' )
3130+
3131+ wf .connect (blip_node , blip_out , apply_xfm , 'inputspec.transform' )
3132+
3133+ outputs = {
3134+ 'desc-preproc_bold' : (apply_xfm , 'outputspec.output_image' )
3135+ }
3136+
3137+ return (wf , outputs )
3138+
3139+
3140+
30363141def warp_timeseries_to_T1template (wf , cfg , strat_pool , pipe_num , opt = None ):
30373142 '''
30383143 Node Block:
@@ -3102,7 +3207,7 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
31023207 "from-T1w_to-template_mode-image_xfm",
31033208 "from-bold_to-T1w_mode-image_desc-linear_xfm",
31043209 "from-bold_to-template_mode-image_xfm",
3105- "blip-warp",
3210+ "fsl- blip-warp",
31063211 "desc-preproc_T1w",
31073212 "space-template_res-bold_desc-brain_T1w",
31083213 "space-template_desc-bold_mask",
@@ -3126,11 +3231,11 @@ def warp_timeseries_to_T1template_abcd(wf, cfg, strat_pool, pipe_num, opt=None):
31263231 node , out = strat_pool .get_data ('desc-preproc_T1w' )
31273232 wf .connect (node , out , convert_func_to_anat_linear_warp , 'reference' )
31283233
3129- if strat_pool .check_rpool ('blip-warp' ):
3234+ if strat_pool .check_rpool ('fsl- blip-warp' ):
31303235 node , out = strat_pool .get_data ('from-bold_to-T1w_mode-image_desc-linear_xfm' )
31313236 wf .connect (node , out , convert_func_to_anat_linear_warp , 'postmat' )
31323237
3133- node , out = strat_pool .get_data ('blip-warp' )
3238+ node , out = strat_pool .get_data ('fsl- blip-warp' )
31343239 wf .connect (node , out , convert_func_to_anat_linear_warp , 'warp1' )
31353240 else :
31363241 node , out = strat_pool .get_data ('from-bold_to-T1w_mode-image_desc-linear_xfm' )
0 commit comments