@auto_tlrc Not Automatically Applying "-xform"

Hi again AFNI team,

A common issue with our dataset is having 3dWarpDrive not converge in the @auto_tlrc command which causes very warped volreg. For these subjects, we have to manually re-run them in a new script adding “-xform shift_rotate_scale” to the @auto_tlrc command. However, on the @auto_tlrc help page, it says this is supposed to be done automatically. We are using an up-to-date AFNI version (22.3.06), and can’t think of any other reason why this wouldn’t be happening for us. Here is the terminal output from that portion of the script as well:

"@auto_tlrc -base MNI_avg152T1+tlrc -input AP1009B_anat_ns+orig -no_ss

*********** Warning *************
Dataset centers are 52.583877 mm
apart. If registration fails, or if
parts of the original anatomy gets
cropped, try adding option
-init_xform AUTO_CENTER
to your @auto_tlrc command.


Padding …
++ 3dZeropad: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
++ output dataset: ./__ats_tmp__ref_MNI_avg152T1_15pad+tlrc.BRIK
Resampling …
++ 3dcalc: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
++ Authored by: A cast of thousands
++ 3dcalc: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
++ Authored by: A cast of thousands
Clipping -0.000100 1004.000100 …
++ 3dcalc: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
++ Authored by: A cast of thousands
++ 3drefit: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
++ Authored by: RW Cox
++ Processing AFNI dataset __ats_tmp___rs_AP1009B_anat_ns+tlrc.HEAD

  • changing dataset view code
  • Changed dataset view type and filenames.
    ++ 3drefit processed 1 datasets
    ++ 3drefit: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
    ++ Authored by: RW Cox
    ++ Processing AFNI dataset __ats_tmp__resamp_NN+tlrc.HEAD
  • changing dataset view code
  • Changed dataset view type and filenames.
    ++ 3drefit processed 1 datasets
    ++ 3drefit: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
    ++ Authored by: RW Cox
    ++ Processing AFNI dataset __ats_tmp__resamp_edge_art+tlrc.HEAD
  • changing dataset view code
  • Changed dataset view type and filenames.
    ++ 3drefit processed 1 datasets
    Registration (cubic final interpolation) …
    ++ 3dWarpDrive: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
    ++ Authored by: RW Cox
    ++ Initial scale factor set to 0.30/138.00=4.6e+02
    RMS[0] = 0.41776 0.3268 ITER = 50/50
    0.41776

Warping used up maximum iterations of 50
Convergence might not have
been reached.
Doubling number of iterations

++ 3drename: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
++ THD_rename_dataset_files: rename __ats_tmp__reg_warpdriveout+orig.HEAD → __ats_tmp__reg_warpdriveout_maxed_iters+orig.HEAD
++ THD_rename_dataset_files: rename __ats_tmp__reg_warpdriveout+orig.BRIK.gz → __ats_tmp__reg_warpdriveout_maxed_iters+orig.BRIK.gz
++ 3dWarpDrive: AFNI version=AFNI_22.3.06 (Nov 15 2022) [64-bit]
++ Authored by: RW Cox
++ Initial scale factor set to 0.30/138.00=4.6e+02
RMS[0] = 0.41776 0.3268 ITER = 100/100
0.41776

Warping used up maximum iterations
even after doubling number of iterations to 100.
Convergence might not have been reached.

If you find the alignment poor, try
rerunning the script with a transform
type of fewer parameters (-xform) or by using
an even higher number of iterations (-maxite).
You can also choose to continue with the
current result (dset: __ats_tmp__reg_warpdriveout+orig
by using the option: -OK_maxite

Accepting result per user’s choice."

Thank you for your help!
Sincerely,
Ian

Hi, Ian-

The output text suggests that the overlap of the two datasets is poor to start with. We can check that visually—what is the output of this:


@djunct_overlap_check \
    -ulay AP1009B_anat_ns+orig \
    -olay MNI_avg152T1+tlrc

… which might produce 2 images, if either of the ulay/olay contains obliquity in the header.

Also, can I ask the context that this is being run in? Is this part of an FMRI processing pipeline?

thanks,
pt

Hi pt,

Thanks for the response! I have attached the output here. It looks like the initial alignment is not great. I tested using “-init_xform AUTO_CENTER” with the @auto_tlrc command just to check, but the same result occurred (convergence not being reached and output being warped). And yes, this is an fMRI processing pipeline. I think the “-xform shift_rotate_scale” option works well for us, my main question is whether it can be applied automatically like it says in the help file (since it would save a lot of time re-running subjects!).

Sincerely,
Ian

Hello again Paul,

I was hoping to check-in one more time about this. I originally found the solution to this problem from the @auto_tlrc help page. Specifically, here:

“1- Oh my God! The brain is horribly distorted (by Jason Stein):
The probable cause is a failure of 3dWarpDrive to converge.
In that case, rerun the script with the option
-xform shift_rotate_scale. That usually takes care of it.
Update:
The script now has a mechanism for detecting cases
where convergence is not reached and it will automatically
change -xform to fix the problem. So you should see very
few such cases. If you do, check the skull stripping
step for major errors and if none are found send the
authors a copy of the command you used, the input and base
data and they’ll look into it.”

But, it also says here that the script is automatically supposed to change -xform when convergence isn’t reached. However, it ends up providing the terminal output from my initial message, and I then always have to reprocess the subject after adding “-xform shift_rotate_scale” manually in the script. I made sure I am using the latest AFNI version and that everything else is up to date, in case that was the problem. This is part of our standard preprocessing pipeline, so it would be super useful if the script automatically changed -xform without having to re-run the entire script. Please let me know if I’m misunderstanding something here, and thanks so much for your help!

Sincerely,
Ian

A few recommendations:

  1. Use @SSwarper instead of @auto_tlrc. It will compute a transformation to an updated version, MNI152_2009_template_SSW.nii.gz (2009c asymmetric) of the MNI template using both an affine and a nonlinear alignment, and it will skullstrip the data too. The output can be used easily with afni_proc.py for an FMRI pipeline.
  2. Use the MNI152_2009c template (MNI152_2009_template.nii.gz) with @auto_tlrc. The original MNI-152 template is very blurry, and that seems to cause some problems getting a good alignment.
  3. auto_warp.py - includes the nonlinear alignment, and it calls @auto_tlrc. Again with the MNI 2009c asymmetric in our distribution.

I would give priority to the first choice which is pretty robust to lots of different kinds of data. If you really want to make this work with @auto_tlrc and the original MNI152 with your data, I would need a copy of some example data, and I can look into it.