Coregistration of highres MT scan to EPI

AFNI version info (afni -ver): 25.0.07

Hi,

I have a highres magnetization transfer (MT) slab of the brainstem that I would like to coregister to EPI space (potentially through an anatomical image?).

What do you think would be the best way to do it? I thought of several scenarios that included align_epi_anat.py, 3dQwarp, cat_matvec and 3dNwarpApply, but I got somewhat confused with computing and concatenating transformation matrices.

Your help is appreciated. Please find below some example images.

Thanks,
Philipp

Example anatomical

Example MT slab

Example EPI

Are you expecting some distortion among these images that requires nonlinear warping?

I would probably align the MT to anatomical, the EPI to the anatomical, both with align_epi_anat.py. The MT to T1 anatomical alignment is the trickiest and would probably require the cost function to be lpc and the -partial_coverage option. If the MT and T1 are already aligned, then that is better, of course. If you already have the alignments already done, then you can invert and chain as you like to arrive in one of the 3 spaces (T1,EPI,MTR).

Hi Daniel,

thanks for the fast response!

I was indeed trying something like
align_epi_anat.py -overwrite -dset1 mt+orig. -dset2 anat+orig. -dset1to2 -partial_axial -dset1_strip None -dset2_strip None -edge -cost lpa

to get the mt2anat matrix and

align_epi_anat.py -overwrite -anat anatSS+orig. -epi epi+orig. -epi_base 0 -master_epi anatSS+orig. -epi2anat -dset1_strip None -dset2_strip None -partial_axial -rigid_body -edge -cost lpa -big_move

for the epi2anat matrix. I indeed had the impression that NL warping would help, therefore I ran

3dQwarp -overwrite -workhard -source anatSS+orig. -base epi_al+orig. -prefix anatSSQ -lpc -maxlev 0 -verb -blur 0 3

for the _WARP file.

I am just wondering how to concatenate them correctly for 3dNwarpApply, which I would use with the -iwarp flag?

Thanks,
Philipp

For example,
if I want to coregister the MT scan to EPI space, I use

cat_matvec -ONELINE epi_al_mat.aff12.1D -I mt_al_mat.aff12.1D > mt2epi.aff12.1D

where epi_al_mat.aff12.1D -I is the inverse of the aligned EPI to anatamical image (because later on, I want to go from anatomical to EPI space) and mt_al_mat.aff12.1D is the MT aligned with the anatomical image.
Together with the output from 3dQwarp (anatSSQ_WARP, which is the warp from the anatomical image to EPI), I finally use

3dNwarpApply -overwrite -nwarp "anatSSQ_WARP+orig. mt2epi.aff12.1D" -source mt+orig. -master epi+orig. -prefix mt_in_epi

Does this make sense? I am asking because when I do it like this, the alignment of the MT with the EPI (here brainstem) is somewhat off:

However, when I do it only with the warp file it looks better even though not perfectly aligned

3dNwarpApply -overwrite -nwarp "anatSSQ_WARP+orig." -source mt+orig. -master epi+orig. -prefix mt_in_epi

I wonder how this is possible.

Bests,
Philipp

The EPI to anatomical dataset almost never uses the nonlinear warp unless there is significant distortion. Verify the affine transformation concatenation first by itself with 3dAllineate -1Dmatrix_apply .

I see. I will try without the NL warping.

Do I understand correctly then that the concatenated matrizes mt2epi.aff12.1D was correct?

Thanks,
Philipp

Try reversing the order to this :

cat_matvec -ONELINE mt_al_mat.aff12.1D epi_al_mat.aff12.1D -I  > mt2epi.aff12.1D

One way to experiment with affine matrix concatenation is to use whereami's space transversing abilities. Create a SessionAtlases.niml file like this:

<TEMPLATE_SPACE
  space_name="A"
  generic_space="A"
  comment="Anat space"
></TEMPLATE_SPACE>

<TEMPLATE_SPACE
  space_name="E"
  generic_space="E"
  comment="EPI"
></TEMPLATE_SPACE>

<TEMPLATE_SPACE
  space_name="M"
  generic_space="M"
  comment="MT"
></TEMPLATE_SPACE>

# mni spaces to tlrc
<XFORM
  ni_type="12*float"
  ni_dimen="1"
  xform_name="E::A"
  source="E"
  dest="A"
  xform_type="Affine" >
  2 0 0 10
  0 2 0 0
  0 0 2 0
>
</XFORM>

<XFORM
  ni_type="12*float"
  ni_dimen="1"
  xform_name="M::A"
  source="M"
  dest="A"
  xform_type="Affine" >
  1 0 0 0
  0 1 0 0
  0 0 1 10
>
</XFORM>

Then use a command like this to show and compute the reduced transformation chain of affine transformations.

whereami -show_chain M E    
++ ----- Transform list: -------
M::A  -> E::A I
whereami -calc_chain M E
++ ----- Transform list: -------
M::A  -> E::A I
++ ----- Transform list: -------
M::E 
++ ----- Transform list: -------
xform: M::E
xform_type: Affine
xform source: M   dest: E
coord order: rai
xform dist: 1.000000  inverse: 0   post: 0   nelts: 12
0.500000 0.000000 0.000000 -5.000000 
0.000000 0.500000 0.000000 0.000000 
0.000000 0.000000 0.500000 5.000000 

++ -------