# Nonlinear fitting using 3dNLfim?

Dear AFNI Experts,

I am trying to do nonlinear fitting to βs I got from 3dDeconvolve using 3dNLfim. Could anybody give me an example code to do that?
For better understanding my question:
I did linear regression using AM2 option in 3dDeconvolve, and fitted the βs(BOLD response to stimuli) with behavior data. Now I want to see whether nonlinear fitting works better or worse than linear regression. But I do not know where to input the behavior data when I tried to do this using 3dNLfim.
Any suggestion is welcome!

Thanks a lot!

Sally.

Hi Sally,

What is the exact non-linear model that you want to fit to the betas? One option is to use -stim_times_IM to generate a set of betas, one per event, and then fit a model to that. That is easier than setting up a new model for 3dNLfim. If there are too many events, particularly with other conditions, then IM is not a great option.

But in any case, can you describe the model you would like to fit to?

• rick

Hi Rick,

Sorry for the late response, it seems that I could not get email alerts.
The model I need to use is quadratic model and I do have a lot of events(300 totally). I am trying to fit fMRI response towards parametrized faces (300) with the behavior data.
Do you have any suggestions about doing this?

Many thanks!

Sally

Hi Rick,

Just want to make sure that this topic has not been buried!

Thanks,
Sally

Hi Sally,

So you expect a quadratic fluctuation of the betas corresponding to some external behavioral parameter? If that is true, this might be more easily solved using amplitude modulation in 3dDeconvolve/3dREMLfit. You could add linear and quadratic modulators (using Legendre polynomials) to the stimulus times, and the result would be 3 betas, for the mean, linear and quadratic magnitudes. That would be more straightforward than trying to implement something in 3dNLfim.

Does that seem like a reasonable option?

• rick

Hi Rick,

Yes, you are right. Your suggestion sounds a great option! But I am still not sure how to do this. It is said in the 3dDeconvolve documentation that"3dDeconvolve does LINEAR regression’', and " If you want NONLINEAR regression, see program 3dNLfim ". Would you please provide a sample about how to achieve this? Where should add the quadratic modulators in the script please? I did see an option "-legendre " but it is for baseline model.

Many thanks!

Sally