# Extracting different frequency bands (alpha, beta, gamma) from brain activity data

I am new to signal processing and despite googling about my question, I still couldn't find the solution.

I have an Electrocorticography (ECoG) dataset. This consists of recording brain activity from many channels. The data is stored in a matrix. Data in each row relates to the brain activity recorded from each channel. Brain activity data was recorded with 10kHz frequency (Therefore, the continues 10,000 elements of each row is the brain activity data of 1s)

Similar to many analysis such as, I need to extract powers of different frequency bands (1-8 hz, etc) from this data and run some regression anlaysis.

For example, as a sentence from a previous study:

A fast Fourier transformation (FFT; EEGLAB v5.03) was performed for each 1-secondsignal to obtain the power of each of the 3 frequency bands(2–8, 8–25, and 80–150Hz) for each electrode

I am still confused how should I apply the fft function of matlab to correctly obtain power of different frequency bands.

Considering I only have this matrix of dataset (each row: brain activity recorded from each channel) and also the fact that I am not very familiar with methods in signal processing, I appreciate if someone can kindly help me how should I do such an analysis.

## 2 Answers

MATLAB's fft returns the FFT of the columns of a matrix X, so by transposing your input matrix before feeding it to the algorithm should work fine: F = fft(X.'); and then you will have the FFT for each channel of yours.

The FFT can be used to obtain the power spectrum. Here is a link with examples and explanations.

Once you have your power spectrum, then there are plenty of ways to extract different frequency bands (mostly based on filtering).

THE FFT of a 1 second block of data that has not been further windowed has an equivalent noise power bandwidth per bin of 1 Hz (the frequency response of each bin approaches a Sinc function for a large number of samples, so the result is actually the result of all energy under that Sinc--- if the signal was white noise this would be equivalent to the result of a brick-wall filter that was 1 bin wide- hence "equivalent noise bandwidth".). If your signal is not white noise, then it is highly recommended to window the time domain data first which decreases the side-lobes making the measurement less sensitive to energy further away, at the expense of making the main lobe (and equivalent noise BW) wider. fred harris has an excellent paper listing the equivalent noise bandwidth for all the common windows.

http://web.mit.edu/xiphmont/Public/windows.pdf

To compute the power, you square the normalized FFT result using a complex conjugate multiplication. So if not windowed, and you wanted the relative power in the 2-8Hz band for a 1 second block of data, each bin is 1 Hz and you would sum the complex conjugate squares of bins 2 through 8 (starting with bin 0 as DC).

If you are windowing this process is not as straight forward as the equivalent filter bands now overlap, resulting in double counting of the total power as well as the processing loss from the window itself. I explain this in more detail at this post: How to calculate resolution of DFT with Hamming/Hann window?

Ultimately for purposes of estimating power this is equivalent to windowing approaches for digital filter design, and without any windowing is equivalent to nulling the FFT output to design a bandpass filter which is the "Frequency Sampling" method of filter design which is an inferior but simple approach to digital filter design (due to the Sinc filter frequency responses give above, also see Why is it a bad idea to filter by zeroing out FFT bins?). An alternate approach is to design the time-domain bandpass filters directly and measure the relative power out of each filter.

• Basically you are suggesting to do windowing and then FFT of the window and then calculate power spectrum and then low pass filtering to extract bands? – noman pouigt Mar 8 '20 at 20:33
• No I wasn't suggesting this. If you don't need to window the process is very straightforward as I outline (square the FFT result to get the power in each bin, so do the sum square for all the bins in your range of interest). This is fine if you don't have a high dynamic range between your strong and weak signals. If you do, then you will need to window and the process is more complex due to the overlap in the equivalent bandwidth in each bin, and for more details on that, refer to the other link I gave. – Dan Boschen Mar 8 '20 at 20:39
• so with windowing the process mentioned by GKH makes sense ? – noman pouigt Mar 9 '20 at 8:02
• With or without windowing. I suggest windowing if you see a high dynamic range between your strongest and weakest signals of interest. – Dan Boschen Mar 9 '20 at 12:20