I have multiple trials of physiological data. I am doing a frequency based analysis to analyze power (amplitude) in certain frequencies of interest. Is averaging multiple trials of equal length and then taking a single FFT of the averaged signal vs computing FFT for each trial and then averaging the frequency bins the same? In practice im finding this not to be the case.

Specifically, the signal naturally has a strong 1/f component and this gets emphasized if I compute the FFT of each individual trial and then average the amplitudes (real part) of each frequency bin. Are the two equivalent? is there a right way to do things? or under what principled conditions should the choice between time domain averaging vs frequency bin averaging be made?


Let me clarify.

  • Fourier transform does not represent the histogram of the signal. Fourier transform is a linear transform that takes signal from time domain (complex function) to frequency domain (another complex function). It takes a complex function to another complex function.
  • Fourier transform is linear as the poster above pointed out.
  • Phase in your samples matters as pointed out above. If trial-by-trial data varies in phase, then you do not want to average before doing a Fourier transform, but you also do not want to average after Fourier transform. You want to average after Fourier transform and norm. I will elaborate below as far as exactly what needs to be done.

The main issue here is that the question is posed wrong. It is not "should I take the Fourier transform before averaging or after averaging". Because it makes no difference due to linearity of Fourier transform.

The correct question to ask is "should I take the amplitude of the Fourier transform before averaging or after averaging". For this question, the answer is before.

Here are the details.

Suppose your sampled data is represented by the sequences:






where $d_1,...d_M$ are data from M trials and $n_1,...n_N$ are sampled time points, then:

$F_1 = \sum_{j=1}^M{|\mathcal{F}\{d_j\}|} \neq |\mathcal{F}\{\sum_{j=1}^M{d_j}\}| = F_2$

So while the transform $\mathcal{F}$ is linear, $|\mathcal{F}|$ is not.

Furthermore, while $d_j[n_i]$ is real for all $i,j$, $\mathcal{F}\{d_j\}$ is not, but $|\mathcal{F}\{d_j\}|$ is.

As for what you should do, you should take the Fourier transform of individual trials (via FFT), get the amplitude of individual trials, and a average them together.

Finally, what is $1/f$. $1/f$ is a short term for the frequency spectrum of "natural" signals (usually people think of images).

When people say there is a large $1/f$ component, it means that the amplitude as a function of frequency looks like $1/f$. It's totally hand-wavy... probably coming from a biologist :p

The inverse Fourier transform of $1/f$ is some sign function, but that is useless. It is an imaginary sign function! Real functions generate symmetric Fourier transform.

In fact saying that the spectrum is $1/f$, tells you something about the signal, but it doesn't let you recover the signal. All that you know is that $|\mathcal{F}\{x(t)\}| = |1/f|$. This doesn't let you uniquely determine $x(t)$ because all the phase information is gone, and we know that the structure of a signal relies heavily on its phase.

What does $1/f$ tell you? Simply that it contains a lot of low frequency and a little high frequency.

Just as important a question, what does averaging buy you? and more important is how to interpret the result? Tune in tomorrow for a more in depth discussion :p

| improve this answer | |
  • 1
    $\begingroup$ +1 Thanks for clarifying. I feel that I misunderstood the underlying issue behind the question, and I think this gets more to the heart of it. $\endgroup$ – jstarr Jan 26 '13 at 3:07

First, the FFT is an algorithm. The transform is called the Fourier Transform! It represents the histogram of the signals. In the discrete case, a high reading in the frequency domains means lots of energy at that frequency.

You should not average the data before the FFT as phase information will cause a significant changes in data.

Imagine 2 samples each consisting of a pure cosine. In the real world you will never capture this cosine at the exact same starting point. One cosine will be shifted reletive to other (or both have different shifts reletive to the start. Mathmatically this is saying y1=cos(wt-A) y2=cos(wt-B) where A & B are shifts. In your model these two better show up as the same thing. With a little math I can choose these values so that y2-y1=0. The average of zero is zero and entirely not what you want. This is the phase problem.

If you goal is to find the average spectrum you should average across spectra, don't average the signals!

| improve this answer | |
  • $\begingroup$ Thanks for that. Certainly was a concern that if there is noise with just the right phase difference from trial to trial it will cancel out either all or signals at frequencies of interest. Im still not clear why the 1/f is accentuated by frequency bin averaging rather than time domain averaging followed by FFT. $\endgroup$ – user1487551 Jan 15 '13 at 7:11
  • $\begingroup$ @user1487551 What does a strong 1/f component mean? The inverse Fourier transform of 1/f is sign function and may hint that your data includes a large chunk when the system is stabilizing. You should probably show a plot or some data. $\endgroup$ – Mikhail Jan 15 '13 at 7:18
  • 1
    $\begingroup$ Note that you can do time-averaging if you have a phase reference that you can synchronise data capture to, and this can be very effective in reducing the noise floor, but otherwise it's true that you need to do ensemble averaging in the frequency domain. $\endgroup$ – Paul R Jan 15 '13 at 7:52

Unless I am completely off base or misunderstand your question, the answer is yes: By linearity of the DFT, averaging the signals in time and then taking the DFT of the average is equivalent to averaging the DFTs of the signals.

To show this, let's define some variables:

  • $x_{n}[\ell]$: $\ell^{th}$-trial time domain sample at time $n$
  • $X_{k}[\ell]$: $\ell^{th}$-trial frequency domain sample at frequency $k$

The "average" signal in the time domain is given by $\frac{1}{L} \sum_{\ell=0}^{L} x_{n}[\ell]$. Taking its DFT, we have

$\sum_{n=0}^{N-1} \frac{1}{L} \sum_{\ell}^{L} x_{n}[\ell] e^{-i 2 \pi k n / N}$.

Switching the order of the summations, we can write

$\frac{1}{L} \sum_{\ell=0}^{L} \sum_{n=0}^{N-1} x_{n}[\ell] e^{-i 2 \pi k n / N},$

but this is the same as

$\frac{1}{L} \sum_{\ell=0}^{L} X_{k}[l]$

which is the same as averaging the DFTs of each trival. This is what we wanted to show.

| improve this answer | |
  • $\begingroup$ To average in the time domain you need some sort of phase reference to which you can synchronize. When this is available though you can sometimes get better results than with ensemble averaging in the frequency domain, mainly due to the reduction in the effects of quantization etc. $\endgroup$ – Paul R Jan 23 '13 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy