根据who和cdc儿童生长标准计算人体测量z值

pygrowup的Python项目详细描述


PyGrowUp计算下列人体测量指标的Z分数:

  • 年龄体重
  • 年龄的长度/身高
  • 长度/高度的重量
  • 年龄的头围
  • 年龄的体重指数

根据世卫组织儿童成长标准: *http://www.who.int/childgrowth/standards/en/ *http://www.who.int/entity/childgrowth/standards/technical_report/en/index.html

并且可以选择使用CDC增长标准: *http://www.cdc.gov/growthcharts

PyGrowUp避免浮点运算以消除不需要的舍入 这混淆了一些igrowup实现的精度: *http://docs.sun.com/source/806-3568/ncg_goldberg.html

要求

安装

pip安装pygrowup

示例用法

典型用法如下:

#!/usr/bin/env python

from pygrowup import Calculator
# helpers contains optional utilities for formatting dates, etc
from pygrowup import helpers

# Height adjustments are part of the WHO specification (see section 5.1)
# to correct for recumbent vs standing measurements,
# but none of the existing software seems to implement this.
# default is false so values are closer to those produced
# by igrowup software
#
# WHO specs include adjustments (see Chapter 7) to z-scores of weight-based
# indicators that are greater than +/- 3 SDs. These adjustments
# correct for right skewness and avoid making assumptions about
# the distribution of data beyond the limits of the observed values.
#
# However, when calculating z-scores in a live data collection
# situation, z-scores greater than +/- 3 SDs are likely to indicate
# data entry or anthropometric measurement errors and should not
# be adjusted. Instead, these large z-scores should be used to
# identify poor data quality and/or entry errors.
# These z-score adjustments are appropriate only when there
# is confidence in data quality.
#
# In this example, Calculator is initialized with its default values
# (i.e., ``calculator = Calculator()`` would do the same thing).
# The ``include_cdc`` option will enable CDC measurements for children >5 years.
calculator = Calculator(adjust_height_data=False, adjust_weight_scores=False,
                       include_cdc=False, logger_name='pygrowup',
                       log_level='INFO')

# for a timeless example, lets pick a birthdate nine months ago
import datetime
great_day = datetime.datetime.utcnow().date()
nine_months_ago = great_day - datetime.timedelta(days=(9 * 30.4374))

# nine months ago in an odd, ambiguous string format
dob = nine_months_ago.strftime("%d%m%y")

my_child = {'date_of_birth' : dob, 'sex' : 'male', 'weight' : '8.0', 'height' : '69.5'}

# optionally use helper functions for formatting data

# transform something like '100309' into '2009-03-10'
valid_date = helpers.get_good_date(my_child['date_of_birth'])

# transform 'male' into 'M'
valid_gender = helpers.get_good_sex('male')

# calculate 9 months from valid_date
valid_age = helpers.date_to_age_in_months(valid_date[1])


# calculate length/height-for-age zscore
lhfa_zscore_for_my_child = calculator.lhfa(my_child['height'], valid_age, valid_gender)

# calculate weight-for-age zscore
wfa_zscore_for_my_child = calculator.wfa(my_child['weight'], valid_age, valid_gender)

# calculate weight-for-length zscore
# optional height parameter is only necessary for weight-for-height
# and weight-for-length
wfl_zscore_for_my_child = calculator.wfl(my_child['weight'], valid_age, valid_gender, my_child['height'])

# Note: for backwards compatibility you may still make calls to:
wfl_zscore_for_my_child = calculator.zscore_for_measurement('wfl', my_child['weight'], valid_age, valid_gender, my_child['height'])

例外情况

来电者应注意:

  • 断言错误在调用方提供不适当的参数时引发

以及更具体的错误(runtimeerror的所有子类):

  • 无效测量当测量对请求的指示器无效时引发
  • invalid age当年龄对请求的指标无效时引发
  • 未发现数据当未找到所需观察的世卫组织/疾病预防控制中心数据时(如Box Cox、Midenal、Coeffeciant of Varance for Age)提出
  • 数据错误在将who/cdc数据加载到内存中时发生错误时引发

测试

安装nose以执行测试: pip安装鼻子

所包含的测试使用从 世卫组织igrowup软件附带的演示数据。 pygroup执行相同的计算并比较结果 世界卫生组织结果。 请参阅“谁是iGrowUp”的软件许可协议,其中 是测试数据文件的来源: http://www.who.int/childgrowth/software/license2.pdf

目前,有4例不能在1个标准差内产生结果 世界卫生组织的报告。我相信这些谨慎是由于谁在使用 在他们的igrowup软件中使用浮点运算,这导致 与PyGrowUp相比的精确计算。如果没有其他的 受信任的测试数据,请注意没有对 pygroup计算的准确性或可靠性。

要运行测试: $nosetests tests.py

开发

借助于 两个惊人的python实用程序:

下面是一个从tsv更改source.txt的示例 到csv(使用pyp)然后到json(使用csvkit的csvjson$cat bmi_girls_2_5_zscores.txt pyp“p.replace('t',',',')”csvjson>;bmifa_girls_2_5_zscores.json

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java对ServiceListener和ServiceTracker调用提供了哪些排序保证?   java找不到方法格式的符号(DateTimeFormatter)?   mysql有没有一种方法可以将TCPDump输出到一个文件中,并用Java对其进行过滤,每5秒钟用新数据覆盖一次该文件?   java如何最好地配置用户上传支持文件的上传位置   java我在Android上使用OData4j,我无法获取实体   JPA实体关系简单示例中的java获取错误   JAVANoClassDefFoundError:安卓。应用程序。用法安卓中的UsageStatsManager   Eclipse中javaoo代码分析   java MethodVisitor抛出类格式错误   java为什么在从ViewModel调用时,改型排队不起作用?   调试小程序Java控制台:删除跟踪消息大小限制   java复杂安卓活动动画   java如何在使用JDOM2解析XML时忽略注释内容   java通过循环创建文本字段   即使在bufferedwriter关闭后也未发现java文件异常   单链表恢复中的java错误