transformations concatenation

AFNI version info (afni -ver): 24.3.00 'Elagabalus'

Hello everyone,
I have a question about designing an afni_proc.py script for multi-echo (3 echoes) task fMRI data.

After the despike and tshift blocks, I would like to perform motion correction (volreg on the second echo) end then apply distortion correction using blip-up/blip-down images (blip block) on the motion corrected dataset.
Then I want to compute the affine matrices and warping fields necessary for alignment and normalization to MNI space.
Once all the matrices and fields have been computed I want to apply them in a single transformation step on the remaining echoes.

How should this be implement in afni_proc.py?
So far, the only working solution I've found (although I am not fully happy with it) is to split the process in in two afni_proc.py scripts.
In the first one I do despike, tshift, volreg (motion correction to a reference volume) and then blip. In the second, I use the output of blip to do the align, tlrc and volreg blocks. The last volreg is to concatenate the align and tlrc steps.

After QC inspection, this procedure seems to work well. However, I would like to merge the two afni_proc.py scripts into a single one. I see I cannot put a volreg two times (-blocks despike tshift volreg blip align tlrc volreg) nor I can only keep one of them because I don't get what I want.
Do you know if is it possible to do what I am trying to do? But most importantly, is it conceptually sound?
Thank you very much for your help, and for your fantastic work developing and maintaining AFNI!
Best,

Giordano

Ciao, Giordano-

I think this should be accomplishable as a single afni_proc.py (AP) command. I'll mention this as a reference for various AP options and examples:

  • Reynolds RC, Glen DR, Chen G, Saad ZS, Cox RW, Taylor PA (2024). Processing, evaluating and understanding FMRI data with afni_proc.py. Imaging Neuroscience 2:1-52.

... and some script examples a link to the full GitHub page here.

And actually, I think one of the examples from the above paper basically covers what you want. Specifically, the 9th one, which is a multi-echo resting state processing, using nonlinear alignment to a volumetric template, and including blip up/down data. You should actually see it displayed fully if you run this command (because the afni_proc.py methods paper above is publication #3, and the "i" is the 9th letter of the alphabet):

afni_proc.py -show_example 'publish 3i'

AP does all the stuff of concatenating the transforms before applying that omnibus transform to the original EPI data.

Note that when we include nonlinear alignment in processing, 99% of the time we will suggest calculating it ahead of time and provide the affine+warp results to AP to use. That way, if you have to rerun and AP command, you don't have to rerun the computationally expensive alignment process. As an added bonus, we usually recommend using sswarper2, which will also give you a skullstripped (the "ss" in the program name stands for that) anatomical along with the estimated warps. We have an example of running sswarper2 before AP in the above GitHub repo, here, but the basic command in general is:

sswarper2                                                             \
    -base           "${template}"                                     \
    -subid          "${subj}"                                         \
    -input          "${dset_anat_00}"                                 \
    -odir           "${sdir_out}"

... and the above AP example shows how the outputs of that are loaded into AP, via the -tlrc_NL_warped_dsets .. option.

How does that seem?

--pt

I implemented the code, tested it and it works perfectly. Thank you very much!