correlation matrix from multiple time series

Hi All,

I have a 1D file that has timeseries data from 200 ROIs (columns) and 187 volumes (rows).

So it has 200 timeseries, one for each ROI.

I want to multiply the time series from each ROI to the time series of every other ROI to create a 200x200 correlation matrix.

Is it possible to do that using afni ?

Can you please provide some example command line for starters.

That will be very helpful.

Many thanks

Ri

Hi, Ri-

As I contemplate the best way to do this with already-made time series in a 1D file, I just want to check—were these created by separately averaging time series within ROIs? If so, you could avoid this intermediate step, and use 3dNetCorr to create the matrix from the ROI map and the EPI time series directly:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/programs/3dNetCorr_sphx.html

–pt

Hi Paul that did the trick for me.

I did

3dNetCorr -inset rsfMRI.nii.gz -in_rois Parcellations/MNI/Schaefer2018_200Parcels_7Networks_order_FSLMNI152_2mm.nii.gz -fish_z -ts_wb_Z -prefix REST_corr

I checked the usage but I didn’t find a flag to set the diagonals to zero. Currently after fisher z transform, the diagonals are 4.

Please suggest

Many thanks

Ri

Hi, Ri-

Glad that worked.

There isn’t a flag to set the diagonals to zero for either the Pearson correlation or Fisher Z-transform output values. I don’t see why it would be necessary, and for Pearson r it should be one on the diagonals (for Fisher Z, it would be infinity, which is hard to store…; 4 is just a cutoff).

There is another reason not to want the diagonals to be uniformly zero: some people have ROIs with no data (e.g., a partial dataset being analyzed with a whole brain set of ROIs). The program by default will complain and not run—it wants to keep users from making an error, where bad alignment or some other mistake produces all-zero time series. But if you use “-push_thru_many_zeros” and “-allow_roi_zeros”, you can get a correlation matrix where the all-zero rows and columns are left in. The only way you can distinguish this outcome from just having tiny correlations is that the diagonal for these “all-zero” time series will then be zero.

Hope that makes sense.

–pt