causes my brain to become UNALIGNED


Using, I was unable to achieve good alignment, so I did a manual alignment, to make’s job easier.

Instead, my brains, which were aligned in original space, became unaligned in Talairach space.

Here is the command I use: -anat2epi -anat ${subj}_mpra+orig
-save_skullstrip -suffix _al_junk
-epi ${subj}_run${run}+orig -epi_base 78
-epi_strip 3dAutomask
-volreg off -tshift off

After Talairaching the anatomy and doing volume registration on the functional data, the volreg, epi2anat and tlrc transformations get catenated, using the following:

cat_matvec -ONELINE                                               \
           ${subj}_mpra_ns+tlrc::WARP_DATA -I                       \
           ${subj}_mpra_al_junk_mat.aff12.1D -I                     \
           mat.r0$run.vr.aff12.1D > mat.r0$run.warp.aff12.1D

Because I already aligned the EPI and anal images by hand, the epi2anat transformation shouldn’t be very much.

Yet the Talairached images are poorly aligned.

Please help me if you can.

I can send along script and data sets, as needed.


Jim Waltz

Hi, Jim-

A few thoughts on this:

  1. Each alignment step of those can/should be checked individually; each alignment is calculated individually, and that is the time to look at output/base comparisons as overlay/underlay. Looking at the final result leaves too much of a question of “which alignment step let the team down”-- probably, it is just one; but even if it is more than one, this can only be checked effectively step-by-step.

  2. And I generally think in cases like this: let’s use for this; are you? the code snippets look reminiscent, but then you don’t have to worry about doing the concatenations yourself and possibly having some small badness/type creep in along they way. Related to #1,’s automatic HTML QC will output images of epi-to-anat alignment and anat-to-template alignment. For free. So you have no extra work. And this would answer the question of where the problem might be.

  3. In modern times, I have only see the need for “nudging” a dataset for alignment in the case of a single-slice-to-whole-brain alignment. I don’t think that is your case here? First thing to check: is there a big difference (either rotationally or center-of-mass-wise) between any pair of dsets you are aligning? That makes alignment trickier, yes, but we still have options to help deal with these things-- in, one would use “-ginormous_move” to overcome some of those challenges; likewise, using “lpc+ZZ” as a cost function for EPI-T1w anatomical alignment is good, to have extra stability piled onto lpc’s excellent abilities. In, one would use "

-align_opts_aea -cost lpc+ZZ    -ginormous_move

You can load up the EPI and T1w volume as overlay and underlay, for example, in the AFNI GUI to see how much they overlap to start.

Similarly, for aligning anatomical to template space, “@SSwarper” is the best tool, which combines skullstripping (the “SS” part of the name") with nonlinear alignment. This is run before, and then its results are handed to the program to use efficiently+wisely. This program also has a “-giant_move” option, if the datasets start off far apart.

  1. All of the above is predicated on having dsets with no large, other features (these aren’t infant brains with different/low contrast; these aren’t odd partial field of view; these aren’t veeeery low contrast/quality; the anatomical is T1w, and so lpc(+ZZ) is an appropriate cost function for that step; etc.). AFNI can handle other situations, but then some other considerations would apply.



Including the options:

-cost lpc+ZZ -ginormous_move

fixed 4 out of 5 alignments.

My version of AFNI is too old to include -align_opts_aea as an option.

There is still an offending data set, and I was wondering if I could share it with you, along with my script.

This is a script that my data analyst developed about 5 years ago (she has since moved one). I think it was developed with, but I have since split it up into multiple scripts, so that I can check the results of the individuals steps.

These are brains from adolescents and young adults, who move a lot.


Jim Waltz

Hi, Jim-

Glad some of those opts sorted things out. I shudder to think how old that version of AFNI is… I would encourage you to update it!

I would also suggest making/using itself, because it would be more easily maintainable+tweakable over time. At the bottom of The Script That Hath Been Passed Down Over Generations, is there the command that generated it (or, that generated its initial form)? We might be able to help retro-fit that process, or start from scratch to make one that has the same features.

Also, a major reason to both update your AFNI version and to use to setup your processing pipeline is that produces several helpful, automatic QC tools, including a table of important values; a driver script to open dsets for you to review; and a full HTML of several aspects of your data:
With this functionality, it is possible to very efficiently (and, importantly, systematically!) review the various aspects of processing.

Happy to check out the problematic dsets, sure.