Project a 4D dataset onto a 3D (spatial regression)

Hi all,

is there any way in AFNI to compute the spatial correlation (or projection) between a 3d dataset (say a probabilistic map of a resting state network) and a 3d+time dataset (e.g. a preprocessed EPI volume time series, or better a time series of residuals after having regressed out potential confounds)? This should output a 1D timecourse.

This is similar to what 3ddot does, but without the need to compute all the correlation pairs: just the correlation between a reference 3d template and all the time points of a 3d+t dataset.

I have the feeling that this was discussed many years ago, but I cannot find the topic anymore...

thanks for any comments!


Hello Giuseppe,

I hope I've accurately understood your goal. Would the first row in the output of the following command yield the result you are seeking?

3ddot -demean 3d.template 3d+t.dataset


Hello Gang,

thanks for the quick reply. Yes, I think that works, but I was wondering whether there was some time-saving shortcut to avoid computing all the pairwise correlations. The note in the help message saying "This program is not efficient when more than two subbricks are input." made me think that maybe there was an alternative way.

very best


Suppose there are 100 sub-bricks in your 3d+t.dataset file. How about the following script?

foreach ii (`seq 0 99`) 
  3ddot -demean 3d.template+tlrc"[0]" 3d+t.dataset+tlrc"[${ii}]" >> giuseppe.1D


I was just about going that way... :-) Thank you again Gang!


Hi Giuseppe,

You can probably also abuse the way output comes using head:

3ddot -demean 3d.template+tlrc"[0]" 3d+t.dataset+tlrc | head -n 1 > giuseppe_test2.1D
  • rick