Skip to content

Commit dd21ded

Browse files
committed
enh: add b0 and mask to output folder
1 parent da5b375 commit dd21ded

File tree

3 files changed

+76
-6
lines changed

3 files changed

+76
-6
lines changed

.circleci/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ jobs:
242242
at: /tmp
243243
- restore_cache:
244244
keys:
245-
- data-ds000206-v1-{{ .Branch }}-{{ .Revision }}-{{ epoch }}
246-
- data-ds000206-v1-{{ .Branch }}-{{ .Revision }}-
247-
- data-ds000206-v1-{{ .Branch }}-
248-
- data-ds000206-v1-master-
249-
- data-ds000206-v1-
245+
- data-ds000206-v2-{{ .Branch }}-{{ .Revision }}-{{ epoch }}
246+
- data-ds000206-v2-{{ .Branch }}-{{ .Revision }}-
247+
- data-ds000206-v2-{{ .Branch }}-
248+
- data-ds000206-v2-master-
249+
- data-ds000206-v2-
250250
- restore_cache:
251251
keys:
252252
- build-v1-{{ .Branch }}-{{ epoch }}

dmriprep/workflows/dwi/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def init_dwi_preproc_wf(dwi_file, has_fieldmap=False):
6565
See Also
6666
--------
6767
* :py:func:`~dmriprep.workflows.dwi.util.init_dwi_reference_wf`
68+
* :py:func:`~dmriprep.workflows.dwi.outputs.init_dwi_derivatives_wf`
6869
* :py:func:`~dmriprep.workflows.dwi.outputs.init_reportlets_wf`
6970
7071
"""
@@ -73,7 +74,7 @@ def init_dwi_preproc_wf(dwi_file, has_fieldmap=False):
7374
)
7475
from ...interfaces.vectors import CheckGradientTable
7576
from .util import init_dwi_reference_wf
76-
from .outputs import init_reportlets_wf
77+
from .outputs import init_dwi_derivatives_wf, init_reportlets_wf
7778
from .eddy import init_eddy_wf
7879

7980
layout = config.execution.layout
@@ -146,15 +147,22 @@ def init_dwi_preproc_wf(dwi_file, has_fieldmap=False):
146147
mem_gb=config.DEFAULT_MEMORY_MIN_GB, omp_nthreads=config.nipype.omp_nthreads
147148
)
148149

150+
dwi_derivatives_wf = init_dwi_derivatives_wf(output_dir=str(config.execution.output_dir))
151+
149152
# MAIN WORKFLOW STRUCTURE
150153
# fmt: off
151154
workflow.connect([
152155
(inputnode, gradient_table, [("dwi_file", "dwi_file"),
153156
("in_bvec", "in_bvec"),
154157
("in_bval", "in_bval")]),
155158
(inputnode, dwi_reference_wf, [("dwi_file", "inputnode.dwi_file")]),
159+
(inputnode, dwi_derivatives_wf, [("dwi_file", "inputnode.source_file")]),
156160
(gradient_table, dwi_reference_wf, [("b0_ixs", "inputnode.b0_ixs")]),
157161
(gradient_table, outputnode, [("out_rasb", "gradients_rasb")]),
162+
(outputnode, dwi_derivatives_wf, [
163+
("dwi_reference", "inputnode.dwi_ref"),
164+
("dwi_mask", "inputnode.dwi_mask"),
165+
]),
158166
])
159167
# fmt: on
160168

dmriprep/workflows/dwi/outputs.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,65 @@ def init_reportlets_wf(output_dir, sdc_report=False, name="reportlets_wf"):
6565
])
6666
# fmt:on
6767
return workflow
68+
69+
70+
def init_dwi_derivatives_wf(output_dir, name="dwi_derivatives_wf"):
71+
"""
72+
Set up a battery of datasinks to store dwi derivatives in the right location.
73+
74+
Parameters
75+
----------
76+
output_dir : :obj:`str`
77+
Directory in which to save derivatives.
78+
name : :obj:`str`
79+
Workflow name (default: ``"dwi_derivatives_wf"``).
80+
81+
Inputs
82+
------
83+
source_file
84+
One dwi file that will serve as a file naming reference.
85+
dwi_ref
86+
The b0 reference.
87+
dwi_mask
88+
The brain mask for the dwi file.
89+
90+
"""
91+
workflow = pe.Workflow(name=name)
92+
inputnode = pe.Node(
93+
niu.IdentityInterface(fields=["source_file", "dwi_ref", "dwi_mask"]),
94+
name="inputnode",
95+
)
96+
97+
ds_reference = pe.Node(
98+
DerivativesDataSink(
99+
base_directory=output_dir,
100+
compress=True,
101+
space="dwi",
102+
suffix="epiref",
103+
datatype="dwi",
104+
),
105+
name="ds_reference",
106+
)
107+
108+
ds_mask = pe.Node(
109+
DerivativesDataSink(
110+
base_directory=output_dir,
111+
compress=True,
112+
space="dwi",
113+
desc="brain",
114+
suffix="mask",
115+
datatype="dwi",
116+
),
117+
name="ds_mask",
118+
)
119+
120+
# fmt:off
121+
workflow.connect([
122+
(inputnode, ds_reference, [("source_file", "source_file"),
123+
("dwi_ref", "in_file")]),
124+
(inputnode, ds_mask, [("source_file", "source_file"),
125+
("dwi_mask", "in_file")]),
126+
])
127+
# fmt:on
128+
129+
return workflow

0 commit comments

Comments
 (0)