Quantcast
Channel: Emotiv
Viewing all articles
Browse latest Browse all 898

Reply To: Alpha/Theta Ratio

$
0
0

Hello All,

Am new to signal processing. I have been trying to extract alpha and theta frequencies. I have used the code that gmac had provided in this post. I was expecting values ranging 8-14 to eeg.alpha. But I see very high numbers.
Example- 1406.2 777.68 2113.7 683.66

Aren’t the eeg.theta, eeg.alpha values supposed to be in Hz? If not, what are the units of these values? What does the below program exactly output?
I believe I have done something wrong or am missing something. Can someone review this, please?

This is what I have done after recording EEG data on Emotive Epoc.

1. Converted the EDF file to CSV file on the test bench. My CSV file has values similar to below numbers.

4308.205023 4320.512715 4278.974254 4342.051176
4295.897331 4320.512715 4275.384511 4337.435791
4294.87169 4327.692202 4277.435793 4333.846048
4304.102459 4325.64092 4283.589639 4336.41015

2. I have used the CSV file EEG2.csv as input to the below code.

inputData=csvread(‘.\EEG2.csv’);
eeg.raw= inputData(:,(3:16));

fftlength = 256;
hanning = (1:fftlength)’;
hanning_in = 2* pi() * (hanning – (fftlength+1)/2)/(fftlength+1);
hanning = (sin(hanning_in)./hanning_in).^2;
hanning = repmat(hanning, 1, size(eeg.raw,2));

f=(128/fftlength:128/fftlength:128);
thetaIndex = find(f>=4 & f<8);
alphaIndex = find(f>=8 & f<12);
lowBetaIndex = find(f>=12 & f<16);
highBetaIndex = find(f>=16 & f<25);
gammaIndex = find(f>=25 & f<40);
totIndex = find(f>=4 & f<=40);
outdata = [] ;

med = median(eeg.raw,2);
eeg.raw = eeg.raw – repmat(med, 1, 14);
for j=2:size(eeg.raw,1) % limit slew rate
del = eeg.raw(j,:) – eeg.raw(j-1,:);
del = min(del, ones(1,14)*15);
del = max(del, -ones(1,14)*15);
eeg.raw(j,:) = eeg.raw(j-1,:) + del;
end
% High pass filter
a = 0.0078125;
b = 0.9921875;

preVal = zeros(1,14);
eeg.filt = zeros(size(eeg.raw));
for j=2:size(eeg.raw,1)
preVal = a * eeg.raw(j,:) + b * preVal;
eeg.filt(j,:) = eeg.raw(j,:) – preVal;
end

eeg.theta = [];
eeg.alpha = [];
eeg.lowBeta = [];
eeg.highBeta = [];
eeg.gamma = [];
eeg.tot = [];
eeg.totmed = [];
for k = fftlength:32:size(eeg.filt,1)
spectrum = fft(eeg.filt(k-fftlength+1:k,:) .* hanning);
spectrum = sqrt(spectrum .* conj(spectrum));
eeg.theta = [eeg.theta; k sum(spectrum(thetaIndex,:))];
eeg.alpha = [eeg.alpha; k sum(spectrum(alphaIndex,:))];
eeg.lowBeta = [eeg.lowBeta; k sum(spectrum(lowBetaIndex,:))];
eeg.highBeta = [eeg.highBeta; k sum(spectrum(highBetaIndex,:))];
eeg.gamma = [eeg.gamma; k sum(spectrum(gammaIndex,:))];
eeg.tot = [eeg.tot; k sum(spectrum(totIndex,:))];
end

3. When I see the values in eeg.alpha, they look like this.

1406.20564453228 777.676698877335 2113.66897776718 683.656336096927
1315.46624145414 1111.31031444531 1856.98478453290 679.703417438634
1120.89883774187 1408.18822017379 1533.96354633473 1174.91463156831

Thanks in advance!!


Viewing all articles
Browse latest Browse all 898

Trending Articles