You are on page 1of 34

Fourier transforms, filtering and convolution

Adrienne Fairhall
Quantitative Methods in Neuroscience
Winter 2009
Quick review: linear algebra

Linearity– two criteria?

Linear transformation– examples?

Projection– how do you do it?

Eigenvalues– how many? What do they mean?

Eigendecomposition– when can you do this, and what does it mean?

Linear transformation, operators, and filtering


Discretization and the “time basis”

f(t)

time t

d(t-t1) * f(t1)
d(t-t2) * f(t2)
d(t-t3) * f(t3)
d(t-t4) * f(t4)
d(t-t5) * f(t5)

d(t-tn) * f(tn)
Basis functions as coordinate axes

f(t)

time t
A function as a point in the time basis

d(t-tn) sin(wnt)

d(t-t2) sin(w2t)
F(w)
d(t-t1) sin(w1t)

f(t)

The Fourier transform is a linear coordinate transformation in function space.


Sinusoids as basis functions

f(t)

time t

Each frequency needs 2 pieces of information, or 2 dimensions


A function as a point in the time basis

d(t-tn) sin(wnt)

d(t-t2) cos(w1t)
F(w)
d(t-t1) sin(w1t)

f(t)

Need to expand the space! (where does the extra information come from/go?)

For each problem, look for a natural coordinate frame that reduces complexity..
data compression
The Fourier transform reexpresses a function of time as a function
of frequency by decomposing it into sinusoids at different frequencies.

Any (finite, square-integrable) function can be written in this way.


Decomposition of a square wave.
The Fourier transform:

The inverse Fourier transform:

Integration against a basis function is the equivalent of a projection


Quick review of complex numbers

Polar representation

f
The Fourier transform returns a complex function

We can split that into its two components:

Both components are needed to capture both the amplitude and phase
at every frequency
Just as the function f(t) consists of a set of coefficients of delta functions
in time,

the transform F(w) consists of a set of coefficients of cosines (real part)


and sines (imaginary part) of different frequencies.
At each frequency w, we have one complex number,

F(w) = Re(F(w)) + i Im(F(w)) = Fweif

The amplitude at that frequency is then |F(w)|;

The phase is f = tan-1 ( Im(F(w)) / Re(F(w)) )

The power at w is the square amplitude |F(w)|2


The power spectrum and Parseval’s theorem

The variance in the time domain is equal to the total power in the frequency domain
The sine/cosine basis is complete and orthogonal

Completeness:

All well behaved functions can be written as a sum of sines and cosines

Orthogonality:
Decomposition of a square wave.
First example: FT of cos(wt)
FT of cosine and sine
More examples
The frequency range of the Fourier transform

• What is the lowest frequency you can detect in your data?

• What is the highest frequency?


The lowest represented frequencies: wrapping

The lowest frequency one can obtain from the FFT is 1/T.
The Nyquist frequency

There is only one value (real) at the Nyquist frequency


Let’s say T = 4.
Nyquist frequency and aliasing
Filtering, convolution and transfer functions

• Filtering in the time domain

• Transforming to the frequency domain: the transfer function

• Equivalence between convolution and multiplication

• Some examples

•Combining filters

• Impulse response function

• White noise analysis


Linear systems

What is a linear system?

The output depends linearly on the input.

The output is a linear combination of the input, at different


times or, equivalently, at different frequencies.

Input f(t)

Output g(t)

.. systems described by a linear differential equation


Linear filtering in the time domain

f(t)

g(t)

g(ti) = Sj hj f(ti-j)

The set of coefficients hj  h(t) is called a filter


(or a kernel, or a Greens function, or a point spread function)
Filtering in the frequency domain

The convolution theorem

G(w) = H(w) F(w)


Filtering in the frequency domain

output G(w) = H(w) F(w) input

Transfer function: H(w) = G(w) / F(w)

Lowpass filter
Highpass filter
H(w)

Bandpass filter

A filter can throw away information; it can’t introduce new information.


Lowpass Highpass
Combining linear operations

This is easiest to see in the frequency domain.

G(w) = H(w) F(w)

Let’s now make an additional linear operation on the output:

I(w) = H’(w) G(w)

Then

I(w) = H’(w) H(w) F(w) = K(w) F(w)

In the time domain, the new filter is the convolution:

k(t) = h’ * h

Note: order doesn’t matter.


How do you figure out what your filter is?
(Linear systems analysis)

Time domain: the impulse response function

What if we put in f(t) = d(t – t)?

 the output is h(t).


How do you figure out what your filter is?

Frequency domain: white noise analysis

Transfer function
H(w) = G(w) / F(w)

A nice input to use is then one with a flat spectrum, F(w) = const.

What happens if the noise is not white (or the impulse is not a perfect
delta function)?

You might also like