ANATICOR, WM and motion regressors

Dear AFNI experts,

I am processing resting-state data with a script with slight modifications to the one generated by Example 11 from
Just for a recap, this pipeline uses, Freesurfer outputs of the T1 and ANATICOR. It doesn’t include band-pass filtering but I have added that myself to the pipeline.

I have a few questions related to this pipeline and I was hoping AFNI experts could help me with those.

  1. One step that I add at the end of the pipeline is that I take certain number of PCA components (say 1, 3 or 5) of the white-matter signal and regress them out of the final residual time-series. My idea is that if the white-matter noise has been taken care of by ANATICOR, then these regressors should not change the time-series, and the resulting connectomes too much. It turns out that the resulting connectomes change, sometime quite a lot. I have attached a scatter plot between connectomes to illustrate this point.
    I guess my question is: should this be happening? and also, can we think of ANATICOR and regressing out PCA components of the white-matter signal as complimentary processes, where they can both help with denoising?

  2. When computing enorm from the motion parameters, should we worry about the fact that three of the parameters are linear displacements, while the other three are angular? Should we somehow convert the angular parameters into linear parameters before computing something like enorm or FD?

  3. My EPI dataset has an isotropic resolution of 4x4x4 mm3. What would you recommend as a suitable radius for the localized ANATICOR regressors?

Thanks for this amazing pipeline and I love the QC html that is generated at the end.



Just wanted to give it another nudge. Anyone?


Hi, Kausar-

Sorry for the delay. Answering in order of increasing difficulty:

Re. Q2:
It’s a good question. Indeed, adding things with units of [deg]^2 and [mm]^2 should make any physicist/engineer’s stomach churn. However, in this case, another factor is that: for an object about the size of a human head, rotation by 1 deg ~ translation by 1 mm at the edge. So, if we are considering “largest motion” estimates, which would be at the edge, this equation works out pretty well for human adults. For macaques, mice, etc. it might be a less good approximation-- basically, rotation is perhaps a bit “underweighted” – but it is still probably pretty reasonable. At the end of the day, we want a parameter that jumps up big if any of the 6 motion parameters is big, while also small if they are all pretty small, and the L2-norm form of the “enorm” parameter does well with that.
Bonus point: the enorm plots in the “mot” block of the QC HTML actually does acknowledge this funny units combination: the units of the plot are “~mm”, meaning “approx. mm”, because of the above considerations.

Re. Q3:
Pretty big voxels (but not unheard of for human FMRI). One consideration with anaticor is that you don’t want the tissue-based masks for ANATICOR regressors overlapping with GM, because then you will crush your GM response locally. This is one reason we recommend using eroded white matter (WMe) masks, rather than pure WM, and similarly for ventricles (if using those). So, I hope you are using those? Partial voluming with such large voxels will be a concern. Actually, if you erode the masks, how much of a WM skeleton do you have left for the ANATICOR procedure?

Re. Q1:
That is an interesting way to think about “checking” to see how much anaticor is doing. I have to think about this a bit (drat). But just to be more clear-- could you please describe what exactly you are showing in the matrix plot and in the Pearson correlation value plots? For example, in the matrix plot, did you take the same set of connectomic ROIs and calculate the average time series in each while processing with just anaticor (set A) and then separately calculate the average time series in each while processing with anaticor+PCA (set B), and then is this matrix the correlation matrix of set A with set B?

In general, I think you could combine PCA with ANATICOR; I thought some examples use PCA from ventricles and anaticor from WM? Just remember that as you add more regressors, you use up more degrees of freedom (DF). If you also add in bandpassing (are you suuuuure you need to?), that will use up a HUGE amount. I’m curious how many degrees of freedom you have left after that (esp. if there is any subject motion)? Of course, your friend the QC HTML can tell you that (and might even warn you about DF usage…).


Hi, Paul-

Thanks for the reply. That was a long post by me, I agree. Sorry about that :slight_smile:

Q2: I had noticed the ~mm thing but I love these little tidbits about AFNI :slight_smile: I think I agree with you that enorm does the job that it’s supposed to be doing.

Q3: Partial volume effect was a concern for me as well, especially with this resolution. So, I am eroding the WM mask by -2 (3dmask_tool). I have attached a picture of this eroded WM mask with this message. There is not too much left, and perhaps it’s an overkill with -2. Please let me know what you think. With this in mind, what do you think should be a reasonable radius for ANATICOR?

Q1: I am sorry I didn’t explain it very well. There is a lot going on in those two figures. I will try to explain it a bit more. In the first figure with the matrices, column labeled ANATICOR represents the functional connectome (FC) when the data is processed with “just” ANATICOR. First, row is the FC while the second row is just the distribution of the correlation values in that FC. Now, the third column labeled wmpca3 for instance, corresponds to the pipeline where after ANATICOR, first 3 principal components of the WM signal are regressed out of the BOLD time-series before computing the connectome.

As for the second figure with the scatter plots, let’s take the scatter plot in the 3rd column in the first row. It shows a scatter plot between correlation values of the FCs corresponding to the “just ANATICOR” pipeline vs the pipeline where after ANATICOR, first 5 principal components of the WM signal were also regressed out of the BOLD time-series.

