# Algorithm used to fit ACF in 3dFWHMx

Hi AFNI gurus
Can someone let me know the details of the algorithm used to fit the auto-correlation function in 3dFWHMx?
Specifically how was the equation ACF(r) = a * exp(-rr/(2b*b)) + (1-a)*exp(-r/c) fitted?
Did you use some kind of a non-linear data fitting algorithm? What were the upper and and lower bounds allowed on the ACF parameters “a”, “b” and “c” ?

Thanks a million
Gopi

Of course, the answer is in the source code (in file mri_fwhm.c).

``````
/* nonlinear optimization of parameters */

xpar = apar  ; xpar = bpar      ; xpar = cpar      ;
xbot = 0.006 ; xbot = 0.05*bpar ; xbot = 0.05*cpar ;
xtop = 0.994 ; xtop = 5.55*bpar ; xtop = 5.55*cpar ;

pp = powell_newuoa_constrained( 3 , xpar , NULL , xbot , xtop ,
666 , 44 , 9 ,
0.05 , 0.0005 , 999 , ACF_modelE_costfunc ) ;

``````

Here, the variables (apar, bpar, cpar) are initialized to crude estimates of the (a,b,c) parameters – in particular, apar=0.5 is the starting point for the mixing fraction parameter. bpar and cpar are initialized by finding the approximate FWHM of the empirical ACF estimate, and then some simple formulae give those parameters. You can see the ranges allowed for the estimates in the snippet of code above.

The method used for optimization is Powell’s NEWUOA https://en.wikipedia.org/wiki/NEWUOA – the function powell_newuoa_constrained() called above is a wrapper that I wrote for use in AFNI. The ACF_modelE_costfunc() function is the thing that powell_newuoa_constrained() minimizes – it is just the least squares penalty function for the model vs. the ACF estimates.

Two points:[ol]
[li] Why do you want to know?
[/li][li] Trust in the Source, Luke!
[/li][/ol]

Thanks Bob!
This information is invaluable.
The reason I asked is that
I just had a hunch from playing around with some synthetic gaussian spatial ACF images that the 3dFWHMx’ s ACF ‘a’ parameter’s upper limit is 0.9940 and hence the -acf option will overestimate the spatial correlation. I guess one should employ the “classic” method FWHM-estimate when the spatial ACF is gaussian.

Regards
Gopi