Search

Gait analysis made simple

The integration of motion analysis and wearable technology.

Open Source IMU Hardware and Gait Database – Data sets

Open source platform for collaborative construction of wearable sensor data sets for human motion analysis and an application for gait analysis

[Journal of Biomedical Informatics]

1. OSHWSP

Open Source Hardware Sensor Platform. an affordable open source hardware and software platform based on inertial wearable sensors in a way that several groups could cooperate in the construction of datasets through common software suitable for collaboration.

https://github.com/bmswgnp/oshwsp-imu_WS

http://www.sciencedirect.com/science/article/pii/S1532046416301113#gr1

http://www.sciencedirect.com/science/article/pii/S1532046416301113#gr2

3. MAREA – Open Source Gait Datasets / Gait Data Database

MAREA (Movement Analysis in Real-world Environments using Accelerometers) Gait Database

http://islab.hh.se/mediawiki/Gait_database

 

Indoor Table.pngOutdoor Table.pngGroundTruthStructure.png

How to get the datasets?

1. Link to the Release Agreement and fill Registration Form: Click_Release Agreement
2. Link to download the datasets: Will be sent by Email after Registration Procedure is completed
2. Link to the code for gait event detection algorithm: Gait Events
Featured post

Complementary filter design

To understand complementary filter before we should know nature of the sensors signals. We know the signals from accelerometer (its slow or fast movind based on Hardware you used and same way the signals from a gyroscope. But the complementary filter design here is to take slow moving signals from accelerometer and fast moving signals from a gyroscope and combine them.

Accelerometer gives a good indicator of orientation in static conditions.

Gyroscope gives a good indicator of tilt in dynamic conditions.

So the idea is to pass the accelerometer signals through a low-pass filter and the gyroscope signals through a high-pass filter and combine them to give the final rate.
The key-point here is that the frequency response of the low-pass and high-pass filters add up to 1 at all frequencies.

  • Combine orientation estimated from Accelerometer readings with that estimated from the Gyroscope readings

Racc – current readings from accelerometer
Rgyro – obtained from Rest(n-1) and current gyroscope readings

 

Measuring Angles: Two sensors, No reliability! Gyros Drift Approximate discrete integration Accelerometers Precise only if...

This means that at any given time the complete signal is subject to either low pass or highpass.
Equation for low-pass filter:
y[n]=(1-alpha).x[n]+alpha.y[n-1]            //use this for angles obtained from accelerometers
x[n] is the pitch/roll/yaw that you get from the accelerometer
y[n] is the filtered final pitch/roll/yaw which you must feed into the next phase of your program

Equation for high-pass filter:
y[n]=(1-alpha)y[n-1]+(1-alpha)(x[n]-x[n-1])    //use this for angles obtained from gyroscopes
x[n] is the pitch/roll/yaw that you get from the gyroscope
y[n] is the filtered final pitch/roll/yaw which you must feed into the next phase of your program

n is the current sample indicator.
alpha is related to time-constant. it defines the boundary where the accelerometer readings stop and the gyroscope readings take over and vice-versa. It controls how much you want the output to depend on the current value or a new value that arrives. Both the alpha’s have to be the same. alpha is usually > 0.5 using the definitions above.

How to choose alpha?

α  = Γ / (Γ + dt)

alpha=(tau)/(tau+dt) where tau is the desired time constant (how fast you want the readings to respond) and dt = 1/fs where fs is your sampling frequency. This equation is derived from filter/control theory will put a link to this  from

A quick and dirty way of implementing a complementary filter:
angle = (1-alpha)*(angle + gyro * dt) + (alpha)*(acc)
First reading is the angle as obtained from gyroscope integration. Second reading is the one from accelerometer.
In the case that gyro = 0, angle will converge to that given by accelerometer.
If alpha is really small the output angle will not believe the reading from the accelerometer so readily and will believe the gyroscope as and when it happens.

Gyroscope Drift problem [7], [6]

Due to non-ideal offset compensation of the gyroscope “gyro_x_scalled” is never equal to zero and with time “angle_x_gyro” will drift away. To solve this problem, angle is also calculated using the accelerometer and then combined with angle calculated by gyroscope. As the MPU6050 chip is placed horizontally to the ground, the z axes acceleration measures 1g (i.e. 9.81) as shown in Figure 3. We can use this acceleration vector and its projection on y and x axes to calculate the angle of x and y.

Figure 3: Projection of z-axis acceleration on x-axis tilt

And the angle calculated using accelerometer are given as

\theta_x^{accel} = \tan^{-1}\frac{accel x scalled}{\sqrt{accel y scalled^2+accel z scalled^2}}
\theta_y^{accel} = \tan^{-1}\frac{accel y scalled}{\sqrt{accel x scalled^2+accel z scalled^2}}

The problem with angle calculated using accelerometer is that they are noisy and any application which have vibrations can affect the accuracy of the calculated angle. Moreover, if the MPU6050 is moved along any axes it register acceleration and messes up the angle calculation. So to get better results, the angle calculated using gyroscope and accelerometer are combined using a simple filter.

\theta_x = Filter_gain*\theta_x^{gyro} + (1-Filter_gain)*\theta_x^{accel}

and use the filtered angle “\theta_x” in the integration of the gyroscope instead of “\theta_x^{gyro} ” to avoid the drift problem. So the equation for the gyroscope angle is changed to

\theta_x^{gyro} (t_n)  = gyro_x_scalled * T  + \theta_x(t_{n-1})

Figure 4 shows the implementation of the given equations in Arduino Sketch

Figure 4: Arduino Sketch calculating angles

Featured post

Sensor Fusion

Sensor Fusion

Sensor Fusion is a process by which IMU data from several different sensors (such as Accelo, Gyro and Magnto) are “fused” to compute something more than could be determined by any one sensor alone or improve accuracy, reliability and filtering IMU sensors data. An example is computing or estimating position and orientation of a body segment in three dimensional space.

  • An accelerometer measures inertial force, such as gravity (and ideally only by gravity), but it might also be caused by acceleration (movement) of the device. Even if the accelerometer is relatively stable, it is very sensitive to vibration and mechanical noise.
  • A gyroscope is less sensitive to linear mechanical movements, the type of noise that accelerometer suffers from. Gyroscopes have other types of problems like drift (not coming back to zero-rate value when rotation stops).
  • Averaging the data that comes from accelerometers and gyroscopes can produce a better estimate of orientation than obtained using accelerometer data alone.

A prerequisite for sensor fusion, is that of calibration: the sensors themselves have to be calibrated and provide measurement in known units. Furthermore, whenever multiple sensors are combined additional calibration issues arise, since the measurements are seldom acquired in the same physical location and expressed in a common coordinate reference frame.

Here, there are using 3 types of sensors. Each of these sensor types provides unique functionality, but also has limitations:

  • Accelerometer: x-, y- and z-axis linear motion sensing, but sensitive to vibration and mechanical noise.
  • Gyroscope: pitch, roll and yaw rotational sensing, gyroscope drift (not coming back to zero-rate value when rotation stops).
  • Magnetometer: x-, y- and z-axis magnetic field sensing, but sensitive to magnetic interference
Accelerometers sense Gyroscopes sense
Accelo changes in direction or orientation/inclination with respect to gravity force Gyroscope to a more exact angular displacement.
Accelerometers are more accurate in static calculations, when the system is closer to its fixed reference point. Gyroscopes are better at detecting orientation when the system is already in motion.
Accelerometers tend to distort accelerations due to external forces as gravitational forces in motion; which accumulates as noise in the system and erroneous spikes in resulting outputs. With the addition of the long-term accuracy of a gyroscope combined with the short-term accuracy of the accelerometer, these sensors can be combined to obtain more accurate orientation readings by utilizing the benefits of each sensor. Gyroscopes sense orientation through angular velocity changes and therefore find orientation, but they have a tendency to drift over time because they only sense changes and have no fixed frame of reference.

Fundamental of  developing sensor fusion algorithm

 

1. Complementary Filtering

Combine orientation estimated from Accelerometer readings with that estimated from the Gyroscope readings

I want to explain briefly how the sensor fusion approach works. In simple terms, the acceletometer sensor data provides the gravity vector (the vector pointing towards the centre of the earth) and the magnetometer works as a compass. The Information from both sensors suffice to calculate the device’s orientation. However both sensor outputs are inaccurate, especially the output from the magnetic field sensor which includes a lot of noise.

The gyroscope in the device is far more accurate and has a very short response time. Its downside is the dreaded gyro drift. The gyro provides the angular rotation speeds for all three axes. To get the actual orientation those speed values need to be integrated over time.  This is done by multiplying the angular speeds with the time interval between the last and the current sensor output. This yields a rotation increment. The sum of all rotation increments yields the absolute orientation of the device. During this process small errors are introduced in each iteration. These small errors add up over time resulting in a constant slow rotation of the calculated orientation, the gyro drift.

To avoid both, gyro drift and noisy orientation, the gyroscope output is applied only for orientation changes in short time intervals, while the magnetometer/acceletometer data is used as support information over long periods of time. This is equivalent to low-pass filtering of the accelerometer and magnetic field sensor signals and high-pass filtering of the gyroscope signals.

Sensor fusion using Complementary Filter and Remove Gyro Drift error

What exactly does high-pass and low-pass filtering of the sensor data mean?

Sensor fusion – gyroscope and accelometer signal data

Combine orientation estimated from Magnetometer readings with that estimated from the Gyroscope readings

  • Rmag – current readings from Magnetometer
  • Rgyro – obtained from Rest(n-1) and current gyroscope readings

The sensors provide their data at (more or less) regular time intervals. Their values can be shown as signals in a graph with the time as the x-axis. The low-pass filtering of the noisy accelerometer/magnetometer signal are orientation angles averaged over time within a constant time window.

Assuming that the device is turned 90° in one direction and after a short time turned back to its initial position, the intermediate signals in the filtering process would look something like this:

Notice the gyro drift in the integrated gyroscope signal. It results from the small irregularities in the original angular speed. Those little deviations add up during the integration and cause an additional undesireable slow rotation of the gyroscope based orientation.


2. Kalman Filter

A Quick Insight of Kalman Filering

It’s nearly not hard to get the full meaning of Kalman Filter by starting from definitions and complicated equations (at least for us mere mortals) whatever you have come across from many resources or books.

For most cases and ref. materials, the state matrices drop out and we obtain the below Kalman filtering equation, which is much easier to start with in simple way to understood.
Kalman Filter - quick insight
Remember, the k‘s on the subscript are states. Here we can treat it as discrete time intervals, such as k=1 means 1ms, k=2 means 2ms.

Iterate steps

Kalman Filter - Iteration Process

 

Kalman Filtering ref. link

Featured post

Statistical analysis : Two-sample t-test

What is t-test an why we do it?

A t-test is an analysis of two populations means through the use of statistical examination; a t-test with two samples is commonly used with small sample sizes, testing the difference between the samples when the variances of two normal distributions are not known.

A t-test looks at the t-statistic, the t-distribution and degrees of freedom to determine the probability of difference between populations; the test statistic in the test is known as the t-statistic. To conduct a test with three or more variables, an analysis of variance (ANOVA) must be used. [1]

Statistical Analysis of the T-Test

The formula used to calculate the test is a ratio: The top portion of the ratio is the easiest portion to calculate and understand, as it is simply the difference between the means or averages of the two samples. The lower half of the ratio is a measurement of the dispersion, or variability, of the scores. The bottom part of this ratio is known as the standard error of the difference. To compute this part of the ratio, the variance for each sample is determined and is then divided by the number of individuals the compose the sample, or group. These two values are then added together, and a square root is taken of the result.

Read more: T-Test http://www.investopedia.com/terms/t/t-test.asp#ixzz4TY1g1WT2

Two-Sample t-test

The two-sample t-test is a parametric test that compares the location parameter of two independent data samples.

The test statistic is

t=¯x¯yGs2xn+s2ym,

where ¯x and ¯y are the sample means, sx and sy are the sample standard deviations, and n and m are the sample sizes.

In the case where it is assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has Student’s t distribution with n + m – 2 degrees of freedom, and the sample standard deviations are replaced by the pooled standard deviation

s=G(n1)s2x+(m1)s2yn+m2.

In the case where it is not assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has an approximate Student’s t distribution with a number of degrees of freedom given by Satterthwaite’s approximation. This test is sometimes called Welch’s t-test.

In Matlab how you can calculate with example:

Syntax

 t-Test for Equal Means Without Assuming Equal Variances

Test the null hypothesis that the two data vectors are from populations with equal means, without assuming that the populations also have equal variances.

[h,p] = ttest2(x,y,'Vartype','unequal')
h = 0
p = 0.9867

The returned value of h = 0 indicates that ttest2 does not reject the null hypothesis at the default 5% significance level even if equal variances are not assumed.

 

Continue reading “Statistical analysis : Two-sample t-test”

Blog at WordPress.com.

Up ↑