glucopy.Gframe.bgi#

Gframe.bgi(per_day: bool = False, 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:
  • per_day (bool, default False) – If True, returns a pandas.Series with the LBGI for each day. If False, returns the BGI for the entire dataset.

  • 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 or High Blood Glucose Index.

Return type:

float | pandas.Series

Notes

Examples

Calculating the LBGI for the entire dataset:

In [1]: import glucopy as gp

In [2]: gf = gp.data('prueba_1')

In [3]: gf.bgi(index_type='l')
Out[3]: 5.738193766531024

Calculating the HBGI for each day:

In [4]: gf.bgi(index_type='h', per_day=True)
Out[4]: 
Day
2020-11-27    65.578288
2020-11-28     8.336938
2020-11-29    14.009624
2020-11-30     3.021797
2020-12-01     8.231709
                ...    
2021-03-14     9.801256
2021-03-15    13.198442
2021-03-16    14.564034
2021-03-17     3.087701
2021-03-18    18.710777
Name: HBGI, Length: 112, dtype: float64