## The Nyquist frequency

A few days ago I realized I had never bothered to explain the nyquist frequency. Considering it’s been over a year now since I explained some of the frequency domain things that I do in my lab, I’m actually surprised I missed something so important. Well, better late than never today we’re going to explain the nyquist frequency and why it matters… to my work at least.

So you record some neural signals. Now what? Well we can look at the frequencies that make up those signals. Now, when a neuron fires, it creates an action potential and a spike in electrical activity. Lucky for us, when one fires, a lot tend to fire. As a oversimplified rule, neurons that fire together, wire together (connect really, but wire rhymes). This little quark of the brain is why we can record signals using EEG.

The brain is thankfully (or unfortunately if you’re a brain researcher) covered by a nice thick skull to protect it from things. And electricity doesn’t pass through bone very easily, so we can’t record individual neurons firing due to something called volume conduction, instead we can only record groups of neurons firing together, non-invasively anyway. That’s enough for us to do some really cool things though!

Frequency analysis is useful because the oscillations those groups of neurons create tell us a whole lot about the brain. We can tell when you’re sleeping, when you’re paying attention to something, we can even tell when you’re about to move BEFORE you move (it’s called a readiness potential and it really screws with the idea of free will).

So now that we know what we can use this information for, let’s talk about Nyquist and his frequency. The Nyquist frequency is one-half the rate at which you sampled your data. If I record EEG at 1000 hz for example (1 sample a millisecond, so pretty quick) the nyquist frequency is 500 hz. That’s all fine, but what does that even mean?

Well to answer that question we need to think about waves. Above is a sine wave. It’s very… wavy. Now your brain waves are made up of combinations of waves, some faster, some slower, but they all are composed of a few parts. There’s the amplitude, the phase (which we will not get into), and the wavelength (or period). The shorter the wavelength, the higher the frequency and so the longer the wavelength the lower the frequency.

When we record EEG data, we do it discreetly. Think of it as taking a picture at a certain rate (video basically). We don’t get to see what happens between frames, only what’s occurred at each frame, this means if we start sampling really quickly and slow it down (increase the time between pictures) we have a larger and larger gap that we can’t account for.

Luckily we can fill in those gaps… to a point. This is where the nyquist frequency comes in. If something is rapidly oscillating (has a high frequency) and we can see examples of this in real life. Video as I alluded to before has a sample frequency, what happens when something moves faster than the sample frequency? You get weird effects, BUT the most startling is when you match the sample frequency.

Thus in order for us to be able to accurately reconstruct a analog (continuous) version of our digital (discrete) signal we need to sample at twice the highest frequency we are interested in or we end up with really weird effects like not being able to tell if propellers are moving or not. Let’s take a quick look at a sine wave example.

Here we are sampling well under the nyquist frequency (red dots) where the actual signal (black) is reconstructed using the information we had (red dashed line) incorrectly. As you see we’re sampling lower the nyquist rate (the rate at which we need to sample to avoid falling below the nyquist frequency) for the actual signal. This causes us to have a poor reconstruction because we lack important information about what the signal is doing in between those time points (which is called aliasing).

To avoid this issue, we typically sample at a high frequency 1000 hz for EEG data because we’re only interested in maybe up to 100 hz on rare occasions, but mostly our lab sticks to the lower frequencies <50 hz, which is very far from the nyquist frequency and for good reason!

I mean the video does a great job showing why we would want to avoid it. Imagine making a breakthrough discovery only to find out it was because you were looking at frequencies higher than the nyquist frequency.

So quick note before we call it a day, biological signals follow a 1/f power rule(ish). This means the lower frequencies have higher power (we covered some of this last year) and that higher frequencies have lower power making them hard to record. That’s great for us because we don’t have to worry about a rogue 510 Hz signal showing up as a 10 Hz signal in our data. For every 1 Hertz above your nyquist frequency the signal will show up as (actual freq – nyquist freq). This helps explain the video, because say the propellers were rotating at 100 hz and you sample at 100 hz, well 100-100 = 0.

If the nyquist frequency is 500 Hz and you have a 510 Hz frequency, it will appear as a 10 Hz frequency because of how it was sampled. BUT!!! Because signals from the body generally follow a ~1/f power spectrum a true 510 Hz frequency is ~1/51 -th the power of a true 10 hz frequency it won’t really make a difference because it is super, incredibly small and you’re already dealing with signals that have tiny power to begin with so you wouldn’t even see it. In fact, you’re more likely to see something causing 10 Hz noise than you would a 10 Hz power increase from a 510 Hz signal.

So there you have it, more than you’ll ever probably need to know about the nyquist frequency! I’m still kind of shocked I never went over this…

This site uses Akismet to reduce spam. Learn how your comment data is processed.