Borrar filtros
Borrar filtros

Ideal way to smoothe gyroscope data

19 visualizaciones (últimos 30 días)
Ines Shekhovtsov
Ines Shekhovtsov el 24 de En. de 2023
Comentada: Star Strider el 25 de En. de 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.

Respuesta aceptada

Star Strider
Star Strider el 24 de En. de 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 comentarios
Ines Shekhovtsov
Ines Shekhovtsov el 25 de En. de 2023
Thank you for all of your help! The raw data in the .csv will need to be resampled. I believe for a lot of my future analysis i will resample EMG and sync data to 2000Hz. The gyro data will only be reseampled to 150Hz so as to not lose too much of original. If you can see from the .csv file the output doesn't manually create a time vector column since there are three different types of signals (EMG, gyroscope and analog signal) all sampled at different frequencies. In the beginning of my code, i removed the NaN values as they are just there to match data point to data point up to the highest sampled signal (The analog is sampled at 2222.2222Hz). And yes, i gave you a small file that is pretty short which is why there is no more signal after 14s. As far as time vector for this analysis, i am assuming i can manually create that based on the number of seconds in the file (14.175s), the number of data points for each signal type and their acquisition frequencies.
Star Strider
Star Strider el 25 de En. de 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.
.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by