Metrics#

This module contains functions for calculating metrics of a glucose time series. The functions are meant to be used by the glucopy.Gframe class, but can be used independently as well as long as the input has the next columns:

  • ‘Timestamp’ : datetime64[ns] # pandas datetime

  • ‘Day’ : datetime.date

  • ‘Time’ : datetime.time

  • ‘CGM’ : number

1. Joint data analysis metrics for glycaemia dynamics#

metrics.mean(df[, per_day])

Calculates the mean of the CGM values.

metrics.std(df[, per_day, ddof])

Calculates the standard deviation of the CGM values.

metrics.cv(df[, per_day, ddof])

Calculates the Coefficient of Variation (CV) of the CGM values.

metrics.quantile(df[, per_day, q, interpolation])

Calculates the quantile of the CGM values.

metrics.iqr(df[, per_day, interpolation])

Calculates the Interquartile Range (IQR) of the CGM values.

metrics.modd(df[, target_time, slack, ignore_na])

Calculates the Mean of Daily Differences (MODD).

metrics.tir(df[, interval, percentage, decimals])

Calculates the Time in Range (TIR) for a given target range of glucose.

2. Analysis of distribution in the plane for glycaemia dynamics#

metrics.fd(df[, interval, decimals, count])

Calculates the Frequency Distribution (FD) for a given target range of glucose.

metrics.auc(df[, time_unit, threshold, above])

Calculates the Area Under the Curve (AUC) using the trapezoidal rule.

3. Amplitude and distribution of frequencies metrics for glycaemia dynamics#

metrics.mage(df)

Calculates the Mean Amplitude of Glycaemic Excursions (MAGE).

metrics.dt(df)

Calculates the Distance Travelled (DT).

4. Metrics for the analysis of glycaemic dynamics using scores of glucose values#

metrics.bgi(df[, unit, index_type, maximum])

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

metrics.grade(df[, percentage, unit])

Calculates the contributions of the Glycaemic Risk Assessment Diabetes Equation (GRADE) to Hypoglycaemia, Euglycaemia and Hyperglycaemia.

5. Metrics for the analysis of glycaemic dynamics using variability estimation#

metrics.mard(cgm_df, smbg_df[, slack, ...])

Calculates the Mean Absolute Relative Difference (MARD).

metrics.conga(df[, m, slack, ignore_na, ddof])

Calculates the Continuous Overall Net Glycaemic Action (CONGA).

metrics.gvp(df)

Calculates the Glucose Variability Percentage (GVP), with time in minutes.

metrics.mag(df[, time_unit])

Calculates the Mean Absolute Glucose Change per unit of time (MAG).

6. Computational methods for the analysis of glycemic dynamics#

metrics.dfa(df[, scale, overlap, integrate, ...])

Calculates the Detrended Fluctuation Analysis (DFA) using neurokit2.fractal_dfa().

metrics.samp_en(df[, delay, dimension, ...])

Calculates the Sample Entropy using neurokit2.entropy_sample()

metrics.mse(df[, scale, dimension, ...])

Calculates the Multiscale Sample Entropy using neurokit2.entropy_multiscale()