Algorithm and application development
When walking, the acceleration signal’s cyclical nature permits step identification using the amplitude at each peak and the time between each peak or zero-crossing. Some basic algorithms set a minimum amplitude threshold that, when surpassed, identifies a step [10,11,20-22]. This approach can be problematic if acceleration fluctuates throughout the gait cycle, introducing false peaks. The time between steps is often used to set a “locking period” during which a second step is not expected [12,20,21,23]. The locking period method requires accurate peak or zero crossing identification. Marschollek et al. [2] compared healthy and mobility-impaired participants using four step counting algorithms: Pan-Tompkins, Dual-Axis, Wolf, autocorrelation. Algorithms that adapted to periodic acceleration patterns, rather than relying on a-priori knowledge of the gait signals, were more adaptable to mobility-impaired participants. Marschollek recommended more complex pattern classification algorithms to recognize steps in samples with differing motion characteristics. Annotated sample forward acceleration signals obtained from our data set, as well as those of Zijlstra et al. [24] and Mellone et al. [15], are shown in Figure 1. In this figure, the acceleration signal from our data set was inversed to match the convention of Zijlstra and Mellone [15,24]. As outlined with square boxes, signals for some people produce similar consecutive peaks and zero crossings. Therefore, a combination of signal processing methods is required to reliably identify steps. The current work built on peak detection and locking period methods and implemented an adaptive signal shape recognition algorithm for reliable step recognition (Section “Processing and Algorithm”).
Distance traveled can be calculated by double integrating the acceleration; however, this requires careful calibration, extensive computation, and works best when the accelerometer is mounted low on the person’s body (i.e., on the foot) [25]. Distance may also be estimated by calculating the stride length using empirical relations with other measurements, including leg length, change in acceleration, and step frequency. The estimated stride length is then multiplied by the number of strides to determine the distance traveled, thereby relying on a consistent stride length. The empirical relationships derived in various studies, such as the Weinberg algorithm, rely on parameters that must be calibrated to each individual from experimental walking data [14]. This requires leg length measurement or participant height for inversed pendulum models [12,26], or determination of constants from walking trials [22,25]. Alternatively, mean step length can be reliably estimated when the distance walked is known [27]. The 6MWT is typically performed on a straight track of known length and therefore offers an ideal opportunity to estimate mean step length for use in total distance calculations.
Processing and algorithm
Turns
Since a person walks back and forth on a predetermined straight track during the 6MWT, turns at the end of the straight track must be identified to accurately divide the data into lengths. These lengths were analyzed separately and steps during turns were not counted, since they did not contribute to the distance walked and would alter the interpretation of linear walking gait characteristics.
Turns were identified using the azimuth signal output from the BlackBerry Z10 smartphone, which was derived from the gyroscope and magnetometer sensors. For this application, azimuth was the angle between the device axis normal to screen and magnetic north. This signal stayed between 0 and 360°, which caused rapid changes in magnitude (Figure 2). This was corrected in software before detecting turns. If a 10° difference between data points was found, the difference was added or subtracted from the signal to correct the curve without losing information on genuine signal changes. The signal correction algorithm is shown in Figure 3.
A turn was detected if azimuth changed by more than 100° within a 3 second window. For each detected turn, turn duration was defined as the azimuth signal section with a standard deviation greater than 10° per 1 second timeframe. These were reliable ranges for turn detection at different speeds.
Step detection and step timing
Steps were detected using the BlackBerry Z10 linear acceleration signal (i.e., device acceleration minus acceleration due to gravity). This signal was filtered using a fourth-order zero-lag Butterworth low pass filter with a 4Hz cutoff frequency. A low cutoff frequency was acceptable since the filtered signal was only used to detect step occurrence and the raw forward acceleration signal was used to identify foot strike time. Cutoff frequencies lower than 4 Hz resulted in missed steps.
A step detection method was developed using a combination of adaptive locking period, similar to [21], peak detection, as in [3,17,28], and a custom adaptive signal shape template. First, the locking period was calculated using a 5 second sample from the filtered vertical acceleration signal at the beginning of the 6MWT trial, therefore no extra training data were required and the locking period was specific to the individual’s results. To establish the locking period, the time was calculated between consecutive positive zero crossings of the vertical acceleration signal. This signal did not cross zero on every step, since the filtered vertical linear acceleration signal sometimes fluctuated from a zero baseline (i.e., the time between zero crossings did not necessarily reflect step duration). Therefore, additional procedures were used to calculate the locking period:
-
As default, the locking period was half the maximum time between zero crossings.
-
If the maximum time between zero crossings was greater than a preset threshold (0.7 s, which is longer than typical step time), the locking period was half the mean time between zero crossings.
-
If the maximum time between zero crossings was less than another threshold (0.4 s, which is shorter than typical step time), the maximum time between zero crossings was multiplied by 0.6.
The number of changes in direction (positive or negative peaks) in the 5 second sample was counted for both forward and vertical acceleration signals. The filtered forward acceleration signal was the default for step detection; however, if the ratio of forward and vertical direction change-counts was greater than 1.4, vertical acceleration was used to detect steps. This 1.4 ratio was determined by observation from a separate data set. In this way, the more appropriate signal for step detection was selected, based on the individual’s walking style.
The 5 second calibration sample was also used to calculate individual thresholds to detect the first and last steps in a walkway, because these steps tended to have lower peak values since the person was starting up from, or slowing down for, a stop or turn. These thresholds were calculated by subtracting the mean filtered forward acceleration from the maximum in the 5 second sample.
The chosen filtered acceleration signal was searched using a moving window with the size of the locking period, shown as a dashed square in Figure 4 (foot strike was detected from the video recording). In each window, the maximum peak acceleration was used to detect one step, shown as a circle in Figure 4. Different people produced different peak amplitudes, with these peak segments being sharp and short, rounded and longer, or asymmetrical, depending on the person’s gait pattern. Thus, step identification was based on signal shape similarity to other identified steps in the same walk, rather than pre-assigned thresholds. Within the search window, differences between a peak and the minima before and after the peak (Figure 4) were calculated as:
$$ Lef{t}_{Diff}= \max \left( locking\ period\right)- \min \left( left\ side\ of\ peak\right) $$
(1)
$$ Righ{t}_{Diff}= \max \left( locking\ period\right)- \min \left( right\ side\ of\ peak\right) $$
(2)
A peak was only identified as a step if the difference between the peak and the minimum on either side were both within 35% of the calculated values from the previous step. This method was reliable when the signal drifted above or below a zero baseline.
$$ \frac{\ Lef{t}_{Diff}\left( current\ step\right)}{\ Lef{t}_{Diff}\left( previous\ step\right)}>0.35 $$
(3)
$$ \frac{\ Righ{t}_{Diff}\left( current\ step\right)}{\ Righ{t}_{Diff}\left( previous\ step\right)}>0.35 $$
(4)
If the duration between 2 consecutive steps was greater than 1.75 times the previous step, this portion of the signal was reanalyzed to check for missed steps. For all peaks in a section, three tests were used to determine if a step occurred:
-
1.
The difference between the peak and the minimum on either side was within 30%.
-
2.
The peak matched the timing pattern of previous step.
-
3.
The acceleration that was not used for step detection (vertical or forward) passed the initial thresholds for the first and last steps.
If no missed steps were identified, or if the duration between identified steps and the next step was still greater than 1.75 times the previous step, this pause in steps was considered a stop (i.e., person stopped walking during the test). This process is depicted in Figure 5.
Once step occurrence was detected, foot strike time was determined from the maximum peak in the raw forward linear acceleration, within the neighborhood of each detected step. Since the phone faced backward, peak forward acceleration corresponded to the maximum negative acceleration during foot strike. This was typically the most prominent signal characteristic for foot strike identification.
Left and right steps
Left and right steps were identified using the left-right (LR) linear acceleration. This signal was filtered using a fourth-order zero-lag Butterworth low pass filter with 1Hz cutoff frequency. At each detected step, the tangent to the filtered LR linear acceleration signal was calculated at 0.25 of step duration, (a), using the following equation.
$$ y=\frac{\left(L{R}_{a+1}-L{R}_{a-1}\right)}{2}\left(x-a\right)+b $$
(5)
where x and y are the horizontal and vertical coordinates in the equation, respectively, of the tangent line; a is the x-coordinate of the LR acceleration at 0.25 step duration; and b is the y-coordinate at 0.25 step duration. LR
a+1
and LR
a-1
are the values of the filtered LR acceleration at times a + 1 and time a-1, respectively, which are used to find the average slope of the curve at a. If the y-value was greater than the filtered LR linear acceleration value at times (a-locking period) and (a + locking period), the person was accelerating to the right. y-values equal to or less than these values indicated acceleration to the left (Figure 6). A sequence of left and right steps were identified and used to fill in the steps that were not identified using the tangent method, as well as to correct double counts. This information was used to calculate the primary outcome measures.
Distance walked
The 6MWT consists of a person walking back and forth along a straight walkway of known length, as per American Thoracic Society guidelines [29]. This constraint provides the opportunity to calculate the distance without the use of additional measurements. Since a 6MWT can be performed on a walkway of any length, depending on the space available, the user must enter their walkway length before the test.
Once turns at the end of the straight portion of the walkway have been identified and steps counted, the number of steps for a predetermined distance (walkway length) is known and the mean step length can be found for each walkway. The distance walked on the last walkway was calculated using the number of steps multiplied by the average step length of the previous walkway. If a stop was detected in the previous walkway, the walkway with no stops, prior to the walkway when the stop occurred, was used to calculate average step length. If the ratio of mean step duration in the last walkway to step duration in the walkway before was less than 0.9 (i.e., more than 10% increase in the mean time of each step), the average step length was multiplied by this ratio before calculating the total distance.
The total distance walked is calculated as the number of full walkways completed multiplied by the known walkway length, in addition to the distance walked in the last (partial) walkway. With this approach, the step length error is not compounded across all walkway lengths. Since a delay was anticipated between the tone that signals the end of data collection and the person stopping, video was used to verify the actual distance traveled by the person in 6 minutes (i.e., video was used to identify the body location at 6 minutes and then direct measurement of the distance to this location).
Evaluation
Participants
A convenience sample of 15 able-bodied staff and students was recruited from The Ottawa Hospital Rehabilitation Centre (TOHRC). Able-bodied participants are a viable proxy for patients with chronic obstructive pulmonary disease, a population that commonly use the 6MWT, since previous research found no significant differences for walking distance, intensity, and cadence [16]. The sample consisted of 10 males (Age = 40.6 ± 15.9 years, Mass = 78.5 ± 12.1 kg, Height = 177.5 ± 5.8 cm) and 5 females (Age = 38.8 ± 9.7 years, Mass = 64.5 ± 10.5 kg, Height = 165.2 ± 4.8 cm). Written, informed consent was obtained from each person before starting data collection. The study was approved by the Ottawa Health Science Network Research Ethics Board.
Protocol
After completing the consent form, participant age, height, sex, weight, waist size, and leg length were recorded. Before testing, a belt was secured around the person’s waist, with a rear pocket at the centre of their lower back. The app was started on a BlackBerry Z10 smartphone and the 25 m track length was entered into a text box. The 6MWT was selected from a drop down menu, from the choice of 2 or 6 minutes tests. The 6 minute test was chosen for evaluation to ensure that the algorithm worked for the longer test, and because the 6MWT is more commonly used in clinical practice. The smartphone was placed upright in the rear pocket, facing outward (therefore backwards). Smartphone audio instructed the participant to begin walking and stop walking when they hear a tone. Participants walked back and forth along a 25 m section of a straight hallway, covering as much distance as possible in 6 minutes. Accelerometer, gyroscope, and magnetometer data were sampled on the Z10 at approximately 50Hz. Smartphones can have a variable sampling rate [15], and the Z10 sensor sample rate varied with a mean standard deviation of 3.84 Hz for all subjects. For every trial, the person was video recorded using a separate and independent BlackBerry 9900 smartphone. At the end of the test, the distance walked on the last length was measured with a measuring tape and recorded on a data sheet as a comparator.
Outcome measures
Foot strike timing, number of steps, turns, and contextual information were extracted from the digital video as a gold-standard comparator. The gold standard time was synchronized with smartphone output by the first identified foot strike event, thereby providing a recognizable accelerometer signal and video event. The 6MWT algorithm was initially developed as a custom Matlab program that was then converted into a BlackBerry 10 app that runs entirely on the phone. The algorithm can be written to run on any commercial smartphone with an accelerometer and gyroscope. The app calculates and saves outcome data as a comma separated value (CSV) file, as well as saving a raw sensor data text file if desired. The outcome data file includes information that would be useful to clinicians; such as, average step length, step time, cadence over time, and cadence per walkway. The app also displays the total distance walked on the phone upon test completion. Individual foot contact times, which are used to calculate the outcomes but are not useful to clinicians on their own, are not included in the output text file. Therefore, to facilitate the evaluation of foot contact identification, a custom Matlab program was used to import the raw data text file, calculate outcomes, and compare results with gold standard outcomes.
The following information was calculated from sensor data: total distance walked, total number of steps, number of steps per walkway length, cadence average (AVG) and standard deviation (SD), step time AVG and SD (left and right steps), stride time AVG and SD, step time symmetry (left and right steps).
Comments
View archived comments (1)