Algorithms Review » History » Version 10
Version 9 (João Samuel Mendo Pousão Gatta, 06/01/2023 06:52) → Version 10/37 (João Samuel Mendo Pousão Gatta, 06/01/2023 06:53)
h1. Algorithms Review
h2. Step counter and status detector
From [1]:
Accelerometer data:
Acceleration along x - axis
Acceleration along y - axis
Acceleration along z – axis
The magnitude of 3-D acceleration data:
Sqr(acc_x^2 + acc_y^2 + acc_z^2)
Get the difference in this magnitude from the previous value.
If the value is greater than a particular threshold value, then increment the steps count.
-Threshold for walking = 17.5
-Threshold for running = 30
p=. !{width:300px}walk-1.png!
h2. Energy Expenditure
"Energy expenditure refers to the amount of energy an individual uses to maintain essential body functions (respiration, circulation, digestion) and as a result of physical activity. Total daily energy expenditure is determined by resting or basal metabolic rate (BMR), food-induced thermogenesis, and energy expended as a result of physical activity[2]."
There are several formulas to calculate a person's energy expenditure, each with a differing level of accuracy and measurement requirements. Our project will focus on the portion of energy expended during physical activity, whether regarding walking, running or even cycling.
In an ideal scenario, either the volume of O2 exhaled or the thermal output of the individual is measured during the physical activity, achieving a highly accurate value of estimated energy expenditure[3]. For our application and for the massively available health monitoring products in the market, this isn't viable, resorting to other metrics such as heart rate, acceleration, body temperature etc.
Given our use of the VitalJacket technology, we will be relying on the individual's self-inputted biometric data, such as weight, height, age, sex and the data acquired by the heart rate sensor and the accelerometer available with the VitalJacket.
To improve the energy expenditure calculation, and considering heart rate is generally a better metric than acceleration[3], several decisions need to be made, such as:
1. Given that the difference in heart rate of someone in a resting rate, when compared to low effort, is so insignificant, should we, for values below a certain HR threshold, solely use the accelerometer or use a REE (resting energy expenditure) value as a placeholder?
2. Due to the lag between our change in acceleration and the correspondent change in heart rate, should we calculate EE using just the acceleration for these sudden differences in speed?
3. If we deem it necessary to offer a TDEE (Total Daily Energy Expenditure) feature in our app, should we consider EPOC[4] (Post-exercise oxygen consumption)?
Another relevant metric is the Basal Metabolic Rate or BMR, this value represents the used calories of an individual at rest during 24 hours, it is different from TDEE as the latter includes energy expended through EAT (Exercise Activity Thermogenesis) and NEAT (Non-exercise Activity Thermogenesis).
BMR is most commonly calculated using a person’s biometric data, such as its height, weight, age and gender; converting to TDEE is usually done by multiplying BMR by a value between 1 and 2, depending on the individual’s average daily activity level. In common calculators such as the Legion Athletics one [5], these varying activity levels are showcased in discrete but subjective (given that most individuals don’t track their exercise intensively, thus their activity level is estimated not determined) levels of different hours spent exercising. The TDEE value of a particular individual is relevant because it sets the reference point with which to compare the energy expended in a given day. Athletes require caloric intakes upwards of 6000[7] kilocalories in a single day, compared to the average public which is around 2960[8], so a given exercise effectiveness needs to be contextualized given the individual’s TDEE value.
With this in mind, designing a fitness app like StepNCount involves a very conscious decision of contextualizing the caloric information or leaving it completely up to the user. Given that we already asked the user for their relevant biometric data we believe it improves the app’s usefulness if we indeed contextualize the caloric information and recommend the user a specific calorie target. Unfortunately since an individual’s daily calories also depend on their food intake, the recommended calorie burn might not be enough or might even be too much. For example, if a person looking to lose weight starts dieting, thus reducing their caloric intake by for example 25% of their TDEE, further caloric reduction via exercise might not be necessary. It’s for this exact reason that most fitness apps simply let the user define their goals, without caring if these goals are actually efficient at bringing about the differences in weight or lean/fat mass ratio the individual desires. In an effort to counteract this tendency StepNCount uses the user’s biometric data to estimate a significant calorie value for the daily goal, recommending it in the app’s goal page. Given the concerns mentioned above, the user is able to change this goal, according to their specific dieting situation and fitness objectives.
The aforementioned estimation relies on the Mifflin - St Jeor Equation[9], considered to be the most reliable[10] to calculate BMR, subsequently multiplying this value by a constant of 1.3, thus converting it to the TDEE of an individual with average exercise habits. After obtaining an individual’s TDEE we take 25% of this value, as recommended here[11], and set it as the default calorie goal.
Given the user’s defined goal, our app’s main function springs into action, using the VitalJacket’s accelerometer data to measure various metrics, including the very important energy expenditure.
There are several equations capable of estimating energy expenditure, here are some examples:
The Freedson equation is a commonly used method that uses a combination of accelerometer data and heart rate data to estimate energy expenditure:
Energy expenditure (kcal/min) = 0.175 x acceleration (g) + 0.029 x heart rate (bpm) - 1.75
The Troiano equation is another method that uses accelerometer data to estimate energy expenditure, based on the assumption that a person's activity level can be classified into one of four categories (sedentary, low, moderate, or vigorous):
Energy expenditure (kcal/day) = (0.1 x acceleration (g) + 2.0) x body mass (kg) x duration (hours/day)
And finally, the one we chose to use, the Freedson VM3:
Kcals/min= 0.001064×VM + 0.087512(BM) - 5.500229
Where, VM = Vector Magnitude = (sqrt(Axis1)^2 + (Axis2)^2 + (Axis3)^2) and
BM is Body Mass in Kg
Again, these are just a few examples of the types of formulas that can be used to estimate energy expenditure from accelerometer data. It is important to note that these methods can have significant error margins, and the accuracy of the estimates will depend on the specific device and the assumptions used in the calculations. It is always a good idea to consult with a healthcare professional or a registered dietitian for personalized nutrition and exercise recommendations.
All of these methods have some error margins and their accuracy will depend on the device, situation, and individual, although, during our testing, the aforementioned Freedson VM3 equation was regularly the more accurate one.
h2. Distance
References :
1 - programmerworld. (2019) How to create walking step counter App using Accelerometer sensor
and Shared Preference in Android? Available at: [[https://programmerworld.co/android/how-to-create-walking-step-counter-app-using-accelerometer-sensor-and-shared-preference-in-android/]]
2 - Heaney, J. (2013). Energy: Expenditure, Intake, Lack of. In: Gellman, M.D., Turner, J.R. (eds) Encyclopedia of Behavioral Medicine. Springer, New York, NY. https://doi.org/10.1007/978-1-4419-1005-9_454
3 - Maughan, Ronald J. (2013). The Encyclopaedia of Sports Medicine (An IOC Medical Commission Publication) || How to Assess the Energy Costs of Exercise and Sport. , 10.1002/9781118692318(), 59–71. doi:10.1002/9781118692318.ch4
4 - https://www.runnersworld.com/training/a22024491/what-is-epoc/
5 - https://legionathletics.com/tools/tdee-calculator/
6 - ActiGraph (2018), What is the difference among the Energy Expenditure Algorithms? Available
at: https://actigraphcorp.my.site.com/support/s/article/What-is-the-difference-among-theEnergy-Expenditure-Algorithms (Accessed: 7 November 2022).
7 - Economos, C.D., Bortz, S.S. & Nelson, M.E. Nutritional Practices of Elite Athletes. Sports Medicine 16, 381–399 (1993). https://doi.org/10.2165/00007256-199316060-00004
8 - https://news.un.org/en/story/2022/12/1131637
9 - Mifflin MD, St Jeor ST, Hill LA, Scott BJ, Daugherty SA, Koh YO. A new predictive equation for resting energy expenditure in healthy individuals. Am J Clin Nutr. 1990 Feb;51(2):241-7. doi: 10.1093/ajcn/51.2.241. PMID: 2305711.
10 - Frankenfield D, Roth-Yousey L, Compher C. Comparison of predictive equations for resting metabolic rate in healthy nonobese and obese adults: a systematic review. J Am Diet Assoc. 2005 May;105(5):775-89. doi: 10.1016/j.jada.2005.02.005. PMID: 15883556.
11 - https://legionathletics.com/tools/tdee-calculator/
h2. Step counter and status detector
From [1]:
Accelerometer data:
Acceleration along x - axis
Acceleration along y - axis
Acceleration along z – axis
The magnitude of 3-D acceleration data:
Sqr(acc_x^2 + acc_y^2 + acc_z^2)
Get the difference in this magnitude from the previous value.
If the value is greater than a particular threshold value, then increment the steps count.
-Threshold for walking = 17.5
-Threshold for running = 30
p=. !{width:300px}walk-1.png!
h2. Energy Expenditure
"Energy expenditure refers to the amount of energy an individual uses to maintain essential body functions (respiration, circulation, digestion) and as a result of physical activity. Total daily energy expenditure is determined by resting or basal metabolic rate (BMR), food-induced thermogenesis, and energy expended as a result of physical activity[2]."
There are several formulas to calculate a person's energy expenditure, each with a differing level of accuracy and measurement requirements. Our project will focus on the portion of energy expended during physical activity, whether regarding walking, running or even cycling.
In an ideal scenario, either the volume of O2 exhaled or the thermal output of the individual is measured during the physical activity, achieving a highly accurate value of estimated energy expenditure[3]. For our application and for the massively available health monitoring products in the market, this isn't viable, resorting to other metrics such as heart rate, acceleration, body temperature etc.
Given our use of the VitalJacket technology, we will be relying on the individual's self-inputted biometric data, such as weight, height, age, sex and the data acquired by the heart rate sensor and the accelerometer available with the VitalJacket.
To improve the energy expenditure calculation, and considering heart rate is generally a better metric than acceleration[3], several decisions need to be made, such as:
1. Given that the difference in heart rate of someone in a resting rate, when compared to low effort, is so insignificant, should we, for values below a certain HR threshold, solely use the accelerometer or use a REE (resting energy expenditure) value as a placeholder?
2. Due to the lag between our change in acceleration and the correspondent change in heart rate, should we calculate EE using just the acceleration for these sudden differences in speed?
3. If we deem it necessary to offer a TDEE (Total Daily Energy Expenditure) feature in our app, should we consider EPOC[4] (Post-exercise oxygen consumption)?
Another relevant metric is the Basal Metabolic Rate or BMR, this value represents the used calories of an individual at rest during 24 hours, it is different from TDEE as the latter includes energy expended through EAT (Exercise Activity Thermogenesis) and NEAT (Non-exercise Activity Thermogenesis).
BMR is most commonly calculated using a person’s biometric data, such as its height, weight, age and gender; converting to TDEE is usually done by multiplying BMR by a value between 1 and 2, depending on the individual’s average daily activity level. In common calculators such as the Legion Athletics one [5], these varying activity levels are showcased in discrete but subjective (given that most individuals don’t track their exercise intensively, thus their activity level is estimated not determined) levels of different hours spent exercising. The TDEE value of a particular individual is relevant because it sets the reference point with which to compare the energy expended in a given day. Athletes require caloric intakes upwards of 6000[7] kilocalories in a single day, compared to the average public which is around 2960[8], so a given exercise effectiveness needs to be contextualized given the individual’s TDEE value.
With this in mind, designing a fitness app like StepNCount involves a very conscious decision of contextualizing the caloric information or leaving it completely up to the user. Given that we already asked the user for their relevant biometric data we believe it improves the app’s usefulness if we indeed contextualize the caloric information and recommend the user a specific calorie target. Unfortunately since an individual’s daily calories also depend on their food intake, the recommended calorie burn might not be enough or might even be too much. For example, if a person looking to lose weight starts dieting, thus reducing their caloric intake by for example 25% of their TDEE, further caloric reduction via exercise might not be necessary. It’s for this exact reason that most fitness apps simply let the user define their goals, without caring if these goals are actually efficient at bringing about the differences in weight or lean/fat mass ratio the individual desires. In an effort to counteract this tendency StepNCount uses the user’s biometric data to estimate a significant calorie value for the daily goal, recommending it in the app’s goal page. Given the concerns mentioned above, the user is able to change this goal, according to their specific dieting situation and fitness objectives.
The aforementioned estimation relies on the Mifflin - St Jeor Equation[9], considered to be the most reliable[10] to calculate BMR, subsequently multiplying this value by a constant of 1.3, thus converting it to the TDEE of an individual with average exercise habits. After obtaining an individual’s TDEE we take 25% of this value, as recommended here[11], and set it as the default calorie goal.
Given the user’s defined goal, our app’s main function springs into action, using the VitalJacket’s accelerometer data to measure various metrics, including the very important energy expenditure.
There are several equations capable of estimating energy expenditure, here are some examples:
The Freedson equation is a commonly used method that uses a combination of accelerometer data and heart rate data to estimate energy expenditure:
Energy expenditure (kcal/min) = 0.175 x acceleration (g) + 0.029 x heart rate (bpm) - 1.75
The Troiano equation is another method that uses accelerometer data to estimate energy expenditure, based on the assumption that a person's activity level can be classified into one of four categories (sedentary, low, moderate, or vigorous):
Energy expenditure (kcal/day) = (0.1 x acceleration (g) + 2.0) x body mass (kg) x duration (hours/day)
And finally, the one we chose to use, the Freedson VM3:
Kcals/min= 0.001064×VM + 0.087512(BM) - 5.500229
Where, VM = Vector Magnitude = (sqrt(Axis1)^2 + (Axis2)^2 + (Axis3)^2) and
BM is Body Mass in Kg
Again, these are just a few examples of the types of formulas that can be used to estimate energy expenditure from accelerometer data. It is important to note that these methods can have significant error margins, and the accuracy of the estimates will depend on the specific device and the assumptions used in the calculations. It is always a good idea to consult with a healthcare professional or a registered dietitian for personalized nutrition and exercise recommendations.
All of these methods have some error margins and their accuracy will depend on the device, situation, and individual, although, during our testing, the aforementioned Freedson VM3 equation was regularly the more accurate one.
h2. Distance
References :
1 - programmerworld. (2019) How to create walking step counter App using Accelerometer sensor
and Shared Preference in Android? Available at: [[https://programmerworld.co/android/how-to-create-walking-step-counter-app-using-accelerometer-sensor-and-shared-preference-in-android/]]
2 - Heaney, J. (2013). Energy: Expenditure, Intake, Lack of. In: Gellman, M.D., Turner, J.R. (eds) Encyclopedia of Behavioral Medicine. Springer, New York, NY. https://doi.org/10.1007/978-1-4419-1005-9_454
3 - Maughan, Ronald J. (2013). The Encyclopaedia of Sports Medicine (An IOC Medical Commission Publication) || How to Assess the Energy Costs of Exercise and Sport. , 10.1002/9781118692318(), 59–71. doi:10.1002/9781118692318.ch4
4 - https://www.runnersworld.com/training/a22024491/what-is-epoc/
5 - https://legionathletics.com/tools/tdee-calculator/
6 - ActiGraph (2018), What is the difference among the Energy Expenditure Algorithms? Available
at: https://actigraphcorp.my.site.com/support/s/article/What-is-the-difference-among-theEnergy-Expenditure-Algorithms (Accessed: 7 November 2022).
7 - Economos, C.D., Bortz, S.S. & Nelson, M.E. Nutritional Practices of Elite Athletes. Sports Medicine 16, 381–399 (1993). https://doi.org/10.2165/00007256-199316060-00004
8 - https://news.un.org/en/story/2022/12/1131637
9 - Mifflin MD, St Jeor ST, Hill LA, Scott BJ, Daugherty SA, Koh YO. A new predictive equation for resting energy expenditure in healthy individuals. Am J Clin Nutr. 1990 Feb;51(2):241-7. doi: 10.1093/ajcn/51.2.241. PMID: 2305711.
10 - Frankenfield D, Roth-Yousey L, Compher C. Comparison of predictive equations for resting metabolic rate in healthy nonobese and obese adults: a systematic review. J Am Diet Assoc. 2005 May;105(5):775-89. doi: 10.1016/j.jada.2005.02.005. PMID: 15883556.
11 - https://legionathletics.com/tools/tdee-calculator/