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
@@ -1024,6 +1028,7 @@ def init_gifti_morphometrics_wf(
1024
1028
return workflow
1025
1029
1026
1030
1031
+ @tag ('anat.hcp-morphs' )
1027
1032
def init_hcp_morphometrics_wf (
1028
1033
* ,
1029
1034
omp_nthreads : int ,
@@ -1167,6 +1172,7 @@ def init_hcp_morphometrics_wf(
1167
1172
return workflow
1168
1173
1169
1174
1175
+ @tag ('anat.segs-to-anat' )
1170
1176
def init_segs_to_native_wf (
1171
1177
* ,
1172
1178
image_type : ty .Literal ['T1w' , 'T2w' ] = 'T1w' ,
@@ -1247,6 +1253,7 @@ def init_segs_to_native_wf(
1247
1253
return workflow
1248
1254
1249
1255
1256
+ @tag ('anat.ribbon-mask' )
1250
1257
def init_anat_ribbon_wf (name = 'anat_ribbon_wf' ):
1251
1258
"""Create anatomical ribbon mask
1252
1259
@@ -1296,23 +1303,19 @@ def init_anat_ribbon_wf(name='anat_ribbon_wf'):
1296
1303
1297
1304
make_ribbon = pe .Node (MakeRibbon (), name = 'make_ribbon' , mem_gb = DEFAULT_MEMORY_MIN_GB )
1298
1305
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
1306
+ workflow .connect ([
1307
+ (inputnode , create_wm_distvol , [
1308
+ ('white' , 'surf_file' ),
1309
+ ('ref_file' , 'ref_file' ),
1310
+ ]),
1311
+ (inputnode , create_pial_distvol , [
1312
+ ('pial' , 'surf_file' ),
1313
+ ('ref_file' , 'ref_file' ),
1314
+ ]),
1315
+ (create_wm_distvol , make_ribbon , [('out_file' , 'white_distvols' )]),
1316
+ (create_pial_distvol , make_ribbon , [('out_file' , 'pial_distvols' )]),
1317
+ (make_ribbon , outputnode , [('ribbon' , 'anat_ribbon' )]),
1318
+ ]) # fmt:skip
1316
1319
return workflow
1317
1320
1318
1321
@@ -1423,6 +1426,7 @@ def init_resample_surfaces_wf(
1423
1426
return workflow
1424
1427
1425
1428
1429
+ @tag ('anat.resample-morphs-grayords' )
1426
1430
def init_morph_grayords_wf (
1427
1431
grayord_density : ty .Literal ['91k' , '170k' ],
1428
1432
omp_nthreads : int ,
@@ -1636,10 +1640,6 @@ def _sorted_by_basename(inlist):
1636
1640
return sorted (inlist , key = lambda x : str (basename (x )))
1637
1641
1638
1642
1639
- def _collate (files ):
1640
- return [files [i : i + 2 ] for i in range (0 , len (files ), 2 )]
1641
-
1642
-
1643
1643
def _extract_fs_fields (filenames : str | list [str ]) -> tuple [str , str ]:
1644
1644
from pathlib import Path
1645
1645
0 commit comments