@@ -80,7 +80,6 @@ def init_raw_boldref_wf(
8080 beginning of ``bold_file``
8181
8282 """
83- from niworkflows .interfaces .bold import NonsteadyStatesDetector
8483 from niworkflows .interfaces .images import RobustAverage
8584
8685 workflow = Workflow (name = name )
@@ -106,6 +105,96 @@ def init_raw_boldref_wf(
106105 name = 'outputnode' ,
107106 )
108107
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+
109198 # Simplify manually setting input image
110199 if bold_file is not None :
111200 inputnode .inputs .bold_file = bold_file
@@ -117,7 +206,6 @@ def init_raw_boldref_wf(
117206 )
118207
119208 get_dummy = pe .Node (NonsteadyStatesDetector (), name = 'get_dummy' )
120- gen_avg = pe .Node (RobustAverage (), name = 'gen_avg' , mem_gb = 1 )
121209
122210 calc_dummy_scans = pe .Node (
123211 niu .Function (function = pass_dummy_scans , output_names = ['skip_vols_num' ]),
@@ -126,22 +214,20 @@ def init_raw_boldref_wf(
126214 mem_gb = DEFAULT_MEMORY_MIN_GB ,
127215 )
128216
129- # fmt: off
130217 workflow .connect ([
131218 (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' )]),
137219 (val_bold , outputnode , [
138220 ('out_file' , 'bold_file' ),
139221 ('out_report' , 'validation_report' ),
140222 ]),
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+ ]),
141230 (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
146232
147233 return workflow
0 commit comments