Saturday, July 5, 2025

How do you visualize glucose data from a glucose CGM report using Python?

Interpretation of data from the python code from my previous post must be exercised with caution. The program explicitly puts red dots over the curve to establish verification that the method indeed achieves its objective. We have seen that the image generated does show large red circles riding the graph. 

It is easy to show by reducing the size to 0, that the curve is traced by very tiny circles shown by an underlying red ness in the trace (zoom to see). These are shown for two the two radii assumed in the next figure.

 


However, a .CSV file is generated by the code. The graphing of this file in Microsoft Excel does not show any difference between the two cases, radius=2 and radius =0 as shown.

  


The reason is these curves (one by visualization and the other set by generated CSV file) are not using the same base.

1. The cv2.circle() visualization: This is what creates the glucose_trace_detected.jpg. 

2. The matplotlib.pyplot.plot() or scatter() visualization: This is what creates the glucose_value_mg_dL plo.

However, in the plotted graphs from CSV files we find gaps in the generated graph. They can indeed correspond to event marker positions. The red dot in the visualization is only for verifying that the entire graph is captured.

We will take a look at this possibility of getting the psotional data of events in the next post, as it gives us valuable information on event times. 


No comments: