Bandpass Filtering EEG Data

5 次查看(过去 30 天)
Sonal Muzumdar
Sonal Muzumdar 2015-7-6
回答: Daniel M 2019-11-9
Hi!
I'm trying to bandpass filter EEG data that has 64 channels. For some reason, the filter is replacing a large part of some channels with NaNs. Here is the code I'm using. Fs in this case is 240 Hz. I have attached the EEG data that I'm using. Thank you so much!
function [ppf] = pfilter(x, Fs)
%First apply a bandpass filter to get frequencies between 0.1 Hz and 40 Hz
Fn = Fs/2; %nyquist frequency
wp = [1 40]/Fn; %normalizing frequency range.
[b,a] = butter(1,wp);%1st order butterworth filter.
[sos,g] = tf2sos(b,a);
figure(1);
freqz(sos, 240, Fs);
ppf = x;
for i = 1:size(x,2);
tmp = ppf(:,i); tmp(tmp==0)=NaN;
tmp(isfinite(tmp)) = detrend(tmp(isfinite(tmp)));
ppf(:,i) = filter(b,a,tmp);
end
end

回答(1 个)

Daniel M
Daniel M 2019-11-9
Here's your problem
tmp(tmp==0)=NaN;
Don't do that.

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by