# Why is discrete cosine preferred to FFT in neuroimaging GLM

High-pass filtering is often used in neuroimaging data analysis. Commonly, whenever a general linear model is fitted to the data (as for instance in statistic parametric mapping) a number of columns of the design matrix are assigned to discrete cosines (DC). See the figure below for a graphical example.

I am curious why this is preferred to taking the fourier transform (FT) of the data, and applying a filter or cutoff. Arguments I think would speak for the FT alternative are:

• You would not have to re-do the high-pass filtering upon every application of a GLM
• Since DCT is discrete I am guessing a FT would be more accurate in extracting all high frequeny components (looking at the figure above, I find it hard to believe that those few cosines cover all the low-frequency spectrum in between them)

Reasons I think DCT might be the preferred method:

• Maybe it is faster than FFT.
• Maybe there is a reason why it is desirable to perform the filtering concomitantly with your GLM fitting.

• Why is DCT preferred?
• Would FFT not be better?
• How can I migrate? Though this seems like a statistics question... I find this trend of creating more and tinier sub-communities counterproductive. the tags I found at my disposal here summarize my question quite nicely. – TheChymera Sep 1 '15 at 19:26
• The best course of action might be to leave this question here on CV for a day or to in case someone in this community is inspired to answer it. If it doesn't attract much attention, then you may flag it for moderator attention with a request to migrate and we can do it. That ought to maximize your chances of getting good answers (and make the most of both the CV and DSP communities). – whuber Sep 1 '15 at 19:46
• Let's see what answers we get here in DSP.SE. One reason may be because the (D)FT is complex, whereas the DCT is real-valued. – Peter K. Sep 26 '15 at 21:34

Say we have a signal,

The DFT assumes the signal is periodic, e.g.,

While the typical DCT assumes the signal is even at the boundaries, e.g.,

In the DFT example you can see there is a big jump from one side of the signal to the other. Since it assumes a periodic signal, this big jump introduces a lot of high frequency components. Thus the energy of the signal is spread out over more frequencies. For example, the log of the absolute values of the DFT is

Because the DCT assumes the signal is even at the boundaries, generally there is no big jump and thus no extra high frequency components. If this assumption is correct, more of the energy is concentrated in the lower frequencies. For example, the log of the absolute values of the DCT is

Actually, point at which the DCT assumes the signal is even can be moved. It doesn't have to be at the boundaries. However, if your signal generally has some large ramp component, then it makes sense to use the boundaries.

For the edge condition the DCT is equivalent (with multiplication by a scalar) to the DFT of the mirrored signal,

The log of the absolute values of the DFT of this signal is

which is the same as the DCT result above.

Note

The DCT doesn't automatically reduce boundary effects. Consider the extreme example of a sine signal, its DFT and DCT:

Because the even assumption didn't hold, the DCT actually resulted in many more high frequency components.

Why use it

I'm guessing because of drift in the nueroimaging signal, it is not periodic, and thus there would be a big jump from start to end. This would introduce lots of high frequency components with the DFT. Using the DCT assumes the signal is even and reduces the boundary effects.