Function Repository Resource:

PhysicalActivityCalculator

Source Notebook

Compute energy expenditure and other properties of various physical activities

Contributed by: Keiko Hirayama

ResourceFunction["PhysicalActivityCalculator"][activities]

returns energy expenditure information for activities as a Dataset.

ResourceFunction["PhysicalActivityCalculator"][activities, format]

returns information in the specified format.

Details and Options

PhysicalActivityCalculator can handle a variety of input forms:
"activities"a single string, with different activities and duration information separated by a delimiting character (default "\n")
{"activity1","activity2",}a list of strings
{{"activity1","duration1"},}a list of lists of activities and duration, with each element given as a string
The following values of format are accepted: "Dataset", "Association", "Table" or "ASCIITable". For "Table", results are returned in a List. For "ASCIITable" the result is a formatted string.
The following options are accepted:
"DelimiterCharacter"","character used to separate activities within a single string
“MetabolicProperties"{"EnergyExpenditure","MetabolicEquivalent", "FatBurned","OxygenConsumption"}properties to be returned for each activity
“BodyWeight"Quantity[160,"Pounds"]body weight described in Quantity to compute energy expenditure
“UnitSystem""Imperial"which unit system ("Metric" or "Imperial") to return results in

Examples

Basic Examples (2) 

Get energy expenditure information about activities specified in a text:

In[1]:=
ResourceFunction[
 "PhysicalActivityCalculator"]["playing soccer 45 min, watching tv 60 min, playing the piano 30 min"]
Out[1]=

Get energy expenditure information about activities specified in lists of activities and duration:

In[2]:=
ResourceFunction[
 "PhysicalActivityCalculator"][{{"aerobics exercise", "15 min"}, {"kick boxing", "30 min"}, {"fishing", "50 min"}}]
Out[2]=

Scope (3) 

Get energy expenditure information as an ASCII table, with columns delimited by pipe characters ("|"):

In[3]:=
ResourceFunction[
 "PhysicalActivityCalculator"][{"driving a car 30 min", "playing frisbee 20 min", "reading a book 40 min", "gardening 20 min", "taking a bath 20 min"}, "ASCIITable"]
Out[3]=

Get energy expenditure information as a List:

In[4]:=
ResourceFunction[
 "PhysicalActivityCalculator"][{{"hand washing laundry", "5 min"}, {"hanging laundry", "5 min"}, {"ironing clothing", "10 min"}}, "Table"]
Out[4]=

Get energy expenditure information as an Association:

In[5]:=
ResourceFunction[
 "PhysicalActivityCalculator"][{{"performing karate", "20 min"}, {"horseback riding", "60 min"}, {"aerobic exercise", "30 min"}}, "Association"]
Out[5]=

Options (5) 

DelimiterCharacter (1) 

Use "DelimiterCharacter" to specify how to split up activities in a string:

In[6]:=
ResourceFunction[
 "PhysicalActivityCalculator"]["ice skating 45 min; playing ice hockey 60 min; speed skating 30 min", "DelimiterCharacter" -> ";"]
Out[6]=

MetabolicProperties (1) 

Specify the desired metabolic properties using the "MetabolicProperties" option:

In[7]:=
ResourceFunction[
 "PhysicalActivityCalculator"]["playing cards 45 min, painting 60 min, knitting 30 min", "MetabolicProperties" -> {"EnergyExpenditure", "FatBurned"}]
Out[7]=

BodyWeight (1) 

Use the "BodyWeight" option to specify the weight variable used to compute energy expenditure:

In[8]:=
ResourceFunction[
 "PhysicalActivityCalculator"]["surfing 45 min, scuba diving 60 min, sailing 45 min", "BodyWeight" -> Quantity[180, "Pounds"]]
Out[8]=

UnitSystem (2) 

Use "UnitSystem" to specify the units of the result:

In[9]:=
ResourceFunction[
 "PhysicalActivityCalculator"]["milking cow 15 min, driving tractor 60 min, feeding animals 10 min", "UnitSystem" -> "Metric"]
Out[9]=

For running exercises, speed information can be added for more specific energy expenditure computation:

In[10]:=
ResourceFunction[
 "PhysicalActivityCalculator"][{"running 6 mph for 30 min", "running 8 mph for 10 min"}, "ASCIITable"]
Out[10]=

Properties and Relations (1) 

PhysicalActivityCalculator uses Interpreter["PhysicalActivity"] internally to convert strings into computable "PhysicalActivity" entities:

In[11]:=
Interpreter["PhysicalActivity"]["mowing the lawn"]
Out[11]=
In[12]:=
Entity["PhysicalActivity", "MowingLawnGeneral"]["EnergyExpenditureRate"]
Out[12]=

Possible Issues (2) 

Information about the duration of an activity is essential to compute specific energy expenditures:

In[13]:=
ResourceFunction[
 "PhysicalActivityCalculator"]["playing basketball", "Dataset"]
Out[13]=

More specific activities can be difficult to find data for:

In[14]:=
ResourceFunction[
 "PhysicalActivityCalculator"][{{"cooking food", "30 min"}, {"baking a pizza", "30 min"}}]
Out[14]=

Neat Examples (4) 

Compute energy expenditure of daily activities:

In[15]:=
activityDataset = ResourceFunction[
  "PhysicalActivityCalculator"][{"sleeping 8 hours", "making beds 1 min", "dressing 2 min", "cooking food 15 min", "eating while sitting 30 min", "washing dishes 5 min", "doing desk work 4 hours", "taking a walk during a lunch break 1 hour", "attending a work meeting 1 hour", "doing desk work 3 hours", "driving a car 30 min", "mowing the lawn 30 min", "watering garden 10 min", "performing yoga 20 min", "preparing food 15 min", "eating while sitting 60 min", "grocery shopping 40 min", "vacuuming 20 min", "folding laundry 10 min", "texting 10 min", "watching TV 60 min", "taking a bath 15 min", "brushing teeth 2 min", "reading a book 45 min"}, "Dataset"]
Out[15]=

Total duration of the record:

In[16]:=
activityDataset[All, #duration &][UnitConvert[Total[#], "Hours"] &]
Out[16]=

Total caloric expenditure:

In[17]:=
activityDataset[All, #"energy expenditure" &][Total]
Out[17]=

Visualize the daily activity pattern:

In[18]:=
DateListStepPlot[
 MapThread[
   List, {DateObject[{2023, 1, 1, 0, 0}, "Minute", "Gregorian", -5.`] + # & /@ Prepend[Drop[
       Accumulate[Normal@activityDataset[All, #duration &]], -1], Quantity[0, "Minutes"]], Normal@activityDataset[All, #"metabolic equivalent" &]}] -> Normal@activityDataset[All, #"interpreted activity" &], Sequence[
 PlotTheme -> "Business", ImageSize -> 600]]
Out[18]=

Version History

  • 1.0.0 – 16 June 2023

Related Resources

License Information