Two-stage alignment to template: grid and orig/tlrc confusion

Hi all,

I would be grateful for some more help…

As I said in the previous thread, my goal is to align an NHP T2 to the NMT template. Direct alignment does not work (in my hands) so I am using the same animal’s T1 as an intermediate.

Step 1 is to align T1 to the template using @animal_warper and that works fine.

Step 2 is to align T2 and T1 and I am using for that. I decided to go with rigid body alignment - both T1 and T2 have problems due to headpost artifacts and, in case of T2, incompleteness, and did not want these to possibly mess up with the entire volume by trying to introducing shear or size change. Direct comparison on a test animal does suggest that rigid body fits more sensibly than affine.

However, T2, though in the same animal, has a crucial difference - an enlargement of a gyrus due to treatment. This leads to misalignment of this region using rigid body - and that’s bad, because this is the area that interests me. I wish I had a T1 taken at the same time with the enlargement, but I don’t.

So I tried
Step 3, which is following the rigid body alignment with an additional non-linear warp using 3dQwarp. The logic (naive?) was that if the volumes are initially well aligned using rigid body, the non-linear warp will not mess to much and mostly affect the enlarged gyrus. With some tuning (mainly -noZdis and -nmi) this seems to be working.

The question is how I put all of this together. I have a linear and nonlinear T1-template warps from Step 1, a linear T2-T1 warp from Step2, and a non-linear T2-T1 warp from Step3.

My plan is to combine the linear warps using cat_matvec and the nonlinear ones with 3dNwarpCat, and then apply them to T2 with 3dNwarpApply, ending up with the T2 in the template space.

I can do the former, but the latter fails because the nonlinear warps are on different grids.

What is the best way to address that? My first idea was to resample the subject T1 using NMT as the master, and then perform Step 3. The alignment worked, but not only the FOV (correct term?) was wrong with much of the bottom of the brain outside the image, but 3dNwarpCat again said “warp from dataset ‘/media/sf_ACC_LESION/ALIGN/FROH/T2_NL_result/FROH_T2post_RB_NL_WARP+tlrc’ doesn’t match earlier input geometry”>

So I guess this not the correct approach… but what is?

Commands I’ve been using:

Step 1:

   @animal_warper -base                 ${templNMT}                     \
                  -input                ${subj}_T1pre_crop+orig        \
                  -atlas_followers      ${atlasNMT}                     \
                  -outdir               aw_results_T1                   \
		              -no_surfaces                                          \
	                -align_centers_meth   cm                              \
                  -skullstrip           ${brainmaskNMT}                 \
                  -maxlev               10                              \
                  -base_abbrev          NMT                             \
                  -input_abbrev         ${subj}                           \
                  -atlas_abbrevs        ARM

Step 2   -epi   ${subj}_T2post_crop+orig                      \
                      -anat  ${aligndir}${subj}/${subj}_T1pre_crop+orig    \
                      -epi_base               0                            \
                      -epi2anat                                            \
                      -partial_coverage                                    \
                      -rigid_body                                          \
                      -suffix                  _al_RB                       \
                      -anat_has_skull          yes                          \
                      -epi_strip               None                        \
                      -tshift                  off                         \
                      -volreg                  off                         \
                      -ex_mode                 echo                        \
                      -output_dir              AEA_results_T2              \
                      -big_move                                            \
                      -cmass                   cmass+xz                    \
                      -master_epi              BASE

Step 3

3dQwarp   -base             ${subj}_T1pre_crop+orig                      \
          -source           ${subj}_T2post_crop_al_RB+orig                  \
          -prefix           ${subj}_T2post_RB_NL                           \
          -resample                                                        \
          -nmi                                                             \
          -expad 10                                                        \
          -noZdis                                                          \
          -minpatch 19

Interesting, as usual…

The rigid_equiv might work for this application too, but I think the nonlinear warp is a good idea to add onto the rigid transformation. You may want to limit the nonlinear warping to stop and start at moderate levels (~4).

I’m surprised that you’re seeing an error like that. We regularly include nonlinear warps in native space and in template space with affine transformations in-between. 3dNwarpApply should handle that, but I would expect 3dNwarpCat to also handle that. You may want to send us those warps and transformations. The workaround is something like what you tried, but instead zeropad the grids to encompass both datasets. It’s useful to center datasets to start around the template to avoid making the zeropadding excessive.

Thank you. I did try messing with levels - though I think I asked it to start at 6 or 7, and to stop at a smallish patch. The idea was “do not touch the big picture, fix small differences”. For some reason this was taking ages to calculate and I ultimately stopped it and re-ran from level 0 which ran considerably faster.

As for 3dNWarpCat - if this is supposed to work as I tried, I think I will first do more checking. Maybe I made a dumb error somewhere.

To make sure that I understand:
If I want to make a T2 -to-T1 NL warp compatible (catenable) with a T1-to-template NL warp, resampling the T1 target of the T2-to-T1 to template resolution should suffice, correct? (supplemented with zero padding if necessary to keep everything fit in the image

That should work. Essentially, that is what is done internally for concatenations with nonlinear warps.