How can I measure maximum frequency component present in my recorded EEG signal so that I can use right filter ahead?
4 views (last 30 days)
Show older comments
JAGRITI SAINI
on 14 Mar 2017
Commented: Star Strider
on 14 Mar 2017
I am working on a single channel EEG dataset but not able to apply hamming window based Low Pass Filter to it for denoising. I am using DenoiseF = filter (Hd,m); {Hd= window function, m= dataset} but it says "??? Undefined function or method 'filter' for input arguments of type 'cell'." Also I need to know maximum frequency component in my signal so that I can decide whether I need to filter it or it is already in usable range. Someone please help. May be I am not using right codes in Matlab.
0 Comments
Accepted Answer
Star Strider
on 14 Mar 2017
Use the filtfilt function to do the actual filtering.
2 Comments
Star Strider
on 14 Mar 2017
My pleasure.
The easiest way to calculate the filter order is to use another window function, and then let the window function design your filter using your desired parameters.
Example (bandpass filter):
Fs = 96E+3; % Sampling Frequency (Hz)
fcuts = [850 891 1122 1163]; % Frequency Vector (Hz)
mags = [0 1 0]; % Magnitude (Defines Passbands & Stopbands)
devs = [0.05 0.01 0.05]; % Allowable Deviations
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
figure(1)
freqz(hh, 1, 2^16, Fs)
set(subplot(2,1,1), 'XLim', [0 1500]) % Set Frequency Axis To Show 0-500 Hz
set(subplot(2,1,2), 'XLim', [0 1500]) % Set Frequency Axis To Show 0-500 Hz
See the documentation on kaiserord for details.
Other options exist, and an IIR filter that approximates the steep rolloff of the FIR filter is a Chebyshev Type II design. You can use the designfilt function, or design it yourself.
Example (different bandpass filter):
Fsp = 1000; % Sampling Frequency
Fn = Fsp/2; % Nyquist Frequency
Wp = [1.0 49]/Fn; % Passband Frequencies (Normalised)
Ws = [0.5 50]/Fn; % Stopband Frequencies (Normalised)
Rp=10; % Passband Ripple (dB)
Rs=30; % Stopband Ripple (dB)
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs); % Calculate Filter Order
[z,p,k] = cheby2(n,Rs,Ws); % Design Filter
[sos,g] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(1)
freqz(sos, 2^16, Fsp)
set(subplot(2,1,1), 'XLim',[0 100]) % ‘Zoom’ X-Axis
set(subplot(2,1,2), 'XLim',[0 100]) % ‘Zoom’ X-Axis
IIR filters have the advantage if being shorter than FIR filters, important with shorter data vectors. For your application, I would use the Chebyshev Type II IIR filter.
More Answers (0)
See Also
Categories
Find more on Single-Rate Filters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!