3131from niworkflows .interfaces .header import ValidateImage
3232from niworkflows .interfaces .nitransforms import ConcatenateXFMs
3333from niworkflows .interfaces .utility import KeySelect
34- from sdcflows .workflows .apply .correction import init_unwarp_wf
3534from sdcflows .workflows .apply .registration import init_coeff2epi_wf
3635
3736from ... import config
@@ -189,7 +188,6 @@ def init_bold_fit_wf(
189188 * :py:func:`~fmriprep.workflows.bold.hmc.init_bold_hmc_wf`
190189 * :py:func:`~niworkflows.func.utils.init_enhance_and_skullstrip_bold_wf`
191190 * :py:func:`~sdcflows.workflows.apply.registration.init_coeff2epi_wf`
192- * :py:func:`~sdcflows.workflows.apply.correction.init_unwarp_wf`
193191 * :py:func:`~fmriprep.workflows.bold.registration.init_bold_reg_wf`
194192 * :py:func:`~fmriprep.workflows.bold.outputs.init_ds_boldref_wf`
195193 * :py:func:`~fmriprep.workflows.bold.outputs.init_ds_hmc_wf`
@@ -547,12 +545,26 @@ def init_bold_fit_wf(
547545 (ds_fmapreg_wf , fmapreg_buffer , [('outputnode.xform' , 'boldref2fmap_xfm' )]),
548546 ]) # fmt:skip
549547
550- unwarp_wf = init_unwarp_wf (
551- free_mem = config .environment .free_mem ,
552- debug = 'fieldmaps' in config .execution .debug ,
553- omp_nthreads = config .nipype .omp_nthreads ,
548+ boldref_fmap = pe .Node (
549+ ReconstructFieldmap (inverse = [True ]), name = 'boldref_fmap' , mem_gb = 1
550+ )
551+
552+ distortion_params = pe .Node (
553+ DistortionParameters (
554+ metadata = metadata ,
555+ in_file = bold_file ,
556+ fallback = config .workflow .fallback_total_readout_time ,
557+ ),
558+ name = 'distortion_params' ,
559+ run_without_submitting = True ,
560+ )
561+
562+ unwarp_boldref = pe .Node (
563+ ResampleSeries (jacobian = jacobian ),
564+ name = 'unwarp_boldref' ,
565+ n_procs = omp_nthreads ,
566+ mem_gb = mem_gb ['resampled' ],
554567 )
555- unwarp_wf .inputs .inputnode .metadata = layout .get_metadata (bold_file )
556568
557569 skullstrip_bold_wf = init_skullstrip_bold_wf ()
558570
@@ -564,24 +576,26 @@ def init_bold_fit_wf(
564576 ('sdc_method' , 'sdc_method' ),
565577 ('fmap_id' , 'keys' ),
566578 ]),
567- (fmap_select , unwarp_wf , [
568- ('fmap_coeff' , 'inputnode.fmap_coeff' ),
579+ (fmapref_buffer , boldref_fmap , [('out' , 'target_ref_file' )]),
580+ (fmapreg_buffer , boldref_fmap , [('boldref2fmap_xfm' , 'transforms' )]),
581+ (fmap_select , boldref_fmap , [
582+ ('fmap_coeff' , 'in_coeffs' ),
583+ ('fmap_ref' , 'fmap_ref_file' ),
569584 ]),
570- (fmapreg_buffer , unwarp_wf , [
571- # This looks backwards, but unwarp_wf describes transforms in
572- # terms of points while we (and init_coeff2epi_wf) describe them
573- # in terms of images. Mapping fieldmap coordinates into boldref
574- # coordinates maps the boldref image onto the fieldmap image.
575- ('boldref2fmap_xfm' , 'inputnode.fmap2data_xfm' ),
585+ (fmapref_buffer , unwarp_boldref , [('out' , 'ref_file' )]),
586+ (enhance_boldref_wf , unwarp_boldref , [
587+ ('outputnode.bias_corrected_file' , 'in_file' ),
576588 ]),
577- (enhance_boldref_wf , unwarp_wf , [
578- ('outputnode.bias_corrected_file' , 'inputnode.distorted' ),
589+ (boldref_fmap , unwarp_boldref , [('out_file' , 'fieldmap' )]),
590+ (distortion_params , unwarp_boldref , [
591+ ('readout_time' , 'ro_time' ),
592+ ('pe_direction' , 'pe_dir' ),
579593 ]),
580- (unwarp_wf , ds_coreg_boldref_wf , [
581- ('outputnode.corrected ' , 'inputnode.boldref' ),
594+ (unwarp_boldref , ds_coreg_boldref_wf , [
595+ ('out_file ' , 'inputnode.boldref' ),
582596 ]),
583- (unwarp_wf , skullstrip_bold_wf , [
584- ('outputnode.corrected ' , 'inputnode.in_file' ),
597+ (ds_coreg_boldref_wf , skullstrip_bold_wf , [
598+ ('outputnode.boldref ' , 'inputnode.in_file' ),
585599 ]),
586600 (skullstrip_bold_wf , ds_boldmask_wf , [
587601 ('outputnode.mask_file' , 'inputnode.boldmask' ),
@@ -591,7 +605,7 @@ def init_bold_fit_wf(
591605 (fmapreg_buffer , func_fit_reports_wf , [
592606 ('boldref2fmap_xfm' , 'inputnode.boldref2fmap_xfm' ),
593607 ]),
594- (unwarp_wf , func_fit_reports_wf , [('outputnode.fieldmap ' , 'inputnode.fieldmap' )]),
608+ (boldref_fmap , func_fit_reports_wf , [('out_file ' , 'inputnode.fieldmap' )]),
595609 ]) # fmt:skip
596610 else :
597611 workflow .connect ([
0 commit comments