spatio-temporal correlation?

Dear AFNIers,

Is there any program (o combination of programs) to compute a timeseries (.1D file) with the spatial correlation between a 3D+time dataset and a reference dataset? Or even more the spatio-temporal correlation if the reference dataset is also a 3D+time dataset with less bricks that defines an spatiotemporal pattern of interesting activity? This is to compute instants when a given spatial (or spatiotemporal) pattern exists within a dataset.

Any help will be highly appreciated.

Thanks very much