Brain computer Interface (EEG)

Thread Starter

hanukaran

Joined Mar 29, 2012
21
I'm Prabakaran Munusamy .Doing Final year project on 'Brainwave pattern recognition' . I'm using Matlab as My platform.I'm a beginner.I already learn to load the file to read the EEG data in Matlab using excel data. I got the graph but in amplitude and time. I need to change the time to frequency.I'm not so sure how to change it to frequency.Is that I need to use FFT. Can any one guide me please.I attached the picture of my result...please anyone can guide me..I can learn faster
 

Attachments

MrChips

Joined Oct 2, 2009
30,802
I presume that your sampling frequency is 250Hz.
Most of the amplitude is from -10 to +10 with some at -20 to +20.
The signal to noise ratio is poor and amplitude is low.
There is no EEG signal that I recognize.
The problem is in the signal acquisition, electrodes and amplifiers.

goggle EEG to see what to expect:

http://en.wikipedia.org/wiki/Electroencephalography

Please state the clinical conditions how the data is acquired (position, rest, sleeping, eyes closed, etc.)
 
Last edited:

Thread Starter

hanukaran

Joined Mar 29, 2012
21
actually my project is need to detect brainwave whether it is in alpha state or other condition.I try to get the data.Most of data is in EDF file .I'm searching data in txt file or excel file. Do you have any suggestion.Or please give me some time....i will try to get the data...I realy need your guide.I'm very glad that you reply my question.

Thanks and regards,

Prabakaran Munusamy
 

panic mode

Joined Oct 10, 2011
2,746
i agree with MrChips but if you think FFT will help, read matlab help or try this code sample

Rich (BB code):
function FFT_test

%% ********************************************
%%      Basic example of FFT in MATLAB
%%          provided by panic mode
%% ********************************************

clc; clear all; close all; % always start fresh,
                           % reset and close anything that may be open

f1 = 1750;                 % pick signal frequency, because here 
                           % we generate our own samples instead of
                           % reading data from file for example
            
Fs = 512000;               % recall Nyquist sampling frequency, it must be
                           % at least twice that of sampled signal
                           % but it is better if it is higher than that

L = 100000;                % length of signal (number of sample values)

T  = 1./Fs;                % sampling period
t  = [0:L-1]*T;            % time scale for time domain
f = Fs/2*linspace(-1,1,L); % frequency scale for freq. domain

signal=cos(2*pi*f1*t);     % generated signal is anything we like

FFTsignal = fft(signal)/L; % fft of signal (freq domain)

figure();                  % always create new figure for your plots

subplot(2,1,1),plot(t,signal); % top graph is time domain signal
axis([0 3/f1 -1.1 1.1]);   % set convenient axis limits for plot
title('Signal in time domain'); % indicate what the plot represents

subplot(2,1,2),plot(f,abs(fftshift(FFTsignal))); % bottom is freq. domain 
axis([-2*f1 2*f1 -1.1 1.1]); % set convenient axis limits for plot 
title('Signal in frequency domain'); % indicate what the plot represents
 

Thread Starter

hanukaran

Joined Mar 29, 2012
21
Rich (BB code):
A=xlsread ('C:\Users\PraBaKAraN\Desktop\mail\The data which tested T4 until P4')
T4=A:),1),T6=A:),2),Fp2=A:),3),F4=A:),4),C4=A:),5),P4=A:),6)
plot (T4)
plot(abs(fft(T4)));

is that i need to include the coding which you sent before this to get the first channel.
Im not sure whether i'm in right path doing this project..can you guide me little specific...sorry ...:)
 

Attachments

panic mode

Joined Oct 10, 2011
2,746
you are on a right track but this is not quite done yet.

graph looks ok but it is shifted version of FFT so
- first half is positive frequencies (0..125Hz),
- second half is negative frequencies (-125...0Hz)
the second half is is simply mirrored version of first half.
instruction fftshift corrects the shift allowing display of
-125...+125Hz.


bigger issue is that there is no indication of actual frequency.
your graph shows 0...3000 which is not right if the sampling was done at 250Hz. (see attached)

also what are the values of your y-axis?

and finally, you don't create new figures. this means that each plot overwrites previous one.
so you don't get to see output of "plot(T4)" because it is immediately replaced by
output of "plot(abs(fft(T4)))". to fix this you need to use either subplot or create separate figures.
 

Attachments

Last edited:

panic mode

Joined Oct 10, 2011
2,746
something like this should work for any number of channels.
it will display time and frequency domain scales correctly
(should work for any length of recording).
however, Matlab is interpreter meaning it is slow so don't go crazy on file size.

Rich (BB code):
function FFT_test

%% ********************************************
%%      Basic example of FFT in MATLAB
%%          provided by panic mode
%% ********************************************

clc; clear all; close all;  % always start fresh,
                            % reset and close anything that may be open

EEG=xlsread('eeg.xls');     % read in XLS file, then get...
[L,ch]=size(EEG);           % length of recording and number of channels

Fs = 250;                   % specify sampling frequency
T=1/Fs;                     % calculate sample period and ...
t  = [0:L-1]*T;             % time scale for time domain plot
f = Fs/2*linspace(-1,1,L);  % frequency axis for FFT plot
                            
for n = 1:ch                            % for each channel...
    figure(n);                          % create new figure and plot..
    subplot(2,1,1);                     % the top graph is...  
    plot(t,EEG(:,n));                   % time domain signal
    xlabel('seconds');                  % display units (seconds)        
    title(['Channel: ',n+48]);          % give it some description
    FFTch(:,n) = fft(EEG(:,n))/L;       % then do the FFT of signal
    subplot(2,1,2);                     % bottom graph is...
    plot(f,abs(fftshift(FFTch(:,n))));  % FFT in frequency domain 
    xlabel('Hz');                       % display units (Hz)    
end
 
Last edited:

Thread Starter

hanukaran

Joined Mar 29, 2012
21
thanks for coding..its really helpful...
so from this frequency i got..i need to mentioned whether this data beta,alpha or delta...am I right sir.....
 

Thread Starter

hanukaran

Joined Mar 29, 2012
21
"The Fourier transform is useful for extracting a signal from a noisy background."
i read in one journal....that's why i'm asking...or is that this data is enough to do the classification...
 

panic mode

Joined Oct 10, 2011
2,746
if you collect some noisy signal, you can run it through FFT. this gives you frequencies and magnitudes of all components that make that signal (noise as well). to remove noise, you simply pick signals of interest (subset of what FFT gives you) and generate your own new signal OR clear (zero out) all unwanted frequencies and run inverse fourier transform. this will give you new signal but only with frequency components you picked (hopefully you picked the right ones).

reading journals is fine but if you want to complete a project you better pick some book on signal processing and get up to speed with fourier. everything mentioned here is basics, probably 2nd year calculus. so, what are you studying?
 

Thread Starter

hanukaran

Joined Mar 29, 2012
21
actually i'm studying in Electronic (computer)..Degree..with the result im having here..is that i'm able to do the classification..:)
 

Thread Starter

hanukaran

Joined Mar 29, 2012
21
You don't have to know everything, if you know where to find it.
When you do ask questions, you may look stupid.
When you do NOT ask questions, you will STAY stupid......hehe..like like
 
Top