AFNI version info (afni -ver): Mar 13 2024 (Version AFNI_24.0.12 'Caracalla')
Dear AFNI experts,
I am attempting to calculate correlation matrices between sets of ROIs in different networks/briks. I understand one is able to do this for one set of ROIs using the 3dNetCorr and I presume 3dTcorrelate may be the program for my question. However, if I understand correctly, 3dTcorrelate would do the correlation between two timeseries datasets whereas I have one timeseries dataset and two different sets of ROIs (belonging to two different resting state networks). I am not sure how to input both a timeseries dataset AND two different ROI masks. Below is the syntax I have so far without the timeseries data.
Just to make sure I understand, let's say you have 5 ROIs in network A and 7 ROIs in network B. Are you wanting the correlation of each ROI in network A with each ROI in network B (so, 7 correlation coefficients for each ROI in network A), and vice versa (so, 5 correlation coefficients for each ROI in network B)?
Or something else, like a 12x12 matrix, where each row and column is made up of a list of ROIs in network A and then those in network B? If your ROIs don't overlap at all, this would be possible with 3dNetCorr, even if you only want a subset of the values in the end.
I don't think 3dTcorrelate would be the tool for this, because it doesn't really do ROI-based calculations---it does voxelwise correlation between two time series datasets that are on the same grid.
Hi, Paul
Thanks so much for your response. I am attempting to do what you describe in the first instance. Each network has a different number of ROIs but it is possible that some ROIs overlap between networks. If I use 3dNetCorr, would I need to maybe create a mask of ALL ROIs (from all networks excluding overlaps) such that I can have one input for the -in_rois flag? Or is it possible to run the program between networks?
--joanah
Okeydoke, that is doable but not in a direct way, because of the overlapping ROIs. The way I would do this involves the following steps:
Use 3dNetCorr -ts_indiv ... separately on each network A and B to calculate the average time series for each ROI (in addition to the correlation matrices, which you might just ignore here). These average time series are stored as a row in separate text files names like ROI_*.netts that end up in the PREFIX output directory.
So, after this step (following the numbers in the previous example case) in the directory PREFIX_A/, you would have 5 ROI_*.netts files and in PREFIX_B/, you would have 7 ROI_*.netts files.
Then, you have to convert each to a column file, which you can do by looping over each and using 1dtranspose.
For example, in each of the directories PREFIX_A/ and PREFIX_B/, in tcsh syntax you could the following:
#!/bin/tcsh
# make a list/array of all relevant files
set all_ts = ( ROI*.netts )
# loop over list of files, processing each in turn
foreach ts_row ( ${all_ts} )
echo "++ Process file: ${ts_row}"
# get base part of filename; that is, BASE from BASE.netts
set ts_base = `basename ${ts_row}`
# transpose row to col file, and save
1dtranspose ${ts_row} > ${ts_base}_col.1D
end
Now, use 1ddot to calculate the correlation among the pairs of *_col.1D files. You might need to add the -dem option to demean the data, and -terse to simply output a correlation matrix. You can run this program on both sets of network files, and take the relevant entries you want.
That is, you might run: 1ddot -dem terse PREFIX_A/ROI*_col.1D PREFIX_B/ROI*_col.1D, and then from the above size of matrices you should get a 12x12 matrix, and you can select out the sub-rectangles that you want.
How does that sound?
--pt
ps: for the last step, there is also 1dCorrelate you could use instead of 1ddot, but that output format is a bit different because it also does confidence interval estimation.
Hi, Paul
I ran the correlations on my data based on your example and I am getting the output I was hoping to get - between-network correlation matrices. Thank you so much!
joanah
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.