When collecting data, the phone is placed in the back right pocket, facing screen-in. The phone's internal coordinate system is oriented as showing in Figure 1.
The directions of motion in relation to the student taking the data are as follows:
The x-dimension is lateral (side to side) motion
The y-dimension is vertical (up and down) motion
The z-dimension is forward and backward
Figure 1: Illustration of phone coordinate system [8]
We collected data on a set of ten steps with good form and a set of ten steps with bad form and compared the frequencies present in each to come up with algorithms to analyze how good a set of ten steps are in each dimension.
In the x (lateral) dimension, a good front stance should have some sinusoidal acceleration because the feet should be tracing in arcs as they move from should width apart to together and back to should width apart.
In the y (vertical) dimension, a good front stance should have an acceleration of 0 as hips should not move up and down.
In the z (forward/backward) dimension, a good front stance should have constant motion with discrete stops in between steps.
To use this algorithm a student should collect acceleration data on at least ten steps in front stance as input.
Moving in martial arts stances is periodic because it consists of performing repeated, controlled steps. The acceleration data was collected in the time domain, but periodic motions are easier to characterize in the frequency domain. In Figures 2a and 2b below, the z-axis acceleration is shown in both the time domain and frequency domain for comparison. There are clearer features showing up in the frequency domain, such as the increased magnitude of frequencies below 0.5 Hz.
Figure 2a: Acceleration over time; No clear pattern
Figure 2b: Acceleration by Frequency; Low frequencies apparent
We used Discrete Fourier Transform (DFT) to map the acceleration data from time to frequency domain. To perform this transformation, multiply time domain data by transformation matrix W: [6]
This can also be written in terms of acceleration a by frequency i directly as: [7, p. 153]
The output matrix of acceleration a is on the range of [0, N-1], but when the frequency range is shifted to center on 0 Hz for easier visualization, the new bounds are:
The three types of filters we used are an averaging function, a naïve implementation of a notch filter, and a maximum filter. A notch filter attenuates the specific frequency band targeted, but our version of this filter is to remove that frequency component entirely.
NOTE: We will be graphing "good" data and "bad" data separately because it is harder to visually distinguish when they are on the same graph due to overlap. However, they are still scaled the same for easy comparison.
Figure 3a: Frequency plot of good front stance x-acceleration
Figure 3b: Frequency plot of bad front stance x-acceleration
Both datasets show that the frequency with the greatest magnitude is 0 Hz, meaning that there were periods with constant or zero acceleration in the x-axis. This matches the expectation because there is a pause in between steps during which the acceleration measured should be zero. The pauses between steps are not as relevant as the steps themselves in judging the difference between good and bad form, so we used the notch filter to attenuate 0 Hz.
The peak at 1 Hz on the good data graph indicates that this is the primary frequency of sinusoidal hip movement. For different individuals or different attempts, the frequency at which this hip movement occurs could change, but it should not change greatly as the front stance should still be performed in a slow and controlled way. We can identify the primary frequency of x-axis movement as the frequency with the highest magnitude other than 0 Hz.
Filtering for the non-zero frequency with the highest magnitude doesn't work on a bad front stance because in the bad data above, the frequency with the second greatest magnitude is not meaningful. Instead, the average magnitude of the rest of the frequency range produces a measure of how much unwanted oscillation is happening during movement. Dividing the magnitude of this "primary frequency" by the average magnitude of the rest of the frequencies produces a ratio gauging how sinusoidal the hip movement is. If the ratio is high, the side-to-side movement of front stance was performed well, with clear sinusoidal hip movement.
If our algorithm senses that the hips have too much high frequency noise, (i.e. if the ratio is less than 4) it will tell the student:
"Your side-to-side movement needs improvement. Try to keep your hips square with your shoulders, below your center of gravity."
Figure 4a: Frequency plot of good front stance y-acceleration
Figure 4b: Frequency plot of bad front stance y-acceleration
In the y-axis data the magnitude of the 0 Hz frequency is the tallest, while the rest of the frequency range has a much lower average value. The 0 Hz frequency measures the component of constant or zero acceleration. In an ideal front stance there should be zero y-acceleration, so it is promising to see that the frequency that measures this has a large relative magnitude.
The difference between the good and the bad front stance here is the magnitude of the unwanted acceleration frequencies. In the bad data we can see that there is more unwanted oscillation happening. We will use the average magnitude across the rest of the frequency range to get a measure of this. Taking the ratio of the 0 Hz magnitude divided by the average magnitude across the rest of the frequency range gives a measure of how much greater the constant acceleration is than the unwanted periodic acceleration.
If the y ratio is less than 100, our algorithm will tell the student:
"Your hips are moving up and down too much. Keep your hips level throughout the stance."
Figure 5a: Frequency plot of good front stance z-acceleration
Figure 5b: Frequency plot of bad front stance z-acceleration
The important part of z-axis movement is the pauses between the steps. To ensure that motion is smooth and does not waste energy, the steps should end as soon as possible without overshooting and causing additional oscillation from regaining their balance.
In Figure 5a, the magnitude of 0 Hz is high relative to the other frequencies, meaning a lot of constant or 0 acceleration. This matches the expectation of the motion model that there would be a higher 0 Hz magnitude due to the stops between steps having a constant acceleration of 0. Comparing this to the bad data in Figure 5b, the magnitude of 0 Hz is smaller than the frequency with the greatest magnitude. This smaller magnitude of 0 Hz means that stops between steps either weren't as long in duration or that they were performed poorly, overshooting to cause a greater amount of oscillation.
To get a measure of how much of the time the student was stopped with 0 acceleration (a good pause between steps) versus how much they were oscillating forwards or backwards, take the ratio of the magnitude of 0 Hz to the average of the rest of the frequency range.
If our algorithm detects that the student isn't fully stopping ( i.e. the ratio is below 8) it will tell the student:
"Your forwards/backwards movement needs improvement. Try working on stopping cleanly between steps."