How can I remove the noise from EEG signal? Sleeping data.
Mostrar comentarios más antiguos
Thank you for your attention. I made this program, but can't run now. Maybe 'bandpass filter' is wrong.
Error message{
Error in MyEEGFil (line 14)
s(:,1) = bpfilter(s(:,1), [0.3 SampleRate]); %bpfilter is another built filter.
Error in MyEEG (line 10)
ans(i,:) = MyEEGFil(record(i,:),fs);
Also I can't use 'designfilt'
function OutputEEG = MyEEGFil(InputEEG,fs)
% Notch filter
s = InputEEG;
s =double(s);
w0 = 50*(1/fs);
[b,a] = iirnotch(w0, w0/35); %iirnotch is notch filter (a built in function in Matlab)
s = filtfilt(b, a, s);
% Bandpass filter
s(:,1) = Bandpass(s(:,1), [0.3 fs]); %bpfilter is another built filter.
s(:,2:3) = Bandpass(s(:,2:3), [0.3 fs]);
s(:,4) = Bandpass(s(:,4), [10 fs]);
% Replace NaN and Inf with 0
s(isnan(s)) = 0;
s(isinf(s)) = 0;
% Convert to single
s = single(s);
lowEnd = 3; % Hz
highEnd = 70; % Hz
filterOrder = 2; % Filter order (e.g., 2 for a second-order Butterworth filter). Try other values too
[b, a] = butter(filterOrder, [lowEnd highEnd]/([fs fs])); % Generate filter coefficients
d = designfilt('bandstopiir','FilterOrder',8, ...
'HalfPowerFrequency1',49,'HalfPowerFrequency2',51, ...
'DesignMethod','butter','SampleRate',fs);
s =double(s);
Foutput(1,:) = filtfilt(d,s(1,:));
Foutput(1,:) = filtfilt(b,a,Foutput(1,:));
OutputEEG = Foutput;
end
3 comentarios
Jan
el 20 de Nov. de 2018
Please explain the important detail what "can't run now" means. It is easier to fix a problem than to guess, what the problem is.
Yusuke Kuroda
el 20 de Nov. de 2018
Editada: Yusuke Kuroda
el 21 de Nov. de 2018
Jan
el 21 de Nov. de 2018
The error message seems to be clear. I do not know, how your file Bandpass() is implemented, but the first argument is expected to be an integer greater than 1. See:
help Bandpass
Respuestas (0)
Categorías
Más información sobre EEG/MEG/ECoG en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!