1. Algorithm description
NeuraActive was designed to recognise and classify human activities in real life conditions. The aim was to use a single Inertial Measurement Unit (IMU), placed on the foot. The current algorithm version focuses on detection of walking, running and cycling activities.
The tracking results are stored in a struct (of type ACT_ActivityTracker_TypeDef) accessible through the function ACT_GetOutput. In particular, the following fields are available:
- ACT_ActivityTracker_TypeDef.ACT_Activity: the tracked activity saved as ActivityType value
- ACT_ActivityTracker_TypeDef.ACT_Cadence: real time cadence for the current activity
- ACT_ActivityTracker_TypeDef.ACT_stepCounter: overall step counter
- ACT_ActivityTracker_TypeDef.ACT_stepCounterWalking: walking step counter
- ACT_ActivityTracker_TypeDef.ACT_stepCounterRunning: running step counter
- ACT_ActivityTracker_TypeDef.ACT_stepCounterCycling: cycling pedaling revolution counter
Note: Cadence output is given in steps per minutes for walking and running activities, while it is in rotations per minutes (rpm) for cycling
Usage:
- call the function ACT_Init to initialize the variables at the beginning of the acquisition
- call the function ACT_Update at each iteration to perform the computation step
- call the function ACT_GetOutput at each iteration to access the output struct
Note:See the sample code Main_example.c to see how to properly use the algorithm functions.
See the flowchart for the block diagram showing the algorithm functioning.
2. Flowchart
Block diagram showing the algorithm functioning.
FIGURE 2.1 ALGORITHM FLOWCHART
3. References
The following lines contain general information about the library, such as version and date of publication, together with the contact details of the 221e internal staff responsible for maintaining and managing the library.
-
Authors and Referents
Luigi Mattiello -
Library Version
v2.0.0 -
Date
July 2022 -
Copyright
Copyright (c) 2020 All Rights Reserved by 221e srl.
4. Requirements
The following lines contain information about the library size occupation and time execution. Tests and measurements have been perfomed with a NUCLEO-F401RE board, clocked @64MHz, and including within Atollic TrueSTUDIO project the ACT static library compiled for NUCLEO-F401RE as well as library header files. No optimization (i.e., -O0) has been applied during library compilation. Results are reported in the following tables.
FLASH Occupation [kB] | RAM Occupation [kB] |
---|---|
36.67 | 3.61 |
TABLE 4.1 ACT MEMORY OCCUPATION
Timing [clock hits] | Timing @64MHz [ms] | |
---|---|---|
ACT_Update in Static phase | Average: 57081, Maximum: 59012 | Average: 0.892, Maximum: 0.922 |
ACT_Update in Dynamic phase | Average: 57727, Maximum: 59107 | Average: 0.902, Maximum: 0.924 |
ACT_Update during Walking | Average: 58099, Maximum: 59035 | Average: 0.908, Maximum: 0.922 |
ACT_Update during Running | Average: 58542, Maximum: 59398 | Average: 0.915, Maximum: 0.928 |
ACT_Update during Cycling | Average: 58665, Maximum: 59495 | Average: 0.917, Maximum: 0.930 |
ACT_Update timing computed over 50000 iterations |
Average: 58161, Maximum: 59495 | Average: 0.909, Maximum: 0.930 |
ACT_Init | Average: 13349, Maximum: 13412 | Average: 0.209, Maximum: 0.210 |
TABLE 4.1 ACT EXECUTION TIMINGS
5. Performances
This section of the paper provides a brief description of the results obtained by applying NeuraActive to the following datasets:
- 221e Dataset: internal dataset containing data logged using 221e systems (Muse and Mitch). The overall
size of the dataset corresponds to 17 hours and 37 minutes. - PAMAP2 Physical Activity Monitoring Data Set: freely available dataset containing data of 18 different physical
activities, performed by 9 subjects wearing 3 inertial measurement units and a heart rate monitor [1] [2]. The
overall size of the dataset corresponds to 25 hours and 34 minutes.
In order to correctly evaluate the NeuraActive performances on PAMAP2 Dataset, the 18 different physical activities were grouped as following:
- Walking (ID 4), nordic walking (ID 7), ascending stairs (ID 12) and descending stairs (ID 13) considered as Walking
- Running (ID 5) corresponding to Running
- Cycling (ID 6) corresponding to Cycling
- All other activities were not considered for the results evalutation.
The results of the classification were quantified using statistical performance metrics and are reported in the following table.
221e Dataset | PAMAP2 Dataset | |||||||
---|---|---|---|---|---|---|---|---|
Activity | Static | Walking | Running | Cycling | Static | Walking | Running | Cycling |
Carry position | Foot, ankle | Foot, ankle | Foot, ankle | Foot, ankle | Ankle | Ankle | Ankle | Ankle |
Accuracy [%] | 98.40 | 98.50 | 99.50 | 99.80 | 93.10 | 94.80 | 99.60 | 97.80 |
Sensitivity [%] | 98.80 | 85.50 | 98.80 |
99.60 | 97.70 | 83.90 | 94.10 | 83.80 |
Specificity [%] | 98.40 | 99.70 | 99.80 | 100.00 | 85.70 | 99.60 | 99.80 | 98.60 |
Precision [%] | 89.00 | 96.20 | 99.50 | 100.00 | 91.50 | 98.80 | 94.10 | 77.60 |
TABLE 5.1 ACT PERFORMANCES
1. Reiss, A.;Weber, M.; Stricker, D. Exploring and extending the boundaries of physical activity recognition. In Proceedings of the 2011 IEEE International Conference on Systems, Man, and Cybernetics, Anchorage, AK, USA, 9–12 October 2011; pp. 46–50.
2. PAMAP2 Physical Activity Monitoring Data Set, [Online]. Available: https://archive.ics.uci.edu/ml/datasets/pamap2+physical+activity+monitoring
6. Data Structure Documentation
6.1 ACT_ActivityTracker_TypeDef Struct Reference
Struct to store the output results of activity tracking.
#include <ACT_Tracker.h>
Data Fields
-
ActivityType ACT_Activity
Currently tracked activity, returned as ActivityType type. - uint8_t ACT_Cadence
Cadence of the currently performed activity. - uint32_t ACT_stepCounter
Overall step counter. - uint32_t ACT_stepCounterWalking
Number of walking steps performed performed. - uint32_t ACT_stepCounterRunning
Number of running steps performed performed. - uint32_t ACT_stepCounterCycling
Number of cycling pedal revolutions performed.
7. Example Documentation
7.1 Main_example.c
This is an example where:
- A proper initialization of NeuraActive algorithm is shown
- Streaming of data is simulated by reading from a .txt file
- A correct call to ACT_Update function is shown
- It is shown how to get the type of activity being performed, the corresponding cadence, the overall count of steps and the steps performed for each activity
Finally, the output is saved in a text file.
const uint32_t inputDataLength = 6; float inputData[6] = {0,0,0,0,0,0}; uint32_t iterationCounter = 0; ACT_ActivityTracker_TypeDef outACT; int main(void){ uint8_t i; // Open I/O files FILE *fIn = fopen("input_file.txt", "r"); FILE *fOut = fopen("output_file.txt", "w"); // Set the adopted system configuration AxisDirection systemConfig[3] = {Lateral,Forward,Up}; // Initialize the algorithm ACT_Init(systemConfig); // Loop to read data from file while (feof(fIn) == 0) { // Read data for (i = 0; i < inputDataLength; i++) fscanf(fIn, "%f", &inputData[i]); // Get data float inAxl[3] = { inputData[0], inputData[1], inputData[2] }; float inGyr[3] = { inputData[3], inputData[4], inputData[5] }; // Perform Update step ACT_Update(inGyr, inAxl); outACT = ACT_GetOutput(); step_count = out.ACT_stepCounter; ActivityType activity = outACT.ACT_Activity; uint8_t cadence = outACT.ACT_Cadence; uint32_t stepCounter = outACT.ACT_stepCounter; uint32_t stepWalking = outACT.ACT_stepCounterWalking; uint32_t stepRunning = outACT.ACT_stepCounterRunning; uint32_t stepCycling = outACT.ACT_stepCounterCycling; // Save data to file fprintf(fOut, "%snt%fnt%dnt%dnt%dnt%dnn", activity, cadence, stepCounter, stepWalking, stepRunning, stepCycling); iterationCounter++; } // Close I/O files fclose(fIn); fclose(fOut); return 0; }
7.2 Visualization
A visual representation of the results is shown in the following figure, where the transition between walking and running is clearly detected and the corresponding cadence is computed.
FIGURE 7.1 ACTIVITY CLASSIFICATION OUTPUT AND CORRESPONDING CADENCE