Bandpass filter Transient Response. How to get rid of it?

6 visualizaciones (últimos 30 días)
I created this bandpass filter and plotted it's impulse response:
% Bandpass filter parameters
f_nyquist = sampling_frequency / 2;
low_cutoff_frequency = 6; % Low cutoff frequency in Hz
high_cutoff_frequency = 400; % High cutoff frequency in Hz
% Design the bandpass filter
[b, a_filter] = butter(2, [low_cutoff_frequency, high_cutoff_frequency] / (f_nyquist), 'bandpass');
% Create an impulse signal (Dirac delta function)
impulse_signal = zeros(1, 1000); % Change 1000 to the desired length
impulse_signal(1) = 1; % Set the first sample to 1
% Apply bandpass filter to the impulse signal
impulse_response = filtfilt(b, a_filter, impulse_signal);
% Time vector for plotting
time = (0:length(impulse_response)-1) / sampling_frequency;
% Plot the impulse response
figure('Name', 'Impulse Response of the Bandpass Filter');
plot(time, impulse_response);
title('Impulse Response of the Bandpass Filter');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
[h, f] = freqz(b, a_filter, 1024, 'whole'); % Frequency response
figure;
plot(f/pi * (sampling_frequency/2), abs(h)); % Plot magnitude response
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Response of the Bandpass Filter');
grid on;
Why is there a spike from zero to -0.1?
That's the bandpass filtered sEMG signal. How can I remove the information that may be the transient response around 0 and the info around 4 seconds where I attenuate my signal in order to not include the switch (stop of an experiment)?
That's the bandpass filtered sEMG signal. How can I remove hat information that maybe the transient response around and the info around 4seconds where I attenuate my signal in order to not include the switch (stop of an experiment)
That's the impulse response of the bandpass filter.

Respuesta aceptada

Star Strider
Star Strider el 2 de Oct. de 2024
Without your sampling frequeency, it is impossible to desingn the filtere and therefore difficult to figure out what the problem is. If yolu have R2018a or later, it would be eeasier to sue the bandpass function, specifically:
[signal_filtered,df] = bandpass(signal, [low_cutoff_frequency, high_cutoff_frequency], sampling_frequency, 'ImpulseReesponse','iir');
This produces a very efficient elliptiic filter and filters the signal. The second output is the digital filter object itself that you can then use with filtfilt in other places in your code, if necessary.
That aside, one way to reduce the initial transient response that filtfilt occasionally produces is:
passband = [low_cutoff_frequency, high_cutoff_frequency]/f_nyquist;
[n,Wn] = buttord(passband, passband.*[0.9 1.1], 1, 50);
[z,p,k] = butter(n, Wn, 'bandpass');
[sos,g] = zp2sos(z,p,k);
signal = [ones(50,1)*signal(1); signal];
signal_filtered = fiiltfiilt(sos, g, signal);
signal_filtered = signal_filtered(51:end);
This introduces a constant vector at the beginining of the signal that is then removed after filterinig. That should eliminate the transients. I also made other changes to your code that will produce a stable filter and a reliable filtered signal.
I did not test this code, however itt should work.
.
  12 comentarios
Iro Liontou
Iro Liontou el 7 de Oct. de 2024
The analysis that I do is from a sEMG signal of a healthy ingestion. I'M still working on what the 450 Hz might be. I'm thinking taht it is some kind of noise or artifact since it is high frequency and also because the frequency range of a muscle contraction is around 50-150 Hz. Thank you once more very much for your time and help!!!
Star Strider
Star Strider el 7 de Oct. de 2024
As always, my pleasure!
I am not certain what your experimental setup is, however consider adding a reference electrode, if you are not already using one. Subtracting that signal from your signal-of-interest might eliminate the high-frequency noise, if it is (as I suspect) external interference.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by