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 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 th volume, for no really necessary reason):
set all_dset = ( DATA1 DATA2 )
foreach ii ( `seq 1 1 $#all_dset` )
-zpad 1 \
-base 5 \
-1Dfile dfile.r$ii.1D \
-prefix rm.epi.volreg.r$ii \
-1Dmatrix_save mat.r$ii.vr.aff12.1D \
“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,
-base DATA1'' \
-input DATA2'' \
-1Dmatrix_save mat.run2to1.aff12.1D \
-cost lpc \
-warp shift_rotate \
… 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 ‘’ 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:
… and then apply that
-master DATA1'' \
-input DATA2 \
-1Dmatrix_apply mat.full_4D_run2to1.aff12.1D \
-final wsinc5 \
… so that the full DATA2 time series should now be on the DATA1 grid, in good alignment with that dset’s volume ‘’.
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…