Adding pre-computed distortion warp to afni_proc pipeline

AFNI version info (afni -ver): Precompiled binary linux_ubuntu_16_64: Dec 7 2023 (Version AFNI_23.3.12 'Septimius Severus')

Hi there,

I've started working on a new dataset that has field maps acquired in the form of two magnitude images of slightly different echo times with a map of the phase difference between the two. In the past, for distortion correction I've really only dealt with pairs of EPIs of reverse phase encoding directions, so this offered the chance to get adventuresome. I pre-computed a distortion warp dataset using "epi_bo_correct.py" and tried to supply this to my afni_proc.py pipeline with the argument "-blip_warp_dset". However, it fails with the error,

-tcat_remove_first_trs: invalid as integers: 0 -blip_warp_dset /data1/2019_Synergy/derivaties/afni/sub-023/b0_correct_test/epi_b0_WARP.nii.gz

Why does it appear to be appending the "-blip_warp_dset" to the arguments of the previous line? Uncommenting the line beginning with "-blip_warp_dset" resolves the error but prevents me from performing the distortion correction I'm going for.

Thanks in advance!
Afni_proc code below:

#!/usr/bin/env tcsh

# set subject identifiers
set subj  = sub-023

# set data directories
set top_dir = /data1/2019_Synergy
set anat_dir  = $top_dir/rawdata/${subj}/ses-02/anat
set epi_dir   = $top_dir/rawdata/${subj}/ses-02/func
set stim_dir  = $top_dir/derivatives/afni/${subj}/timing/langloc
set warp_dir = $top_dir/derivaties/afni/${subj}/b0_correct_test

# run afni_proc.py to create a single subject processing script
afni_proc.py                                                                    \
  -subj_id $subj                                            	                  \
  -out_dir langloc_ses-02                                                       \
	-script proc.langloc.$subj -scr_overwrite                             	      \
	-blocks align volreg combine surf blur scale regress                          \
	-copy_anat $anat_dir/${subj}_ses-02_T1w.nii.gz                                \
  -dsets_me_run $epi_dir/${subj}_ses-02_task-langloc_echo*_run-1_bold.nii.gz    \
  -combine_method OC                                                            \
  -echo_times 13.4 34.8 56.2                                                    \
	-tcat_remove_first_trs 0                                                      \
  -blip_warp_dset $warp_dir/epi_b0_WARP.nii.gz                                            \
	-align_opts_aea -giant_move                                                   \
  -cost lpc+ZZ                                                                  \
	-volreg_align_to MIN_OUTLIER                                                  \
	-volreg_align_e2a                                                             \
	-volreg_interp -Fourier						                                            \
	-volreg_post_vr_allin yes                                                     \
        -volreg_pvra_base_index MIN_OUTLIER                                     \
        -radial_correlate_blocks volreg                                         \
        -radial_correlate_opts                                                  \
            -nfirst 0                                                           \
	-surf_anat $top_dir/derivatives/fs/${subj}/surf/SUMA/${subj}_SurfVol.nii      \
	-surf_spec $top_dir/derivatives/fs/${subj}/surf/SUMA/std.141.${subj}_?h.spec  \
	-blur_size 4.0                                                                \
	-regress_stim_times                                                           \
		$stim_dir/sentences.1D                                                      \
		$stim_dir/wordlists.1D                                                      \
	-regress_stim_labels 							                                            \
			sentences wordlists                                                       \
	-regress_basis 'BLOCK(5.1667,1)'					                                    \
	-regress_censor_motion 0.5                                                    \
	-regress_motion_per_run                                                       \
	-regress_opts_3dD                                                             \
			-jobs 15                                                                  \
			-gltsym 'SYM: 1*sentences -1*wordlists' -glt_label 1 SentVsList           \
	-regress_make_ideal_sum sum_ideal.1D

Note my distortion warp dset was created with the following code:

epi_b0_correct.py                                                              \
     -in_epi_json   sub-023_ses-02_fmap_echo-2_bold_ph.json                    \
     -in_freq       sub-023_ses-02_fmap_echo-2_bold_ph.nii.gz                  \
     -in_magn       sub-023_ses-02_fmap_echo-2_bold.nii.gz                     \
     -in_epi        sub-023_ses-02_task-langloc_echo-1_run-1_bold.nii.gz       \
     -in_anat       sub-023_ses-02_T1w+orig.HEAD                               \
     -epi_pe_bwpp   805                                                        \
     -scale_freq    0.311785                                                   \
     -do_recenter_freq  median                                                 \
     -prefix        b0_corr

Hello,

To be sure, you say that the problem is happening when -blip_warp_dset is commented out, is that correct? So this is really just a shell issue.

Given that, you are probably putting the comment character '#' as the first character on the line, and probably attached to -blip. Put one or more spaces before the comment character, to separate it from the effect of the previous line continuation.

-rick

Hi Rick,

Please accept my apologies for I had mistyped my earlier message - it's actually the opposite of what I stated. The error occurs when "-blip_warp_dset dset" is included and resolves when only that particular line is commented out. So, the error appears to be isolated to the inclusion of "-blip_warp_dset dset ". I was extra careful to make sure I had included backslashes at the end of each line continuation, so I'm not sure what else it could be. Thanks!

Hi-

I think you just need to update your AFNI version to have this work. The option only went in in 2024, and your afni version is from 2023:

 05 Aug 2024, RC Reynolds, afni_proc.py, level 2 (MINOR), type 6 (ENHANCE)
    add option -blip_warp_dset to input a pre-computed warp

    For example, one can import the warp from epi_b0_correct.py.

Therefore, afni_proc.py doesn't know that "-blip_warp_dset" is a program option, and thinks it might be something to apply to the preceding option.

--pt

Thanks, Paul! You were right that I just needed to update my AFNI version. Next time, I will add that to the top of my troubleshooting checklist. I really appreciate the help!

Cool, glad that worked to sort it.

--pt