Resting-state Functional Connectivity in AFNI

Dear all,

I wrote the following script shown at the end of my post to utilize resting-state FC measurements via AFNI. I have some basic questions concerning FC calculation. Some facts about my dataset and preprocessing with AFNI_proc:

  • TR=1s
  • No bandpassing in AFNI_proc
  • Physiological nuisance regression (of both respiration and cardiac signals) via RetroTS and the subsequent embedding of its result in AFNI_proc

First question: is it still necessary or suggested to use bandpassing in the first part of the script, that is in 3dRSFC (e.g. 0.01 to 0.1 Hz?), even though respiration and cardiac signals are regressed out? I read that bandpassing should not be applied in AFNI_proc when the preprocessed errts file is subsequently used for FC measurements in AFNI. At the same time, bandpassing is then used in 3dRSFC. Is the result then not the same, i.e., using bandpassing first in AFNI_proc or in a second step in 3dRSFC?

Second question: my script works. In the final (third part) of the script, that is, when using 3dGroupInCorr, I start AFNI via “AFNI -niml”, then I paste my 3dGroupInCorr script into the terminal (I am on a Mac), and AFNI recognizes the script. I can then select the seed voxel and inspect the correlation map via the AFNI GUI. However, I don’t understand where I can find the results such as the Z-scores etc. They are neither printed in the terminal, nor are there files created as output. I would really like to directly save the results as files, this is why I additionally used the “batch mode” of 3dGroupInCorr in the end. But again, it seems that no result files are created and saved even when using the batch mode. What am I missing?


Here is my script (currently only 2 subjects for testing are included)


for subject in Subject1 Subject2
for fMRIruns (errts.${subject}_Rest.anaticor+tlrc)

mkdir /volumes/sandisk/fmri/dataset/processed/$subject/Functional_Connectivity
cd $directory_subjects

-band 0.01 0.1
-input errts.${subject}_Rest.anaticor+tlrc
-prefix /volumes/sandisk/fmri/dataset/processed/$subject/Functional_Connectivity/$subject



mkdir /volumes/sandisk/fmri/dataset/Average_Values_RestingState

cd $directory_average

Combine functional masks into a group mask

-prefix 3dSetup_AverageMask
$directory_subjects/subject2/Preprocessing_RestingState/full_mask.Subject2_Rest+tlrc \

-mask $directory_average/3dSetup_AverageMask+tlrc
-prefix 3dSetupGroupInCorr

-setA /volumes/sandisk/fmri/dataset/Average_Values_RestingState/3dSetupGroupInCorr.grpincorr.niml
-seedrad 15
-labelA LFF_FC

Alternative: 3dGroupInCorr via its “Batch Mode”

cd /volumes/sandisk/fmri/dataset/Average_Values_RestingState

-batch XYZ /volumes/sandisk/fmri/dataset/Average_Values_RestingState/LFF_FC_Coordinates.txt
-seedrad 15
-setA /volumes/sandisk/fmri/dataset/Average_Values_RestingState/3dSetupGroupInCorr.grpincorr.niml

Hi Philipp,

I will defer to Paul for details on this, but some of the 3dRSFC computations expect that bandpassing has not been previously done, which is why 3dLombScargle was written. Bandpassing is not a preprocessing step in 3dRSFC, it is applied as part of the computation.

For the second question, note that you can save a dataset from the afni GUI. To save the overlay for example, consider:

Define Datamode → Saveas: OLay

To save an overlay from 3dGroupInCorr -batch, note that the FILE line format for XYZ/XYZAVE has an output “prefix” as the first term on the line. Most of the -batch methods include an output prefix. In your case, the LFF_FC_Coordinates.txt file should contain lines like:


  • rick

Dear Rick,

this is very good information. In fact, the solution to question number 2 was much easier than I thought. Both options, that is, the one via the GUI and the one via the -batch method work now.

I would have another question beside question 1 in my first post, also in relation to this topic. My dataset contains 25 subjects and I am analyzing three sessions:

  • One resting-state session (1 run per subject)
  • One task-based with 6 runs but processed as if it were a resting-state run (for dynamic measurements and their comparison with the resting-state session)
  • One task-based with 6 runs (same as above) but properly processed as task-based.

The dataset has physiological recordings (both cardiac and respiration) for almost all subjects and runs. However, some physiological recordings are missing:

  • Subject 3: cardiac and respiration recordings are missing for run 5 and 6
  • Subject 8: respiration is missing for run 6
  • Subject 16: both physiological recordings are missing for the resting-state

My question is if I should apply a bandpassfilter of 0.01-0.05 Hz for these subjects’ runs or simply preprocess these subjects’ runs without bandpassing, even though they will consequently lack physiological regression? I learnt all the deficits that come with bandpassing from you AFNI people and I generally try to avoid bandpassing now. I was just thinking if it is appropriate to skip the physiological regression in these specific runs without bandpassing and to proceed like this for further resting-state as well as task-based measurements.

Hi Philipp,

This is one difficulty with the physiological recordings. Sometimes they are bad or missing altogether. It would be messy to process subjects in multiple ways, with reviewers reasonably wondering whether those subjects have a meaningful affect on the results. That is to say, perhaps you might need to consider processing without that data.

Note that PC regression of the lateral ventricles is also done to hopefully regress out physiological artifacts. That would also be an alternative to the ricor block, but without the enormous penalty of bandpassing. But still, the same issue would remain with analyzing subjects in multiple ways.

Whatever you decide is reasonable to do, think through your justification.

  • rick