glucopy.metrics.bgi#

glucopy.metrics.bgi(df: DataFrame, unit: str = 'mg/dL', index_type: str = 'h', maximum: bool = False)[source]#

Calculates the Low Blood Glucose Index (LBGI) or the High Blood Glucose Index (LBGI).

\[LBGI = \frac{1}{N} \sum_{i=1}^N rl(X_i)\]
\[HBGI = \frac{1}{N} \sum_{i=1}^N rh(X_i)\]
  • \(N\) is the number of glucose readings.

  • \(rl(X_i) = 22.77 * f(X_i)^2\) if \(f(X_i) < 0\) and \(0\) otherwise.

  • \(rh(X_i) = 22.77 * f(X_i)^2\) if \(f(X_i) > 0\) and \(0\) otherwise.

  • \(f(X_i) = 1.509 * (\ln(X_i)^{1.084} - 5.381)\) for glucose readings in mg/dL.

  • \(X_i\) is the glucose value in mg/dL at time i.

Parameters:
  • df (pandas.DataFrame) – DataFrame containing the CGM values. The dataframe must contain ‘CGM’ column present in glucopy.Gframe.data.

  • unit (str, default 'mg/dL') – Unit of the CGM values. Can be ‘mg/dL’ or ‘mmol/L’.

  • index_type (str, default 'h') – Type of index to calculate. Can be ‘h’ (High Blood Glucose Index) or ‘l’ (Low Blood Glucose Index).

  • maximum (bool, default False) – If True, returns the maximum LBGI or HBGI. If False, returns the mean LBGI or HBGI.

Returns:

bgi – Low Blood Glucose Index (LBGI) or High Blood Glucose Index (HBGI).

Return type:

float

Notes

This function is meant to be used by glucopy.Gframe.bgi()