6161from .fit .registration import init_register_template_wf
6262from .outputs import (
6363 init_anat_reports_wf ,
64- init_anat_second_derivatives_wf ,
6564 init_ds_anat_volumes_wf ,
6665 init_ds_dseg_wf ,
6766 init_ds_fs_registration_wf ,
67+ init_ds_fs_segs_wf ,
6868 init_ds_grayord_metrics_wf ,
6969 init_ds_mask_wf ,
7070 init_ds_surface_metrics_wf ,
@@ -287,7 +287,6 @@ def init_anat_preproc_wf(
287287 ds_std_volumes_wf = init_ds_anat_volumes_wf (
288288 bids_root = bids_root ,
289289 output_dir = output_dir ,
290- name = 'ds_std_volumes_wf' ,
291290 )
292291
293292 workflow .connect ([
@@ -320,10 +319,10 @@ def init_anat_preproc_wf(
320319 ]),
321320 (anat_fit_wf , ds_std_volumes_wf , [
322321 ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
323- ('outputnode.t1w_preproc' , 'inputnode.t1w_preproc ' ),
324- ('outputnode.t1w_mask' , 'inputnode.t1w_mask ' ),
325- ('outputnode.t1w_dseg' , 'inputnode.t1w_dseg ' ),
326- ('outputnode.t1w_tpms' , 'inputnode.t1w_tpms ' ),
322+ ('outputnode.t1w_preproc' , 'inputnode.anat_preproc ' ),
323+ ('outputnode.t1w_mask' , 'inputnode.anat_mask ' ),
324+ ('outputnode.t1w_dseg' , 'inputnode.anat_dseg ' ),
325+ ('outputnode.t1w_tpms' , 'inputnode.anat_tpms ' ),
327326 ]),
328327 (template_iterator_wf , ds_std_volumes_wf , [
329328 ('outputnode.std_t1w' , 'inputnode.ref_file' ),
@@ -335,17 +334,12 @@ def init_anat_preproc_wf(
335334 ]) # fmt:skip
336335
337336 if freesurfer :
338- anat_second_derivatives_wf = init_anat_second_derivatives_wf (
337+ ds_fs_segs_wf = init_ds_fs_segs_wf (
339338 bids_root = bids_root ,
340339 output_dir = output_dir ,
341- cifti_output = cifti_output ,
342- )
343- surface_derivatives_wf = init_surface_derivatives_wf (
344- cifti_output = cifti_output ,
345- )
346- ds_surfaces_wf = init_ds_surfaces_wf (
347- bids_root = bids_root , output_dir = output_dir , surfaces = ['inflated' ]
348340 )
341+ surface_derivatives_wf = init_surface_derivatives_wf ()
342+ ds_surfaces_wf = init_ds_surfaces_wf (output_dir = output_dir , surfaces = ['inflated' ])
349343 ds_curv_wf = init_ds_surface_metrics_wf (
350344 bids_root = bids_root , output_dir = output_dir , metrics = ['curv' ], name = 'ds_curv_wf'
351345 )
@@ -355,7 +349,7 @@ def init_anat_preproc_wf(
355349 ('outputnode.t1w_preproc' , 'inputnode.reference' ),
356350 ('outputnode.subjects_dir' , 'inputnode.subjects_dir' ),
357351 ('outputnode.subject_id' , 'inputnode.subject_id' ),
358- ('outputnode.fsnative2t1w_xfm' , 'inputnode.fsnative2t1w_xfm ' ),
352+ ('outputnode.fsnative2t1w_xfm' , 'inputnode.fsnative2anat_xfm ' ),
359353 ]),
360354 (anat_fit_wf , ds_surfaces_wf , [
361355 ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
@@ -369,12 +363,12 @@ def init_anat_preproc_wf(
369363 (surface_derivatives_wf , ds_curv_wf , [
370364 ('outputnode.curv' , 'inputnode.curv' ),
371365 ]),
372- (anat_fit_wf , anat_second_derivatives_wf , [
366+ (anat_fit_wf , ds_fs_segs_wf , [
373367 ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
374368 ]),
375- (surface_derivatives_wf , anat_second_derivatives_wf , [
376- ('outputnode.out_aseg' , 'inputnode.t1w_fs_aseg ' ),
377- ('outputnode.out_aparc' , 'inputnode.t1w_fs_aparc ' ),
369+ (surface_derivatives_wf , ds_fs_segs_wf , [
370+ ('outputnode.out_aseg' , 'inputnode.anat_fs_aseg ' ),
371+ ('outputnode.out_aparc' , 'inputnode.anat_fs_aparc ' ),
378372 ]),
379373 (surface_derivatives_wf , outputnode , [
380374 ('outputnode.out_aseg' , 't1w_aseg' ),
@@ -765,10 +759,12 @@ def init_anat_fit_wf(
765759 longitudinal = longitudinal ,
766760 omp_nthreads = omp_nthreads ,
767761 num_files = num_t1w ,
768- contrast = 'T1w' ,
762+ image_type = 'T1w' ,
769763 name = 'anat_template_wf' ,
770764 )
771- ds_template_wf = init_ds_template_wf (output_dir = output_dir , num_t1w = num_t1w )
765+ ds_template_wf = init_ds_template_wf (
766+ output_dir = output_dir , num_anat = num_t1w , image_type = 'T1w'
767+ )
772768
773769 # fmt:off
774770 workflow .connect ([
@@ -781,11 +777,11 @@ def init_anat_fit_wf(
781777 ('outputnode.out_report' , 'inputnode.t1w_conform_report' ),
782778 ]),
783779 (anat_template_wf , ds_template_wf , [
784- ('outputnode.anat_realign_xfm' , 'inputnode.t1w_ref_xfms ' ),
780+ ('outputnode.anat_realign_xfm' , 'inputnode.anat_ref_xfms ' ),
785781 ]),
786782 (sourcefile_buffer , ds_template_wf , [('source_files' , 'inputnode.source_files' )]),
787- (t1w_buffer , ds_template_wf , [('t1w_preproc' , 'inputnode.t1w_preproc ' )]),
788- (ds_template_wf , outputnode , [('outputnode.t1w_preproc ' , 't1w_preproc' )]),
783+ (t1w_buffer , ds_template_wf , [('t1w_preproc' , 'inputnode.anat_preproc ' )]),
784+ (ds_template_wf , outputnode , [('outputnode.anat_preproc ' , 't1w_preproc' )]),
789785 ])
790786 # fmt:on
791787 else :
@@ -954,16 +950,16 @@ def init_anat_fit_wf(
954950 workflow .connect ([
955951 (fast , lut_t1w_dseg , [('partial_volume_map' , 'in_dseg' )]),
956952 (sourcefile_buffer , ds_dseg_wf , [('source_files' , 'inputnode.source_files' )]),
957- (lut_t1w_dseg , ds_dseg_wf , [('out' , 'inputnode.t1w_dseg ' )]),
958- (ds_dseg_wf , seg_buffer , [('outputnode.t1w_dseg ' , 't1w_dseg' )]),
953+ (lut_t1w_dseg , ds_dseg_wf , [('out' , 'inputnode.anat_dseg ' )]),
954+ (ds_dseg_wf , seg_buffer , [('outputnode.anat_dseg ' , 't1w_dseg' )]),
959955 ])
960956 if not have_tpms :
961957 ds_tpms_wf = init_ds_tpms_wf (output_dir = output_dir )
962958 workflow .connect ([
963959 (fast , fast2bids , [('partial_volume_files' , 'inlist' )]),
964960 (sourcefile_buffer , ds_tpms_wf , [('source_files' , 'inputnode.source_files' )]),
965- (fast2bids , ds_tpms_wf , [('out' , 'inputnode.t1w_tpms ' )]),
966- (ds_tpms_wf , seg_buffer , [('outputnode.t1w_tpms ' , 't1w_tpms' )]),
961+ (fast2bids , ds_tpms_wf , [('out' , 'inputnode.anat_tpms ' )]),
962+ (ds_tpms_wf , seg_buffer , [('outputnode.anat_tpms ' , 't1w_tpms' )]),
967963 ])
968964 # fmt:on
969965 else :
@@ -998,7 +994,9 @@ def init_anat_fit_wf(
998994 omp_nthreads = omp_nthreads ,
999995 templates = templates ,
1000996 )
1001- ds_template_registration_wf = init_ds_template_registration_wf (output_dir = output_dir )
997+ ds_template_registration_wf = init_ds_template_registration_wf (
998+ output_dir = output_dir , image_type = 'T1w'
999+ )
10021000
10031001 # fmt:off
10041002 workflow .connect ([
@@ -1081,17 +1079,17 @@ def init_anat_fit_wf(
10811079
10821080 fsnative_xfms = precomputed .get ('transforms' , {}).get ('fsnative' )
10831081 if not fsnative_xfms :
1084- ds_fs_registration_wf = init_ds_fs_registration_wf (output_dir = output_dir )
1082+ ds_fs_registration_wf = init_ds_fs_registration_wf (output_dir = output_dir , image_type = 'T1w' )
10851083 # fmt:off
10861084 workflow .connect ([
10871085 (sourcefile_buffer , ds_fs_registration_wf , [
10881086 ('source_files' , 'inputnode.source_files' ),
10891087 ]),
10901088 (surface_recon_wf , ds_fs_registration_wf , [
1091- ('outputnode.fsnative2t1w_xfm' , 'inputnode.fsnative2t1w_xfm ' ),
1089+ ('outputnode.fsnative2t1w_xfm' , 'inputnode.fsnative2anat_xfm ' ),
10921090 ]),
10931091 (ds_fs_registration_wf , outputnode , [
1094- ('outputnode.fsnative2t1w_xfm ' , 'fsnative2t1w_xfm' ),
1092+ ('outputnode.fsnative2anat_xfm ' , 'fsnative2t1w_xfm' ),
10951093 ]),
10961094 ])
10971095 # fmt:on
@@ -1114,7 +1112,7 @@ def init_anat_fit_wf(
11141112 (surface_recon_wf , refinement_wf , [
11151113 ('outputnode.subjects_dir' , 'inputnode.subjects_dir' ),
11161114 ('outputnode.subject_id' , 'inputnode.subject_id' ),
1117- ('outputnode.fsnative2t1w_xfm' , 'inputnode.fsnative2t1w_xfm ' ),
1115+ ('outputnode.fsnative2t1w_xfm' , 'inputnode.fsnative2anat_xfm ' ),
11181116 ]),
11191117 (t1w_buffer , refinement_wf , [
11201118 ('t1w_preproc' , 'inputnode.reference_image' ),
@@ -1135,7 +1133,7 @@ def init_anat_fit_wf(
11351133 longitudinal = longitudinal ,
11361134 omp_nthreads = omp_nthreads ,
11371135 num_files = len (t2w ),
1138- contrast = 'T2w' ,
1136+ image_type = 'T2w' ,
11391137 name = 't2w_template_wf' ,
11401138 )
11411139 bbreg = pe .Node (
@@ -1216,15 +1214,13 @@ def init_anat_fit_wf(
12161214 LOGGER .info (f'ANAT Stage 8: Creating GIFTI surfaces for { surfs + spheres } ' )
12171215 if surfs :
12181216 gifti_surfaces_wf = init_gifti_surfaces_wf (surfaces = surfs )
1219- ds_surfaces_wf = init_ds_surfaces_wf (
1220- bids_root = bids_root , output_dir = output_dir , surfaces = surfs
1221- )
1217+ ds_surfaces_wf = init_ds_surfaces_wf (output_dir = output_dir , surfaces = surfs )
12221218 # fmt:off
12231219 workflow .connect ([
12241220 (surface_recon_wf , gifti_surfaces_wf , [
12251221 ('outputnode.subject_id' , 'inputnode.subject_id' ),
12261222 ('outputnode.subjects_dir' , 'inputnode.subjects_dir' ),
1227- ('outputnode.fsnative2t1w_xfm' , 'inputnode.fsnative2t1w_xfm ' ),
1223+ ('outputnode.fsnative2t1w_xfm' , 'inputnode.fsnative2anat_xfm ' ),
12281224 ]),
12291225 (gifti_surfaces_wf , surfaces_buffer , [
12301226 (f'outputnode.{ surf } ' , surf ) for surf in surfs
@@ -1240,7 +1236,7 @@ def init_anat_fit_wf(
12401236 surfaces = spheres , to_scanner = False , name = 'gifti_spheres_wf'
12411237 )
12421238 ds_spheres_wf = init_ds_surfaces_wf (
1243- bids_root = bids_root , output_dir = output_dir , surfaces = spheres , name = 'ds_spheres_wf'
1239+ output_dir = output_dir , surfaces = spheres , name = 'ds_spheres_wf'
12441240 )
12451241 # fmt:off
12461242 workflow .connect ([
@@ -1316,7 +1312,6 @@ def init_anat_fit_wf(
13161312 LOGGER .info ('ANAT Stage 9: Creating fsLR registration sphere' )
13171313 fsLR_reg_wf = init_fsLR_reg_wf ()
13181314 ds_fsLR_reg_wf = init_ds_surfaces_wf (
1319- bids_root = bids_root ,
13201315 output_dir = output_dir ,
13211316 surfaces = ['sphere_reg_fsLR' ],
13221317 name = 'ds_fsLR_reg_wf' ,
@@ -1341,7 +1336,6 @@ def init_anat_fit_wf(
13411336 LOGGER .info ('ANAT Stage 10: Creating MSM-Sulc registration sphere' )
13421337 msm_sulc_wf = init_msm_sulc_wf (sloppy = sloppy )
13431338 ds_msmsulc_wf = init_ds_surfaces_wf (
1344- bids_root = bids_root ,
13451339 output_dir = output_dir ,
13461340 surfaces = ['sphere_reg_msm' ],
13471341 name = 'ds_msmsulc_wf' ,
@@ -1375,7 +1369,7 @@ def init_anat_template_wf(
13751369 longitudinal : bool ,
13761370 omp_nthreads : int ,
13771371 num_files : int ,
1378- contrast : str ,
1372+ image_type : ty . Literal [ 'T1w' , 'T2w' ] ,
13791373 name : str = 'anat_template_wf' ,
13801374):
13811375 """
@@ -1388,7 +1382,7 @@ def init_anat_template_wf(
13881382
13891383 from smriprep.workflows.anatomical import init_anat_template_wf
13901384 wf = init_anat_template_wf(
1391- longitudinal=False, omp_nthreads=1, num_files=1, contrast ="T1w"
1385+ longitudinal=False, omp_nthreads=1, num_files=1, image_type ="T1w"
13921386 )
13931387
13941388 Parameters
@@ -1400,8 +1394,8 @@ def init_anat_template_wf(
14001394 Maximum number of threads an individual process may use
14011395 num_files : :obj:`int`
14021396 Number of images
1403- contrast : :obj:`str`
1404- Name of contrast, for reporting purposes, e.g., T1w, T2w, PDw
1397+ image_type : :obj:`str`
1398+ MR image type ( T1w, T2w, etc.)
14051399 name : :obj:`str`, optional
14061400 Workflow name (default: anat_template_wf)
14071401
@@ -1427,8 +1421,8 @@ def init_anat_template_wf(
14271421 if num_files > 1 :
14281422 fs_ver = fs .Info ().looseversion () or '(version unknown)'
14291423 workflow .__desc__ = f"""\
1430- An anatomical { contrast } -reference map was computed after registration of
1431- { num_files } { contrast } images (after INU-correction) using
1424+ An anatomical { image_type } -reference map was computed after registration of
1425+ { num_files } { image } images (after INU-correction) using
14321426`mri_robust_template` [FreeSurfer { fs_ver } , @fs_template].
14331427"""
14341428
0 commit comments