Skip to main content

Calculate z-scores of anthropometric measurements based on WHO child growth standards

Project description

pygrowup

pygrowup calculates z-scores for the growth measurements of children. The indicators it supports are:

  • weight-for-age
  • length/height-for-age
  • weight-for-length/height
  • head circumference-for-age
  • arm circumference-for-age (MUAC)
  • BMI-for-age
  • subscapular skinfold-for-age
  • triceps skinfold-for-age

These are all based on the WHO Child Growth Standards (with the exception of MUAC for 5-19 years; see notes below about an additional data source).

It requires Python 3.10 or later.

Installation

pip install pygrowup2

Or install from source:

pip install git+https://github.com/jbaldivieso/pygrowup2.git

Usage

pygrowup is modelled based on an "observation" of a child. The age of the child at the time of the observation is captured either explicitly, or inferred based on the child's date of birth and the date of the observation. Once an Observation object is instantiated, multiple methods are available to compute the z-scores for the various indicators.

Examples:

from datetime import date, timedelta
from decimal import Decimal

from pygrowup import Observation

# Three ways of instantiating roughly comparable Observations for a
# 13-month-old boy.
today = date.today()
thirteen_months_ago = today - timedelta(days=365 + 30)
obs = Observation(sex=Observation.MALE, age_in_days=13*30)
obs = Observation(sex=Observation.MALE, age_in_months=13)
obs = Observation(sex=Observation.MALE, dob=thirteen_months_ago,
                  date_of_observation=today)

# Now calculate some z-scores for this child
print(obs.head_circumference_for_age(Decimal('46.5')))

# Or, if you're into the whole brevity thing, each method has an alias. And
# measurements can be expressed as ints, floats, or Decimals.
print(obs.hcfa(46.5))  # Same result as the previous computation.

print(obs.weight_for_age(Decimal('9.6')))
print(obs.length_or_height_for_age(Decimal('77')))
print(obs.weight_for_length(Decimal('9.6'), Decimal('77')))

Except for weight-for-length and weight-for-height, the z-score methods expect a single argument for the measurement. (That means BMI must be calculated separately and passed in as the measurement.)

Each method for calculating z-scores has a verbose name and a more succinct alias. The full list of them (aliases in parentheses) is:

  • arm_circumference_for_age (acfa)
  • bmi_for_age (bmifa)
  • head_circumference_for_age (hcfa)
  • length_or_height_for_age (lhfa)
  • subscapular_skinfold_for_age (ssfa)
  • triceps_skinfold_for_age (tsfa)
  • weight_for_age (wfa)
  • weight_for_height (wfh)
  • weight_for_length (wfl)

Differences from earlier versions of pygrowup

Some differences from the current version and version 0.8.1 and before are:

  • This package employs precision based off of a child's age to the day-level where possible (up to 5 years of age); the original rounds to nearest completed month
  • There is no CDC-data-based option for the growth metrics
  • This package includes the more esoteric metrics (subscapular skinfold-for-age, triceps skinfold-for-age, arm circumference-for-age)

About tests

Run the tests like this:

python -m pygrowup.tests

The tests run against two distinct datasets: one originating from the R implementation of WHO's igrowup software, and the other based on data SPOON (see credits) collected and processed using the Stata version of igrowup. Using the WHO data, this package's z-scores are generally within 0.1 of the test datasets with 7 (with earlier versions of Python, this was only 2; unclear why) exceptions. However, a number of results differ by at least 0.05. It's not clear if that's due to the other implementations' use of floating point arithmetic (in contrast with this package's use of python's Decimal library for more precise computation) or if there are small inaccuracies in this package. So, caveat emptor!

About MUAC data extension

The WHO dataset for mid-upper arm circumference only goes to 5 years. However, it can be a useful proxy when weight is difficult to measure. Therefore, an option is available to extend the range to 19 years by employing a dataset compiled by Lazarus Mramba, et al. The data themselves were derived from a PDF from that publication.

Credits

The initial implementation of this work was by SPOON, and was heavily inspired by Evan Wheeler's original pygrowup.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygrowup2-1.0.0.tar.gz (565.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygrowup2-1.0.0-py3-none-any.whl (597.4 kB view details)

Uploaded Python 3

File details

Details for the file pygrowup2-1.0.0.tar.gz.

File metadata

  • Download URL: pygrowup2-1.0.0.tar.gz
  • Upload date:
  • Size: 565.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pygrowup2-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bf6daa6711a54daf745d67223280678f73005233de77d547db115eadae0e92f2
MD5 7e6557f2fd444786c1d3cff004ac6546
BLAKE2b-256 521c8a9d4243c0ee8aace29f6f4c02bc0b7c36c9c349217f4413d89c3706a721

See more details on using hashes here.

File details

Details for the file pygrowup2-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pygrowup2-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 597.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pygrowup2-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c65ad4900dd32ddb88f8bcda09bfb9f29df4eb9b7dba0539b5842cf701b7c83
MD5 7e8d98760c8cce2eeeda3a57912e677b
BLAKE2b-256 f8bbca07460e93b5769a4335583e32fa70bcd70930ba53e657b2ab24730a566a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page