Skip to content

Commit 329c1d4

Browse files
committed
address review comments
1 parent b675937 commit 329c1d4

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

dmriprep/workflows/base.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,10 @@ def init_single_subject_wf(subject_id):
321321
("outputnode.t1w2fsnative_xfm", "inputnode.t1w2fsnative_xfm"),
322322
("outputnode.fsnative2t1w_xfm", "inputnode.fsnative2t1w_xfm")]),
323323
(bids_info, dwi_preproc_wf, [("subject", "inputnode.subject_id")]),
324-
(fmap_wf, dwi_preproc_wf,
325-
[("outputnode.fmap", "inputnode.fmap"),
326-
("outputnode.fmap_ref", "inputnode.fmap"),
327-
("outputnode.fmap_coeff", "inputnode.fmap"),
328-
("outputnode.fmap_mask", "inputnode.fmap")])
324+
])
329325
# fmt: on
330326

331327
if "fieldmap" in config.workflow.ignore:
332-
sdc = False
333328
return workflow
334329

335330
from sdcflows import fieldmaps as fm

dmriprep/workflows/dwi/base.py

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
88
from ...interfaces import DerivativesDataSink
9-
from sdcflows.workflows.apply.registration import init_coeff2epi_wf
109

11-
def init_dwi_preproc_wf(dwi_file):
10+
11+
def init_dwi_preproc_wf(dwi_file, has_fieldmap=False):
1212
"""
1313
Build a preprocessing workflow for one DWI run.
1414
@@ -30,7 +30,8 @@ def init_dwi_preproc_wf(dwi_file):
3030
----------
3131
dwi_file : :obj:`os.PathLike`
3232
One diffusion MRI dataset to be processed.
33-
sdc : :bool:
33+
has_fieldmap : :obj:`bool`
34+
Build the workflow with a path to register a fieldmap to the DWI.
3435
3536
Inputs
3637
------
@@ -82,6 +83,11 @@ def init_dwi_preproc_wf(dwi_file):
8283
"dwi_file",
8384
"in_bvec",
8485
"in_bval",
86+
# From fmap
87+
"fmap",
88+
"fmap_ref",
89+
"fmap_coeff",
90+
"fmap_mask",
8591
# From anatomical
8692
"t1w_preproc",
8793
"t1w_mask",
@@ -115,26 +121,21 @@ def init_dwi_preproc_wf(dwi_file):
115121
mem_gb=config.DEFAULT_MEMORY_MIN_GB, omp_nthreads=config.nipype.omp_nthreads
116122
)
117123

118-
coeff2epi_wf = init_coeff2epi_wf(omp_nthreads=config.nipype.omp_nthreads, write_coeff=True)
119-
120124
# MAIN WORKFLOW STRUCTURE
121-
# fmt:off
125+
# fmt: off
122126
workflow.connect([
123127
(inputnode, gradient_table, [("dwi_file", "dwi_file"),
124128
("in_bvec", "in_bvec"),
125129
("in_bval", "in_bval")]),
126130
(inputnode, dwi_reference_wf, [("dwi_file", "inputnode.dwi_file")]),
127131
(gradient_table, dwi_reference_wf, [("b0_ixs", "inputnode.b0_ixs")]),
128-
(dwi_reference_wf, coeff2epi_wf, [
129-
("outputnode.ref_image", "target_ref"),
130-
("outputnode.dwi_mask", "target_mask"),
131132
#outputnode, [
132133
# ("outputnode.ref_image", "dwi_reference"),
133134
# ("outputnode.dwi_mask", "dwi_mask"),
134-
]),
135+
#]),
135136
(gradient_table, outputnode, [("out_rasb", "gradients_rasb")]),
136137
])
137-
# fmt:on
138+
# fmt: on
138139

139140
if config.workflow.run_reconall:
140141
from niworkflows.interfaces.nibabel import ApplyMask
@@ -162,7 +163,7 @@ def init_dwi_preproc_wf(dwi_file):
162163
def _bold_reg_suffix(fallback):
163164
return "coreg" if fallback else "bbregister"
164165

165-
# fmt:off
166+
# fmt: off
166167
workflow.connect([
167168
(inputnode, bbr_wf, [
168169
("fsnative2t1w_xfm", "inputnode.fsnative2t1w_xfm"),
@@ -181,11 +182,30 @@ def _bold_reg_suffix(fallback):
181182
('outputnode.out_report', 'in_file'),
182183
(('outputnode.fallback', _bold_reg_suffix), 'desc')]),
183184
])
184-
# fmt:on
185+
# fmt: on
186+
187+
if has_fieldmap:
188+
from sdcflows.workflows.apply.registration import init_coeff2epi_wf
189+
from sdcflows.workflows.apply.correction import init_unwarp_wf
190+
191+
coeff2epi_wf = init_coeff2epi_wf(
192+
omp_nthreads=config.nipype.omp_nthreads, write_coeff=True
193+
)
194+
unwarp_wf = init_unwarp_wf(omp_nthreads=config.nipype.omp_nthreads)
195+
196+
# fmt: off
197+
workflow.connect([
198+
(dwi_reference_wf, coeff2epi_wf, [
199+
("outputnode.ref_image", "inputnode.target_ref"),
200+
("outputnode.dwi_mask", "inputnode.target_mask")]),
201+
(coeff2epi_wf, unwarp_wf, [
202+
("outputnode.fmap_coeff", "inputnode.fmap_coeff")])
203+
])
204+
# fmt: on
185205

186206
# REPORTING ############################################################
187207
reportlets_wf = init_reportlets_wf(str(config.execution.output_dir))
188-
# fmt:off
208+
# fmt: off
189209
workflow.connect([
190210
(inputnode, reportlets_wf, [("dwi_file", "inputnode.source_file")]),
191211
(dwi_reference_wf, reportlets_wf, [
@@ -194,7 +214,7 @@ def _bold_reg_suffix(fallback):
194214
("outputnode.validation_report", "inputnode.validation_report"),
195215
]),
196216
])
197-
# fmt:on
217+
# fmt: on
198218

199219
return workflow
200220

0 commit comments

Comments
 (0)