Nonlinear registration for hires slab

Hi all,

as promised in my last thread "3dNwarpApply error: Warp dataset ‘nwarp native_al_mat.aff12.1D’ name is too much like a matrix text file " and encouraged by ptaylor :slight_smile: I would be happy to discuss nonlinear registration of my data set. As you can see from the attached image “ROI_alignment_comp” the affine transformation was not successful - the red circle (manually drawn) is where the ROI should be after transformation and the blue patch is where the region actually is. Following is my plan and a description of my data:

I want to use several ROIs from an atlas that depict nuclei in the brainstem, hence it is necessary to transform the ROIs from the atlas via a T1 structural image to native (subject) space that looks similar to a T2 contrast. The caveat is that the native space image is high resolution but only covers a relevant part of the brainstem as can be also seen in the attached image.

The atlas is in MNI space with 1x1x1 mm resolution (MNI152_T1_1mm).
The individual T1 anatomical has 0.7x0.7x0.7mm resolution
The target native space has 0.4x0.4x0.4 mm resolution (but only covers a part of the brainstem)

I took a first step with 3dQwarp and 3dNwarpApply but the results were not satisfactory.
In more detail, I conducted the following steps (also following the SAMPLE USAGE ~1~ in the help file AFNI program: 3dQwarp):

3dWarp -overwrite -quintic -deoblique -prefix anat orig_T1_UNI-DEN.nii.gz
3dWarp -overwrite -quintic -deoblique -prefix target_native mtc.nii.gz
3dWarp -overwrite -quintic -deoblique -prefix mni MNI152_T1_1mm.nii.gz

3dUnifize -prefix anat_U -input anat+orig
3dSkullStrip -input anat_U+orig -prefix anatT1_U_brain -niter 400 -ld 40

#Linear registration of the target_native space to the anatT1 image -overwrite -dset1 target_native+orig. -dset2 anat_U+orig. -dset1to2 -partial_axial -dset1_strip None -dset2_strip None -edge -cost lpa

#Affine registration of the skullstripped anatT1 to MNI space
3dAllineate -prefix anatT1_to_MNI -base mni+tlrc -source anatT1_U_brain+orig. -twopass -cost lpa -1Dmatrix_save anatT1_to_MNI.aff12.1D -autoweight -fineblur 3 -cmass -twobest MAX -source_automask

As can be seen in the attached pic “transformation_steps”, row A, there is some deviation.

#Nonlinear warping of the affine transformed anatT1 to MNI space and saving the inverted warp field for later
3dQwarp -prefix QA_anatT1_to_MNI -blur 0 3 -base mni+tlrc -source anatT1_to_MNI+tlrc -iwarp

As can be seen in the attached pic “transformation_steps”, row B, the deviation is reduced but not gone.

Inverting and concatenating the transformation matrices from align_epi_anat (MNI–>target_native) and from 3dAllineate (MNI–>anat)

cat_matvec -ONELINE anatT1_to_MNI.aff12.1D -I target_native_al_mat.aff12.1D -I > mat_MNI_to_target_native.aff12.1D

Inverting the atlas ROI from MNI–>target_native space

3dNwarpApply -prefix mni2target_native_warped -source mni+tlrc -master target_native+orig. -nwarp QA_anatT1_to_MNI_WARPINV+tlrc mat_MNI_to_target_native.aff12.1D

As can be seen in the attached pic “transformation_steps”, row C (and ROI_alignment_comp), the inversion was not.successful.

Happy to learn more about how to improve the registration!


Hi, Philipp-

Well, I guess I asked for it… Silly me.

In the transformation_steps.jpg image you sent, is Panel A-left really a subject native space thing? It looks like a template.

Just to check about deobliquing, can you generate the following images:

@djunct_overlap_check \
    -ulay orig_T1_UNI-DEN.nii.gz  \
    -olay MNI152_T1_1mm.nii.gz   \
    -prefix olap_t1_mni


@djunct_overlap_check \
    -ulay target_native mtc.nii.gz  \
    -olay orig_T1_UNI-DEN.nii.gz  \
    -prefix olap_epi_t1

Each will likely make 2 images (one ignoring obliquity values, and one applying them), and it would be good to see both—because of a quirk of the MB underlying software, this might require 2 replies (because I think the most images that can be uploaded per post is 2).

Let’s start there…



“Well, I guess I asked for it… Silly me.”
I am still happy that you did :slight_smile: The procedure turns out to be far more complex than I expected.

“In the transformation_steps.jpg image you sent, is Panel A-left really a subject native space thing? It looks like a template.”
You are right, the left image in rows A and B is the MNI152_T1_1mm.nii.gz template. The respective image on the right is the coregistered anatomical T1 image, in row A via 3dAllineate and in row B via 3dQwarp. The MNI152_T1_1mm image is the template I want to coregister the individual anatomical image to.

Is the order correct?

-ulay orig_T1_UNI-DEN.nii.gz
-olay MNI152_T1_1mm.nii.gz
-prefix olap_t1_mni

I am asking because here it looks as the MNI template was registered to the anatomical T1, while the other way around is true in my case.

Please find attached images of the respective output.