Help for SPMers using 3dFWHMx

Dear AFNI community,

This question is related to previous posts from earlier this year:,150509,150596#msg-150596,81761,81780#msg-81780

In short, we want to double check that we are using the proper inputs to 3dFWHMx, particularly regarding the -acf and -detrend flags.

  1. Our understanding is that AFNI expects residuals to be standard deviations, so we are square rooting the residuals. Can we confirm that this is what the function expects and therefore SPM users should square root their ResMS.nii file prior to inputting it into 3dFWHMx?
  2. Our output is identical with and without the -detrend flag. We assume this is probably related to us doing all prior analysis steps in SPM. Is it essential to use the -detrend flag?
  3. Perhaps most importantly, is it essential to get the smoothness estimates from the first level models? If so, how would one go about doing that, can you average single subject level ACF estimates if you were willing to calculate them individually? If they cannot be averaged in that fashion, does this mean that SPM users simply cannot effectively use 3dFWHMx (and by extension, 3dClustSim) anymore?

These are the commands we are currently using:
3dcalc -a ResMS.nii -expr ‘sqrt(a)’ -prefix sqrt_ResMS.nii
3dFWHMx -mask mask.nii -acf -detrend sqrt_ResMS.nii
3dClustSim -mask mask.nii -acf .313041 7.71974 11.8638

Thank you,
UO Developmental Social Neuroscience Lab


  1. No. The input to 3dFWHMx should be residuals, such as a
    residual time series, without any square root. You can see
    examples of how it is used in processing scripts,
    such as AFNI_data6/FT_analysis/s12.proc.FT.align .

  2. That is very strange, unless your input is only 1 volume.

  3. Yes. It should work well to average the 3dFWHMx parameters
    across subjects for use at the group level.

Unfortunately, it is harder to tell how big the ACF parameters
are at a glance. So I cannot tell how reasonable yours look.

  • rick

Hi Rick,

Thank you so much for your input. We have the added difficulty that we’re doing most of our analysis in SPM.

  1. Our residuals file is from the group-level model from SPM – ResMS.nii is the map of mean squared residuals. This is why we believe we have to take the square-root. Sounds like that’s consistent with what you’re saying.

  2. So, because our residual file is from the group-level model, it is in fact just one volume.

  3. Thanks, estimating for each participant and averaging may be the way we’ll have to go. Do you have any thoughts on whether it’s appropriate to use the group-level model residuals?

Thank you very much for your help,
UO Developmental Social Neuroscience Lab

Well, certainly communicating between packages means
it is hard to verify what you are doing from our end.

  1. I don’t know if the average squared residual (or
    just the average, after sqrt()) is as appropriate as
    the actual set of residual volumes, or if that is as
    appropriate as the set of first level residuals (per
    subject) that we tend to work with.

I would certainly want to compare those estimates with
those that came from the first level, before having
confidence in them.

  1. Even from the group level, a “time” series would be
    expected (one volume per subject). You are using the
    mean of that, it seems.

  2. If you have the ability to compute parameters from
    the first level results, it would be a great idea to
    compare them with those from the second level.

Perhaps Gang will chime in and confirm whether the
second level residuals are appropriate. He might
even prefer them.

  • rick

As Rick says, our estimation of smoothness of the noise is based directly on the noise (the residuals themselves), not on some summary statistics of the noise. I’ve never thought about how to estimate smoothness from the mean square of the residuals.

You may be able to directly obtain the residuals at the group level through the following step:

SPM > Stats > Model Estimation > Write residuals > Yes/No