Bandpass Filtering EEG Data

7 Ansichten (letzte 30 Tage)
Sonal Muzumdar
Sonal Muzumdar am 6 Jul. 2015
Beantwortet: Daniel M am 9 Nov. 2019
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

Antworten (1)

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

Kategorien

Mehr zu EEG/MEG/ECoG finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by