Accelerometer data filtering during standing balance measurement
Afficher commentaires plus anciens
I was using a body worn tri-axial accelerometer for measuring sway during standing balance. In the literature, I have read something about eliminating gravitational component followed by filtering the data in the accelerometer. As I am from medical background I don't have much knowledge on this. does anyone knows something about this and filtering a accelerometer data measured at 100hz sampling rate like what kind of filtering and cut-off frequency i should use for those data..
Réponses (1)
Star Strider
le 2 Déc 2014
The filter you design depends on the signals you have. In order to filter out the gravitational component (a constant), you probably need to design a bandpass filter with a stopband lower cutoff of 0.1 Hz, and an upper cutoff of about 40 Hz. If you have the Signal Processing Toolbox, you can see if this filter design does what you want:
Fs = 100; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
passband = [5.0 20]/Fn; % Passband (Hz)
stopband = [0.1 40]/Fn; % Stopband (Hz)
passripple = 1; % Passband Ripple (dB)
stopripple = 10; % Stopband Ripple (dB)
[n,Wn] = buttord(passband, stopband, passripple, stopripple);
[z,p,k] = butter(n,Wn);
[sos,g] = zp2sos(z,p,k);
figure(1)
freqz(sos,[0:0.1:50], Fs)
then use the filtfilt function to filter your data. See the documentation for the various functions for details on them. If you get too much noise, reduce the upper passband and stopband frequencies. You will probably have to experiment with it to get the result you want.
8 commentaires
Surendar
le 2 Déc 2014
Star Strider
le 2 Déc 2014
Modifié(e) : Star Strider
le 2 Déc 2014
My pleasure.
Put the code in this comment in your script after the code in my Answer.
You need to define the filter passbands to pass and reject the frequencies you are comfortable with, but using the filter I designed in my Answer, this is how I filtered and plotted your data. The filtfilt function can filter all three signals in a single call to it, so you do not have to filter every signal individually. Note that the constants (including the gravitational acceleration) do not appear in the filtered signal because the filter is designed to exclude such constants, so no other processing other than the filter is necessary:
[d,s,r] = xlsread('Surendar PAT113069_0E_14_07.csv','B1:D107517');
Lv = size(d,1); % Length Of Data Vectors
Ts = 1/Fs; % Sampling Interval (s)
Tv = linspace(0,(Lv-1)*Ts,Lv); % Time Vector
df = filtfilt(sos,g,d); % Filter Signals
figure(2)
plot(Tv, d)
grid
xlabel('Time (s)')
ylabel('Acceleration (G)')
title('Unfiltered Signals')
figure(3)
subplot(3,1,1)
plot(Tv, df(:,1))
grid
ylabel('Acceleration (G)')
title('Channel #1 (X?)')
subplot(3,1,2)
plot(Tv, df(:,2))
grid
ylabel('Acceleration (G)')
title('Channel #2 (Y?)')
subplot(3,1,3)
plot(Tv, df(:,3))
grid
xlabel('Time (s)')
ylabel('Acceleration (G)')
title('Channel #3 (Z?)')
figure(4)
plot3(df(:,1), df(:,2), df(:,3))
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
Figures 1 through 3 are self-explanatory. Figure 4 plots all three together in a 3D plot. (I include figure(4) for illustration. It is not necessary to understand your data.)
Surendar
le 3 Déc 2014
Star Strider
le 3 Déc 2014
It ran perfectly with the file you gave me. I would not have posted it if it didn’t.
I renamed your file so I can keep track of downloaded files. You may want to change the xlsread line to:
[d,s,r] = xlsread('PAT113069_0E_14_07.csv','B1:D107517');
I’m using R2014b, so if you have a different release you may need to consult the documentation for xlsread for your version. (My code doesn’t use ‘s’ and ‘r’. I read them in so I can see where any problems might arise. You only need to read in ‘d’.)
Surendar
le 3 Déc 2014
Star Strider
le 3 Déc 2014
You can simply negate all the values in the filtered accelerometer data if that works for you. It would not affect the RMS, it would reverse the sway path in every dimension, and would reverse the sign of the velocity (after you integrate the acceleration with the cumtrapz function), so you may not want to negate them.
They are your data, so these decisions are yours. I would follow whatever the literature conventions are, since those are the standards you want to meet.
Surendar
le 3 Déc 2014
Star Strider
le 3 Déc 2014
If you mounted the sensor upside down your other axes would likely be flipped as well, so you would likely need to negate all your x,y,z data with d=-d for the rest of your analyses. You may have to re-run your experiment with the accelerometer oriented correctly to determine how best to correct your current data.
Otherwise, since the idea of the filter is to eliminate the constant offsets and high-frequency noise, the filter should not adversely affect your results. You may want to correct for the baseline effects, the baselines given by their respective means over a range of data:
BLI = 20000:100000; % Representative Baseline Data Indices
dm = mean(d(BLI,:)); % Means
xm = dm(1); % X-Mean
ym = dm(3); % Y-Mean
zm = dm(2); % Z-Mean
You can use those to adjust your data based on those collected with your accelerometer mounted correctly.
The orientation of your accelerometer will not affect the results of the filter output. You may want to add back the ‘xm’, ‘ym’, and ‘zm’ offsets to the filtered data depending on how you designed your experiment.
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!