3dvolreg - Sequential Data Sets

Hi All,

I have two sequential data sets I want to compare. So I’d like to do some inter and intra registrations. The first is T2-weighted (DATA1), and the second is T1-weighted (DATA2), so different contrast. I am trying to work on the registration and I think I’ve progressed decently but there’s one part I would appreciate some guidance on, please.

I’ve registered the first data set with the following command:

3dvolreg -twopass -twodup -cubic -dfile Data1_RegParam -prefix Data1_Reg Data1+orig

So I’ve saved the motion parameters to ‘Data1_RegParam’. Now, I’d like to use the motion parameters from the last BRIK in DATA1 and use it to move the first BRIK in DATA2 (inter-registration). Then I can perform an intra-registration of DATA2 with the same command as above.

QUESTION: My question goes to the inter-registration part. How do I use the values of the motion parameters (below is what I get in my ‘dfile’) to move a BRIK in another data set? Please let me know if my questions doesn’t make sense and I can aim to clarify.

7 0.0519 0.2553 -0.0855 -0.1496 0.1732 -0.1117 3068 2452

Thank you in advance for any and all help.

Cheers,
Edwin

Hi, Edwin-

I have a few questions to clarify things in my mind first, if that’s OK:

  1. Are your DATA1 and DATA2 files each time series? 3dvolreg is normally for aligning time series (EPI volumes, not anatomicals). Normally I don’t see T1w or T2w time series, per se. For example, what is the output of:

3dinfo -nv -prefix DATA1 DATA2

  1. Are you just trying to assess motion (so only rotations+translations are expected to have occurred), or possible distortions (so shape changes may have occurred)?

  2. What is the spatial resolution of each dset? That is, what is the output of:


3dinfo -ad3 -prefix DATA1 DATA2

  1. Are you registering these volumes just to each other, or are you registering them to a standard space, as well?

When performing alignment, one has to choose:

  1. how much to let a volume “move” to look like another; that is, how many degrees of freedom to allow to change (can dset A change shape to look like dset B, and if so, by how much?)
  2. what the tissue contrasts of the dsets are-- is it the same, or different? This determines the choice of cost function.
    A lot of these things are discussed in the AFNI Bootcamp slides here:
    https://afni.nimh.nih.gov/pub/dist/edu/latest/afni_handouts/afni14_alignment.pdf

–pt

Hi PT,

Thank you for your response and time into this issue. In response:

  1. Yes, both are time series (3D + t, or 4D). ‘3dinfo -nv’ yields 8 and 13, respectively.

  2. Yes, just motion (translation + rotation). Not aiming to consider distortions or any non-rigid transformations at the moment. (I think you consider translation or motion as both rigid, but new to registering so pardon me if my jargon is incorrect).

  3. The resolution of both data sets are exactly the same, [0.1042 0.1849 0.2200], in mm.

  4. To each other I suppose you would say. I’m really trying to register DATA2 to DATA1. DATA2 is acquired directly after DATA1. So I want to ultimately compare voxels between the two data sets. So my initial aim is to use the motion of the last time point in DATA1 and copy it to the first time point in DATA2. Then I will register the rest of DATA2 to its first time point in hopes that voxels are relatively aligned for all DATA1 and DATA2. I hope that helps. Excuse me if that isn’t clear and I can aim to clarify further.

Thanks for the link to the bootcamp file. I will look it over.

Cheers,
Edwin

Hi PT/All,

After reading into the documents of different functions it seems like ‘3drotate’ is just what I need. I think I initially overlooked it because I presumed it was just pure rotation and didn’t realize you can also translate with it. I will try it out. Thanks for your time!

Cheers,
Edwin

Hi, Edwin-

Sorry for the delayed reply. So, you do have two 4D data sets, DATA1 and DATA2, with differing contrasts. Interesting.

To do find the “motion parameters” (i.e., solid body registration parameters) across time within each set, you could use 3dvolreg (because the contrast across time for each is the same); assuming that there is no motion or serious distortion within each run, you could use the [0]th or a middle run of each, say, as a reference volume for within-run registration. The output in each case would be a 4D dataset that should be motion corrected across time, and you can also export a file of the alignment parameters for each volume to your reference volume.

Taking an example from afni_proc.py-generated 3dvolreg usage (I chose the [5]th volume, for no really necessary reason):


#!/bin/tcsh

set all_dset = ( DATA1 DATA2 )

foreach ii ( `seq 1 1 $#all_dset` ) 

    3dvolreg \
        -zpad 1                               \
        -base 5                               \
        -1Dfile dfile.r$ii.1D                 \
        -prefix rm.epi.volreg.r$ii            \
        -cubic                                \
        -1Dmatrix_save mat.r$ii.vr.aff12.1D   \
        "$all_dset[$i]"
end

“mat.r$ii.vr.aff12.1D” will contain the alignment parameters for each time series, and dfile.r$ii.1D will be the 6 motion parameters you could plot with, say, 1dplot
(“1dplot -volreg dfile.r$ii.1D”, in each case, say).

To align across modalities, you would want ot use 3dAllineate and pick a cost function that is specific for the different tissue contrasts: namely, lpc (or its souped-up version, lpc+ZZ). For example,


3dAllineate \
    -base  DATA1'[5]'                             \
    -input DATA2'[5]'                             \
    -1Dmatrix_save mat.run2to1.aff12.1D      \
    -cost lpc                                \
    -warp shift_rotate            \
    -prefix  dset_2to1.nii

… which would only do solid body registration-- rotation+translation-- as written, becasue of the “-warp shift_rotate” option; if you wanted to allow for larger relative warps, up to 12 DOF affine alignment, then you could just alter/remove that. The matrix for that is mat.run2to1.aff12.1D. The ‘[5]’ subbrick selectors are there to align the reference volumes from each-- if you change the reference volume in the first part, it woudl make sense to change that to match.

To bring the whole 4D time series DATA2 into nice overlap with DATA1, you would want to concatenate the matrices (the ‘motion correction’ matrix from the first part with the inter-dataset alignment of the second part). To do that, one could:


cat_matvec \
    -ONELINE \
    mat.run2to1.aff12.1D \
    mat.r2.vr.aff12.1D \
   > mat.full_4D_run2to1.aff12.1D

… and then apply that


3dAllineate \
    -master  DATA1'[5]'                             \
    -input DATA2                             \
    -1Dmatrix_apply mat.full_4D_run2to1.aff12.1D      \
    -final wsinc5 \
    -prefix  full_DATA2_2to1.nii

… so that the full DATA2 time series should now be on the DATA1 grid, in good alignment with that dset’s volume ‘[5]’.

Does that make sense?

*small caveat to the above, I have just typed it, not actually run it with a dset, so please let me know if anything looks funny or a filename is wrong as you use that…

–pt