Skip to content

Commit 34283f9

Browse files
committed
enh: connect workflow
1 parent f15ac0a commit 34283f9

File tree

3 files changed

+32
-39
lines changed

3 files changed

+32
-39
lines changed

dmriprep/workflows/base.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -447,29 +447,27 @@ def init_single_subject_wf(
447447
use_syn=use_syn,
448448
)
449449

450-
# workflow.connect([
451-
# (anat_preproc_wf, dwi_preproc_wf,
452-
# [(('outputnode.t1_preproc', _pop), 'inputnode.t1_preproc'),
453-
# ('outputnode.t1_brain', 'inputnode.t1_brain'),
454-
# ('outputnode.t1_mask', 'inputnode.t1_mask'),
455-
# ('outputnode.t1_seg', 'inputnode.t1_seg'),
456-
# ('outputnode.t1_aseg', 'inputnode.t1_aseg'),
457-
# ('outputnode.t1_aparc', 'inputnode.t1_aparc'),
458-
# ('outputnode.t1_tpms', 'inputnode.t1_tpms'),
459-
# ('outputnode.template', 'inputnode.template'),
460-
# ('outputnode.forward_transform', 'inputnode.anat2std_xfm'),
461-
# ('outputnode.reverse_transform', 'inputnode.std2anat_xfm'),
462-
# ('outputnode.joint_template', 'inputnode.joint_template'),
463-
# ('outputnode.joint_forward_transform', 'inputnode.joint_anat2std_xfm'),
464-
# ('outputnode.joint_reverse_transform', 'inputnode.joint_std2anat_xfm'),
465-
# # Undefined if --no-freesurfer, but this is safe
466-
# ('outputnode.subjects_dir', 'inputnode.subjects_dir'),
467-
# ('outputnode.subject_id', 'inputnode.subject_id'),
468-
# ('outputnode.t1_2_fsnative_forward_transform',
469-
# 'inputnode.t1_2_fsnative_forward_transform'),
470-
# ('outputnode.t1_2_fsnative_reverse_transform',
471-
# 'inputnode.t1_2_fsnative_reverse_transform')]),
472-
# ])
450+
workflow.connect([
451+
(anat_preproc_wf, dwi_preproc_wf,
452+
[(('outputnode.t1w_preproc', _pop), 'inputnode.t1w_preproc'),
453+
('outputnode.t1w_brain', 'inputnode.t1w_brain'),
454+
('outputnode.t1w_mask', 'inputnode.t1w_mask'),
455+
('outputnode.t1w_dseg', 'inputnode.t1w_dseg'),
456+
('outputnode.t1w_aseg', 'inputnode.t1w_aseg'),
457+
('outputnode.t1w_aparc', 'inputnode.t1w_aparc'),
458+
('outputnode.t1w_tpms', 'inputnode.t1w_tpms'),
459+
('outputnode.template', 'inputnode.template'),
460+
('outputnode.anat2std_xfm', 'inputnode.anat2std_xfm'),
461+
('outputnode.std2anat_xfm', 'inputnode.std2anat_xfm'),
462+
('outputnode.joint_template', 'inputnode.joint_template'),
463+
('outputnode.joint_anat2std_xfm', 'inputnode.joint_anat2std_xfm'),
464+
('outputnode.joint_std2anat_xfm', 'inputnode.joint_std2anat_xfm'),
465+
# Undefined if --fs-no-reconall, but this is safe
466+
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
467+
('outputnode.subject_id', 'inputnode.subject_id'),
468+
('outputnode.t1w2fsnative_xfm', 'inputnode.t1w2fsnative_xfm'),
469+
('outputnode.fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm')]),
470+
])
473471

474472
return workflow
475473

dmriprep/workflows/dwi/base.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
"""
2-
Orchestrating the dMRI-preprocessing workflow.
3-
4-
"""
1+
"""Orchestrating the dMRI-preprocessing workflow."""
52

63
from nipype import logging
74

@@ -16,9 +13,6 @@
1613
from ...interfaces.reports import DiffusionSummary
1714
from ...interfaces.vectors import CheckGradientTable
1815

19-
# dwi workflows
20-
from .util import init_dwi_reference_wf
21-
2216

2317
LOGGER = logging.getLogger('nipype.workflow')
2418

@@ -109,6 +103,7 @@ def init_dwi_preproc_wf(
109103
* :py:func:`~dmriprep.workflows.dwi.util.init_dwi_reference_wf`
110104
111105
"""
106+
from .util import init_dwi_reference_wf
112107

113108
wf_name = _get_wf_name(dwi_file)
114109

@@ -139,7 +134,12 @@ def init_dwi_preproc_wf(
139134
metadata = layout.get_metadata(dwi_file)
140135

141136
inputnode = pe.Node(niu.IdentityInterface(
142-
fields=['dwi_file', 'bvec_file', 'bval_file']),
137+
fields=['dwi_file', 'bvec_file', 'bval_file',
138+
'subjects_dir', 'subject_id',
139+
't1w_preproc', 't1w_brain', 't1w_mask', 't1w_dseg', 't1w_tpms',
140+
't1w_aseg', 't1w_aparc', 'anat2std_xfm', 'std2anat_xfm', 'template',
141+
'joint_anat2std_xfm', 'joint_std2anat_xfm', 'joint_template',
142+
't1w2fsnative_xfm', 'fsnative2t1w_xfm']),
143143
name='inputnode')
144144
inputnode.inputs.dwi_file = dwi_file
145145
inputnode.inputs.bvec_file = bvec_file
@@ -201,10 +201,12 @@ def init_dwi_preproc_wf(
201201
def _get_wf_name(dwi_fname):
202202
"""
203203
Derive the workflow name for supplied dwi file.
204+
204205
>>> _get_wf_name('/completely/made/up/path/sub-01_dwi.nii.gz')
205206
'dwi_preproc_wf'
206207
>>> _get_wf_name('/completely/made/up/path/sub-01_run-1_dwi.nii.gz')
207208
'dwi_preproc_run_1_wf'
209+
208210
"""
209211
from nipype.utils.filemanip import split_filename
210212
fname = split_filename(dwi_fname)[1]

dmriprep/workflows/dwi/util.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
DEFAULT_MEMORY_MIN_GB = 0.01
1515

1616

17-
def init_dwi_reference_wf(omp_nthreads, dwi_file=None,
18-
name='dwi_reference_wf', gen_report=False):
17+
def init_dwi_reference_wf(omp_nthreads, name='dwi_reference_wf', gen_report=False):
1918
"""
2019
Build a workflow that generates a reference b0 image from a DWI dataset.
2120
@@ -37,8 +36,6 @@ def init_dwi_reference_wf(omp_nthreads, dwi_file=None,
3736
3837
Parameters
3938
----------
40-
dwi_file : str
41-
dwi NIfTI file
4239
omp_nthreads : int
4340
Maximum number of threads an individual process may use
4441
name : str
@@ -83,10 +80,6 @@ def init_dwi_reference_wf(omp_nthreads, dwi_file=None,
8380
'dwi_mask', 'validation_report']),
8481
name='outputnode')
8582

86-
# Simplify manually setting input image
87-
if dwi_file is not None:
88-
inputnode.inputs.dwi_file = dwi_file
89-
9083
validate = pe.Node(ValidateImage(), name='validate', mem_gb=DEFAULT_MEMORY_MIN_GB)
9184

9285
extract_b0 = pe.Node(ExtractB0(), name='extract_b0')

0 commit comments

Comments
 (0)