Skip to content

Commit c605d41

Browse files
committed
feat: Save fieldmap mask to output directory
1 parent e3bc6f5 commit c605d41

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

sdcflows/workflows/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def init_fmap_preproc_wf(
137137
fmap_derivatives_wf = init_fmap_derivatives_wf(
138138
output_dir=str(output_dir),
139139
write_coeff=True,
140+
write_mask=True,
140141
bids_fmap_id=estimator.bids_id,
141142
name=f'fmap_derivatives_wf_{estimator.sanitized_id}',
142143
)
@@ -172,14 +173,14 @@ def init_fmap_preproc_wf(
172173
("outputnode.fmap_ref", "inputnode.fmap_ref"),
173174
("outputnode.fmap_mask", "inputnode.fmap_mask"),
174175
]),
176+
(est_wf, out_map, [
177+
("outputnode.method", "method")
178+
]),
175179
(fmap_derivatives_wf, out_map, [
176180
("outputnode.fieldmap", "fmap"),
177181
("outputnode.fmap_ref", "fmap_ref"),
178182
("outputnode.fmap_coeff", "fmap_coeff"),
179-
]),
180-
(est_wf, out_map, [
181183
("outputnode.fmap_mask", "fmap_mask"),
182-
("outputnode.method", "method")
183184
]),
184185
]) # fmt:skip
185186

sdcflows/workflows/outputs.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def init_fmap_derivatives_wf(
123123
custom_entities=None,
124124
name='fmap_derivatives_wf',
125125
write_coeff=False,
126+
write_mask=False,
126127
):
127128
"""
128129
Set up datasinks to store derivatives in the right location.
@@ -164,7 +165,7 @@ def init_fmap_derivatives_wf(
164165
name='inputnode',
165166
)
166167
outputnode = pe.Node(
167-
niu.IdentityInterface(fields=['fieldmap', 'fmap_coeff', 'fmap_ref']),
168+
niu.IdentityInterface(fields=['fieldmap', 'fmap_coeff', 'fmap_ref', 'fmap_mask']),
168169
name='outputnode',
169170
)
170171

@@ -216,6 +217,28 @@ def init_fmap_derivatives_wf(
216217
(ds_reference, outputnode, [("out_file", "fmap_ref")]),
217218
]) # fmt:skip
218219

220+
if write_mask:
221+
ds_mask = pe.Node(
222+
DerivativesDataSink(
223+
base_directory=output_dir,
224+
compress=True,
225+
desc='brain',
226+
suffix='mask',
227+
datatype='fmap',
228+
dismiss_entities=('fmap',),
229+
allowed_entities=tuple(custom_entities),
230+
),
231+
name='ds_mask',
232+
)
233+
234+
ds_mask.inputs.trait_set(**custom_entities)
235+
236+
workflow.connect([
237+
(inputnode, ds_mask, [("source_files", "source_file"),
238+
("fmap_mask", "in_file")]),
239+
(ds_mask, outputnode, [("out_file", "fmap_mask")]),
240+
]) # fmt:skip
241+
219242
if not write_coeff:
220243
return workflow
221244

0 commit comments

Comments
 (0)