Extracting EEG Components from Signal within MATLAB

那年仲夏 提交于 2021-02-19 02:34:07

问题


I have a simple EEG signal in MATLAB such as that shown in the figure below. And what I wanted was to extract the components of the EEG according to the following table.

  • Delta - up to 4 Hz;
  • Theta - 4 -> 8 Hz
  • Alpha - 8 -> 13 Hz
  • Beta - 13 -> 30 Hz
  • Gamma - 30 -> 100 Hz

In a first attempt to solve this problem I tried to build a bandpass filter with 'fdatool' from MATLAB to extract the component' theta 'signal, but without success.

Along attached the code for the filter obtained with the 'fdatool'.

function Hd = filt_teta
%FILTROPARA TETA Returns a discrete-time filter object.

%
% M-File generated by MATLAB(R) 7.9 and the Signal Processing Toolbox 6.12.
%
% Generated on: 05-May-2011 16:41:40
%

% Butterworth Bandpass filter designed using FDESIGN.BANDPASS.

% All frequency values are in Hz.
Fs = 48000;  % Sampling Frequency

Fstop1 = 3;           % First Stopband Frequency
Fpass1 = 4;           % First Passband Frequency
Fpass2 = 7;           % Second Passband Frequency
Fstop2 = 8;           % Second Stopband Frequency
Astop1 = 80;          % First Stopband Attenuation (dB)
Apass  = 1;           % Passband Ripple (dB)
Astop2 = 80;          % Second Stopband Attenuation (dB)
match  = 'stopband';  % Band to match exactly

% Construct an FDESIGN object and call its BUTTER method.
h  = fdesign.bandpass(Fstop1, Fpass1, Fpass2, Fstop2, Astop1, Apass, ...
                      Astop2, Fs);
Hd = design(h, 'butter', 'MatchExactly', match);

Any suggestions how I can solve the problem?

Thanks to all


回答1:


One simpler approach might be to simply take the FFT and zero out frequency components other than the specific range you might be interested in, and then inverse FFT to go back to the time domain.

Keep in mind that you'll have to zero out the positive frequency and negative frequency to maintain that the signal in the frequency domain is conjugate symmetric about the 0 frequency. If you don't do this, you'll get a complex signal upon computing the inverse FFT.

EDIT: For instance the following code, produces two sinusoids in the time domain, a corresponding DFT (computed with FFT), and then one of the peaks removed.

t = 0:0.01:0.999;
x = sin(t*2*pi*4) + cos(t*2*pi*8);
subplot(2,2,1);
plot(x)
title('time domain')
subplot(2,2,2);
xf = fft(x);
plot(abs(xf))
title('frequency domain');
subplot(2,2,3);
xf(9) = 0; xf(93) = 0;  % manual removal of the higher frequency
plot(abs(xf));
title('freq. domain (higher frequency removed)');
subplot(2,2,4);
plot(ifft(xf));
title('Time domain (with one frequency removed)')

A couple things to note. The frequency domain in the DFT has a few different ranges: a DC offset (constant) which is the 0 frequency; a positive frequency range, which are (for a length N original signal) the entries from 1 to N/2; a negative frequency range which are the entries from N/2 to N-1; Note, this is not a typo, the highest frequency (the one at N/2) is duplicated and is the same value for both positive and negative frequencies. (Some people use fftshift to show this as a human might plot it, but that's really just for looks/understanding.)

As far as which frequencies to remove, you'll have to figure this out yourself, but I can give you a hint. The highest frequency (at frequency position N/2) is going to correspond to the highest frequency representable by your system, that is fs/2 where fs is your sampling rate. You can scale accordingly to figure out which ones to negate.

If you don't negate the corresponding negative frequencies correctly, you'll get an imaginary signal upon inverse fft.

One last comment. This method will only work if you have the luxury of having all of your signal ahead of time since you need to use the DFT on the whole signal. If you want to do this real time, you will need to create some kind of filter as you were doing previously.




回答2:


If filters do not have any restriction of them regarding their length, choose sharper edges for filters. If I were in your shoes, I would build different filters(low pass and high pass) and process the outcome in Fourier Transform to see any high frequency or low frequency is mixed up with the range of frequencies. 1)Build a low pass, extract delta 2) Build bandpass for theta alpha beta 3) Build a high pass filter, extract gamma.



来源:https://stackoverflow.com/questions/5901927/extracting-eeg-components-from-signal-within-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!