CGM-Freq: A Python Library for Frequency Domain Analysis of Continuous Glucose Monitoring Data

Authors: elizabeth  healey
isaac  kohane
Venue: IEEE_org_EMBS_BHI_2024_Conference
Published: 2024-07-05 15:18:58

Abstract: In recent years, the number of patients using continuous
glucose monitoring (CGM) has increased. In addition
to helping patients manage their disease, CGM produces time
series data that can be used for integration in control algorithms,
predictive models, and for retrospective analyses. Through feature
extraction, many digital biomarkers can be derived from
CGM. In this work, we provide a tool to extract features derived
from the frequency domain. We first introduce a novel open-source
Python library, CGM-Freq, for the analysis of CGM
data in the frequency domain. We then test the library on real
data. This work provides an open-source tool to further investigate the
frequency domain of CGM signals.

Main paper: 
 i. introduction: 
 Continuous glucose monitors (CGM) are commonly used wearable devices among patients with diabetes that collect continuous data on interstitial glucose levels [1] . Increasingly, there has been interest in analyzing retrospective CGM data to improve clinical outcomes through building predictive models and identifying associations between CGM features and clinical outcomes [2] - [4] . Much of this work has leveraged feature extraction from raw CGM data.While there have been many recent advances in computational tools for analyzing CGM data [5] , there has been limited work focusing specifically on frequency-domain analysis of CGM data. In this work, we present a new open-source tool in Python that can be used when analyzing CGM data in the frequency domain. We discuss the components of the library and test it on open-source data.Our primary contributions are:1) We provide an easy-to-use tool to visualize CGM signals in the frequency domain using advanced signal processing techniques. 2) We provide a library with functions for the generation of tabular digital biomarkers from the CGM data. The feature generation from time series data includes features derived from the frequency domain and features derived from the time domain. These features can be used when building predictive models or analyzing retrospective data.3) We test the library on publicly available CGM data.Through this analysis, we confirm the potential of features from the frequency domain to discriminate different disease states.Over the past decade, there have been many different computational tools developed for the analysis of CGM data [6] - [13] . These tools exist in multiple programming languages including R, Python, MATLAB, and through online graphical user interfaces (GUI), and they provide plots and feature derivation from raw CGM data. One of the limitations of the currently available tools is that they do not include a comprehensive frequency domain analysis.There has been recent interest in analyzing the frequency spectrum of CGM signals. Fourier analysis of CGM has been explored in recent literature, and the results of which have suggested that there may be insights to be gained from analyzing the frequency domain of CGM signals [14] - [17] . In Fico et al., the authors analyzed the CGM signals from individuals and showed that frequency-domain features were associated with the different diagnoses of T2D, T1D, and individuals at risk for T2D. Features from the frequency domain have also been incorporated in predictive models [18] , further supporting the rationale for developing more analysis tools.Further, in the broader landscape of physiological signal processing, there has been demonstrated interest in characterizing the frequency spectrum of biological signals, and computational resources exist for this purpose [19] , [20] . However, these tools are not specialized for CGM data.A. Overview CGM-Freq is a library for analyzing CGM features in the frequency domain. The toolbox takes in raw CGM input from a file with required headers for columns representing the time and the CGM values.The library has four primary modules: The CGM signal first must be preprocessed using a function called process cgm(). The output of this function is two arrays: an array of the CGM values and an array of the time values. A warning is also printed making note of how many CGM readings are estimated to be missing based on the sampling frequency. In the current version of our library, we do not impute missing data.The CGM data is filtered using a low-pass filter. The input to the function includes the time and CGM values and the cutoff frequency, which can be adjusted. In this function, a filtered CGM signal is returned and plots are produced for visualization. Fig. 2 shows the visualization that is produced by this function. The raw CGM data is plotted with the filtered data.Features are generated using two different functions. Table I shows the features generated and their definitions. The feature generation functions are split by frequency domain features and time domain features.The first function generates features from the frequency domain. These features are derived based on previous work [17] which extracts frequency-domain features from the signal using advanced signal processing techniques [21] , [22] . In this function, the Discrete Fourier Transform is computed using the fast Fourier transform (FFT) algorithm. Additionally, the power spectral density (PSD) is generated using the Welch method [23] . Here, the window type and the number of samples per segment are input variables that can be modified to change the frequency resolution of the PSD.The second function captures the time-domain features of the signal. We draw from metrics described in literature for CGM interpretation [24] . Since the purpose of this package is frequency analysis of CGM signals, we do not include a comprehensive list of time-domain features that have been previously reported. Both functions produce tabular data, enabling a quick transformation of the time series data for downstream tasks.The visualize() function takes in raw CGM data and returns a plot with three components. Fig. 3 shows the output of the function. The plots contain the FFT, the PSD, and the raw CGM data. The function also takes in the sampling frequency and optionally takes in additionally arguments for the PSD. The PSD is obtained using the welch() from SciPy [25] . While only 24 hours of data are shown, the function is capable of plotting longer time periods of time.This part of the toolbox produces both a visual output and numerical outputs of the spectrogram transformation from SciPy [25] . In Fig. 4 , the visual output of the spectrogram function is shown. The function also returns the raw output of the spectrogram transformation, for analysis of the power spectrum as a function of time at different frequencies. The visual output can be used to identify temporal trends in the frequency domain of the signal. The percent of readings in the range 70mg/dL to 180mg/dL in the segment TAR 1 (>180)The percent of readings above 180 mg/dL in the segment TAR 2 (>250)The percent of readings above 250 mg/dL in the segment TBR 1 (<70)The percent of readings below 70 mg/dL in the segment TBR 2 (<54)The percent of readings below 54 mg/dL in the segment StdThe standard deviation of glucose readings in the segment CVThe coefficient of variation of glucose readings in the segment The features and definitions for the frequency domain features are drawn from definitions in [17] and the features and definitions for the time domain features are drawn from [24] G. MethodsWe leverage several existing Python libraries including NumPy [26] , SciPy [25] , and Matplotlib [27] . Specifically, we leverage the find peaks() function from SciPy. The full list of dependencies for the library are listed in the Github repository. The publicly available data used in this work was made available under a Creative Commons Attribution License [28] .We used a public dataset from Hall et al. [28] that has CGM data from individuals with T2D, with pre-diabetes, and with no diabetes. We used CGM-Freq to extract features from daily CGM data for each individual in the dataset. When analyzing the data, we included only CGM data where there were greater than 280 readings in the day.To analyze the features, we plotted the mean and standard deviation of the features by diagnosis group. Fig. 5 shows a visual representation of the separation of means for each of the features by diagnosis group. Many of the time-domain features and frequency-domain features had different mean values for each diagnosis group. As expected, the mean average glucose was higher in individual with diabetes than patients without diabetes.In Table II , the mean and standard deviation of each feature is shown for each diagnosis group. The total number of individuals and CGM days is also shown in the table. A ttest was performed to assess significance in differences in the mean between the "No diabetes" group and the "prediabetes" group, and between the "No diabetes" group and the "diabetes" group. Many of the features had statistically significant different means. These results align with previous findings from Fico et al, [17] which found statistically significant differences in values of many frequency domain features, such as the maximum peak of the PSD, between groups of individuals with T2D and individuals at risk of diabetes.We further analyzed the CGM features across the individuals to understand the heterogeneity. We took the mean value of each CGM feature for each individual and plotted the absolute value of the correlation coefficients of the features. Fig. 6 shows how the CGM features are correlated with one another. Both the fft75 frequency and psd75 frequency have correlation coefficients less than .7 with all time-domain features, but statistical significance in distinguishing groups based on diagnosis. This suggests that the frequency domain features may provide unique insight into glycemic dynamics. The library was tested on a public dataset of patients with diabetes, pre-diabetes, and no diabetes. The results of the testing were presented in the paper, confirming the discriminative power of multiple frequency-domain features, which is consistent with previous literature [17] .The data this was tested on contained only a small number of individuals with limited heterogeneity in disease phenotype. We expect that the discriminative power of the features may be different in a larger cohort. Our library provides a tool to include frequency-domain features in future analyses of CGM data. Below we highlight some potential use cases of our library:1) Predictive models: Predictive models from time series data are often built using extracted features in tabular form. This library provides an easy-to-use feature extraction function to quickly transform raw CGM data into features that can be used to build predictive models. 2) Anomaly detection: By studying how frequency components change over time, it may be possible to identify anomalies in the data. 3) Unsupervised clustering: Digital biomarkers that char-acterize CGM signals in the frequency domain can be included in clustering approaches to identify novel phenotypes.CGM-Freq is a library for researchers to quickly transform CGM data into time and frequency domain features in Python. Our library serves as an additional computational resource that investigators can use when analyzing CGM data. The toolbox will continue to be updated and expanded to include more features as research in this space progresses. 
 
 Appendix:  



