AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
January 08, 2014 12:21PM
You could use Unix redirection to redirect the output to a file or parse the output with something like grep, awk or sed. Alternatives to using 3dfim+ are 3dTcorr1D or 1ddot (and, per Ziad's recommendation, 1dCorrelate). In AFNI, "1D" files are the same simple text files of columns of numbers. For 3dTcorr1D, the usual input is a 3D+time dataset, but it can also be a single column of numbers. In that case, transposing the input with \' lets AFNI read it as equivalent to a 3D+time dataset with just a single voxel. The correlation is computed against each column of the second 1D file. In the example below, the output is stored in a file named testtcorr.1D using the supplied prefix. By default, the output would otherwise be named Tcorr.1D. The output has some extra information in there, but you can see just the resulting correlations with the 1dcat command.

3dTcorr1D -prefix testtcorr epi_r1_ideal.1D\' motion.1D

1dcat testtcorr.1D
0.0696493 -0.105526 0.0557999 -0.0381557 0.073944 0.0900172


1ddot deals with single and multiple column text files too. You may want 1ddot to demean the input vectors first with a command like this:

1ddot -demean epi_r1_ideal.1D motion.1D'{0..151}' > correlations.txt

Here the output has been redirected to a file, but you could also parse the output for just the correlations like this:

1ddot -demean epi_r1_ideal.1D motion.1D'{0..151}' | grep -A 9 "++ Correlation Matrix:" | tail -6
01: 0.06965 1.00000 -0.20283 0.80194 0.54886 0.92099 0.05400
02: -0.10553 -0.20283 1.00000 -0.08956 -0.27962 -0.19024 -0.16783
03: 0.05580 0.80194 -0.08956 1.00000 0.27395 0.80063 0.09023
04: -0.03816 0.54886 -0.27962 0.27395 1.00000 0.57706 0.11634
05: 0.07394 0.92099 -0.19024 0.80063 0.57706 1.00000 -0.02739
06: 0.09002 0.05400 -0.16783 0.09023 0.11634 -0.02739 1.00000

or get just the first column of correlations with:

1ddot -demean epi_r1_ideal.1D motion.1D'{0..151}' | grep -A 9 "++ Correlation Matrix:" | tail -6 | awk '{print $2}'
0.06965
-0.10553
0.05580
-0.03816
0.07394
0.09002

The 3dfim+ program will work similarly, but it only takes a single column input, and linear detrending is the default for the input1D time series. All these programs have slightly different options for removing the mean or detrending, so choose what's appropriate for your data. 1ddot does no detrending or demeaning by default but demeaning is an option. 3dTcorr1D does no detrending or demeaning, and it recommends using 3dDetrend separately. 1dCorrelate demeans by default.



Edited 2 time(s). Last edit at 01/08/2014 12:27PM by Daniel Glen.
Subject Author Posted

Correlating Resting State Networks

Emily January 07, 2014 02:53PM

Re: Correlating Resting State Networks

ziad January 08, 2014 12:01PM

Re: Correlating Resting State Networks

Daniel Glen January 08, 2014 12:21PM