Savitzky-Golay filtering on emg signal

23 vues (au cours des 30 derniers jours)
Zainab
Zainab le 26 Juin 2024
Hello everyone,
I am working on a project that uses SEMG signals to move a prosthetic arm. I am trying to figure out how to use the Savitzky Golay filter to smooth the "sound" on the graph. I am trying to only have the full "contractions" and the smooth the "rest" parts of the graph

Réponses (3)

Diego Caro
Diego Caro le 26 Juin 2024
What works best for me is just filtering the EMG signal with a lowpass butterworth filter with a very low cutoff frequency.
For example:
% Take a look at the raw signal
t = time_range;
emg = raw_emg;
figure
plot(t,emg)
Now lets add the lowpass filter and compare its output.
fc = 3; % Cutoff frequency in Hz.
n = 4; % Filter order.
fs = 100; % Sample rate.
[b,a] = butter(n,fc/(fs/2),"low");
emg_filt = filter(b,a,emg);
figure
hold on
plot(t,emg)
plot(t,emg_filt,'LineWidth',1.5,'Color','r')
legend('Raw EMG','Filtered EMG')
Here I used a cutoff frequency of 3 Hz, which is very low, but you can go as low as you want if you desire a more agressive smoothing. There are several other methods you can use to smooth an EMG signal, but as I said, this is my personal preference.
Regards,
Diego.

Umar
Umar le 26 Juin 2024
Hi Zainab,
To achieve this in Matlab, you can utilize the sgolayfilt function. This function applies the Savitzky-Golay filter to your signal. You can specify the frame length and polynomial order to control the smoothing effect. Here's a simple example of how to use the Savitzky-Golay filter in Matlab:
% Sample SEMG signal data signal = your_signal_data;
% Define parameters for the filter frame_length = 15; % Adjust based on your signal characteristics poly_order = 3; % Adjust for desired smoothing
% Apply Savitzky-Golay filter smoothed_signal = sgolayfilt(signal, poly_order, frame_length);
% Plot the original and smoothed signals figure; plot(signal, 'b', 'LineWidth', 1.5); hold on; plot(smoothed_signal, 'r', 'LineWidth', 1.5); legend('Original Signal', 'Smoothed Signal'); xlabel('Time'); ylabel('Amplitude'); title('SEM Signal Smoothing using Savitzky-Golay Filter');
By adjusting the frame_length and poly_order parameters, you can tailor the smoothing effect to enhance the "contractions" while effectively smoothing the "rest" parts of your SEMG signal graph.

Star Strider
Star Strider le 26 Juin 2024
Calcualte the Fourier transform of the data (fft) to determine tthe frequency content of the signal, and then use a frequency-selective filter (either lowpass or bandpass) to remove the high-frequency noise and, if necessary, baseline offset and baseline drift. The Savitzky-Golay filter is essentially a multiband FIR filter that while appropriate in some applications, is simply too slow for any sort of real-time application. Experiment with the discrete (digital) filters with your recorded signals, and then implement them in hardware for your intended real-time continuous application.

Community Treasure Hunt

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

Start Hunting!

Translated by