Skip to content

Commit 04f3f30

Browse files
authored
Merge pull request #463 from nipreps/enh/tag-anat
ENH: Tag anatomical workflows
2 parents 1bf2c43 + f39aec8 commit 04f3f30

File tree

11 files changed

+109
-105
lines changed

11 files changed

+109
-105
lines changed

nibabies/workflows/anatomical/apply.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import nipype.interfaces.utility as niu
44
import nipype.pipeline.engine as pe
5+
from niworkflows.engine import tag
56
from smriprep.workflows.outputs import (
67
init_ds_anat_volumes_wf,
78
init_ds_grayord_metrics_wf,
@@ -25,6 +26,7 @@
2526
LOGGER = config.loggers.workflow
2627

2728

29+
@tag('anat.apply')
2830
def init_infant_anat_apply_wf(
2931
*,
3032
bids_root: str,

nibabies/workflows/anatomical/brain_extraction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
from nipype.interfaces import utility as niu
66
from nipype.pipeline import engine as pe
7+
from niworkflows.engine import tag
78

89

10+
@tag('anat.brain-extraction')
911
def init_infant_brain_extraction_wf(
1012
*,
1113
omp_nthreads: int,

nibabies/workflows/anatomical/fit.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from nipype.interfaces import utility as niu
66
from nipype.pipeline import engine as pe
77
from niworkflows.anat.ants import init_n4_only_wf
8-
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
8+
from niworkflows.engine import Workflow, tag
99
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
1010
from niworkflows.interfaces.header import ValidateImage
1111
from niworkflows.interfaces.nibabel import ApplyMask, Binarize
@@ -53,6 +53,7 @@
5353
LOGGER = logging.getLogger('nipype.workflow')
5454

5555

56+
@tag('anat.fit')
5657
def init_infant_anat_fit_wf(
5758
*,
5859
age_months: int,
@@ -1374,6 +1375,7 @@ def init_infant_anat_fit_wf(
13741375
return workflow
13751376

13761377

1378+
@tag('anat.fit')
13771379
def init_infant_single_anat_fit_wf(
13781380
*,
13791381
age_months: int,

nibabies/workflows/anatomical/outputs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from nipype.interfaces import utility as niu
1111
from nipype.pipeline import engine as pe
12-
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
12+
from niworkflows.engine import Workflow, tag
1313
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
1414
from smriprep.workflows.outputs import init_template_iterator_wf
1515

@@ -21,6 +21,7 @@
2121
BIDS_TISSUE_ORDER = ('GM', 'WM', 'CSF')
2222

2323

24+
@tag('anat.coreg-report')
2425
def init_coreg_report_wf(*, output_dir, name='coreg_report_wf'):
2526
"""
2627
Generate and store a report in the right location.
@@ -85,6 +86,7 @@ def init_coreg_report_wf(*, output_dir, name='coreg_report_wf'):
8586
return workflow
8687

8788

89+
@tag('anat.reports')
8890
def init_anat_reports_wf(
8991
*,
9092
spaces: SpatialReferences,
@@ -283,6 +285,7 @@ def init_anat_reports_wf(
283285
return workflow
284286

285287

288+
@tag('anat.derivatives')
286289
def init_anat_derivatives_wf(
287290
*,
288291
bids_root: Path | str,

nibabies/workflows/anatomical/preproc.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import nipype.interfaces.utility as niu
22
import nipype.pipeline.engine as pe
3-
from niworkflows.engine.workflows import LiterateWorkflow
3+
from niworkflows.engine import Workflow, tag
44

55

6+
@tag('anat.preproc')
67
def init_anat_preproc_wf(
78
*,
89
bspline_fitting_distance: int = 200,
910
name: str = 'anat_preproc_wf',
10-
) -> LiterateWorkflow:
11+
) -> Workflow:
1112
"""Polish up raw anatomical data.
1213
1314
This workflow accepts T1w/T2w images as inputs (either raw or a merged template) and performs:
@@ -30,7 +31,7 @@ def init_anat_preproc_wf(
3031
from niworkflows.interfaces.header import ValidateImage
3132
from niworkflows.interfaces.nibabel import IntensityClip
3233

33-
wf = LiterateWorkflow(name=name)
34+
wf = Workflow(name=name)
3435
inputnode = pe.Node(
3536
niu.IdentityInterface(fields=['in_anat']),
3637
name='inputnode',
@@ -68,10 +69,11 @@ def init_anat_preproc_wf(
6869
return wf
6970

7071

71-
def init_csf_norm_wf(name: str = 'csf_norm_wf') -> LiterateWorkflow:
72+
@tag('anat.csf_norm')
73+
def init_csf_norm_wf(name: str = 'csf_norm_wf') -> Workflow:
7274
"""Replace low intensity voxels within the CSF mask with the median value."""
7375

74-
workflow = LiterateWorkflow(name=name)
76+
workflow = Workflow(name=name)
7577
workflow.__desc__ = (
7678
'The CSF mask was used to normalize the anatomical template by the median of voxels '
7779
'within the mask.'

nibabies/workflows/anatomical/registration.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
)
1212
from nipype.interfaces.ants.base import Info as ANTsInfo
1313
from nipype.pipeline import engine as pe
14-
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
14+
from niworkflows.engine import Workflow, tag
1515
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
1616
from smriprep.workflows.fit.registration import (
1717
TemplateDesc,
@@ -21,6 +21,7 @@
2121
)
2222

2323

24+
@tag('anat.coreg')
2425
def init_coregistration_wf(
2526
*,
2627
bspline_fitting_distance: int = 200,
@@ -249,6 +250,7 @@ def init_coregistration_wf(
249250
return workflow
250251

251252

253+
@tag('anat.coreg-derivatives')
252254
def init_coregister_derivatives_wf(
253255
*, t1w_mask: bool, t1w_aseg: bool, t2w_aseg: bool, name: str = 'coregister_derivatives_wf'
254256
):
@@ -301,6 +303,7 @@ def init_coregister_derivatives_wf(
301303
return workflow
302304

303305

306+
@tag('anat.concat-reg')
304307
def init_concat_registrations_wf(
305308
*,
306309
templates,

nibabies/workflows/anatomical/resampling.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import nipype.interfaces.utility as niu
44
import nipype.pipeline.engine as pe
55
import templateflow.api as tf
6-
from niworkflows.engine.workflows import LiterateWorkflow
6+
from niworkflows.engine import Workflow, tag
77
from smriprep.interfaces.workbench import SurfaceResample
88
from smriprep.workflows.surfaces import init_morph_grayords_wf
99

@@ -12,11 +12,12 @@
1212
from nibabies.interfaces.utils import CiftiSelect
1313

1414

15+
@tag('anat.resample-surfs')
1516
def init_anat_fsLR_resampling_wf(
1617
grayord_density: ty.Literal['91k'], mcribs: bool, name='anat_fsLR_resampling_wf'
17-
) -> LiterateWorkflow:
18+
) -> Workflow:
1819
"""Resample the surfaces into fsLR space"""
19-
workflow = LiterateWorkflow(name=name)
20+
workflow = Workflow(name=name)
2021
fslr_density = '32k' if grayord_density == '91k' else '59k'
2122

2223
workflow.__desc__ = """\
@@ -93,20 +94,18 @@ def init_anat_fsLR_resampling_wf(
9394
# resample surfaces / morphometrics to 32k
9495
if mcribs:
9596
morph_grayords_wf = init_mcribs_morph_grayords_wf(grayord_density)
96-
# fmt:off
97+
9798
workflow.connect([
9899
(inputnode, morph_grayords_wf, [
99100
('morphometrics', 'inputnode.morphometrics'),
100101
('surfaces', 'inputnode.surfaces'),
101102
('sphere_reg_fsLR', 'inputnode.sphere_reg')]),
102103
(joinnode, morph_grayords_wf, [
103104
('midthickness_fsLR', 'inputnode.midthickness_fsLR')]),
104-
])
105-
# fmt:on
105+
]) # fmt:skip
106106
else:
107107
morph_grayords_wf = init_morph_grayords_wf(grayord_density)
108108

109-
# fmt:off
110109
workflow.connect([
111110
(inputnode, select_surfaces, [
112111
('surfaces', 'surfaces'),
@@ -126,11 +125,11 @@ def init_anat_fsLR_resampling_wf(
126125
(morph_grayords_wf, outputnode, [
127126
('outputnode.cifti_morph', 'cifti_morph'),
128127
('outputnode.cifti_metadata', 'cifti_metadata')]),
129-
])
130-
# fmt:on
128+
]) # fmt:skip
131129
return workflow
132130

133131

132+
@tag('anat.resample-morphs-grayords')
134133
def init_mcribs_morph_grayords_wf(
135134
grayord_density: ty.Literal['91k'], # Only 91k supported ATM
136135
name: str = 'morph_grayords_wf',
@@ -174,7 +173,6 @@ def init_mcribs_morph_grayords_wf(
174173
175174
"""
176175
from nipype.interfaces.workbench import MetricResample
177-
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
178176
from smriprep.interfaces.cifti import GenerateDScalar
179177

180178
from nibabies.interfaces.workbench import SurfaceVertexAreas

nibabies/workflows/anatomical/segmentation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from nipype.interfaces.ants.segmentation import JointFusion
88
from nipype.pipeline import engine as pe
99
from niworkflows.data import load as load_nwf
10-
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
10+
from niworkflows.engine import Workflow, tag
1111
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
1212
from niworkflows.interfaces.fixes import FixHeaderRegistration as Registration
1313
from niworkflows.utils.connections import listify
@@ -23,6 +23,7 @@
2323
LOGGER = config.loggers.workflow
2424

2525

26+
@tag('anat.segmentation')
2627
def init_segmentation_wf(
2728
*,
2829
sloppy: bool,
@@ -129,6 +130,7 @@ def init_segmentation_wf(
129130
return workflow
130131

131132

133+
@tag('anat.segmentation.jlf')
132134
def init_jlf_wf(
133135
jlf_template_dir: Path,
134136
sloppy: bool,

nibabies/workflows/anatomical/surfaces.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from nipype.interfaces import utility as niu
99
from nipype.interfaces.ants import N4BiasFieldCorrection
1010
from nipype.pipeline import engine as pe
11-
from niworkflows.engine.workflows import LiterateWorkflow
11+
from niworkflows.engine import Workflow, tag
1212
from niworkflows.interfaces.freesurfer import (
1313
PatchedLTAConvert as LTAConvert,
1414
)
@@ -41,6 +41,7 @@
4141
]
4242

4343

44+
@tag('anat.recon')
4445
def init_mcribs_surface_recon_wf(
4546
*,
4647
omp_nthreads: int,
@@ -67,7 +68,7 @@ def init_mcribs_surface_recon_wf(
6768
inputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_INPUTS), name='inputnode')
6869
outputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_OUTPUTS), name='outputnode')
6970

70-
workflow = LiterateWorkflow(name=name)
71+
workflow = Workflow(name=name)
7172
workflow.__desc__ = (
7273
'Brain surfaces were reconstructed with a modified `MCRIBReconAll` [M-CRIB-S, @mcribs]'
7374
'workflow, using the reference T2w and a pre-computed anatomical segmentation'
@@ -224,6 +225,7 @@ def init_mcribs_surface_recon_wf(
224225
return workflow
225226

226227

228+
@tag('anat.fslr-reg')
227229
def init_mcribs_dhcp_wf(*, name='mcribs_dhcp_wf'):
228230
"""
229231
Generate GIFTI registration files to dhcp (42-week) space.
@@ -233,7 +235,7 @@ def init_mcribs_dhcp_wf(*, name='mcribs_dhcp_wf'):
233235
"""
234236
from smriprep.interfaces.workbench import SurfaceSphereProjectUnproject
235237

236-
workflow = LiterateWorkflow(name=name)
238+
workflow = Workflow(name=name)
237239

238240
inputnode = pe.Node(
239241
niu.IdentityInterface(['sphere_reg', 'sulc']),
@@ -294,6 +296,7 @@ def init_mcribs_dhcp_wf(*, name='mcribs_dhcp_wf'):
294296
return workflow
295297

296298

299+
@tag('anat.recon')
297300
def init_infantfs_surface_recon_wf(
298301
*,
299302
age_months: int,
@@ -304,7 +307,7 @@ def init_infantfs_surface_recon_wf(
304307
):
305308
from nibabies.interfaces.freesurfer import InfantReconAll
306309

307-
workflow = LiterateWorkflow(name=name)
310+
workflow = Workflow(name=name)
308311
inputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_INPUTS), name='inputnode')
309312
outputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_OUTPUTS), name='outputnode')
310313

@@ -382,6 +385,7 @@ def init_infantfs_surface_recon_wf(
382385
return workflow
383386

384387

388+
@tag('anat.midthickness')
385389
def init_make_midthickness_wf(
386390
*, omp_nthreads: int, name: str = 'make_midthickness_wf'
387391
) -> pe.Workflow:
@@ -435,6 +439,7 @@ def init_make_midthickness_wf(
435439
return workflow
436440

437441

442+
@tag('anat.resample-surfs')
438443
def init_resample_surfaces_dhcp_wf(
439444
surfaces: list[str],
440445
grayord_density: ty.Literal['91k', '170k'],
@@ -470,7 +475,7 @@ def init_resample_surfaces_dhcp_wf(
470475
midthickness
471476
GIFTI surface mesh corresponding to the midthickness surface, resampled to fsLR
472477
"""
473-
workflow = LiterateWorkflow(name=name)
478+
workflow = Workflow(name=name)
474479

475480
fslr_density = '32k' if grayord_density == '91k' else '59k'
476481

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
"nireports >= 23.2.0",
2626
"nitime",
2727
"nitransforms >= 24.1.1",
28-
"niworkflows >= 1.12.2",
28+
"niworkflows >= 1.13.1",
2929
"numpy >= 1.21.0",
3030
"packaging",
3131
"pandas",

0 commit comments

Comments
 (0)