DoF is definitely a concern. I am doing bandpass filtering using 3dTproject at the same time when I do all regressing out. The QC script does not detect the degrees related to bandpassing in this fashion. So, I have 320 time-points total (TR = 2.2 sec) and the QC script mostly shows that I am left with DoFs anywhere between 200-270 (approximately), after censoring and everything else. But, since I am also doing bandpass (0.01-0.1), I am actually loosing a lot more DoFs.

The main reason why I am doing bandpass filtering is to take care of the physiological noise (I don’t have any physiological recordings) and so the reviewers won’t hackle me :slight_smile: Can you please give me a solid defense against this line of potential criticism against a reviewer? If yes, I would be happy to drop the bandpass filtering because I don’t like this step much either, due to the fact that it costs so much DoF loss.

Thanks again for all your help!


Hi Kauser,

That bandpass limit should take out another 140+ DoF. This suggests that you are not using for the analysis. It would include the regressors, censoring and bandpassing in one step. It is typical that when band passing is done separately, it is not done correctly.
Would you show your 3dTproject command?

Regarding the white matter PCA regression, making a big difference does suggest there is BOLD signal coming from the white matter PCs (or ANATICOR), which would corrupt the results (in an unknown way).

But one basic problem is the voxel size, as Paul mentions. With such big voxels, a proper erosion is almost impossible, since it would often leave no voxels for the resgression. This includes the CSF, and notably, will vary quite a bit across subjects.

The mask you show does not look eroded to me. If that were already eroded by 2 voxels, then the original WM mask would include the dilation of this one by 2 voxels, and that would go way into the grey matter.

Tissue-based regression begs for smaller voxels.

  • rick

Hi Rick,

I generated the script using but I have made changes to it. For instance, doing bandpassing is one of them. Instead of generating sinusoidal regressors using 1dBport, I do bandpassing directly using 3dTproject:
3dTproject -polort 0 -input $output_dir/pb05.$SBJ.r*.scale+orig.HEAD
-censor $output_dir/censor_${SBJ}_combined_2.1D -cenmode ZERO
-dsort $output_dir/Local_FSWe_rall+orig
-ort $output_dir/X.nocensor.xmat.1D
-passband 0.01 0.1
-prefix $output_dir/errts.$SBJ.fanaticor -overwrite

I don’t remember where but I remember reading one of the help files, where it was highly recommended to bandpass using 3dTproject, so I made the change.

As for the white-matter mask erosion, I should have mentioned that -2 erosion was done before the mask was resampled to the epi image. So the erosion was performed at 1x1x1 and then the mask was resampled to 4x4x4 during the alignment step. Perhaps I can use a -3 erosion? But, even right, the white-matter mask seems okay, doesn’t it? There does not seem to be any overlap between the mask and the gray matter?

Finally, if ANATICOR is not the answer for 4x4x4 resolution, what would you recommend is my best option for noise removal?

Thanks again for all the help guys!! Really appreciate it.


Hi Kausar,

The script will also use 3dTproject for the regression, but it will use 1dBport to generate those regressors, so that one can properly keep track of degrees of freedom.

What you are doing looks fine though, it is still doing all of the regression in a single step. It is effectively the same as the script, except that you do not track DoF. Note that this regression could also be done with 3dDeconvolve (which is not what does in this case), except that 3dDeconvolve would be much slower for this computation, as it has to worry about partial statistics and such. 3dTproject is used for speed when one simply wants to project out “the bad stuff”.

But while what you are doing should produce the same results, there is also no gain in it. It would be safer not to worry about errors in script changes that are not beneficial.

There are multiple issues concerning the WM regression. One is the partial volume effect where the mask even gets a little into the grey matter. And since the fluctuations in grey matter tend to dominate those in white, it can be almost as bad as a pure grey matter regression.

The other issue, which gets less attention, is alignment. Particularly due to EPI distortion, it is often difficult to get great alignment across the entire brain. Places where that fails can cause tissue-based regressors to be contaminated by grey matter BOLD. Plus, what FreeSurfer considers white matter is not perfect.

In the end, we try to avoid these pitfalls, particularly with distortion or large voxels, it is difficult (and distortion tends to get worse as voxels get smaller, good times :).

Do you have physiological recordings? Those are helpful as they do not come from the FMRI data.

  • rick

Hi Rick,

Unfortunately, I don’t have physiological recordings, which I guess would have solved all my problems.

I think I will use the 1dBport and 3dDeconvolve to create the X matrix and use 3dTproject to actually regress out the “bad stuff”. That way the QC html page would track DoFs correctly.

On that note, I would like to ask the bandpass filter question again:
I have a dataset with a TR=2.2sec with 320 TRs. I would like to avoid bandpass filtration if possible. But, we have had real problems with reviewers in the past when we don’t bandpass filter, especially with resting-state. The “loss of DoF” argument gets trumped by the “physiological noise and high frequency noise” argument. Are there any papers which talk about the negatives of bandpass filtration with respect to the DoF argument, that I can use to defend my decision not to bandpass? Or is there a way that I can present this argument a little differently which might be more convincing?

Thanks again for all your help!