# detrending: linear, quadratic, spline.. how to know?

Hello,

I am running a script that, in addition to band-pass filtering and performing nuisance signal regression, it also removes linear and quadratic trends.
I have searched high and low through the literature to try to understand how to choose which trends to remove based on your data and research questions, but have been unable to find anything.

How do we know which detrending option to go for?

How do we know which detrending option to go for?

To answer the question, you would have to build a few models with different orders for the polynomial fitting of the slow drift, and check out the results through option -bout in 3dDeconvolve (and maybe F-test for those polynomial coefficients through -glt). By default, it adds an extra order for the polynomials in AFNI through option -polort A in 3dDeconvolve/3dREMLfit.

It’s better to check the fit with options like Gang’s “bout” recommendation and the fitts option to see the overall fit. The default polynomial fit to the baseline is automatically determined by the following formula in 3dDeconvolve’s help (the int(D/150) is actually “floor(D/150)”). That order is a guideline that generally seems to work well, but it is not guaranteed, and you should examine the fit of the model. 3dDetrend can also be used to explore this, but we generally incorporate the baseline fit into the general model.

[-polort pnum] pnum = degree of polynomial corresponding to the
null hypothesis [default: pnum = 1]
** For pnum > 2, this type of baseline detrending
is roughly equivalent to a highpass filter
with a cutoff of (p-2)/D Hz, where ‘D’ is the
duration of the imaging run: D = N*TR
** If you use ‘A’ for pnum, the program will
automatically choose a value based on the
time duration D of the longest run:
pnum = 1 + int(D/150)
==>>** 3dDeconvolve is the ONLY AFNI program with the
-polort option that allows the use of ‘A’ to
set the polynomial order automatically!!!
** Use ‘-1’ for pnum to specifically NOT include
any polynomials in the baseline model. Only
do this if you know what this means!