Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmje committed Dec 10, 2020
1 parent b675937 commit 329c1d4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
7 changes: 1 addition & 6 deletions dmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,10 @@ def init_single_subject_wf(subject_id):
("outputnode.t1w2fsnative_xfm", "inputnode.t1w2fsnative_xfm"),
("outputnode.fsnative2t1w_xfm", "inputnode.fsnative2t1w_xfm")]),
(bids_info, dwi_preproc_wf, [("subject", "inputnode.subject_id")]),
(fmap_wf, dwi_preproc_wf,
[("outputnode.fmap", "inputnode.fmap"),
("outputnode.fmap_ref", "inputnode.fmap"),
("outputnode.fmap_coeff", "inputnode.fmap"),
("outputnode.fmap_mask", "inputnode.fmap")])
])
# fmt: on

if "fieldmap" in config.workflow.ignore:
sdc = False
return workflow

from sdcflows import fieldmaps as fm
Expand Down
50 changes: 35 additions & 15 deletions dmriprep/workflows/dwi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from niworkflows.engine.workflows import LiterateWorkflow as Workflow
from ...interfaces import DerivativesDataSink
from sdcflows.workflows.apply.registration import init_coeff2epi_wf

def init_dwi_preproc_wf(dwi_file):

def init_dwi_preproc_wf(dwi_file, has_fieldmap=False):
"""
Build a preprocessing workflow for one DWI run.
Expand All @@ -30,7 +30,8 @@ def init_dwi_preproc_wf(dwi_file):
----------
dwi_file : :obj:`os.PathLike`
One diffusion MRI dataset to be processed.
sdc : :bool:
has_fieldmap : :obj:`bool`
Build the workflow with a path to register a fieldmap to the DWI.
Inputs
------
Expand Down Expand Up @@ -82,6 +83,11 @@ def init_dwi_preproc_wf(dwi_file):
"dwi_file",
"in_bvec",
"in_bval",
# From fmap
"fmap",
"fmap_ref",
"fmap_coeff",
"fmap_mask",
# From anatomical
"t1w_preproc",
"t1w_mask",
Expand Down Expand Up @@ -115,26 +121,21 @@ def init_dwi_preproc_wf(dwi_file):
mem_gb=config.DEFAULT_MEMORY_MIN_GB, omp_nthreads=config.nipype.omp_nthreads
)

coeff2epi_wf = init_coeff2epi_wf(omp_nthreads=config.nipype.omp_nthreads, write_coeff=True)

# MAIN WORKFLOW STRUCTURE
# fmt:off
# fmt: off
workflow.connect([
(inputnode, gradient_table, [("dwi_file", "dwi_file"),
("in_bvec", "in_bvec"),
("in_bval", "in_bval")]),
(inputnode, dwi_reference_wf, [("dwi_file", "inputnode.dwi_file")]),
(gradient_table, dwi_reference_wf, [("b0_ixs", "inputnode.b0_ixs")]),
(dwi_reference_wf, coeff2epi_wf, [
("outputnode.ref_image", "target_ref"),
("outputnode.dwi_mask", "target_mask"),
#outputnode, [
# ("outputnode.ref_image", "dwi_reference"),
# ("outputnode.dwi_mask", "dwi_mask"),
]),
#]),
(gradient_table, outputnode, [("out_rasb", "gradients_rasb")]),
])
# fmt:on
# fmt: on

if config.workflow.run_reconall:
from niworkflows.interfaces.nibabel import ApplyMask
Expand Down Expand Up @@ -162,7 +163,7 @@ def init_dwi_preproc_wf(dwi_file):
def _bold_reg_suffix(fallback):
return "coreg" if fallback else "bbregister"

# fmt:off
# fmt: off
workflow.connect([
(inputnode, bbr_wf, [
("fsnative2t1w_xfm", "inputnode.fsnative2t1w_xfm"),
Expand All @@ -181,11 +182,30 @@ def _bold_reg_suffix(fallback):
('outputnode.out_report', 'in_file'),
(('outputnode.fallback', _bold_reg_suffix), 'desc')]),
])
# fmt:on
# fmt: on

if has_fieldmap:
from sdcflows.workflows.apply.registration import init_coeff2epi_wf
from sdcflows.workflows.apply.correction import init_unwarp_wf

coeff2epi_wf = init_coeff2epi_wf(
omp_nthreads=config.nipype.omp_nthreads, write_coeff=True
)
unwarp_wf = init_unwarp_wf(omp_nthreads=config.nipype.omp_nthreads)

# fmt: off
workflow.connect([
(dwi_reference_wf, coeff2epi_wf, [
("outputnode.ref_image", "inputnode.target_ref"),
("outputnode.dwi_mask", "inputnode.target_mask")]),
(coeff2epi_wf, unwarp_wf, [
("outputnode.fmap_coeff", "inputnode.fmap_coeff")])
])
# fmt: on

# REPORTING ############################################################
reportlets_wf = init_reportlets_wf(str(config.execution.output_dir))
# fmt:off
# fmt: off
workflow.connect([
(inputnode, reportlets_wf, [("dwi_file", "inputnode.source_file")]),
(dwi_reference_wf, reportlets_wf, [
Expand All @@ -194,7 +214,7 @@ def _bold_reg_suffix(fallback):
("outputnode.validation_report", "inputnode.validation_report"),
]),
])
# fmt:on
# fmt: on

return workflow

Expand Down

0 comments on commit 329c1d4

Please sign in to comment.