Visit Homepage
Press "Enter" to skip to content

How to Calculate Frequencies and Amplitudes

This is what a one second sample of brainwaves looks like when graphed:one-second-graph

So based on these squiggly brainwaves, how do we calculate frequencies and amplitudes?

Luckily mathematicians have come up with a solution called “Spectrum Analysis using Fourier transform”. The basic idea is that every wave, no matter how complex and irregular, can be represented by combining a number of simple (sine and cosine) waves.

For example:

fourier-synthesis

From:  http://cmc.music.columbia.edu/musicandcomputers/chapter3/03_03.php

where two sine waves are added together, creating a more complex waveform, this is called “Fourier Synthesis”.  “Fourier Transform” is the opposite, where a complex waveform is broken down into it’s simpler waves (called sinusoidal or spectral components).

The Brainwave Analyzer, using “Fast Fourier Transform” or FFT, calculates the FFT real numbers and the FFT imaginary numbers.

Original input file:

one-second-input

You can download this file here:  

And then import into the Brainwave Analyzer.

Click on the “Analyze” button, then scroll down until you get to the “File Export” section.

export

Then, where it says “Export numbers table for all seconds”, click on “Download file”.

And here is what the downloaded file looks like:

one-second-results

And here’s what the FFT and FFTimag (FFT imaginary number) look like when graphed:

fft-graph

This is how the amplitude is calculated:

Amplitude = square root ( (FFT x FFT) + (FFTimag x FFTimag))

And next to “Amplitude” in the results spreadsheet, is “Frequency Index”.

As you can see, the “Frequency Index” looks like this: 0,1,2,3,4,5,6, etc…

index5

Note, if you are opening the csv file using excel, make sure to increase the width of the columns so that you can see at least 5 or 6 decimal places.

So for example to calculate the “Amplitude” at “Frequency Index” 1

Amplitude = square root ( (-5060.595 x -5060.595) + (-7575.272 x -7575.272))

Amplitude = square root ( (25609621.754025) + (57384745.873984))

Amplitude = square root ( 82994367.628009 )

Amplitude = 9110.12445732818

Amplitude = 9110.124 (rounded down)

The same method is used to calculate the amplitude at “Frequency Index” 2, 3, 4, 5, etc…

The Mindwave has a sampling rate of 512 Hz, or in other words 512 lines of data per second. EEG machines vary in their sampling rates, some higher-end EEG machines have sampling rates of 1000 Hz or even higher, while many have sampling rates of 200 Hz or 250 Hz. The sampling rate has to be twice has high as the highest frequency to be measured. Since the high end of Gamma brainwaves is usually considered to be 100 Hz, an EEG machine with a sampling rate of 200 Hz is sufficient.

Because the Mindwave has a sampling rate of 512, the Frequency Index goes up to 256 (half of 512).

index6

The Brainwave Analyzer doesn’t calculate anything past the Frequency Index of 256, as they results would be a mirror image of the first 256 Frequency Index.

Using excel, I did a bar graph of the Amplitude and Frequency Index:

index7

And this is how the Brainwave Analyzer graphs the Amplitudes and Frequency Index:index8

The results show that this one second of EEG readings contains multitudes of different frequencies of different amplitudes.

The thing is though, unless you are an advanced math expert this method is pretty strange and makes no logical sense.

Luckily there is a way to test this method. Here is a simple wave with a frequency of 3  

If you download it, import it into the Brainwave Analyzer, and click on “Analyze”, here are the results:

sine-512-3-waves

 

No advanced math is needed to see that this wave has a frequency of 3, and this is exactly the results of the Brainwave Analyzer thanks to the power of “Spectrum Analysis using Fourier transform”.

And here is a simple wave with a frequency of 4  

These csv files were created using an equation I found in the excellent book “Fundamentals of Time-Frequency Analyses
in Matlab/Octave” by Mike X Cohen.  

More on Fourier Transform:

The Fourier Transform isn’t just used to analyze brainwaves, in fact it is essential for the analysis of sound, light, energy, chemicals, images, etc… It is no wonder it is considered one of the most important mathematical equations ever discovered.

https://www.theguardian.com/science/2014/jul/13/fourier-transform-maths-equations-history

https://en.wikipedia.org/wiki/Fourier_analysis

https://www.nayuki.io/page/free-small-fft-in-multiple-languages

https://www.nayuki.io/page/how-to-implement-the-discrete-fourier-transform

 

If you have any questions, don’t hesitate to post in comments.

See also How to Calculate EEG Bands

2 Comments

    • katie356
      katie356 February 8, 2017

      Hi Princeton

      Thank you so much for your kind words!

      May your successes multiply and your difficulties divide.

      Katie

Leave a Reply to katie356 Cancel reply

Your email address will not be published. Required fields are marked *