@@ -2256,52 +2256,23 @@ def bold_to_T1template_xfm_connector(
22562256 return (wf , outputs )
22572257
22582258
2259- @nodeblock (
2260- name = "register_FSL_anat_to_template" ,
2261- config = ["registration_workflows" , "anatomical_registration" ],
2262- switch = ["run" ],
2263- option_key = ["registration" , "using" ],
2264- option_val = ["FSL" , "FSL-linear" ],
2265- inputs = [
2266- (
2267- [
2268- "desc-preproc_T1w" ,
2269- "longitudinal-template_space-longitudinal_desc-reorient_T1w" ,
2270- "longitudinal-template_space-longitudinal_desc-head_T1w" ,
2271- ],
2272- [
2273- "desc-brain_T1w" ,
2274- "longitudinal-template_space-longitudinal_desc-brain_T1w" ,
2275- ],
2276- ),
2277- "T1w-template" ,
2278- "T1w-brain-template" ,
2279- "FNIRT-T1w-template" ,
2280- "FNIRT-T1w-brain-template" ,
2281- "template-ref-mask" ,
2282- ],
2283- outputs = {
2284- "space-template_desc-preproc_T1w" : {"Template" : "T1w-brain-template" },
2285- "space-template_desc-head_T1w" : {"Template" : "T1w-template" },
2286- "space-template_desc-T1w_mask" : {"Template" : "T1w-template" },
2287- "space-template_desc-T1wT2w_biasfield" : {"Template" : "T1w-template" },
2288- "from-T1w_to-template_mode-image_desc-linear_xfm" : {"Template" : "T1w-template" },
2289- "from-template_to-T1w_mode-image_desc-linear_xfm" : {"Template" : "T1w-template" },
2290- "from-T1w_to-template_mode-image_xfm" : {"Template" : "T1w-template" },
2291- "from-T1w_to-template_mode-image_warp" : {"Template" : "T1w-template" },
2292- "from-longitudinal_to-template_mode-image_desc-linear_xfm" : {
2293- "Template" : "T1w-template"
2294- },
2295- "from-template_to-longitudinal_mode-image_desc-linear_xfm" : {
2296- "Template" : "T1w-template"
2297- },
2298- "from-longitudinal_to-template_mode-image_xfm" : {"Template" : "T1w-template" },
2299- },
2300- )
2301- def register_FSL_anat_to_template (wf , cfg , strat_pool , pipe_num , opt = None ):
2302- """Register T1w to template with FSL."""
2259+ def _register_FSL_anat_to_template (
2260+ wf : pe .Workflow ,
2261+ cfg : Configuration ,
2262+ strat_pool : ResourcePool ,
2263+ pipe_num : int ,
2264+ opt : str ,
2265+ symmetric : bool ,
2266+ ) -> NODEBLOCK_RETURN :
2267+ """Register T1w to symmetric template with FSL."""
2268+ symmetric_str = "_symmetric_" if symmetric else ""
2269+ template_str = "template-symmetric" if symmetric else "template"
23032270 fsl , outputs = FSL_registration_connector (
2304- f"register_{ opt } _anat_to_template_{ pipe_num } " , cfg , orig = "T1w" , opt = opt
2271+ f"register_{ opt } _anat_to_template_{ symmetric_str } _{ pipe_num } " ,
2272+ cfg ,
2273+ orig = "T1w" ,
2274+ opt = opt ,
2275+ symmetric = symmetric ,
23052276 )
23062277
23072278 fsl .inputs .inputspec .interpolation = cfg .registration_workflows [
@@ -2325,16 +2296,16 @@ def register_FSL_anat_to_template(wf, cfg, strat_pool, pipe_num, opt=None):
23252296 ]["ref_resolution" ]
23262297 == cfg .registration_workflows ["anatomical_registration" ]["resolution_for_anat" ]
23272298 ):
2328- node , out = strat_pool .get_data ("T1w-brain-template " )
2299+ node , out = strat_pool .get_data (f "T1w-brain-{ template_str } " )
23292300 wf .connect (node , out , fsl , "inputspec.reference_brain" )
23302301
2331- node , out = strat_pool .get_data ("T1w-template " )
2302+ node , out = strat_pool .get_data (f "T1w-{ template_str } " )
23322303 wf .connect (node , out , fsl , "inputspec.reference_head" )
23332304 else :
2334- node , out = strat_pool .get_data ("FNIRT-T1w-brain-template " )
2305+ node , out = strat_pool .get_data (f "FNIRT-T1w-brain-{ template_str } " )
23352306 wf .connect (node , out , fsl , "inputspec.reference_brain" )
23362307
2337- node , out = strat_pool .get_data ("FNIRT-T1w-template " )
2308+ node , out = strat_pool .get_data (f "FNIRT-T1w-{ template_str } " )
23382309 wf .connect (node , out , fsl , "inputspec.reference_head" )
23392310
23402311 node , out = strat_pool .get_data (
@@ -2346,23 +2317,80 @@ def register_FSL_anat_to_template(wf, cfg, strat_pool, pipe_num, opt=None):
23462317 )
23472318 wf .connect (node , out , fsl , "inputspec.input_head" )
23482319
2349- node , out = strat_pool .get_data ("template-ref-mask" )
2320+ node , out = strat_pool .get_data (
2321+ "dilated-symmetric-brain-mask" if symmetric else "template-ref-mask"
2322+ )
23502323 wf .connect (node , out , fsl , "inputspec.reference_mask" )
23512324
23522325 if "space-longitudinal" in brain :
23532326 for key in list (outputs .keys ()):
23542327 if "from-T1w" in key :
23552328 new_key = key .replace ("from-T1w" , "from-longitudinal" )
23562329 outputs [new_key ] = outputs [key ]
2357- # del outputs[key]
2330+ del outputs [key ]
23582331 if "to-T1w" in key :
23592332 new_key = key .replace ("to-T1w" , "to-longitudinal" )
23602333 outputs [new_key ] = outputs [key ]
2361- # del outputs[key]
2334+ del outputs [key ]
23622335
23632336 return wf , outputs
23642337
23652338
2339+ @nodeblock (
2340+ name = "register_FSL_anat_to_template" ,
2341+ config = ["registration_workflows" , "anatomical_registration" ],
2342+ switch = ["run" ],
2343+ option_key = ["registration" , "using" ],
2344+ option_val = ["FSL" , "FSL-linear" ],
2345+ inputs = [
2346+ (
2347+ [
2348+ "desc-preproc_T1w" ,
2349+ "longitudinal-template_space-longitudinal_desc-reorient_T1w" ,
2350+ "longitudinal-template_space-longitudinal_desc-head_T1w" ,
2351+ ],
2352+ [
2353+ "desc-brain_T1w" ,
2354+ "longitudinal-template_space-longitudinal_desc-brain_T1w" ,
2355+ ],
2356+ ),
2357+ "T1w-template" ,
2358+ "T1w-brain-template" ,
2359+ "FNIRT-T1w-template" ,
2360+ "FNIRT-T1w-brain-template" ,
2361+ "template-ref-mask" ,
2362+ ],
2363+ outputs = {
2364+ "space-template_desc-preproc_T1w" : {"Template" : "T1w-brain-template" },
2365+ "space-template_desc-head_T1w" : {"Template" : "T1w-template" },
2366+ "space-template_desc-T1w_mask" : {"Template" : "T1w-template" },
2367+ "space-template_desc-T1wT2w_biasfield" : {"Template" : "T1w-template" },
2368+ "from-T1w_to-template_mode-image_desc-linear_xfm" : {"Template" : "T1w-template" },
2369+ "from-template_to-T1w_mode-image_desc-linear_xfm" : {"Template" : "T1w-template" },
2370+ "from-T1w_to-template_mode-image_xfm" : {"Template" : "T1w-template" },
2371+ "from-T1w_to-template_mode-image_warp" : {"Template" : "T1w-template" },
2372+ "from-longitudinal_to-template_mode-image_desc-linear_xfm" : {
2373+ "Template" : "T1w-template"
2374+ },
2375+ "from-template_to-longitudinal_mode-image_desc-linear_xfm" : {
2376+ "Template" : "T1w-template"
2377+ },
2378+ "from-longitudinal_to-template_mode-image_xfm" : {"Template" : "T1w-template" },
2379+ },
2380+ )
2381+ def register_FSL_anat_to_template (
2382+ wf : pe .Workflow ,
2383+ cfg : Configuration ,
2384+ strat_pool : ResourcePool ,
2385+ pipe_num : int ,
2386+ opt : str = "" ,
2387+ ) -> NODEBLOCK_RETURN :
2388+ """Register T1w to template with FSL."""
2389+ return _register_FSL_anat_to_template (
2390+ wf , cfg , strat_pool , pipe_num , opt , symmetric = False
2391+ )
2392+
2393+
23662394@nodeblock (
23672395 name = "register_symmetric_FSL_anat_to_template" ,
23682396 config = ["registration_workflows" , "anatomical_registration" ],
@@ -2409,62 +2437,18 @@ def register_FSL_anat_to_template(wf, cfg, strat_pool, pipe_num, opt=None):
24092437 },
24102438 },
24112439)
2412- def register_symmetric_FSL_anat_to_template (wf , cfg , strat_pool , pipe_num , opt = None ):
2440+ def register_symmetric_FSL_anat_to_template (
2441+ wf : pe .Workflow ,
2442+ cfg : Configuration ,
2443+ strat_pool : ResourcePool ,
2444+ pipe_num : int ,
2445+ opt : str = "" ,
2446+ ) -> NODEBLOCK_RETURN :
24132447 """Register T1w to symmetric template with FSL."""
2414- fsl , outputs = FSL_registration_connector (
2415- f"register_{ opt } _anat_to_template_symmetric_{ pipe_num } " ,
2416- cfg ,
2417- orig = "T1w" ,
2418- opt = opt ,
2419- symmetric = True ,
2448+ return _register_FSL_anat_to_template (
2449+ wf , cfg , strat_pool , pipe_num , opt , symmetric = True
24202450 )
24212451
2422- fsl .inputs .inputspec .interpolation = cfg .registration_workflows [
2423- "anatomical_registration"
2424- ]["registration" ]["FSL-FNIRT" ]["interpolation" ]
2425-
2426- fsl .inputs .inputspec .fnirt_config = cfg .registration_workflows [
2427- "anatomical_registration"
2428- ]["registration" ]["FSL-FNIRT" ]["fnirt_config" ]
2429-
2430- connect , brain = strat_pool .get_data (
2431- ["desc-brain_T1w" , "longitudinal-template_space-longitudinal_desc-brain_T1w" ],
2432- report_fetched = True ,
2433- )
2434- node , out = connect
2435- wf .connect (node , out , fsl , "inputspec.input_brain" )
2436-
2437- node , out = strat_pool .get_data ("T1w-brain-template-symmetric" )
2438- wf .connect (node , out , fsl , "inputspec.reference_brain" )
2439-
2440- node , out = strat_pool .get_data (
2441- [
2442- "desc-preproc_T1w" ,
2443- "longitudinal-template_space-longitudinal_desc-reorient_T1w" ,
2444- "longitudinal-template_space-longitudinal_desc-head_T1w" ,
2445- ]
2446- )
2447- wf .connect (node , out , fsl , "inputspec.input_head" )
2448-
2449- node , out = strat_pool .get_data ("T1w-template-symmetric" )
2450- wf .connect (node , out , fsl , "inputspec.reference_head" )
2451-
2452- node , out = strat_pool .get_data ("dilated-symmetric-brain-mask" )
2453- wf .connect (node , out , fsl , "inputspec.reference_mask" )
2454-
2455- if "space-longitudinal" in brain :
2456- for key in list (outputs .keys ()):
2457- if "from-T1w" in key :
2458- new_key = key .replace ("from-T1w" , "from-longitudinal" )
2459- outputs [new_key ] = outputs [key ]
2460- del outputs [key ]
2461- if "to-T1w" in key :
2462- new_key = key .replace ("to-T1w" , "to-longitudinal" )
2463- outputs [new_key ] = outputs [key ]
2464- del outputs [key ]
2465-
2466- return (wf , outputs )
2467-
24682452
24692453@nodeblock (
24702454 name = "register_FSL_EPI_to_template" ,
0 commit comments