|
25 | 25 | ++++++++++++++++++++++
|
26 | 26 |
|
27 | 27 | .. autofunction:: init_bold_reg_wf
|
28 |
| -.. autofunction:: init_bold_t1_trans_wf |
29 | 28 | .. autofunction:: init_bbreg_wf
|
30 | 29 | .. autofunction:: init_fsl_bbr_wf
|
31 | 30 |
|
@@ -193,215 +192,6 @@ def init_bold_reg_wf(
|
193 | 192 | return workflow
|
194 | 193 |
|
195 | 194 |
|
196 |
| -def init_bold_t1_trans_wf( |
197 |
| - freesurfer: bool, |
198 |
| - mem_gb: float, |
199 |
| - omp_nthreads: int, |
200 |
| - use_compression: bool = True, |
201 |
| - name: str = 'bold_t1_trans_wf', |
202 |
| -): |
203 |
| - """ |
204 |
| - Co-register the reference BOLD image to T1w-space. |
205 |
| -
|
206 |
| - The workflow uses :abbr:`BBR (boundary-based registration)`. |
207 |
| -
|
208 |
| - Workflow Graph |
209 |
| - .. workflow:: |
210 |
| - :graph2use: orig |
211 |
| - :simple_form: yes |
212 |
| -
|
213 |
| - from fmriprep.workflows.bold.registration import init_bold_t1_trans_wf |
214 |
| - wf = init_bold_t1_trans_wf(freesurfer=True, |
215 |
| - mem_gb=3, |
216 |
| - omp_nthreads=1) |
217 |
| -
|
218 |
| - Parameters |
219 |
| - ---------- |
220 |
| - freesurfer : :obj:`bool` |
221 |
| - Enable FreeSurfer functional registration (bbregister) |
222 |
| - mem_gb : :obj:`float` |
223 |
| - Size of BOLD file in GB |
224 |
| - omp_nthreads : :obj:`int` |
225 |
| - Maximum number of threads an individual process may use |
226 |
| - use_compression : :obj:`bool` |
227 |
| - Save registered BOLD series as ``.nii.gz`` |
228 |
| - name : :obj:`str` |
229 |
| - Name of workflow (default: ``bold_reg_wf``) |
230 |
| -
|
231 |
| - Inputs |
232 |
| - ------ |
233 |
| - name_source |
234 |
| - BOLD series NIfTI file |
235 |
| - Used to recover original information lost during processing |
236 |
| - ref_bold_brain |
237 |
| - Reference image to which BOLD series is aligned |
238 |
| - If ``fieldwarp == True``, ``ref_bold_brain`` should be unwarped |
239 |
| - ref_bold_mask |
240 |
| - Skull-stripping mask of reference image |
241 |
| - t1w_brain |
242 |
| - Skull-stripped bias-corrected structural template image |
243 |
| - t1w_mask |
244 |
| - Mask of the skull-stripped template image |
245 |
| - t1w_aseg |
246 |
| - FreeSurfer's ``aseg.mgz`` atlas projected into the T1w reference |
247 |
| - (only if ``recon-all`` was run). |
248 |
| - t1w_aparc |
249 |
| - FreeSurfer's ``aparc+aseg.mgz`` atlas projected into the T1w reference |
250 |
| - (only if ``recon-all`` was run). |
251 |
| - bold_split |
252 |
| - Individual 3D BOLD volumes, not motion corrected |
253 |
| - hmc_xforms |
254 |
| - List of affine transforms aligning each volume to ``ref_image`` in ITK format |
255 |
| - itk_bold_to_t1 |
256 |
| - Affine transform from ``ref_bold_brain`` to T1 space (ITK format) |
257 |
| - fieldwarp |
258 |
| - a :abbr:`DFM (displacements field map)` in ITK format |
259 |
| -
|
260 |
| - Outputs |
261 |
| - ------- |
262 |
| - bold_t1 |
263 |
| - Motion-corrected BOLD series in T1 space |
264 |
| - bold_t1_ref |
265 |
| - Reference, contrast-enhanced summary of the motion-corrected BOLD series in T1w space |
266 |
| - bold_mask_t1 |
267 |
| - BOLD mask in T1 space |
268 |
| - bold_aseg_t1 |
269 |
| - FreeSurfer's ``aseg.mgz`` atlas, in T1w-space at the BOLD resolution |
270 |
| - (only if ``recon-all`` was run). |
271 |
| - bold_aparc_t1 |
272 |
| - FreeSurfer's ``aparc+aseg.mgz`` atlas, in T1w-space at the BOLD resolution |
273 |
| - (only if ``recon-all`` was run). |
274 |
| -
|
275 |
| - See also |
276 |
| - -------- |
277 |
| - * :py:func:`~fmriprep.workflows.bold.registration.init_bbreg_wf` |
278 |
| - * :py:func:`~fmriprep.workflows.bold.registration.init_fsl_bbr_wf` |
279 |
| -
|
280 |
| - """ |
281 |
| - from niworkflows.engine.workflows import LiterateWorkflow as Workflow |
282 |
| - from niworkflows.func.util import init_bold_reference_wf |
283 |
| - from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms |
284 |
| - from niworkflows.interfaces.itk import MultiApplyTransforms |
285 |
| - from niworkflows.interfaces.nibabel import GenerateSamplingReference |
286 |
| - from niworkflows.interfaces.nilearn import Merge |
287 |
| - |
288 |
| - from fmriprep.interfaces.maths import Clip |
289 |
| - |
290 |
| - workflow = Workflow(name=name) |
291 |
| - inputnode = pe.Node( |
292 |
| - niu.IdentityInterface( |
293 |
| - fields=[ |
294 |
| - 'name_source', |
295 |
| - 'ref_bold_brain', |
296 |
| - 'ref_bold_mask', |
297 |
| - 't1w_brain', |
298 |
| - 't1w_mask', |
299 |
| - 't1w_aseg', |
300 |
| - 't1w_aparc', |
301 |
| - 'bold_split', |
302 |
| - 'fieldwarp', |
303 |
| - 'hmc_xforms', |
304 |
| - 'itk_bold_to_t1', |
305 |
| - ] |
306 |
| - ), |
307 |
| - name='inputnode', |
308 |
| - ) |
309 |
| - |
310 |
| - outputnode = pe.Node( |
311 |
| - niu.IdentityInterface( |
312 |
| - fields=['bold_t1', 'bold_t1_ref', 'bold_mask_t1', 'bold_aseg_t1', 'bold_aparc_t1'] |
313 |
| - ), |
314 |
| - name='outputnode', |
315 |
| - ) |
316 |
| - |
317 |
| - gen_ref = pe.Node( |
318 |
| - GenerateSamplingReference(), name='gen_ref', mem_gb=0.3 |
319 |
| - ) # 256x256x256 * 64 / 8 ~ 150MB |
320 |
| - |
321 |
| - mask_t1w_tfm = pe.Node( |
322 |
| - ApplyTransforms(interpolation='MultiLabel'), name='mask_t1w_tfm', mem_gb=0.1 |
323 |
| - ) |
324 |
| - # fmt:off |
325 |
| - workflow.connect([ |
326 |
| - (inputnode, gen_ref, [('ref_bold_brain', 'moving_image'), |
327 |
| - ('t1w_brain', 'fixed_image'), |
328 |
| - ('t1w_mask', 'fov_mask')]), |
329 |
| - (inputnode, mask_t1w_tfm, [('ref_bold_mask', 'input_image')]), |
330 |
| - (gen_ref, mask_t1w_tfm, [('out_file', 'reference_image')]), |
331 |
| - (inputnode, mask_t1w_tfm, [('itk_bold_to_t1', 'transforms')]), |
332 |
| - (mask_t1w_tfm, outputnode, [('output_image', 'bold_mask_t1')]), |
333 |
| - ]) |
334 |
| - # fmt:on |
335 |
| - if freesurfer: |
336 |
| - # Resample aseg and aparc in T1w space (no transforms needed) |
337 |
| - aseg_t1w_tfm = pe.Node( |
338 |
| - ApplyTransforms(interpolation='MultiLabel', transforms='identity'), |
339 |
| - name='aseg_t1w_tfm', |
340 |
| - mem_gb=0.1, |
341 |
| - ) |
342 |
| - aparc_t1w_tfm = pe.Node( |
343 |
| - ApplyTransforms(interpolation='MultiLabel', transforms='identity'), |
344 |
| - name='aparc_t1w_tfm', |
345 |
| - mem_gb=0.1, |
346 |
| - ) |
347 |
| - # fmt:off |
348 |
| - workflow.connect([ |
349 |
| - (inputnode, aseg_t1w_tfm, [('t1w_aseg', 'input_image')]), |
350 |
| - (inputnode, aparc_t1w_tfm, [('t1w_aparc', 'input_image')]), |
351 |
| - (gen_ref, aseg_t1w_tfm, [('out_file', 'reference_image')]), |
352 |
| - (gen_ref, aparc_t1w_tfm, [('out_file', 'reference_image')]), |
353 |
| - (aseg_t1w_tfm, outputnode, [('output_image', 'bold_aseg_t1')]), |
354 |
| - (aparc_t1w_tfm, outputnode, [('output_image', 'bold_aparc_t1')]), |
355 |
| - ]) |
356 |
| - # fmt:on |
357 |
| - |
358 |
| - bold_to_t1w_transform = pe.Node( |
359 |
| - MultiApplyTransforms(interpolation="LanczosWindowedSinc", float=True, copy_dtype=True), |
360 |
| - name='bold_to_t1w_transform', |
361 |
| - mem_gb=mem_gb * 3 * omp_nthreads, |
362 |
| - n_procs=omp_nthreads, |
363 |
| - ) |
364 |
| - |
365 |
| - # Interpolation can occasionally produce below-zero values as an artifact |
366 |
| - threshold = pe.MapNode( |
367 |
| - Clip(minimum=0), name="threshold", iterfield=['in_file'], mem_gb=DEFAULT_MEMORY_MIN_GB |
368 |
| - ) |
369 |
| - |
370 |
| - # merge 3D volumes into 4D timeseries |
371 |
| - merge = pe.Node(Merge(compress=use_compression), name='merge', mem_gb=mem_gb) |
372 |
| - |
373 |
| - # Generate a reference on the target T1w space |
374 |
| - gen_final_ref = init_bold_reference_wf(omp_nthreads, pre_mask=True) |
375 |
| - |
376 |
| - # Merge transforms placing the head motion correction last |
377 |
| - merge_xforms = pe.Node( |
378 |
| - niu.Merge(3), |
379 |
| - name='merge_xforms', |
380 |
| - run_without_submitting=True, |
381 |
| - mem_gb=DEFAULT_MEMORY_MIN_GB, |
382 |
| - ) |
383 |
| - # fmt:off |
384 |
| - workflow.connect([ |
385 |
| - (inputnode, merge, [('name_source', 'header_source')]), |
386 |
| - (inputnode, merge_xforms, [ |
387 |
| - ('hmc_xforms', 'in3'), # May be 'identity' if HMC already applied |
388 |
| - ('fieldwarp', 'in2'), # May be 'identity' if SDC already applied |
389 |
| - ('itk_bold_to_t1', 'in1')]), |
390 |
| - (inputnode, bold_to_t1w_transform, [('bold_split', 'input_image')]), |
391 |
| - (merge_xforms, bold_to_t1w_transform, [('out', 'transforms')]), |
392 |
| - (gen_ref, bold_to_t1w_transform, [('out_file', 'reference_image')]), |
393 |
| - (bold_to_t1w_transform, threshold, [('out_files', 'in_file')]), |
394 |
| - (threshold, merge, [('out_file', 'in_files')]), |
395 |
| - (merge, gen_final_ref, [('out_file', 'inputnode.bold_file')]), |
396 |
| - (mask_t1w_tfm, gen_final_ref, [('output_image', 'inputnode.bold_mask')]), |
397 |
| - (merge, outputnode, [('out_file', 'bold_t1')]), |
398 |
| - (gen_final_ref, outputnode, [('outputnode.ref_image', 'bold_t1_ref')]), |
399 |
| - ]) |
400 |
| - # fmt:on |
401 |
| - |
402 |
| - return workflow |
403 |
| - |
404 |
| - |
405 | 195 | def init_bbreg_wf(
|
406 | 196 | use_bbr: bool,
|
407 | 197 | bold2t1w_dof: AffineDOF,
|
|
0 commit comments