@@ -80,7 +80,6 @@ def init_raw_boldref_wf(
80
80
beginning of ``bold_file``
81
81
82
82
"""
83
- from niworkflows .interfaces .bold import NonsteadyStatesDetector
84
83
from niworkflows .interfaces .images import RobustAverage
85
84
86
85
workflow = Workflow (name = name )
@@ -106,6 +105,96 @@ def init_raw_boldref_wf(
106
105
name = 'outputnode' ,
107
106
)
108
107
108
+ # Simplify manually setting input image
109
+ if bold_file is not None :
110
+ inputnode .inputs .bold_file = bold_file
111
+
112
+ validation_and_dummies_wf = init_validation_and_dummies_wf ()
113
+
114
+ gen_avg = pe .Node (RobustAverage (), name = 'gen_avg' , mem_gb = 1 )
115
+
116
+ workflow .connect ([
117
+ (inputnode , validation_and_dummies_wf , [
118
+ ('bold_file' , 'inputnode.bold_file' ),
119
+ ('dummy_scans' , 'inputnode.dummy_scans' ),
120
+ ]),
121
+ (validation_and_dummies_wf , gen_avg , [
122
+ ('outputnode.bold_file' , 'in_file' ),
123
+ ('outputnode.t_mask' , 't_mask' ),
124
+ ]),
125
+ (validation_and_dummies_wf , outputnode , [
126
+ ('outputnode.bold_file' , 'bold_file' ),
127
+ ('outputnode.skip_vols' , 'skip_vols' ),
128
+ ('outputnode.algo_dummy_scans' , 'algo_dummy_scans' ),
129
+ ('outputnode.validation_report' , 'validation_report' ),
130
+ ]),
131
+ (gen_avg , outputnode , [('out_file' , 'boldref' )]),
132
+ ]) # fmt:skip
133
+
134
+ return workflow
135
+
136
+
137
+ def init_validation_and_dummies_wf (
138
+ bold_file = None ,
139
+ name = 'validation_and_dummies_wf' ,
140
+ ):
141
+ """
142
+ Build a workflow that validates a BOLD image and detects non-steady-state volumes.
143
+
144
+ Workflow Graph
145
+ .. workflow::
146
+ :graph2use: orig
147
+ :simple_form: yes
148
+
149
+ from fmriprep.workflows.bold.reference import init_validation_and_dummies_wf
150
+ wf = init_validation_and_dummies_wf()
151
+
152
+ Parameters
153
+ ----------
154
+ bold_file : :obj:`str`
155
+ BOLD series NIfTI file
156
+ name : :obj:`str`
157
+ Name of workflow (default: ``validation_and_dummies_wf``)
158
+
159
+ Inputs
160
+ ------
161
+ bold_file : str
162
+ BOLD series NIfTI file
163
+ dummy_scans : int or None
164
+ Number of non-steady-state volumes specified by user at beginning of ``bold_file``
165
+
166
+ Outputs
167
+ -------
168
+ bold_file : str
169
+ Validated BOLD series NIfTI file
170
+ skip_vols : int
171
+ Number of non-steady-state volumes selected at beginning of ``bold_file``
172
+ algo_dummy_scans : int
173
+ Number of non-steady-state volumes agorithmically detected at
174
+ beginning of ``bold_file``
175
+
176
+ """
177
+ from niworkflows .interfaces .bold import NonsteadyStatesDetector
178
+
179
+ workflow = Workflow (name = name )
180
+
181
+ inputnode = pe .Node (
182
+ niu .IdentityInterface (fields = ['bold_file' , 'dummy_scans' ]),
183
+ name = 'inputnode' ,
184
+ )
185
+ outputnode = pe .Node (
186
+ niu .IdentityInterface (
187
+ fields = [
188
+ 'bold_file' ,
189
+ 'skip_vols' ,
190
+ 'algo_dummy_scans' ,
191
+ 't_mask' ,
192
+ 'validation_report' ,
193
+ ]
194
+ ),
195
+ name = 'outputnode' ,
196
+ )
197
+
109
198
# Simplify manually setting input image
110
199
if bold_file is not None :
111
200
inputnode .inputs .bold_file = bold_file
@@ -117,7 +206,6 @@ def init_raw_boldref_wf(
117
206
)
118
207
119
208
get_dummy = pe .Node (NonsteadyStatesDetector (), name = 'get_dummy' )
120
- gen_avg = pe .Node (RobustAverage (), name = 'gen_avg' , mem_gb = 1 )
121
209
122
210
calc_dummy_scans = pe .Node (
123
211
niu .Function (function = pass_dummy_scans , output_names = ['skip_vols_num' ]),
@@ -126,22 +214,20 @@ def init_raw_boldref_wf(
126
214
mem_gb = DEFAULT_MEMORY_MIN_GB ,
127
215
)
128
216
129
- # fmt: off
130
217
workflow .connect ([
131
218
(inputnode , val_bold , [('bold_file' , 'in_file' )]),
132
- (inputnode , get_dummy , [('bold_file' , 'in_file' )]),
133
- (inputnode , calc_dummy_scans , [('dummy_scans' , 'dummy_scans' )]),
134
- (val_bold , gen_avg , [('out_file' , 'in_file' )]),
135
- (get_dummy , gen_avg , [('t_mask' , 't_mask' )]),
136
- (get_dummy , calc_dummy_scans , [('n_dummy' , 'algo_dummy_scans' )]),
137
219
(val_bold , outputnode , [
138
220
('out_file' , 'bold_file' ),
139
221
('out_report' , 'validation_report' ),
140
222
]),
223
+ (inputnode , get_dummy , [('bold_file' , 'in_file' )]),
224
+ (inputnode , calc_dummy_scans , [('dummy_scans' , 'dummy_scans' )]),
225
+ (get_dummy , calc_dummy_scans , [('n_dummy' , 'algo_dummy_scans' )]),
226
+ (get_dummy , outputnode , [
227
+ ('n_dummy' , 'algo_dummy_scans' ),
228
+ ('t_mask' , 't_mask' ),
229
+ ]),
141
230
(calc_dummy_scans , outputnode , [('skip_vols_num' , 'skip_vols' )]),
142
- (gen_avg , outputnode , [('out_file' , 'boldref' )]),
143
- (get_dummy , outputnode , [('n_dummy' , 'algo_dummy_scans' )]),
144
- ])
145
- # fmt: on
231
+ ]) # fmt:skip
146
232
147
233
return workflow
0 commit comments