# Utilities
# glucoseVectorToTimetable
dataTimetable = glucoseVectorToTimetable(data, sampleTime, startTime)
Function that converts a vector containing glucose samples sampled on an homogeneous timegrid with timestep sampleTime in a timetable. The resulting timetable timestamps will start from startTime. If startTime is not specified, 2000-01-01 00:00 is used as default.
# Inputs
- data: vector of double (required) 
 A vector of doubled containing the glucose data (in mg/dl) supposed to be sampled in a homogeneous timegrid with timestepsampleTime;
- sampleTime: integer (required) 
 An integer defining the sample time of data (in min);
- startTime: datetime (required) 
 A dateTime defining the first timestamp of the resulting timetable. If startTime is not provided, 2000-01-01 00:00, is used as default.
# Output
- dataTimetable: timetable 
 datatransformed in timetable having two columns:Time, which contains the timestamps, andglucosecontaining the corresponding glucose data (in mg/dl).
# Preconditions
- datamust be a vector of double supposed to be sampled in a homogeneous timegrid with timestep- sampleTime;
- sampleTimemust be an integer;
- startTimemust be a datetime.
# Reference
- None
# timetableToGlucoseVector
dataVector = timetableToGlucoseVector(data)
Function that converts a timetable with column Time and glucose containing the glucose data, in a double vector containing the glucose data in the glucose column.
# Input
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data (in mg/dl).
# Output
- dataVector: vector of double 
 A vector of double containing the glucose data in theglucosecolumn.
# Preconditions
- datamust be a timetable having an homogeneous time grid;
- datamust contain a column named- Timeand another named- glucose.
# Reference
- None
# glucoseTimeVectorsToTimetable
function dataTimetable = glucoseTimeVectorsToTimetable(glucose, time)
Function that converts the two given vectors containing the glucose samples and the corresponding timestamps, respectively, in a timetable.
# Inputs
- glucose: vector of double (required) 
 A vector of double containing the glucose data (in mg/dl);
- time: vector of datetime (required) 
 A vector of datetime containing the timestamps of eachglucosedatapoint.
# Output
- dataTimetable: timetable 
 dataandtimevectors transformed in timetable having two columns:Time, which contains the timestamps, andglucosecontaining the corresponding glucose data (in mg/dl).
# Preconditions
- dataand- timemust be of the same length;
- glucosemust be a vector of double;
- timemust be a a vector of datetime.
# Reference
- None
# timetableToGlucoseTimeVectors
function [dataVector, timeVector] = timetableToGlucoseTimeVectors(data)
Function that converts a timetable with column Time and glucose containing the timestamps and the respective glucose data, in two vectors: one containing the timestamp data in the Time column and the other containing the glucose data in the glucose column.
# Input
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data (in mg/dl).
# Outputs
- dataVector: vector of double 
 A vector of double containing the glucose data in theglucosecolumn;
- timeVector: vector of datetime 
 A vector of datetime containing the timestamp data in theTimecolumn.
# Preconditions
- datamust be a timetable having an homogeneous time grid;
- datamust contain a column named- Timeand another named- glucose.
# Reference
- None
# toMGDL
function data = toMGDL(data)
Function that converts a timetable with column Time and glucose containing the timestamps and the respective glucose data in mmol/L to mg/dL.
# Input
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data (in mmol/l).
# Outputs
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data (in mg/dl).
# Preconditions
- datamust contain a column named- Timeand another named- glucose.
# Reference
- None
# toMMOLL
function data = toMMOLL(data)
Function that converts a timetable with column Time and glucose containing the timestamps and the respective glucose data in mg/dL to mmol/l.
# Input
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data (in mg/dl).
# Outputs
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data (in mmol/l).
# Preconditions
- datamust contain a column named- Timeand another named- glucose.
# Reference
- None
# readFreestyleLibreData
function data = readFreestyleLibreData(file)
Function that reads data from a .xlsx file downloaded from the Freestyle Libre CGM system and converts it in a timetable compatible with AGATA.
# Input
- file: vector of character (required) 
 A vector of characters containing the relative path to the .xslx file to be converted in a timetable compatible with AGATA.
# Outputs
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data to analyze (in mg/dl).
# Preconditions
- filemust be a vector of characters.
# Reference
- None
# readEversenseData
function data = readEversenseData(file)
Function that reads data from a .xlsx file downloaded from the Eversense CGM system and converts it in a timetable compatible with AGATA.
# Input
- file: vector of character (required) 
 A vector of characters containing the relative path to the .xslx file to be converted in a timetable compatible with AGATA.
# Outputs
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data to analyze (in mg/dl).
# Preconditions
- filemust be a vector of characters.
# Reference
- None
# readDexcomData
function data = readDexcomData(file)
Function that reads data from a .xlsx file downloaded from the Dexcom CGM system and converts it in a timetable compatible with AGATA.
# Input
- file: vector of character (required) 
 A vector of characters containing the relative path to the .xslx file to be converted in a timetable compatible with AGATA.
# Outputs
- data: timetable (required) 
 A timetable with columnTimeandglucosecontaining the glucose data to analyze (in mg/dl).
# Preconditions
- filemust be a vector of characters.
# Reference
- None