polynomial order for 3dToutcount


I’m trying to learn to preprocess fMRI data with AFNI.

I’m at ‘outcount’ stage, and have a question about deciding the order of Legendre polynomial for the option, -polort in 3dToutcount function.

I’ve heard that the order of polynomial varies according to the total length of time series of fMRI data and that it can be calculated through an equation.

But I can’t find the equation in internet and I wonder how I can give the order to AFNI.

Could you let me know how to decide the most appropriate order of Legendre polynomial when I use 3dToutcount? Is there an equation which helps to get the polynomial order?


I highly suggest starting with afni_proc.py to generate
a processing script, and then understand the details of
that. For example, I would suggest using the same
polort that is used in the regression for outliers, which
you would see in a generated proc script.

See afni_proc.py -help for details (command line or web
link), or some of the example commands that go with our
class data under AFNI_data6/FT_analysis.

  • rick

Thanks for the comment.

But I’ve finished the tutorial(FT_analysis) and tried to work on the real data.

And the length of time series of the tutorial data and the data I’ve got from the subjects are different, so I think I should apply different polynomial order for 3dToutcount to the real dataset compared to the tutorial dataset, since the characteristics of the dataset are different.

That’s why I ask how I can get the appropriate polynomial order for 3dToutcount. One of my seniors told me there would be an equation which helps me to calculate the polynomial order, but I couldn’t find one.

I’d be very appreciated for your reply. Thanks.

Great, going through that by hand is really important.

Once you have a good understanding of the steps, or even
before then, I still suggest using afni_proc.py to write
an analysis script. That gives you something to compare
against, both in terms of ideas for writing a processing
script and in terms of the actual resulting statistics.

The formula that we use for polort, which is applied by
afni_proc.py and by “3dDeconvolve -polort A”, is
pnum = 1 + floor(run_duration/150), where times are in

For help, see the description of option -polort in
“3dDeconvolve -help”, as well as -regress_polort or
even -outlier_polort in “afni_proc.py -help”.

  • rick

Thank you so much!

By the way, in the above equation, pnum = 1 + floor(run_duration/150),

do you mean

pnum = the order of polynomial in 3dToutcout or 3dDeconvolve functions,
run_duration = the number of time series in seconds ??

If the total length of MR scan is 840s(or 14 min), is the order of polynomial for the above functions 6?

afni_proc.py is really useful and I’m enjoying learning it step by step. Thank you :slight_smile:

Yes, pnum would be the order of polynomial used in 3dToutcount
or 3dDeconvolve, while run_duration is the duration of the run
in seconds (regardless of the number of time points).

Yes, polort=6 is right for a run length of 840 s. That is a
long run.

I am glad you are finding afni_proc.py useful!

  • rick

Thank you so much for the reply!!

Your comment is really helpful to my study :slight_smile:

Hope everything goes well.