Skip to content

Commit 993f44c

Browse files
committed
FIX: Syntax & connections
1 parent ce1ab4a commit 993f44c

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

nibabies/workflows/anatomical/base.py

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ def init_infant_anat_wf(
8080
"""
8181
from nipype.interfaces.ants.base import Info as ANTsInfo
8282
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
83-
from sdcflows.workflows.ancillary import (
84-
init_brainextraction_wf as init_sdc_brain_extraction_wf,
85-
)
8683

8784
from ...utils.misc import fix_multi_source_name
8885
from .brain_extraction import (
@@ -270,31 +267,45 @@ def init_infant_anat_wf(
270267

271268
# fmt:off
272269
wf.connect([
273-
(inputnode, t1w_template_wf, [("t1w", "inputnode.in_files")]),
274-
(inputnode, t2w_template_wf, [("t2w", "inputnode.in_files")]),
270+
(inputnode, t1w_template_wf, [("t1w", "inputnode.anat_files")]),
271+
(inputnode, t2w_template_wf, [("t2w", "inputnode.anat_files")]),
275272
(inputnode, anat_reports_wf, [("t1w", "inputnode.source_file")]),
276273
(inputnode, coreg_report_wf, [("t1w", "inputnode.source_file")]),
277274
(inputnode, anat_norm_wf, [(("t1w", fix_multi_source_name), "inputnode.orig_t1w")]),
278275

279276
(t1w_template_wf, outputnode, [
280-
("outputnode.realign_xfms", "anat_ref_xfms")]),
281-
(t1w_template_wf, t1w_preproc_wf, [("outputnode.out_file", "inputnode.in_anat")]),
282-
(t2w_template_wf, t2w_preproc_wf, [("outputnode.out_file", "inputnode.in_anat")]),
277+
("outputnode.anat_realign_xfm", "anat_ref_xfms")]),
278+
(t1w_template_wf, t1w_preproc_wf, [("outputnode.anat_ref", "inputnode.in_anat")]),
283279
(t1w_template_wf, anat_derivatives_wf, [
284-
("outputnode.valid_list", "inputnode.source_files"),
285-
("outputnode.realign_xfms", "inputnode.t1w_ref_xfms")]),
280+
("outputnode.anat_valid_list", "inputnode.source_files"),
281+
("outputnode.anat_realign_xfm", "inputnode.t1w_ref_xfms")]),
282+
(t1w_template_wf, anat_reports_wf, [
283+
("outputnode.out_report", "inputnode.t1w_conform_report")]),
284+
285+
(t2w_template_wf, t2w_preproc_wf, [("outputnode.anat_ref", "inputnode.in_anat")]),
286286
(t2w_template_wf, anat_derivatives_wf, [
287-
("outputnode.valid_list", "inputnode.t2w_source_files")]),
287+
("outputnode.anat_valid_list", "inputnode.t2w_source_files")]),
288288

289289
(t1w_preproc_wf, coregistration_wf, [("outputnode.anat_preproc", "inputnode.in_t1w")]),
290290
(t1w_preproc_wf, coreg_report_wf, [("outputnode.anat_preproc", "inputnode.t1w_preproc")]),
291-
(t1w_preproc_wf, anat_norm_wf, [
292-
("outputnode.t1w_preproc", "inputnode.moving_image"),
293-
("outputnode.t1w_mask", "inputnode.moving_mask")]),
294291

295292
(coregistration_wf, coreg_report_wf, [
296293
("outputnode.t1w_mask", "inputnode.in_mask"),
297294
("outputnode.t2w_preproc", "inputnode.t2w_preproc")]),
295+
(coregistration_wf, anat_norm_wf, [
296+
("outputnode.t1w_preproc", "inputnode.moving_image"),
297+
("outputnode.t1w_mask", "inputnode.moving_mask")]),
298+
(coregistration_wf, anat_seg_wf, [("outputnode.t1w_brain", "inputnode.anat_brain")]),
299+
(coregistration_wf, anat_derivatives_wf, [
300+
("outputnode.t1w_mask", "inputnode.t1w_mask"),
301+
("outputnode.t1w_preproc", "inputnode.t1w_preproc"),
302+
("outputnode.t2w_preproc", "inputnode.t2w_preproc"),
303+
]),
304+
(coregistration_wf, outputnode, [
305+
("outputnode.t1w_preproc", "anat_preproc"),
306+
("outputnode.t1w_brain", "anat_brain"),
307+
("outputnode.t1w_mask", "anat_mask"),
308+
]),
298309

299310
(anat_seg_wf, outputnode, [
300311
("outputnode.anat_dseg", "anat_dseg"),
@@ -321,20 +332,6 @@ def init_infant_anat_wf(
321332
("outputnode.anat2std_xfm", "inputnode.anat2std_xfm"),
322333
("outputnode.std2anat_xfm", "inputnode.std2anat_xfm")]),
323334

324-
(coregistration_wf, anat_seg_wf, [("outputnode.t1w_brain", "inputnode.anat_brain")]),
325-
(coregistration_wf, anat_derivatives_wf, [
326-
("outputnode.t1w_mask", "inputnode.t1w_mask"),
327-
("outputnode.t1w_preproc", "inputnode.t1w_preproc"),
328-
("outputnode.t2w_preproc", "inputnode.t2w_preproc"),
329-
]),
330-
(coregistration_wf, outputnode, [
331-
("outputnode.t1w_preproc", "anat_preproc"),
332-
("outputnode.t1w_brain", "anat_brain"),
333-
("outputnode.t1w_mask", "anat_mask"),
334-
]),
335-
336-
(t1w_template_wf, anat_reports_wf, [
337-
("outputnode.out_report", "inputnode.t1w_conform_report")]),
338335
(outputnode, anat_reports_wf, [
339336
("anat_preproc", "inputnode.t1w_preproc"),
340337
("anat_mask", "inputnode.t1w_mask"),
@@ -347,9 +344,12 @@ def init_infant_anat_wf(
347344
if precomp_mask:
348345
# Ensure the mask is conformed along with the T1w
349346
t1w_template_wf.inputs.inputnode.anat_mask = precomp_mask
347+
# fmt:off
350348
wf.connect([
351349
(t1w_template_wf, coregistration_wf, [("outputnode.anat_mask", "inputnode.in_mask")]),
350+
(t2w_preproc_wf, coregistration_wf, [("outputnode.anat_preproc", "inputnode.in_t2w")])
352351
])
352+
# fmt:on
353353
else:
354354
# Run brain extraction on the T2w
355355
brain_extraction_wf = init_infant_brain_extraction_wf(
@@ -361,7 +361,7 @@ def init_infant_anat_wf(
361361
sloppy=sloppy,
362362
debug="registration" in config.execution.debug,
363363
)
364-
364+
# fmt:off
365365
wf.connect([
366366
(t1w_preproc_wf, brain_extraction_wf, [
367367
("outputnode.anat_preproc", "inputnode.in_t1w")]),
@@ -372,13 +372,12 @@ def init_infant_anat_wf(
372372
("outputnode.out_mask", "inputnode.in_mask"),
373373
("outputnode.out_probmap", "inputnode.in_probmap")]),
374374
])
375+
# fmt:on
375376

376377
if precomp_aseg:
377378
# Ensure the segmentation is conformed along with the T1w
378379
t1w_template_wf.inputs.inputnode.anat_aseg = precomp_aseg
379-
wf.connect([
380-
(t1w_template_wf, anat_seg_wf, [("outputnode.anat_aseg", "inputnode.anat_aseg")]),
381-
])
380+
wf.connect(t1w_template_wf, "outputnode.anat_aseg", anat_seg_wf, "inputnode.anat_aseg")
382381

383382
if not freesurfer:
384383
return wf
@@ -411,7 +410,7 @@ def init_infant_anat_wf(
411410
("outputnode.anat_aseg", "inputnode.ants_segs"),
412411
]),
413412
(t1w_template_wf, surface_recon_wf, [
414-
("outputnode.out_file", "inputnode.t1w"),
413+
("outputnode.anat_ref", "inputnode.t1w"),
415414
]),
416415
(coregistration_wf, surface_recon_wf, [
417416
("outputnode.t1w_brain", "inputnode.skullstripped_t1"),

nibabies/workflows/anatomical/preproc.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import nipype.engine.pipeline as pe
21
import nipype.interfaces.utility as niu
2+
import nipype.pipeline.engine as pe
33
from niworkflows.engine.workflows import LiterateWorkflow
44

55

6-
def init_preproc_anat_wf(
7-
*, bspline_fitting_distance: int = 200, name: str = "preproc_anat_wf"
6+
def init_anat_preproc_wf(
7+
*, bspline_fitting_distance: int = 200, name: str = "anat_preproc_wf"
88
) -> LiterateWorkflow:
99
"""Polish up raw anatomical data.
1010
1111
This workflow accepts T1w/T2w images as inputs (either raw or a merged template) and performs:
12-
- Intesity clipping
12+
- Intensity clipping
1313
- Denoising
1414
- N4 Bias Field Correction
1515
@@ -53,7 +53,6 @@ def init_preproc_anat_wf(
5353

5454
# fmt:off
5555
wf.connect([
56-
# 1. Massage T2w
5756
(inputnode, clip, [("in_anat", "in_file")]),
5857
(clip, denoise, [("out_file", "input_image")]),
5958
(denoise, n4_correct, [("output_image", "input_image")]),

nibabies/workflows/anatomical/registration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ def init_coregistration_wf(
177177
# Generate a quick, rough mask of the T2w to be used to facilitate co-registration.
178178
from sdcflows.interfaces.brainmask import BrainExtraction
179179

180-
masker = pe.Node(BrainExtraction(), name="t2w-masker")
180+
masker = pe.Node(BrainExtraction(), name="t2w_masker")
181181
# fmt:off
182182
workflow.connect([
183+
(inputnode, masker, [("in_t2w", "in_file")]),
183184
(masker, reg_mask, [("out_mask", "in_file")]),
184185
(masker, refine_mask, [("out_mask", "in_file")]),
185186
(inputnode, apply_mask, [("in_mask", "in_mask")]),

nibabies/workflows/anatomical/segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def init_anat_segmentations_wf(
5555
niu.IdentityInterface(fields=["anat_aseg", "anat_dseg", "anat_tpms"]),
5656
name="outputnode",
5757
)
58-
buffernode = niu.IdentityInterface(fields=["final_aseg"], name='buffernode')
58+
buffernode = pe.Node(niu.IdentityInterface(fields=["final_aseg"]), name='buffernode')
5959

6060
wf.__desc__ = """Brain tissue segmentation of cerebrospinal fluid (CSF),
6161
white-matter (WM) and gray-matter (GM) was performed on """

nibabies/workflows/anatomical/template.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ def init_anat_template_wf(
8686
outputnode = pe.Node(
8787
niu.IdentityInterface(
8888
fields=[
89-
"out_file",
90-
"valid_list",
91-
"realign_xfms",
89+
"anat_ref",
90+
"anat_valid_list",
91+
"anat_realign_xfm",
9292
"out_report",
93+
# only if precomputed inputs
9394
"anat_mask",
9495
"anat_aseg",
9596
],
@@ -118,7 +119,7 @@ def init_anat_template_wf(
118119
anat_mask_conform = pe.Node(Conform(), name='anat_mask_conform')
119120
# fmt:off
120121
wf.connect([
121-
(inputnode, anat_mask_conform, [('aseg', 'in_file')]),
122+
(inputnode, anat_mask_conform, [('anat_mask', 'in_file')]),
122123
(anat_ref_dimensions, anat_mask_conform, [
123124
('target_zooms', 'target_zooms'),
124125
('target_shape', 'target_shape')]),
@@ -129,7 +130,7 @@ def init_anat_template_wf(
129130
anat_aseg_conform = pe.Node(Conform(), name='anat_aseg_conform')
130131
# fmt:off
131132
wf.connect([
132-
(inputnode, anat_aseg_conform, [('aseg', 'in_file')]),
133+
(inputnode, anat_aseg_conform, [('anat_aseg', 'in_file')]),
133134
(anat_ref_dimensions, anat_aseg_conform, [
134135
('target_zooms', 'target_zooms'),
135136
('target_shape', 'target_shape')]),

0 commit comments

Comments
 (0)