Skip to content

Commit b1ddee0

Browse files
tsalooesteban
authored andcommitted
Add multiecho argument to init_bold_reference_wf.
Also updates the workflow description based on whether multiecho is True or False.
1 parent 91f3727 commit b1ddee0

File tree

2 files changed

+47
-16
lines changed

2 files changed

+47
-16
lines changed

niworkflows/func/util.py

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def init_bold_reference_wf(
3131
omp_nthreads,
3232
bold_file=None,
3333
pre_mask=False,
34+
multiecho=False,
3435
name="bold_reference_wf",
3536
gen_report=False,
3637
):
@@ -51,13 +52,16 @@ def init_bold_reference_wf(
5152
5253
Parameters
5354
----------
54-
bold_file : str
55+
bold_file : :obj:`str`
5556
BOLD series NIfTI file
56-
omp_nthreads : int
57+
omp_nthreads : :obj:`int`
5758
Maximum number of threads an individual process may use
58-
name : str
59+
multiecho : :obj:`bool`
60+
If multiecho data was supplied, data from the first echo
61+
will be selected
62+
name : :obj:`str`
5963
Name of workflow (default: ``bold_reference_wf``)
60-
gen_report : bool
64+
gen_report : :obj:`bool`
6165
Whether a mask report node should be appended in the end
6266
6367
Inputs
@@ -98,7 +102,13 @@ def init_bold_reference_wf(
98102
99103
"""
100104
workflow = Workflow(name=name)
101-
workflow.__desc__ = """\
105+
if multiecho:
106+
workflow.__desc__ = """\
107+
First, a reference volume and its skull-stripped version were generated
108+
from the first echo using a custom methodology of *fMRIPrep*.
109+
"""
110+
else:
111+
workflow.__desc__ = """\
102112
First, a reference volume and its skull-stripped version were generated
103113
using a custom methodology of *fMRIPrep*.
104114
"""
@@ -129,12 +139,17 @@ def init_bold_reference_wf(
129139
if bold_file is not None:
130140
inputnode.inputs.bold_file = bold_file
131141

132-
validate = pe.MapNode(
133-
ValidateImage(),
134-
name="validate",
135-
mem_gb=DEFAULT_MEMORY_MIN_GB,
136-
iterfield=["in_file"],
137-
)
142+
if multiecho:
143+
validate = pe.MapNode(
144+
ValidateImage(),
145+
name="validate",
146+
mem_gb=DEFAULT_MEMORY_MIN_GB,
147+
iterfield=["in_file"],
148+
)
149+
else:
150+
validate = pe.Node(
151+
ValidateImage(), name="validate", mem_gb=DEFAULT_MEMORY_MIN_GB
152+
)
138153

139154
gen_ref = pe.Node(
140155
EstimateReferenceImage(), name="gen_ref", mem_gb=1
@@ -155,17 +170,12 @@ def init_bold_reference_wf(
155170
(inputnode, enhance_and_skullstrip_bold_wf, [
156171
("bold_mask", "inputnode.pre_mask"),
157172
]),
158-
(inputnode, validate, [(("bold_file", ensure_list), "in_file")]),
159173
(inputnode, gen_ref, [("sbref_file", "sbref_file")]),
160174
(inputnode, calc_dummy_scans, [("dummy_scans", "dummy_scans")]),
161175
(validate, gen_ref, [("out_file", "in_file")]),
162176
(gen_ref, enhance_and_skullstrip_bold_wf, [
163177
("ref_image", "inputnode.in_file"),
164178
]),
165-
(validate, outputnode, [
166-
(("out_file", select_first), "bold_file"),
167-
("out_report", "validation_report"),
168-
]),
169179
(gen_ref, calc_dummy_scans, [("n_volumes_to_discard", "algo_dummy_scans")]),
170180
(calc_dummy_scans, outputnode, [("skip_vols_num", "skip_vols")]),
171181
(gen_ref, outputnode, [
@@ -178,6 +188,19 @@ def init_bold_reference_wf(
178188
("outputnode.skull_stripped_file", "ref_image_brain"),
179189
]),
180190
])
191+
192+
if multiecho:
193+
workflow.connect([
194+
(inputnode, validate, [(("bold_file", ensure_list), "in_file")]),
195+
(validate, outputnode, [(("out_file", select_first), "bold_file"),
196+
("out_report", "validation_report")]),
197+
])
198+
else:
199+
workflow.connect([
200+
(inputnode, validate, [("bold_file", "in_file")]),
201+
(validate, outputnode, [("out_file", "bold_file"),
202+
("out_report", "validation_report")]),
203+
])
181204
# fmt: on
182205

183206
if gen_report:

niworkflows/interfaces/registration.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,14 @@ class _EstimateReferenceImageInputSpec(BaseInterfaceInputSpec):
424424
usedefault=True,
425425
desc="Which software to use to perform motion correction",
426426
)
427+
multiecho = traits.Bool(
428+
False,
429+
usedefault=True,
430+
desc=(
431+
"If multiecho data was supplied, data from "
432+
"the first echo will be selected."
433+
),
434+
)
427435

428436

429437
class _EstimateReferenceImageOutputSpec(TraitedSpec):

0 commit comments

Comments
 (0)