Skip to content

Commit 7e80006

Browse files
committed
ENH: Conform precomputed mask/aseg if available (only for single runs)
1 parent f5ab000 commit 7e80006

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

nibabies/workflows/anatomical/template.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ def init_anat_template_wf(
1212
longitudinal: bool = False,
1313
bspline_fitting_distance: int = 200,
1414
sloppy: bool = False,
15+
precomputed_mask: bool = False,
16+
precomputed_aseg: bool = False,
1517
name: str = "anat_template_wf",
1618
) -> LiterateWorkflow:
1719
"""
@@ -78,9 +80,20 @@ def init_anat_template_wf(
7880
`mri_robust_template` [FreeSurfer {fs_ver}, @fs_template].
7981
"""
8082

81-
inputnode = pe.Node(niu.IdentityInterface(fields=["anat_files"]), name="inputnode")
83+
inputnode = pe.Node(
84+
niu.IdentityInterface(fields=["anat_files", "anat_mask", "anat_aseg"]), name="inputnode"
85+
)
8286
outputnode = pe.Node(
83-
niu.IdentityInterface(fields=["out_file", "valid_list", "realign_xfms", "out_report"]),
87+
niu.IdentityInterface(
88+
fields=[
89+
"out_file",
90+
"valid_list",
91+
"realign_xfms",
92+
"out_report",
93+
"anat_mask",
94+
"anat_aseg",
95+
],
96+
),
8497
name="outputnode",
8598
)
8699

@@ -101,6 +114,28 @@ def init_anat_template_wf(
101114
# fmt:on
102115

103116
if num_files == 1:
117+
if precomputed_mask:
118+
anat_mask_conform = pe.Node(Conform(), name='anat_mask_conform')
119+
# fmt:off
120+
wf.connect([
121+
(inputnode, anat_mask_conform, [('aseg', 'in_file')]),
122+
(anat_ref_dimensions, anat_mask_conform, [
123+
('target_zooms', 'target_zooms'),
124+
('target_shape', 'target_shape')]),
125+
(anat_mask_conform, outputnode, [('out_file', 'anat_mask')]),
126+
])
127+
# fmt:on
128+
if precomputed_aseg:
129+
anat_aseg_conform = pe.Node(Conform(), name='anat_aseg_conform')
130+
# fmt:off
131+
wf.connect([
132+
(inputnode, anat_aseg_conform, [('aseg', 'in_file')]),
133+
(anat_ref_dimensions, anat_aseg_conform, [
134+
('target_zooms', 'target_zooms'),
135+
('target_shape', 'target_shape')]),
136+
(anat_aseg_conform, outputnode, [('out_file', 'anat_aseg')])
137+
])
138+
# fmt:on
104139
get1st = pe.Node(niu.Select(index=[0]), name="get1st")
105140
outputnode.inputs.anat_realign_xfm = [
106141
get_file("smriprep", "data/itkIdentityTransform.txt")

0 commit comments

Comments
 (0)