Program name: corrAnalysis
Function: Voxelwise correlation and partial correlation analysis of imaging data.
Author: Babak A. Ardekani, Ph.D.
Usage:
corrAnalysis [–v] [–c variable codes file] [–FWMH FWHM]
[–m mask] [–o prefix] [–pvox voxel p-value] [–pclus cluster p-value]
[–cc size] [–x column] [–y row] [–z slice] –d datafile
Required argument:
–d datafile
This argument specifies a text file containing a table to be used in the correlation or partial correlation analysis. The first column in this file should include the image filenames, possibly including pathnames. The images are expected to be in ANALYZE format and of type ‘short’. The subsequent columns should contain numerical variables used for computing voxelwise correlations or partial correlations with the images. An example datafile may be:
FA/C375FA.hdr 1.0 1 1.0 18.0
FA/C380FA.hdr 2.0 1 3.0 14.0
FA/C499FA.hdr 3.0 0 2.0 -15.0
FA/C510FA.hdr 4.0 0 6.0 17.0
FA/C520FA.hdr 1.0 1 5.0 -17.0
FA/C557FA.hdr 2.0 1 8.0 -17.0
FA/C661FA.hdr 3.0 0 7.0 15.0
FA/C663FA.hdr 5.0 0 9.0 12.0
FA/C671FA.hdr 3.0 1 9.0 14.0
FA/C683FA.hdr 1.0 1 1.0 -18.0
FA/C704FA.hdr 1.0 1 3.0 -14.0
FA/C713FA.hdr 1.0 1 3.0 -16.0
FA/C741FA.hdr 1.0 0 8.0 12.0
FA/C745FA.hdr 1.0 0 7.0 13.0
Here, the first column specifies 14 images ‘C*FA.hdr’ in a directory named ‘FA’. These images are assumed to be spatially registered, and have equal matrix size and number of slices. The remaining columns specify 4 numerical values associated with each image.
Optional arguments:
–c variable codes file
Specifies a text file containing an integer code for each column of datafile. The integer codes can only be 1, -1, or 0. For example, corresponding to the above datafile, the codes could be:
1 -1 0 1 -1
When code 0 is specified for a column, the program ignores the variable, that is, the variable is not used in any computation. When code -1 is given, the corresponding columns are ‘partial-ed out’ (‘controlled for’) in the process of computing the partial correlations map. Only two columns may have code 1, which signifies the columns for which correlations or partial correlations are to be computed. Therefore, in the above example, the program would compute the partial correlations between columns 1 (the voxel values) and 4, while controlling for the variables in columns 2 and 5, and ignore the variable in column 3.
As another example, the following code ‘1 1 0 0 0’ simply computes the Pearson’s correlation between the voxel values and the variable in the second column. The code ‘1 1 1 0 0 -1’ results in an error condition since more than two columns are assigned code 1. The code ‘-1 1 1 0 0’ also results in an error condition, because the first column (i.e., the voxel data) should always be one of the two variables used for computing correlations. Whenever an error condition is detected in the format of the variable codes file, the program reverts to its default code, which is code 1 for the first two columns and code –1 for the remaining columns. In the above example, the default code would be ‘1 1 -1 -1 -1’
–cc size
After thresholding the correlation map (spm_r) according to the specified p-value(s), only spatially contiguous clusters of size voxels or greater are retained in the output files: prefix_cluster_r and prefix_cluster_t. That is, clusters of size less that size voxels are eliminated.
–FWHM FWHM
Specifies the full width half maximum in millimeters of a Gaussian filter that is applied to all input images before correlations are computed. Default FWHM=0.
–m mask
This option specifies an ANALYZE image of type ‘short’. Voxels where the mask image value is zero are not used in the analysis. Correlations are computed at all non-zero voxels of the mask (regardless of their sign). If no mask image is specified, all image voxels are analyzed.
–o prefix
This option can be used to specify a prefix for the output images. The program outputs up to four images: (1) prefix_spm_r, (2) prefix_spm_t, (3) prefix_cluster_r, and (4) prefix_cluster_t. The image prefix_spm_r contains the (partial) correlation coefficients computed for every voxel. The image prefix_spm_t contains the t-values corresponding to the correlation coefficients in prefix_spm_r. Images prefix_cluster_r, and prefix_cluster_t contain the voxels that survive thresholding operations performed on prefix_spm_r and prefix_spm_t, respectively. Images prefix_cluster_r, and prefix_cluster_t are only created if the –pvox option is specified. All output images are in ANALYZE format and are of type ‘float’. The program also outputs a log file prefix.log. The default value of prefix=CA.
–pvox voxel p-value
When this option is specified, the computed correlation map (prefix_spm_r) and its corresponding t-map (prefix_spm_t) are thresholded at the specified p-value using a two-tailed test. The thresholded maps are saved in prefix_cluster_r and prefix_cluster_t, respectively.
–pclus cluster p-value
This option specifies a cluster level p-value requiring that all clusters that survive the first level of thresholding (specified using the –pvox option) include at least one voxel with a p-value of cluster p-value or lower. When this option is selected in addition to the –pvox option, tests become more conservative, that is, a smaller number of voxels survive thresholding operations performed on the correlation map or equivalently on its corresponding t-map.
–v
Puts the program in verbose mode.
–x column –y row –z slice
These options are intended to testing the software. When specified, a table in created and written to the file ‘voxel.dat’. This table can be ported into the statistical programs (e.g., SPSS) and used to compare the (partial) correlations computed by these programs and the ones computed by the ‘corrAnalysis’ program for the specified voxel.
Outputs:
The program outputs up to four images: (1) prefix_spm_r, (2) prefix_spm_t, (3) prefix_cluster_r, and (4) prefix_cluster_t. The image prefix_spm_r contains the (partial) correlation coefficientss computed for every voxel. The image prefix_spm_t contains the t-values corresponding to the correlation coefficients in prefix_spm_r. Images prefix_cluster_r, and prefix_cluster_t contain the voxels that survive thresholding operations performed on prefix_spm_r and prefix_spm_t, respectively. Images prefix_cluster_r, and prefix_cluster_t are only created if the –pvox option is specified. All output images are in ANALYZE format and are of type ‘float’. The program also outputs a prefix.log file containing the same information that are printed on the screen when the program is running.
Bugs:
Please let me know if you find any!
Theory: Let y be a (n´1) matrix representing measurements of a variable from n different subjects. For example, y could represent heights of n different individuals in centimeters. Let z be another (n´1) matrix representing some other measured variable on the same n subjects, for example, their weights in kilograms. In addition, let X be a (n´p) matrix with n>p, representing p other variables associated with the n subjects, where each column of X represents one of the variables. We would like to compute the partial correlation between y and z while correcting for the variables in X. The matrix X defines a subspace of dimension q£p, where q is the rank of X. Any given vector can be projected onto this subspace by pre-multiplication with a projection matrix PX, where
![]()
and
is a generalized
inverse of the (p´p) matrix
The component of
vector y perpendicular to this subspace can be obtained as:
![]()
Similarly, we can find z^, which is the component of the vector z perpendicular to the subspace spanned by X. The partial correlation between y and z correcting for X is simply the Pearson product moment correlation coefficient between y^ and z^. To test the statistical significance of the partial correlation, we compute an F statistic with 1 and n-2-q degrees of freedom as follows:
![]()
where E1 is the variance (energy) in the mean-corrected y^ that is contained in the direction of the mean-corrected z^ only, and E is the total variance (energy) in the mean corrected y^. Mean-correction refers to the process of subtracting the mean of the elements of a vector from each of its element. Note that the square of the partial correlation coefficient equals to the ratio of E1 to E. That is, it represents to fraction of the total variance in the mean corrected y^ (i.e., E) that is explained by the component of the mean-corrected y^ that lies in the direction of the mean-corrected z^.