Ideal way to smoothe gyroscope data
18 views (last 30 days)
Show older comments
Ines Shekhovtsov
on 24 Jan 2023
Commented: Star Strider
on 25 Jan 2023
Hello,
I have a .csv file that contains EMG and gyroscope data collected from the Delsys Trigno Avanti System. These wireless electrodes collect EMG data at 1924.233Hz and gyroscope data at 74.0741Hz (Honestly i'm a bit confused as to why the sampling frequency is not a whole number). I know how to work with EMG data but this is my first time working with gyroscope data. Each sensor collects gyroscope data in x,y and z directions. I am creating a figure that shows EMG data on left and the corresponding gyroscope data in all three directio on the right. The x, y and z direction plots are overlayed on top of each other. I would like to smooth this gyroscope data and a brief google search made me even more unsure of what the best approach might be for this. I know it depends on what we want to do with the data but i am not sure of that yet. As of now i just want to smoothe the data. Previously for smoothing we have used a LPF at 10Hz. I am just curious what you all would suggest. Thank you for your time.
0 Comments
Accepted Answer
Star Strider
on 24 Jan 2023
The LPF approach is likely appropriate, and an IIR filter (elliptical is most efficient) is likely the best option.
First, determine if the sampling intervals are constant. This can be done by taking the mean and std of the differences (diff) of the time vector. If the standard deviation is small (on the order of or so times the mean value), the time vector can be used without resampling. If it is larger than that, it might first be necessary to use the resample function to resample it to a reliable time vector. Use a sampling frequency at least 2 times ‘1/mean(diff(t))’ for this. Most signal processing (and all filtering) require a regularly-sampled time vector to work correctly with the signal.
The problem then may be in selecting the passband and stopband frequencies. The best way to do that is to calculate the fft of the signal, and then search the plot of it for the ‘best’ passband frequency. Sometimes, this can be automated, however most times it will require experimenting with different frequencies to determine which one produces the best result when it is used to filter the signal.
The fft will also help to determine if there’s broadband noise in the signal. If there is, the two options to reduce it are to use wavelet denoising on the original signal, or use the Savitzky-Golay filter (sgolayfilt) on the original signal. Again, the sgolayfilt arguments will require experimentation. I usually use a 3-degree polynomial and then choose the ‘framelen’ parameter to produce the best result. Do that before doing frequency-selective lowpass filtering.
This outlines the workflow I usually use in processing experimental data. I can help you if you need my help.
.
8 Comments
Star Strider
on 25 Jan 2023
As always, my pleasure!
It will be necessary to have the original time vectors for the gyroscope signals in order to resample them correctly to a new, constant-interval, time vector.
I use the syntax:
[sr,tr] = resample(s,t,Fs);
for such problems, where ‘s’ is the original signal,‘t’ the original time vector, ‘Fs’ the desired sampling frequency of the resampled signal (it can be anything that reasonably preserves the original signal data without doing excessive interpolation, here likely 70 Hz to 80 Hz, rethinking my earlier suggestion of 150 Hz), ‘sr’ is the resampled signal, and ‘tr’ is the resampled time vector.
For regularly-sampled signals with a known sampling frequency, you can calculate the time vector the same way I calculated ‘t’ in my code.
The rest of my code should work essentially as written for the resampled signals, with necessary changes to some of the parameters. I will of course help to get it to run with the resampled data if there are any problems with it.
I did not include any of the EMG data in my code, since I understood that the gyroscope data were the primary concern. I can include the EMG data if I understand what you want to do with them.
.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!