Dear AFNI users,
I’m looking for a way to compute an NxM (rectangular) correlation matrix - meaning that I would like to compute a correlation score (based on timeseries) for each voxel of a given brain area (containing 503 voxels) with the rest of the brain (whole brain mask).
I tried to use 3dNetCorr or @ROI_Corr_Mat but it seems that these programs only deal with NxN matrices. Am I wrong?
Would anyone have an idea to suggest me?
Thank you in advance for any help!
So for each voxel in the brain, you want the correlation
with each of the 503 voxels in an ROI? That would be a
503 x 100000 element matrix, say. Is that right?
If so, then maybe 3dAutoTcorrelate will do that, where
the 503 voxel mask might be provided via -mask, and the
brain mask might be provided via -mask_source. Note that
the output would be a 530 ‘time point (voxel index)’
Please see the -help output for details. The ‘Example’
there might match what you are doing.
Note that you can calculate whole brain correlation maps with 3dNetCorr; so, you would get a 503x503 matrix of those ‘regions’, and then you would get 503 whole brain correlation maps which is essentially your 503 x Nvoxels; and as Rick noted, Nvoxels might be really large.
Thanks to you two for your answers!
Yes it is exactly what I mean a 503x100000 voxels (for example). Thanks, I’m going to try these options.
But indeed, as you point out it would give a very large matrix …
Actually, I was wondering if it is possible to use a different grid for both inputs? : for example a 2x2x2 grid for the region of interest of 503 voxels, and a resample grid to 4x4x4 for the whole brain mask. (in order to reduce the computing time).
The direct way to do this would be to
- extract the 503 time series from the ROI using a command like
3dmaskdump -noijk -mask ROImask.nii -o ROIdump.1D timeseries.nii
- transpose the output file so that each column is a voxel timeseries, rather than each row
1dtranspose ROIdump.1D > ROIts.1D
- Produce a 503 sub-brick dataset of the correlation of each column with all voxels:
3dTcorr1D -pearson -prefix ROIcorr.nii -mask Brainmask.nii timeseries.nii ROIts.1D
The i-th volume in the output dataset ROIcorr.nii will have the correlations of the i-th column in ROIts.1D with all the voxel timeseries from ROIts.1D. If you now want to extract all those to a text file, you can do that with 3dmaskdump. Note that this would be a pretty big file: 503 correlations times (say) 100,000 brain voxels = 50.3 million numbers in text form.
After you extract the 503 time series into a text .1D file (as described in my earlier post), you could correlate them with any other dataset, not just the one they were taken from. So you could downsample the original dataset. Which (unless it was already blurred) should be done with a little bit of blurring first (3dmerge -1blur_fwhm 4 …, or 3dBlurInMask -FWHM 4 …) followed by 3dresample.
THANK YOU! That was extremely helpful!
I will do that!