Reviews: review: title: title: CGM-Freq: A Python Library for Frequency Domain Analysis of Continuous Glucose Monitoring Data
paper_summary: paper_summary: The paper presents a tool for continuous glucose monitors (CGM). The authors use several features to differentiate between patients without diabetes, those with pre-diabetes, and those with diabetes. The authors perform a statistical analysis to confirm that are differences between the three groups of patients. A more robust analysis should be performed.
strength_weakness: strength_weakness: Scientific contribution is poor. A study of the metrics assessed and the changes with characteristics from the patients would increase the impact of the study.
Several sentences are vague, such as: "Many of the features had statistical significantly different means."
questions: questions: In section 3, the authors describe: "This module takes in the CGM signal and applies a low-pass filter based on a desired cutoff frequency." How this cut off can influence the results? This is a very subjective point in the analysis that can comprise the next steps of the processing.

The manuscript represents a description of a toolbox, but not a scientific contribution.

The Feature List presented in Table III was based on the literature? Please, provide more refs to support.
title: title: Review of CGM-Freq
paper_summary: paper_summary: The paper is about introducing a python package using frequency domain analysis of glucose monitoring data.
strength_weakness: strength_weakness: - Please put spaces between a word and parantheses for defininng an abbreviation such as defining T2D.
- Please put space after the dot of end of each sentence and the next sentence if they are in one paragraph such as in Section I: "... diabetes [5].Much ..."
- In Section III-C: please state the value 0.0005 properly, not .0005.
- Please use "Fig. X" to mention Figure X in the text as it is in the figure captions.
- In Table III: the authors should revise the  dominant frequency and psd_dominant frequency to match the writing style.
- In Fig. 4, if I am right, the x axis of the top figure is Time. Can you please write the x axis for the top figure? This enhances the readability of this figure.
- Please use a separate section for References.
questions: questions: In Fig. 2, how do the authors define the time axis? You mentioned the CGM device samples glucose every 5 min, but I can't catch that in this figure. Please make the time axis a bit clear or explain it in the caption. In Fig. 3 (bottom), you showed it better.
title: title: Applicable for analyzing continuous glucose data, but its validation and efficacy need further investigation.
paper_summary: paper_summary: The paper "CGM-Freq: A Python Library for Frequency Domain Analysis of Continuous Glucose Monitoring Data" introduces an open-source Python package designed for the frequency domain analysis of continuous glucose monitoring (CGM) data. This tool enables researchers to extract and analyze digital biomarkers from CGM data using advanced signal processing techniques, such as Fast Fourier Transform (FFT) and Power Spectral Density (PSD). The library was tested on a public dataset, demonstrating its capability to identify significant differences in frequency domain features among individuals with different glycemic statuses (no diabetes, pre-diabetes, and diabetes).
strength_weakness: strength_weakness: The current version requires users to manually validate data quality, which can be a cumbersome process.
questions: questions: -	Reference 21 should be modified to an identifiable work
-	Regarding the feature extraction for predictive models, how does the CGM-Freq library ensure the reliability and relevance of the features extracted from raw CGM data for use in predictive models?
-	How effective is the CGM-Freq library in identifying digital biomarkers for understanding disease heterogeneity, and what specific advantages does it offer over existing methods, considering the frequency domains analysis?