All 3 components of the step counter

All 3 components of the step counter

Introduction:

My step counter was the second iteration of the gait identifier, where I used a GY-61 accelerometer on the right hip along with the ankle attachment. To capture both leg movements, the ankle attachment was moved to my left ankle. IMU data was captured from both accelerometers, normalized as a z-score, before being put through the neural net. Five copies of the neural net with a total of 22,626 weights were trained with the result being the average of the neural nets. The final layer outputs logits that score the likelihood of my foot hitting the ground. After, the logits are put into a sigmoid function, where high logits values become +1, and are added to the step counter. Step count results and distance traveled were showed on the UnoQ’s LED matrix.

GY-61 Accelerometer attached above the UnoQ

GY-61 Accelerometer attached above the UnoQ

Although the neural net was trained on 46 training sets, it was not 100% accurate. Therefore, a secondary webpage was added to show the 95% confidence interval of the step counter. The standard deviation was calculated by adding up 3 components, model, event, and systematic. The model component is calculated by the standard deviation of the output of the 5 neural nets. The event component is determined by summing up $c(1-c)$ of all steps, where c is the confidence that a step was taken. Finally, the systematic term is calculated by $rN$, where r is the percentage the network’s typically off from the true count. When testing the confidence interval with 12 separate training sessions, only 92% of the true means were captured in the 95% confidence interval. Although this result raised some concerns, the limited number of training sessions could have played a role in the 92% of true means being captured.

Top of webpage showing step count, distance, status, where variance is coming from, and IMU data

Top of webpage showing step count, distance, status, where variance is coming from, and IMU data

To calculate distance, the model uses the hip’s vertical acceleration, and converts it to length with Weinberg’s formula from 2002 Analog Devices:

$$ L_i = K \sqrt[4]{a_{\max,i} - a_{\min,i}} $$

K was calculated from several calibration walks of preset distances, and used the lengths and acceleration data to find the constant. $L_i$ would then be added to the sum of distance traveled. In the event that no hip vertical acceleration was detected, 0.73m were added to the total distance, as that was the average length of my stride. Just like the step counter, the distance calculation had a 95% confidence interval, where the standard deviation was $avg(L_i)*\sigma_N$, where $\sigma_N$ is the standard deviation of the number of steps.

Step timeline with recording session, UnoQ connection and diagnostics

Step timeline with recording session, UnoQ connection and diagnostics

Along with the webpage showing the confidence interval of the step tracker, it also offers additional features. These include a timeline for how many steps were taken, a record session to collect data, and debugging tools to show the connection between the attachments and computer.

Video:

Video of me walking with the tracker

Video of me walking with the tracker

Screen recording of me walking in video above.

Screen recording of me walking in video above.

How the Neural Network works:

This system uses a temporal convolutional network, where it has a stack of 1D convolutions that slide with time. The neural network takes 12 inputs with the time step, being the ankle’s x,y,z acceleration, gyro’s x,y,z rotation rate, ankle acceleration magnitude, hip horizontal and vertical acceleration, hip acceleration magnitude, and whether the ankle and hip are connected. These inputs are normalized with their z-score, while the model is training and running. The neural network output are 2 numbers, being the logits of the left and right foot for each 10 ms time step.

The network uses 6 layers. The first layer is a convolution with 32 channels, where each filter takes a weighted sum of 5 samples across all 12 inputs, applies a ReLU activation to set negative results to 0, so each channel reports how strongly it sees a pattern. Layers 2-5 are residual blocks with the same structure of 32 channels and ReLU activation. Additionally, from layer 1 to layer 5, the spacing between the 5 samples doubles each layer from 1 in layer 1 to 16 in layer 5, so each layer looks further than the previous. Each block adds its results back onto its input. Layer 6 is a convolution with no activation that combines the 32 channels into the 2 logits. In total, the networks have 22,626 weights. Finally, a Sigmoid function is applied to the outputs to turn the logits into probabilities between 0 and 1.

The system runs five independently trained copies of the network and averages their probabilities, then counts steps whenever the averaged probability forms a peak of at least 0.84, with 0.3 seconds after the previous step. The disagreement between the five copies contributes to the uncertainty of the step count.

Animation on System Functionality