Skip to content

Commit

Permalink
Merge pull request #44 from rcpch/eatyourpeas/issue43
Browse files Browse the repository at this point in the history
adds midparental height functions
  • Loading branch information
eatyourpeas authored Nov 2, 2024
2 parents 4b3fe61 + 9f47965 commit 4627fcf
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.2.1
current_version = 4.2.3
tag = False
commit = True

Expand Down
21 changes: 11 additions & 10 deletions rcpchgrowth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from .age_advice_strings import comment_prematurity_correction
from .bmi_functions import bmi_from_height_weight, weight_for_bmi_height
from .cdc import select_reference_data_for_cdc_chart
from .centile_bands import centile_band_for_centile
from .chart_functions import create_chart, generate_custom_sds_line
from .constants import *
from .date_calculations import chronological_decimal_age, corrected_decimal_age, chronological_calendar_age, estimated_date_delivery, corrected_gestational_age
from .dynamic_growth import create_thrive_line, return_correlation, create_thrive_lines
from .global_functions import centile, sds_for_measurement, measurement_from_sds, percentage_median_bmi, mid_parental_height, measurement_for_z, cubic_interpolation, linear_interpolation
from .centile_bands import centile_band_for_centile
from .cdc import select_reference_data_for_cdc_chart
from .bmi_functions import bmi_from_height_weight, weight_for_bmi_height
from .age_advice_strings import comment_prematurity_correction
from .fictional_child import generate_fictional_child_data
from .dynamic_growth import create_thrive_line, return_correlation, create_thrive_lines
from .uk_who import select_reference_data_for_uk_who_chart
from .turner import select_reference_data_for_turner
from .measurement import Measurement
from .mid_parental_height import *
from .trisomy_21 import select_reference_data_for_trisomy_21
from .trisomy_21_aap import select_reference_data_for_trisomy_21_aap
from .measurement import Measurement
from .chart_functions import create_chart, generate_custom_sds_line
from .constants import *
from .turner import select_reference_data_for_turner
from .uk_who import select_reference_data_for_uk_who_chart
50 changes: 50 additions & 0 deletions rcpchgrowth/mid_parental_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from .constants import HEIGHT, MALE, FEMALE, UK_WHO
from .global_functions import sds_for_measurement
"""
Functions to calculate mid-parental height
cf
Tanner JM, Whitehouse RH, Takaishi M. Standards from birth to maturity for height, weight, height velocity, and weight velocity: British children, 1965. I. Arch Dis Child. 1966;41(219):454-471.
The strengths and limitations of parental heights as a predictor of attained height, Charlotte M Wright, Tim D Cheetham, Arch Dis Child 1999;81:257–260
"""

def mid_parental_height(maternal_height, paternal_height, sex):
"""
Calculate mid-parental height
"""
if sex == MALE:
return (maternal_height + paternal_height + 13) / 2
else:
return (maternal_height + paternal_height - 13) / 2

def mid_parental_height_z(maternal_height, paternal_height, reference=UK_WHO):
"""
Calculate mid-parental height standard deviation
"""

# convert parental heights to z-scores
maternal_height_z = sds_for_measurement(reference=reference, age=20.0, measurement_method=HEIGHT, observation_value=maternal_height, sex=FEMALE)
paternal_height_z = sds_for_measurement(reference=reference, age=20.0, measurement_method=HEIGHT, observation_value=paternal_height, sex=MALE)

# take the measn of the z-scores and apply the regression coefficient of 0.5 - simplifed: (MatHtz +PatHtz)/4
mid_parental_height_z_score = (maternal_height_z + paternal_height_z) / 4.0

return mid_parental_height_z_score

def expected_height_z_from_mid_parental_height_z(mid_parental_height_z):
"""
Calculate expected height z score from mid-parental height z-score
Ninety per cent of children had values within 1.4 SDS of their expected SDS (just over two
centile spaces) and only 1% had values > 2 SDS (three centile spaces) below (cf Wright et al)
"""

return mid_parental_height_z * 0.5

def lower_and_upper_limits_of_expected_height_z(mid_parental_height_z):
"""
Calculate lower and upper limits of expected height z score from mid-parental height z-score
Returns a tuple of (lower, upper) limits
"""

return mid_parental_height_z - 1.4, mid_parental_height_z + 1.4
16 changes: 16 additions & 0 deletions rcpchgrowth/tests/test_mid_parental_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest

from rcpchgrowth.constants import MALE, FEMALE, UK_WHO, CDC
from rcpchgrowth.mid_parental_height import mid_parental_height, mid_parental_height_z, expected_height_z_from_mid_parental_height_z

maternal_height = 151
paternal_height = 167
ACCURACY = 1e-3


def test_midparental_height():
assert mid_parental_height(maternal_height=maternal_height, paternal_height=paternal_height, sex=MALE) == 165.5
assert mid_parental_height(maternal_height=maternal_height, paternal_height=paternal_height, sex=FEMALE) == 152.5
assert mid_parental_height_z(maternal_height=maternal_height, paternal_height=paternal_height, reference=UK_WHO) == pytest.approx(-0.8943229, ACCURACY)
assert mid_parental_height_z(maternal_height=maternal_height, paternal_height=paternal_height, reference=CDC) == pytest.approx(-0.8177165233046019, ACCURACY)
assert expected_height_z_from_mid_parental_height_z(mid_parental_height_z=-0.8943229) == pytest.approx(-0.44716145, ACCURACY)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="rcpchgrowth",
version="4.2.1",
version="4.2.3",
description="SDS and Centile calculations for UK Growth Data",
long_description=long_description,
url="https://github.com/rcpch/digital-growth-charts/blob/master/README.md",
Expand Down

0 comments on commit 4627fcf

Please sign in to comment.