• No results found

2.3 Conclusions and Future Work

3.1.2 Implemented Algorithms

3.1.2.1 Peak Detector

We implemented the algorithm proposed by Gu et. al. to be representative of peak detection algorithms because it is very recent (2017) and provides enough detail for reimplementation [48]. The algorithm applies preliminary processing to find the magnitude of the signal, identifies peaks, and applies three conditions to each peak in order to determine if it is a step as summarized in Figure 3.5.The algorithm performs signal preprocessing by finding the magnitude of acceleration through use of Equation 2.1. Then, local maxima are detected and the data is segmented based on these peaks. Based on the variance within these samples, the segments are classified as idle, walking, or running. In our implementation of this algorithm, because our dataset only examines walking, we classify the data as either idle or walking only.

In phase two of the algorithm, periodicity, similarity, and continuity of the peaks are scored. The similarity measure compares the magnitude of every other peak. The algorithm examines every

Figure 3.5: Flowchart of the peak detection algorithm. Parameters used in the algorithm are listed, with the values used in the publication in bold.

other peak because these correspond to steps taken with the same foot. For example, if peak 1 is associated with a step taken with the right foot, it is natural to assume that peak 2 would be associated with a step taken by the left foot, and peak 3 would be back to the right foot. This is particularly important when considering the ankle position because peak magnitudes will vary greatly. In order to score periodicity, the time difference between two neighboring peaks is measured and recorded. This value is later compared against a threshold to remove peaks not associated with steps. The continuity of each peak is also scored by counting the number of neighboring peaks that take place during walking (as opposed to idle time segments).

In phase three of the algorithm, thresholds are applied to each peak based on the periodicity, similarity, and continuity scores calculated in phase two. First, the number of neighboring peaks that occur during walking, as calculated as the continuity score, must exceed a threshold for the peak to be considered further. Then, the similarity score, which is the difference in magnitude of alternating peaks, must be less than a threshold. This comparison is based on the concept that if peaks differ significantly, they are more likely to be noise, rather than steps. Finally, the time between consecutive peaks must be greater than a minimum threshold and less than a maximum

threshold in order to be considered steps. These thresholds are based on the frequency of steps occurring in human walking. If a peak passes all three of the specified thresholds, then the peak is considered to be a step.

3.1.2.2 Threshold Based

We selected the algorithm developed by Zhao to be our representative sample because the algorithm provided sufficient detail for reimplementation and was representative of multiple zero crossing algorithms [67]. The algorithm’s steps are summarized in Figure 3.6. The algorithm first preprocesses the signal by performing a smoothing, essentially averaging every four data points. The algorithm then determines the dynamic zero crossing threshold by finding the maximum and minimum values at 1/2 second intervals. The threshold for the used for detecting zero crossings is the average of the maximum and minimum values found. It is important to note that the values used to determine the threshold for every interval is based on the actual maximum and minimum values calculated for the previous 1/2 second interval. In this way, the maximum and minimum values used to determine the adaptive threshold are delayed for each interval.

After determining the adaptive threshold for each time interval, individual data points are evaluated. This process begins with placing the data into registers, sample new and sample old. When a new data sample is considered, the sample new register is shifted to the sample old register unconditionally. Then, the new data sample is only placed in to sample new only if the change in acceleration is greater than a precision value. If the new data sample does not change at least as much as the precision threshold, sample new is not updated. Then, if there is a negative slope in the acceleration plot (sample new is less than sample old) when the acceleration crosses the dynamic threshold, a potential step is detected. This detection process is performed on the x, y, and z axes independently, and whichever axis has the greatest change in acceleration is used to determine if a potential step is present.

The algorithm then adds two conditions to verify whether each potential step is considered to be an actual step. First, a time window is used to rule out vibrations. The time window is based on the assumption that people can run as rapidly as 5 steps per second or walk as slowly as one step per two seconds. Based on this, the time interval between two valid steps must be between 0.2 seconds and 2.0 seconds. Any steps with intervals outside this window are discarded. Subsequently, the algorithm requires that four consecutive valid steps must be found in sequence in order for

Figure 3.6: Flowchart of the threshold based algorithm. Parameters used in the algorithm are listed, with the values used in the publication in bold.

Figure 3.7: Flowchart of the autocorrelation algorithm. Parameters used in the algorithm are listed, with the values used in the publication in bold.

the steps to be counted. If even one invalid step is found, steps are no longer recorded until four consecutive valid steps are found.

3.1.2.3 Autocorrelation

Of the two algorithms we found using autocorrelation, we reimplemented the algorithm listed by Rai et. al. [61]. Both papers using this algorithm are from the same research group, so we used the paper providing a greater level of detail regarding algorithm implementation. The algorithm was designed for data collection from a smartphone and is summarized in Figure 3.7. Male participants kept the smartphone in the shirt pocket, front and rear pants pockets, and in hand (while using and not using the phone). Female participants placed the smartphone in a handbag and in hand (while using and not using the phone). These locations should provide similar signals to the hip and wrist sensors used in our data collection process.

The algorithm is based on calculating the autocorrelation at each sample. Autocorrelation is determined based on measures of mean and standard deviation values for intervals of time. This autocorrelation is calculated and normalized for a window size of τ for the mthsample as shown in

Equation 3.1

χ(m, τ ) =

Pk=τ −1

k=0 [(a(m + k) − µ(m, τ ))(a(m + k + τ ) − µ(m + τ, τ ))]

τ σ(m, τ )σ(m + τ, τ ) (3.1)

where µ(k, τ ) and σ(k, τ ) are the mean and standard deviation of the acceleration samples from k to k + τ + 1. The normalized autocorrelation value approaches 1 as the acceleration in the windows being compared becomes more similar.

The challenge in this process is determining the correct window size, or τ , to use for com- paring intervals of time. For example, if a participant is walking at a rate of 1 step per second, the appropriate window for autocorrelation evaluation would be 1 second. If, instead, the participant is taking two steps per second, the appropriate window would be 0.5 seconds. Because this value is not known and can change through data collection, the algorithm tests a range of window sizes for each sample being evaluated. For each sample, windows sizes ranging from τminto τmaxare tested.

Whichever window size produces the highest autocorrelation score is used (the window size and autocorrelation value are saved). The values of τmin and τmax are varied throughout the analysis

process. At the start, τmin is set to be .8 seconds, or in our case, with a sample rate of 15 Hz,

12 samples and τmax is initialized to 2 seconds, or 30 samples. Once a valid step is found by the

algorithm, the optimal window size (τopt) recorded for the sample is then used to adjust the values

of τmin and τmax such that τmin = τopt - 3 and τmax= τopt + 3.

The final process in determining steps is classifying the state as idle or walking based on the magnitude of acceleration and maximum autocorrelation score found for each data point. If the magnitude of the data point being examined is less that 0.01 gravities, then the state is determined to be idle, so no steps are recorded. Otherwise, if the maximum autocorrelation score found for the data point is greater that 0.7, then the state is determined to be walking. If neither of these conditions are true, then the state does not change. Then, if the state is walking, the optimal window size, τoptfor the data point is used to generate a step at every

τopt

2 samples.