Skip to content

Commit 133c0b7

Browse files
committed
FIX+DOC: Missing connections, outputs, clean up imports
1 parent ffcacc4 commit 133c0b7

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

nibabies/workflows/anatomical/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def init_infant_anat_wf(
419419

420420
surface_recon_wf = init_mcribs_surface_recon_wf(
421421
use_aseg=bool(precomp_aseg),
422-
mcribs_dir=config.execution.mcribs_dir, # Needed to preserve runs
422+
mcribs_dir=str(config.execution.mcribs_dir), # Needed to preserve runs
423423
)
424424

425425
# fmt:off

nibabies/workflows/anatomical/surfaces.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
from niworkflows.engine.workflows import LiterateWorkflow
77
from niworkflows.interfaces.freesurfer import PatchedLTAConvert as LTAConvert
88
from niworkflows.interfaces.freesurfer import PatchedRobustRegister as RobustRegister
9+
from niworkflows.utils.connections import pop_file
910
from smriprep.workflows.surfaces import init_gifti_surface_wf
1011

12+
from ...config import DEFAULT_MEMORY_MIN_GB
13+
1114
SURFACE_INPUTS = [
1215
"subjects_dir",
1316
"subject_id",
@@ -30,7 +33,9 @@
3033
]
3134

3235

33-
def init_mcribs_surface_recon_wf(*, use_aseg, mcribs_dir=None, name="mcribs_surface_recon_wf"):
36+
def init_mcribs_surface_recon_wf(
37+
*, use_aseg: bool, mcribs_dir: str = None, name: str = "mcribs_surface_recon_wf"
38+
):
3439
"""
3540
Reconstruct cortical surfaces using the M-CRIB-S pipeline.
3641
@@ -41,6 +46,11 @@ def init_mcribs_surface_recon_wf(*, use_aseg, mcribs_dir=None, name="mcribs_surf
4146

4247
from ...interfaces.mcribs import MCRIBReconAll
4348

49+
if not use_aseg:
50+
raise NotImplementedError(
51+
"A previously computed segmentation is required for the M-CRIB-S workflow."
52+
)
53+
4454
inputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_INPUTS), name='inputnode')
4555
outputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_OUTPUTS), name='outputnode')
4656

@@ -100,6 +110,7 @@ def init_mcribs_surface_recon_wf(*, use_aseg, mcribs_dir=None, name="mcribs_surf
100110

101111
fssource = pe.Node(nio.FreeSurferSource(), name='fssource', run_without_submitting=True)
102112
norm2nii = pe.Node(fs.MRIConvert(out_type="niigz"), name="norm2nii")
113+
aparc2nii = pe.Node(fs.MRIConvert(out_type="niigz"), name="aparc2nii")
103114

104115
fsnative2t1w_xfm = pe.Node(
105116
RobustRegister(auto_sens=True, est_int_scale=True),
@@ -115,42 +126,40 @@ def init_mcribs_surface_recon_wf(*, use_aseg, mcribs_dir=None, name="mcribs_surf
115126
# fmt:off
116127
wf.connect([
117128
(inputnode, t2w_las, [("t2w", "in_file")]),
118-
(inputnode, map_labels, [("ants_segs", "in_file")])
129+
(inputnode, map_labels, [("ants_segs", "in_file")]),
130+
(inputnode, outputnode, [("ants_segs", "out_aseg")]), # Input segs are final
119131
(map_labels, seg_las, [("out_file", "in_file")]),
120132
(inputnode, mcribs_recon, [
121133
("subjects_dir", "subjects_dir"),
122134
("subject_id", "subject_id")]),
123135
(t2w_las, mcribs_recon, [("out_file", "t2w_file")]),
124136
(seg_las, mcribs_recon, [("out_file", "segmentation_file")]),
125-
(map_labels, outputnode, [("out_file", "out_aseg")]),
137+
(inputnode, fssource, [("subject_id", "subject_id")]),
138+
(mcribs_recon, fssource, [("subjects_dir", "subjects_dir")]),
139+
(mcribs_recon, outputnode, [("subjects_dir", "subjects_dir")]),
140+
(inputnode, outputnode, [("subject_id", "subject_id")]),
126141

127-
# copied from infantFS workflow
128142
(inputnode, fsnative2t1w_xfm, [('skullstripped_t1', 'target_file')]),
129143
(fssource, norm2nii, [('norm', 'in_file')]),
144+
(fssource, aparc2nii, [(('aparc_aseg', pop_file), 'in_file')]),
145+
(aparc2nii, outputnode, [('out_file', 'out_aparc')]),
130146
(norm2nii, fsnative2t1w_xfm, [('out_file', 'source_file')]),
131147
(fsnative2t1w_xfm, t1w2fsnative_xfm, [('out_reg_file', 'in_lta')]),
132148
(inputnode, gifti_surface_wf, [
133-
("subjects_dir", "subjects_dir"),
134-
("subject_id", "subject_id")]),
149+
("subjects_dir", "inputnode.subjects_dir"),
150+
("subject_id", "inputnode.subject_id")]),
135151
(fsnative2t1w_xfm, gifti_surface_wf, [
136152
('out_reg_file', 'inputnode.fsnative2t1w_xfm')]),
153+
(fsnative2t1w_xfm, outputnode, [('out_reg_file', 'fsnative2t1w_xfm')]),
154+
(t1w2fsnative_xfm, outputnode, [('out_lta', 't1w2fsnative_xfm')]),
137155
(gifti_surface_wf, outputnode, [
138156
('outputnode.surfaces', 'surfaces'),
139-
('outputnode.morphometrics', 'morphometrics'),
140-
]),
157+
('outputnode.morphometrics', 'morphometrics')]),
141158
])
142159
# fmt:on
143160
return wf
144161

145162

146-
from nipype.interfaces import fsl
147-
from nipype.interfaces import utility as niu
148-
from nipype.pipeline import engine as pe
149-
150-
from ...config import DEFAULT_MEMORY_MIN_GB
151-
from ...interfaces.workbench import CreateSignedDistanceVolume
152-
153-
154163
def init_infantfs_surface_recon_wf(
155164
*, age_months, use_aseg=False, name="infantfs_surface_recon_wf"
156165
):
@@ -251,6 +260,10 @@ def init_infantfs_surface_recon_wf(
251260

252261

253262
def init_anat_ribbon_wf(name="anat_ribbon_wf"):
263+
from nipype.interfaces import fsl
264+
265+
from nibabies.interfaces.workbench import CreateSignedDistanceVolume
266+
254267
# 0, 1 = wm; 2, 3 = pial; 6, 7 = mid
255268
# note that order of lh / rh within each surf type is not guaranteed due to use
256269
# of unsorted glob by FreeSurferSource prior, but we can do a sort

0 commit comments

Comments
 (0)