diff --git a/rcpchgrowth/chart_functions.py b/rcpchgrowth/chart_functions.py index 38ca878..960f387 100644 --- a/rcpchgrowth/chart_functions.py +++ b/rcpchgrowth/chart_functions.py @@ -13,6 +13,8 @@ COLE_TWO_THIRDS_SDS_NINE_CENTILE_COLLECTION, EIGHTY_FIVE_PERCENT_CENTILES, EIGHTY_FIVE_PERCENT_CENTILE_COLLECTION, + EXTENDED_WHO_CENTILES, + EXTENDED_WHO_CENTILES_COLLECTION, FEMALE, FENTON, FIVE_PERCENT_CENTILES, @@ -353,16 +355,17 @@ def create_uk_who_chart( z=0.0 #initialise centile_value=0.0 #initialise - if cole_method: - z = rounded_sds_for_centile(centile_sds) # a centile was provided, so convert to z - centile_value=centile_sds # store the original centile value + # if cole_method: + # z = rounded_sds_for_centile(centile_sds) # a centile was provided, so convert to z + # centile_value=centile_sds # store the original centile value + # else: + if (is_sds): + z=centile_sds # an sds was supplied + centile_value=centile(centile_sds) # convert the z to a centile and store else: - if (is_sds): - z=centile_sds # an sds was supplied - centile_value=centile(centile_sds) # convert the z to a centile and store - else: - z = sds_for_centile(centile_sds) # a centile was provided, so convert to z - centile_value=centile_sds # store the original centile value + z = sds_for_centile(centile_sds) # a centile was provided, so convert to z + print(f"z: {z}") + centile_value=centile_sds # store the original centile value centile_data = [] try: @@ -1038,5 +1041,7 @@ def select_centile_format(centile_format: str): return FIVE_PERCENT_CENTILE_COLLECTION elif centile_format == EIGHTY_FIVE_PERCENT_CENTILES: return EIGHTY_FIVE_PERCENT_CENTILE_COLLECTION + elif centile_format == EXTENDED_WHO_CENTILES: + return EXTENDED_WHO_CENTILES_COLLECTION else: return COLE_TWO_THIRDS_SDS_NINE_CENTILE_COLLECTION \ No newline at end of file diff --git a/rcpchgrowth/constants/reference_constants.py b/rcpchgrowth/constants/reference_constants.py index cda48ff..421ccd7 100644 --- a/rcpchgrowth/constants/reference_constants.py +++ b/rcpchgrowth/constants/reference_constants.py @@ -92,7 +92,8 @@ FIVE_PERCENT_CENTILES = "five-percent-centiles" EIGHTY_FIVE_PERCENT_CENTILES = "eighty-five-percent-centiles" COLE_TWO_THIRDS_SDS_NINE_CENTILES = "cole-nine-centiles" -CENTILE_FORMATS = [THREE_PERCENT_CENTILES, COLE_TWO_THIRDS_SDS_NINE_CENTILES] +EXTENDED_WHO_CENTILES = "extended-who-centiles" +CENTILE_FORMATS = [THREE_PERCENT_CENTILES, FIVE_PERCENT_CENTILES, EIGHTY_FIVE_PERCENT_CENTILES, EXTENDED_WHO_CENTILES, COLE_TWO_THIRDS_SDS_NINE_CENTILES] THREE_PERCENT_CENTILE_COLLECTION = [3.0, 5.0, 10.0, 25.0, 50.0, 75.0, 90.0, 95.0, 97.0] EIGHTY_FIVE_PERCENT_CENTILE_COLLECTION = [5.0, 10.0, 25.0, 50.0, 75.0, 85.0, 90.0, 95, 98.0, 99.0, 99.9, 99.99] # use for CDC Extended BMI centiles 2022 @@ -108,3 +109,4 @@ 98.0, 99.6, ] +EXTENDED_WHO_CENTILES_COLLECTION = [1, 3, 5, 10, 15, 50, 85, 90, 95, 97, 99] diff --git a/rcpchgrowth/global_functions.py b/rcpchgrowth/global_functions.py index ec2f958..0442430 100644 --- a/rcpchgrowth/global_functions.py +++ b/rcpchgrowth/global_functions.py @@ -187,7 +187,7 @@ def generate_centile( WHO_2006_UNDER_TWOS_AGES = [0.038329911, 0.057494867, 0.076659822, 0.083333333, 0.095824778, 0.114989733, 0.134154689, 0.153319644, 0.166666667, 0.1724846, 0.191649555, 0.210814511, 0.229979466, 0.249144422, 0.25, 0.333333333, 0.416666667, 0.5, 0.583333333, 0.666666667, 0.75, 0.833333333, 0.916666667, 1, 1.083333333, 1.166666667, 1.25, 1.333333333, 1.416666667, 1.5, 1.583333333, 1.666666667, 1.75, 1.833333333, 1.916666667, 2] UK_WHO_2006_OVER_TWOS_AGES = [2, 2.083333333, 2.166666667, 2.25, 2.333333333, 2.416666667, 2.5, 2.583333333, 2.666666667, 2.75, 2.833333333, 2.916666667, 3, 3.083333333, 3.166666667, 3.25, 3.333333333, 3.416666667, 3.5, 3.583333333, 3.666666667, 3.75, 3.833333333, 3.916666667, 4] WHO_2006_OVER_TWOS_AGES = [2, 2.083333333, 2.166666667, 2.25, 2.333333333, 2.416666667, 2.5, 2.583333333, 2.666666667, 2.75, 2.833333333, 2.916666667, 3, 3.083333333, 3.166666667, 3.25, 3.333333333, 3.416666667, 3.5, 3.583333333, 3.666666667, 3.75, 3.833333333, 3.916666667, 4, 3.083333333, 4.166666667, 4.25, 4.333333333, 4.416666667, 4.5, 4.583333333, 4.666666667, 4.75, 4.833333333, 4.916666667, 5.0] - WHO_2007_AGES = [5,5.08,5.17,5.25,5.33,5.42, 5.5,5.58,5.67,5.75,5.83,5.92,6,6.08,6.17,6.25,6.33,6.42, 6.5,6.58,6.67,6.75,6.83,6.92,7,7.08,7.17,7.25,7.33,7.42, 7.5,7.58,7.67,7.75,7.83,7.92,8,8.08,8.17,8.25,8.33,8.42, 8.5,8.58,8.67,8.75,8.83,8.92,9,9.08,9.17,9.25,9.33,9.42, 9.5,9.58,9.67,9.75,9.83,9.92,10,10.08,10.17,10.25,10.33,10.42, 10.5,10.58,10.67,10.75,10.83,10.92,11,11.08,11.17,11.25,11.33,11.42, 11.5,11.58,11.67,11.75,11.83,11.92,12,12.08,12.17,12.25,12.33,12.42, 12.5,12.58,12.67,12.75,12.83,12.92,13,13.08,13.17,13.25,13.33,13.42, 13.5,13.58,13.67,13.75,13.83,13.92,14,14.08,14.17,14.25,14.33,14.42, 14.5,14.58,14.67,14.75,14.83,14.92,15,15.08,15.17,15.25,15.33,15.42, 15.5,15.58,15.67,15.75,15.83,15.92,16,16.08,16.17,16.25,16.33,16.42, 16.5,16.58,16.67,16.75,16.83,16.92,17,17.08,17.17,17.25,17.33,17.42, 17.5,17.58,17.67,17.75,17.83,17.92, 18,18.08,18.17,18.25,18.33,18.42, 18.5,18.58,18.67,18.75,18.83,18.92,19] + WHO_2007_AGES = [5.08,5.17,5.25,5.33,5.42, 5.5,5.58,5.67,5.75,5.83,5.92,6,6.08,6.17,6.25,6.33,6.42, 6.5,6.58,6.67,6.75,6.83,6.92,7,7.08,7.17,7.25,7.33,7.42, 7.5,7.58,7.67,7.75,7.83,7.92,8,8.08,8.17,8.25,8.33,8.42, 8.5,8.58,8.67,8.75,8.83,8.92,9,9.08,9.17,9.25,9.33,9.42, 9.5,9.58,9.67,9.75,9.83,9.92,10,10.08,10.17,10.25,10.33,10.42, 10.5,10.58,10.67,10.75,10.83,10.92,11,11.08,11.17,11.25,11.33,11.42, 11.5,11.58,11.67,11.75,11.83,11.92,12,12.08,12.17,12.25,12.33,12.42, 12.5,12.58,12.67,12.75,12.83,12.92,13,13.08,13.17,13.25,13.33,13.42, 13.5,13.58,13.67,13.75,13.83,13.92,14,14.08,14.17,14.25,14.33,14.42, 14.5,14.58,14.67,14.75,14.83,14.92,15,15.08,15.17,15.25,15.33,15.42, 15.5,15.58,15.67,15.75,15.83,15.92,16,16.08,16.17,16.25,16.33,16.42, 16.5,16.58,16.67,16.75,16.83,16.92,17,17.08,17.17,17.25,17.33,17.42, 17.5,17.58,17.67,17.75,17.83,17.92, 18,18.08,18.17,18.25,18.33,18.42, 18.5,18.58,18.67,18.75,18.83,18.92,19] UK90_AGES = [4, 4.083, 4.167, 4.25, 4.333, 4.417, 4.5, 4.583, 4.667, 4.75, 4.833, 4.917, 5, 5.083, 5.167, 5.25, 5.333, 5.417, 5.5, 5.583, 5.667, 5.75, 5.833, 5.917, 6, 6.083, 6.167, 6.25, 6.333, 6.417, 6.5, 6.583, 6.667, 6.75, 6.833, 6.917, 7, 7.083, 7.167, 7.25, 7.333, 7.417, 7.5, 7.583, 7.667, 7.75, 7.833, 7.917, 8, 8.083, 8.167, 8.25, 8.333, 8.417, 8.5, 8.583, 8.667, 8.75, 8.833, 8.917, 9, 9.083, 9.167, 9.25, 9.333, 9.417, 9.5, 9.583, 9.667, 9.75, 9.833, 9.917, 10, 10.083, 10.167, 10.25, 10.333, 10.417, 10.5, 10.583, 10.667, 10.75, 10.833, 10.917, 11, 11.083, 11.167, 11.25, 11.333, 11.417, 11.5, 11.583, 11.667, 11.75, 11.833, 11.917, 12, 12.083, 12.167, 12.25, 12.333, 12.417, 12.5, 12.583, 12.667, 12.75, 12.833, 12.917, 13, 13.083, 13.167, 13.25, 13.333, 13.417, 13.5, 13.583, 13.667, 13.75, 13.833, 13.917, 14, 14.083, 14.167, 14.25, 14.333, 14.417, 14.5, 14.583, 14.667, 14.75, 14.833, 14.917, 15, 15.083, 15.167, 15.25, 15.333, 15.417, 15.5, 15.583, 15.667, 15.75, 15.833, 15.917, 16, 16.083, 16.167, 16.25, 16.333, 16.417, 16.5, 16.583, 16.667, 16.75, 16.833, 16.917, 17, 17.083, 17.167, 17.25, 17.333, 17.417, 17.5, 17.583, 17.667, 17.75, 17.833, 17.917, 18, 18.083, 18.167, 18.25, 18.333, 18.417, 18.5, 18.583, 18.667, 18.75, 18.833, 18.917, 19, 19.083, 19.167, 19.25, 19.333, 19.417, 19.5, 19.583, 19.667, 19.75, 19.833, 19.917] CDC_TO_TWO=[0, 0.041666667, 0.125, 0.208333333, 0.291666667, 0.375, 0.458333333, 0.541666667, 0.625, 0.708333333, 0.791666667, 0.875, 0.958333333, 1.041666667, 1.125, 1.208333333, 1.291666667, 1.375, 1.458333333, 1.541666667, 1.625, 1.708333333, 1.791666667, 1.875, 1.958333333, 2] CDC_TWO_TWENTY = [2, 2.041666667, 2.125, 2.208333333, 2.291666667, 2.375, 2.458333333, 2.541666667, 2.625, 2.708333333, 2.791666667, 2.875, 2.958333333, 3.041666667, 3.125, 3.208333333, 3.291666667, 3.375, 3.458333333, 3.541666667, 3.625, 3.708333333, 3.791666667, 3.875, 3.958333333, 4.041666667, 4.125, 4.208333333, 4.291666667, 4.375, 4.458333333, 4.541666667, 4.625, 4.708333333, 4.791666667, 4.875, 4.958333333, 5.041666667, 5.125, 5.208333333, 5.291666667, 5.375, 5.458333333, 5.541666667, 5.625, 5.708333333, 5.791666667, 5.875, 5.958333333, 6.041666667, 6.125, 6.208333333, 6.291666667, 6.375, 6.458333333, 6.541666667, 6.625, 6.708333333, 6.791666667, 6.875, 6.958333333, 7.041666667, 7.125, 7.208333333, 7.291666667, 7.375, 7.458333333, 7.541666667, 7.625, 7.708333333, 7.791666667, 7.875, 7.958333333, 8.041666667, 8.125, 8.208333333, 8.291666667, 8.375, 8.458333333, 8.541666667, 8.625, 8.708333333, 8.791666667, 8.875, 8.958333333, 9.041666667, 9.125, 9.208333333, 9.291666667, 9.375, 9.458333333, 9.541666667, 9.625, 9.708333333, 9.791666667, 9.875, 9.958333333, 10.04166667, 10.125, 10.20833333, 10.29166667, 10.375, 10.45833333, 10.54166667, 10.625, 10.70833333, 10.79166667, 10.875, 10.95833333, 11.04166667, 11.125, 11.20833333, 11.29166667, 11.375, 11.45833333, 11.54166667, 11.625, 11.70833333, 11.79166667, 11.875, 11.95833333, 12.04166667, 12.125, 12.20833333, 12.29166667, 12.375, 12.45833333, 12.54166667, 12.625, 12.70833333, 12.79166667, 12.875, 12.95833333, 13.04166667, 13.125, 13.20833333, 13.29166667, 13.375, 13.45833333, 13.54166667, 13.625, 13.70833333, 13.79166667, 13.875, 13.95833333, 14.04166667, 14.125, 14.20833333, 14.29166667, 14.375, 14.45833333, 14.54166667, 14.625, 14.70833333, 14.79166667, 14.875, 14.95833333, 15.04166667, 15.125, 15.20833333, 15.29166667, 15.375, 15.45833333, 15.54166667, 15.625, 15.70833333, 15.79166667, 15.875, 15.95833333, 16.04166667, 16.125, 16.20833333, 16.29166667, 16.375, 16.45833333, 16.54166667, 16.625, 16.70833333, 16.79166667, 16.875, 16.95833333, 17.04166667, 17.125, 17.20833333, 17.29166667, 17.375, 17.45833333, 17.54166667, 17.625, 17.70833333, 17.79166667, 17.875, 17.95833333, 18.04166667, 18.125, 18.20833333, 18.29166667, 18.375, 18.45833333, 18.54166667, 18.625, 18.70833333, 18.79166667, 18.875, 18.95833333, 19.04166667, 19.125, 19.20833333, 19.29166667, 19.375, 19.45833333, 19.54166667, 19.625, 19.70833333, 19.79166667, 19.875, 19.95833333, 20] @@ -257,8 +257,7 @@ def should_default_to_youngest_reference(age: float, reference_name: str): default_youngest_reference = False if should_default_to_youngest_reference(age, reference_name): default_youngest_reference = True - if default_youngest_reference: - print(default_youngest_reference, reference_name, age) + try: measurement = measurement_from_sds( reference=reference,