# Introduction

By using EEG to collect EEG data from our brain, sometimes we will need to know which frequency band does our signal fall in to provide more features and information for later tasks. In this experiment, we are about to analyze a signal using Fast Fourier Transform (FFT) and Power Spectral Density (PSD). There are two ways in obtaining the PSD of a signal. One way is to obtain the log magnitude square of the FFT of the signal, the other method is taking the FFT of the auto-correlation of the signal.

This time, we only measured signals from the channels: O1, OZ, O2, FP1 and FP2. There’re two datasets measured, one with eyes open and another with eyes closed. To motivation of this experiment is to observe the difference in alpha band between eyes closed and eyes opened. Since Independent Component Analysis (ICA) is performed to remove all possible noise that could come from our eyes, the resulting signal to be analyzed would help us understand how alpha band represent the visual input processing or neuronal activation in occipital area. Our signal is also passed through a bandpass filter to remove all other artifacts (beta wave, etc.) that would affect our observation on alpha wave.

# Using EEGLab

- Data can be imported to EEGLab by “File→Import data→Using EEGLAB functions and plugins→From NEUROSCAN .cnt file”.
- Since we’re only working with certain channels, we can remove the channels we don’t want via “Edit→Select data” and pick the channel we don’t want after clicking “…” and remember to tick “on→remove these” box.
- We can start running ICA using Tools→Run ICA.
- We then remove data that is related to eye blinks be going into “Tools→Reject data using ICA→Reject components by map”.

- We then confirm our removal by going to “Tools→Remove components”
- We can then start using the data that is available in our MATALB workspace.

# Using MATLAB

Under “Workspace” in MATLAB, we should be able to see a “1×3 struct” variable called “ALLEEG”, double click it to see what resides in it. If you closely follow the steps above, you’ll see 3 rows where the latest data will be on the last row. The column that we want to work with is “data” which is a “5x[sample number]” matrix. You can check what’s each row represents by first exporting the data into a text file using EEGLab (“File→Export→Data and ICA activity to text file”)and open the text file using MATLAB. You’ll see something similar to the diagram shown below:

As we can refer to that data from the matrix we mentioned above, each row corresponds to the rows we can see here. Thus we only need rows 3 to 5 of the matrix “data” for analysis. Thus we will store then into the variable O1, OZ and O2.

## Obtaining Power Spectral Density (PSD)

In this experiment, we would like to compare the difference between obtaining the PSD using the autocorrelation method and another by taking the log magnitude square of the FFT of the signal.

We will compare both methods and the implementation using MATLAB is shown below:

`% Sampling Freq of EEG hat`

`Fs = 500;`

` `

`pruned_data = ALLEEG(3).data;`

`O1 = pruned_data(3,:);`

`OZ = pruned_data(4,:);`

`O2 = pruned_data(5,:);`

` `

`% Autocorrelation`

`R_O1 = xcorr(O1, 'biased');`

`R_OZ = xcorr(OZ, 'biased');`

`R_O2 = xcorr(O2, 'biased');`

` `

`% FFT of Autocorrelation`

`R_O1_f = abs(fftshift(fft(R_O1)));`

`R_O1_f = R_O1_f(length(R_O1_f)/2:length(R_O1_f));`

`R_OZ_f = abs(fftshift(fft(R_OZ)));`

`R_OZ_f = R_OZ_f(length(R_OZ_f)/2:length(R_OZ_f));`

`R_O2_f = abs(fftshift(fft(R_O2)));`

`R_O2_f = R_O2_f(length(R_O2_f)/2:length(R_O2_f));`

` `

`% Normalize timestamp according to FS`

`freq = 0:Fs/length(R_O1):Fs/2;`

` `

`%Plot`

`figure`

`plot(freq,R_O1_f)`

`title('PSD of O1 (Using Autocorrelation)')`

`grid on`

`xlabel('Freq')`

`ylabel('PSD')`

`figure`

`plot(freq,R_OZ_f)`

`title('PSD of OZ (Using Autocorrelation)')`

`grid on`

`xlabel('Freq')`

`ylabel('PSD')`

`figure`

`plot(freq,R_O2_f)`

`title('PSD of O2 (Using Autocorrelation)')`

`grid on`

`xlabel('Freq')`

`ylabel('PSD')`

` `

`% Non-autocorrelation method`

`% FFT`

`O1_f = abs(fftshift(fft(O1)));`

`OZ_f = abs(fftshift(fft(OZ)));`

`O2_f = abs(fftshift(fft(O2)));`

` `

`% PSD`

`P_O1 = (1/length(O1)) * O1_f.^2;`

`P_O1 = P_O1(length(P_O1)/2:length(P_O1));`

`P_OZ = (1/length(OZ)) * OZ_f.^2;`

`P_OZ = P_OZ(length(P_OZ)/2:length(P_OZ));`

`P_O2 = (1/length(O2)) * O2_f.^2;`

`P_O2 = P_O2(length(P_O2)/2:length(P_O2));`

` `

`% Normalize timestamp according to FS`

`freq = 0:Fs/length(O1):Fs/2;`

` `

`%Plot`

`figure`

`plot(freq,P_O1)`

`title('PSD of O1')`

`grid on`

`xlabel('Freq')`

`ylabel('PSD')`

`figure`

`plot(freq,P_OZ)`

`title('PSD of OZ')`

`grid on`

`xlabel('Freq')`

`ylabel('PSD')`

`figure`

`plot(freq,P_O2)`

`title('PSD of O2')`

`grid on`

`xlabel('Freq') `

`ylabel('PSD')`

## Plots

The plots for different methods will be shown. We will start with the “eyes-open” dataset. Signals from different channels will be shown in the title of the plot.

We then show the PSD of obtained with eyes closed.

# Discussion

As we can observed, the alpha band falls around 10Hz. The other thing that we can observe is the difference in amplitude of PSD when eyes are open and eye are closed. Ther reasonings that I found on Wiki are as follows:

“Historically, they were thought to represent the activity of the visual cortex in an idle state. More recent papers have argued that they inhibit areas of the cortex not in use, or alternatively that they play an active role in network coordination and communication.”

The other observation and experiment results that were obtained from other researchers is that “alpha waves decrease and beta waves increase upon a subject opening their eyes”

The application that were mentioned in Wiki that is made available from the observation of alpha wave is as shown below:

“Zen-trained meditation masters produce noticeably more alpha waves during meditation. This fact has led to a popular trend of biofeedback training programs for everyday stress relief.”

# Reference

### Like this:

Like Loading...

*Related*