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