Meals & AUC
Meal-response and area-under-the-curve analysis.
analyzeMealResponse
Import: @glucoseiq/core/metrics
analyzeMealResponse(readings: GlucoseReading[], mealTime: string, options?: MealResponseOptions): MealResponseResultAnalyzes the glucose response to a meal.
Returns: Meal-response metrics; valid: false if the window has fewer than two readings
import { type GlucoseReading } from '@glucoseiq/core'
import { analyzeMealResponse } from '@glucoseiq/core/metrics'
const readings: GlucoseReading[] = [
{ value: 98, unit: 'mg/dL', timestamp: '2024-01-01T12:25:00Z' },
{ value: 162, unit: 'mg/dL', timestamp: '2024-01-01T13:15:00Z' },
{ value: 125, unit: 'mg/dL', timestamp: '2024-01-01T13:45:00Z' },
]
const result = analyzeMealResponse(readings, '2024-01-01T12:30:00Z')
const delta = result.valid ? result.delta : null
void delta| Parameter | Description |
|---|---|
readings | Glucose readings with ISO 8601 timestamps |
mealTime | ISO 8601 timestamp of the meal (t=0) |
options | Window length and output unit |
glucoseAUC
Import: @glucoseiq/core/metrics
glucoseAUC(readings: GlucoseReading[], options?: AUCOptions): numberTotal area under the glucose-time curve (trapezoidal rule).
Returns: Area in (unit × minutes), or NaN if fewer than two valid readings
import { type GlucoseReading } from '@glucoseiq/core'
import { glucoseAUC } from '@glucoseiq/core/metrics'
const readings: GlucoseReading[] = [
{ value: 100, unit: 'mg/dL', timestamp: '2024-01-01T08:00:00Z' },
{ value: 120, unit: 'mg/dL', timestamp: '2024-01-01T08:05:00Z' },
]
const area = glucoseAUC(readings) // mg/dL·min| Parameter | Description |
|---|---|
readings | Glucose readings with ISO 8601 timestamps |
options | Output unit |
incrementalAUC
Import: @glucoseiq/core/metrics
incrementalAUC(readings: GlucoseReading[], baseline: number, options?: AUCOptions): numberIncremental area under the curve above a baseline (Wolever iAUC).
Only above-baseline area is counted; a segment crossing the baseline
contributes only its above-baseline triangle, and fully-below segments
contribute zero. For a meal response, pass the pre-meal value as baseline.
Returns: Incremental area in (unit × minutes), or NaN if fewer than two valid readings
import { type GlucoseReading } from '@glucoseiq/core'
import { incrementalAUC } from '@glucoseiq/core/metrics'
const readings: GlucoseReading[] = [
{ value: 100, unit: 'mg/dL', timestamp: '2024-01-01T08:00:00Z' },
{ value: 140, unit: 'mg/dL', timestamp: '2024-01-01T08:30:00Z' },
]
const preMealValue: number = 100
const area = incrementalAUC(readings, preMealValue)| Parameter | Description |
|---|---|
readings | Glucose readings with ISO 8601 timestamps |
baseline | Baseline value in the output unit (e.g. the pre-meal reading) |
options | Output unit (must match the unit of baseline) |