vitawasalreadytaken / glucoscape

Glucoscape is a small application that helps visualize Continuous Glucose Monitoring (CGM) data quickly and intuitively. It provides a heatmap representation of time spent below range, in range, and above range, allowing for easy identification of glucose patterns.
https://vitawasalreadytaken.github.io/glucoscape/
MIT License
10 stars 1 forks source link

mmol display fixes #3

Closed RansomTime closed 10 months ago

RansomTime commented 11 months ago

Some fixes for mmol/l display

Both of these can be tested with my nightscout instance. Running on nightscout.ransomti.me with token reporter-eedc563cda3d55b7

vitawasalreadytaken commented 11 months ago

Hi, thank you for giving Glucoscape a shot! It's so nice to hear from someone who also uses mmol/l 😄

May I ask what version of Nightscout you're running? I'm on 14.2.6, am also using mmol/l units, and my Nightscout returns the target range in mmol/l 🤔 I did think that that was strange because the actual CGM values are always in mg/dl...

Just to be sure, I've now checked whether I set my target range correctly in NS. The Profile Editor screenshot I'm attaching is a bit ambiguous: it says Target BG range [mg/dL,mmol/L]. But I actually set my target range with environment variables BG_TARGET_BOTTOM and BG_TARGET_TOP, and those are supposed to be in the same units as the chosen display unit: https://nightscout.github.io/nightscout/setup_variables/#alarms

So I set them in mmol/l. Is it possible that you set your target range in NS in mg/dl? Or perhaps there's some difference between NS versions...

RansomTime commented 10 months ago

Wow that's super weird.

My first debug step was updating from 14.2.something to 15.0.2 (I'm using docker for nightscout so just refreshed the image) but in both circumstances it returned mgdl

image

Removing these and only having one range for a day is also gives mg/dl image

I also commented out the below from my docker config (they were in mmol) to see if that helped, didn't change anything though.

      # BG_LOW: 3.8
      # ALARM_LOW: off
      # BG_HIGH: 15.0
      # BG_TARGET_TOP: 10.0
      # BG_TARGET_BOTTOM: 3.8

Not sure if this is a bug in NS, and the best way of fixing this for glucoscape (heuristically determining the units of the target range?)

RansomTime commented 10 months ago

It's 100% getting those values from the environment variables, as commenting those out/changing them changes the display on glucoscape.

Above commit looks to see if bgTargetTop is greater than 30, if it is then it's an mg/dl value (for comparason, the maximum values of CGMs are in the low 20s, so it's extremely unlikely that 30 is anything but an mg/dl value.

Does that work on your NS?

vitawasalreadytaken commented 10 months ago

Thank you for this fix. If you don't mind, I've implemented it slightly differently: the target range is always kept in mg/dl (however much I despise that unit) and only converted to mmol/l when displayed. I prefer it this way because all CGM values are also kept in mg/dl so it's all consistent.

Hope this works for you. I've tested it with my NS and also with the instance whose details you've provided (very helpful, thanks for that!) https://github.com/vitawasalreadytaken/glucoscape/pull/6