35
35
from nipype .interfaces import utility as niu
36
36
from nipype .interfaces .base import Undefined
37
37
from nipype .pipeline import engine as pe
38
- from niworkflows .engine . workflows import LiterateWorkflow as Workflow
38
+ from niworkflows .engine import Workflow , tag
39
39
from niworkflows .interfaces .freesurfer import (
40
40
FSDetectInputs ,
41
41
FSInjectBrainExtracted ,
62
62
from ..interfaces .workbench import CreateSignedDistanceVolume
63
63
64
64
65
+ @tag ('anat.recon' )
65
66
def init_surface_recon_wf (
66
67
* ,
67
68
omp_nthreads : int ,
@@ -329,6 +330,7 @@ def init_surface_recon_wf(
329
330
return workflow
330
331
331
332
333
+ @tag ('anat.mask-refine' )
332
334
def init_refinement_wf (
333
335
* , image_type : ty .Literal ['T1w' , 'T2w' ] = 'T1w' , name : str = 'refinement_wf'
334
336
) -> Workflow :
@@ -420,6 +422,7 @@ def init_refinement_wf(
420
422
return workflow
421
423
422
424
425
+ @tag ('anat.fs-autorecon-resume' )
423
426
def init_autorecon_resume_wf (* , omp_nthreads , name = 'autorecon_resume_wf' ):
424
427
r"""
425
428
Resume recon-all execution, assuming the `-autorecon1` stage has been completed.
@@ -569,7 +572,6 @@ def _dedup(in_list):
569
572
raise ValueError (f"Non-identical values can't be deduplicated:\n { in_list !r} " )
570
573
return vals .pop ()
571
574
572
- # fmt:off
573
575
workflow .connect ([
574
576
(inputnode , cortribbon , [('use_T2' , 'use_T2' ),
575
577
('use_FLAIR' , 'use_FLAIR' )]),
@@ -587,12 +589,12 @@ def _dedup(in_list):
587
589
(('subject_id' , _dedup ), 'subject_id' )]),
588
590
(autorecon3 , outputnode , [('subjects_dir' , 'subjects_dir' ),
589
591
('subject_id' , 'subject_id' )]),
590
- ])
591
- # fmt:on
592
+ ]) # fmt:skip
592
593
593
594
return workflow
594
595
595
596
597
+ @tag ('anat.surface-derivatives' )
596
598
def init_surface_derivatives_wf (
597
599
* ,
598
600
image_type : ty .Literal ['T1w' , 'T2w' ] = 'T1w' ,
@@ -703,6 +705,7 @@ def init_surface_derivatives_wf(
703
705
return workflow
704
706
705
707
708
+ @tag ('anat.fslr-reg' )
706
709
def init_fsLR_reg_wf (* , name = 'fsLR_reg_wf' ):
707
710
"""Generate GIFTI registration files to fsLR space"""
708
711
from ..interfaces .workbench import SurfaceSphereProjectUnproject
@@ -743,6 +746,7 @@ def init_fsLR_reg_wf(*, name='fsLR_reg_wf'):
743
746
return workflow
744
747
745
748
749
+ @tag ('anat.msm-sulc' )
746
750
def init_msm_sulc_wf (* , sloppy : bool = False , name : str = 'msm_sulc_wf' ):
747
751
"""Run MSMSulc registration to fsLR surfaces, per hemisphere."""
748
752
from ..interfaces .msm import MSM
@@ -835,6 +839,7 @@ def init_msm_sulc_wf(*, sloppy: bool = False, name: str = 'msm_sulc_wf'):
835
839
return workflow
836
840
837
841
842
+ @tag ('anat.gifti-surfaces' )
838
843
def init_gifti_surfaces_wf (
839
844
* ,
840
845
surfaces : list [str ] = ('pial' , 'midthickness' , 'inflated' , 'white' ),
@@ -932,6 +937,7 @@ def init_gifti_surfaces_wf(
932
937
return workflow
933
938
934
939
940
+ @tag ('anat.gifti-morphs' )
935
941
def init_gifti_morphometrics_wf (
936
942
* ,
937
943
morphometrics : list [str ] = ('thickness' , 'curv' , 'sulc' ),
@@ -1024,6 +1030,7 @@ def init_gifti_morphometrics_wf(
1024
1030
return workflow
1025
1031
1026
1032
1033
+ @tag ('anat.hcp-morphs' )
1027
1034
def init_hcp_morphometrics_wf (
1028
1035
* ,
1029
1036
omp_nthreads : int ,
@@ -1167,6 +1174,7 @@ def init_hcp_morphometrics_wf(
1167
1174
return workflow
1168
1175
1169
1176
1177
+ @tag ('anat.segs-to-anat' )
1170
1178
def init_segs_to_native_wf (
1171
1179
* ,
1172
1180
image_type : ty .Literal ['T1w' , 'T2w' ] = 'T1w' ,
@@ -1247,6 +1255,7 @@ def init_segs_to_native_wf(
1247
1255
return workflow
1248
1256
1249
1257
1258
+ @tag ('anat.ribbon-mask' )
1250
1259
def init_anat_ribbon_wf (name = 'anat_ribbon_wf' ):
1251
1260
"""Create anatomical ribbon mask
1252
1261
@@ -1296,26 +1305,23 @@ def init_anat_ribbon_wf(name='anat_ribbon_wf'):
1296
1305
1297
1306
make_ribbon = pe .Node (MakeRibbon (), name = 'make_ribbon' , mem_gb = DEFAULT_MEMORY_MIN_GB )
1298
1307
1299
- # fmt: off
1300
- workflow .connect (
1301
- [
1302
- (inputnode , create_wm_distvol , [
1303
- ('white' , 'surf_file' ),
1304
- ('ref_file' , 'ref_file' ),
1305
- ]),
1306
- (inputnode , create_pial_distvol , [
1307
- ('pial' , 'surf_file' ),
1308
- ('ref_file' , 'ref_file' ),
1309
- ]),
1310
- (create_wm_distvol , make_ribbon , [('out_file' , 'white_distvols' )]),
1311
- (create_pial_distvol , make_ribbon , [('out_file' , 'pial_distvols' )]),
1312
- (make_ribbon , outputnode , [('ribbon' , 'anat_ribbon' )]),
1313
- ]
1314
- )
1315
- # fmt: on
1308
+ workflow .connect ([
1309
+ (inputnode , create_wm_distvol , [
1310
+ ('white' , 'surf_file' ),
1311
+ ('ref_file' , 'ref_file' ),
1312
+ ]),
1313
+ (inputnode , create_pial_distvol , [
1314
+ ('pial' , 'surf_file' ),
1315
+ ('ref_file' , 'ref_file' ),
1316
+ ]),
1317
+ (create_wm_distvol , make_ribbon , [('out_file' , 'white_distvols' )]),
1318
+ (create_pial_distvol , make_ribbon , [('out_file' , 'pial_distvols' )]),
1319
+ (make_ribbon , outputnode , [('ribbon' , 'anat_ribbon' )]),
1320
+ ]) # fmt:skip
1316
1321
return workflow
1317
1322
1318
1323
1324
+ @tag ('anat.resample-surfs' )
1319
1325
def init_resample_surfaces_wf (
1320
1326
surfaces : list [str ],
1321
1327
grayord_density : ty .Literal ['91k' , '170k' ],
@@ -1423,6 +1429,7 @@ def init_resample_surfaces_wf(
1423
1429
return workflow
1424
1430
1425
1431
1432
+ @tag ('anat.resample-morphs-grayords' )
1426
1433
def init_morph_grayords_wf (
1427
1434
grayord_density : ty .Literal ['91k' , '170k' ],
1428
1435
omp_nthreads : int ,
@@ -1636,10 +1643,6 @@ def _sorted_by_basename(inlist):
1636
1643
return sorted (inlist , key = lambda x : str (basename (x )))
1637
1644
1638
1645
1639
- def _collate (files ):
1640
- return [files [i : i + 2 ] for i in range (0 , len (files ), 2 )]
1641
-
1642
-
1643
1646
def _extract_fs_fields (filenames : str | list [str ]) -> tuple [str , str ]:
1644
1647
from pathlib import Path
1645
1648
0 commit comments