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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sample Diabetes Data - Test Your App! ๐
|
| 2 |
+
|
| 3 |
+
## ๐ File: `sample_diabetes_data.csv`
|
| 4 |
+
|
| 5 |
+
This is **realistic synthetic CGM data** for a full day (24 hours) with interesting events!
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## ๐ฏ What's in the Data
|
| 10 |
+
|
| 11 |
+
### Timeline: January 15, 2025 (6:00 AM - 11:55 PM)
|
| 12 |
+
**200 data points** @ 5-minute intervals
|
| 13 |
+
|
| 14 |
+
### Key Events to Watch For:
|
| 15 |
+
|
| 16 |
+
#### 1. **Morning Hypo Risk** (6:00 AM - 7:20 AM)
|
| 17 |
+
- Glucose drops from 95 โ 80 mg/dL
|
| 18 |
+
- **Alert should trigger** around 7:15 AM
|
| 19 |
+
- **Breakfast bolus**: 45g carbs + 4.5u insulin at 7:20 AM
|
| 20 |
+
- Recovery to 128 mg/dL
|
| 21 |
+
|
| 22 |
+
#### 2. **Post-Breakfast Spike** (7:20 AM - 8:30 AM)
|
| 23 |
+
- Glucose rises to 128 mg/dL
|
| 24 |
+
- Gradual descent back to normal range
|
| 25 |
+
|
| 26 |
+
#### 3. **Morning Exercise** (10:30 AM - 12:00 PM)
|
| 27 |
+
- Heart rate increases (65 โ 130 BPM)
|
| 28 |
+
- Steps accumulate rapidly
|
| 29 |
+
- Glucose stays stable due to activity
|
| 30 |
+
|
| 31 |
+
#### 4. **Lunch Spike** (12:00 PM - 1:15 PM)
|
| 32 |
+
- **Large meal**: 60g carbs + 6u insulin
|
| 33 |
+
- Glucose spikes to **176 mg/dL** (near hyper threshold)
|
| 34 |
+
- **Alert should trigger** around 1:00 PM
|
| 35 |
+
- Gradual descent over 3 hours
|
| 36 |
+
|
| 37 |
+
#### 5. **Late Afternoon Stability** (3:00 PM - 6:00 PM)
|
| 38 |
+
- Glucose stable in target range (100-110 mg/dL)
|
| 39 |
+
- Minimal significance scores expected
|
| 40 |
+
|
| 41 |
+
#### 6. **Dinner** (6:00 PM - 7:00 PM)
|
| 42 |
+
- 55g carbs + 5.5u insulin
|
| 43 |
+
- Moderate spike to 159 mg/dL
|
| 44 |
+
- Controlled descent
|
| 45 |
+
|
| 46 |
+
#### 7. **SEVERE HYPO EVENT** โ ๏ธ (10:00 PM)
|
| 47 |
+
- **CRITICAL**: Glucose drops to **15 mg/dL**!
|
| 48 |
+
- Overcorrection with 3u insulin (mistake scenario)
|
| 49 |
+
- **Multiple alerts expected**
|
| 50 |
+
- Emergency 15g carbs consumed
|
| 51 |
+
- Recovery to safe levels
|
| 52 |
+
|
| 53 |
+
#### 8. **Overnight Stability** (11:00 PM onwards)
|
| 54 |
+
- Glucose settles around 100 mg/dL
|
| 55 |
+
- Normal sleep HR (52-60 BPM)
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## ๐งช Expected Results
|
| 60 |
+
|
| 61 |
+
### Activation Patterns:
|
| 62 |
+
- **High activation**: During hypo (7:15 AM, 10:00 PM), hyper (1:00 PM)
|
| 63 |
+
- **Low activation**: Stable periods (3-6 PM, after 11 PM)
|
| 64 |
+
- **Target activation rate**: ~15-20% overall
|
| 65 |
+
|
| 66 |
+
### Alerts Expected:
|
| 67 |
+
Approximately **3-5 high-risk alerts**:
|
| 68 |
+
1. Morning hypo warning (~7:15 AM)
|
| 69 |
+
2. Lunch hyper warning (~1:00-1:15 PM)
|
| 70 |
+
3. **CRITICAL hypo** (~10:00-10:20 PM) - multiple alerts
|
| 71 |
+
|
| 72 |
+
### Energy Savings:
|
| 73 |
+
- **~80-85%** energy saved vs always-on
|
| 74 |
+
- Most savings during stable periods
|
| 75 |
+
- More activations during risk events
|
| 76 |
+
|
| 77 |
+
### Significance Components:
|
| 78 |
+
Watch how they change:
|
| 79 |
+
- **Glycemic deviation**: High during hypo/hyper
|
| 80 |
+
- **Velocity risk**: Spikes during rapid changes
|
| 81 |
+
- **IOB risk**: High after insulin doses
|
| 82 |
+
- **COB risk**: High after meals
|
| 83 |
+
- **Activity risk**: Elevated during exercise
|
| 84 |
+
- **Variability**: Shows instability during events
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## ๐ฎ How to Test
|
| 89 |
+
|
| 90 |
+
### Option 1: Local App
|
| 91 |
+
```bash
|
| 92 |
+
cd "C:\Users\adminidiakhoa\sundew_algorithms\HULL_use\diabetes\sundew_diabetes_watch"
|
| 93 |
+
streamlit run app_advanced.py
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
1. **Uncheck** "Use synthetic example"
|
| 97 |
+
2. Click "Browse files"
|
| 98 |
+
3. Upload `sample_diabetes_data.csv`
|
| 99 |
+
4. Watch the magic! โจ
|
| 100 |
+
|
| 101 |
+
### Option 2: Hugging Face Space
|
| 102 |
+
1. Visit: https://huggingface.co/spaces/mgbam/sundew_diabetes_watch
|
| 103 |
+
2. Upload `sample_diabetes_data.csv`
|
| 104 |
+
3. Explore the visualizations
|
| 105 |
+
|
| 106 |
+
---
|
| 107 |
+
|
| 108 |
+
## ๐ What to Look For
|
| 109 |
+
|
| 110 |
+
### 1. Performance Dashboard
|
| 111 |
+
- Total events: **200**
|
| 112 |
+
- Activations: **30-40** (15-20%)
|
| 113 |
+
- Energy savings: **80-85%**
|
| 114 |
+
- Alerts: **3-5**
|
| 115 |
+
|
| 116 |
+
### 2. Glucose Chart
|
| 117 |
+
- See the full day pattern
|
| 118 |
+
- Identify meal spikes
|
| 119 |
+
- Spot hypo events
|
| 120 |
+
|
| 121 |
+
### 3. Significance vs Threshold
|
| 122 |
+
- **Watch the PI controller adapt!**
|
| 123 |
+
- Threshold moves to maintain 15% activation
|
| 124 |
+
- Significance spikes during risk events
|
| 125 |
+
|
| 126 |
+
### 4. Energy Level
|
| 127 |
+
- **Bio-inspired regeneration** visible
|
| 128 |
+
- Drops during activations
|
| 129 |
+
- Regenerates during idle periods
|
| 130 |
+
- Should fluctuate, not flat
|
| 131 |
+
|
| 132 |
+
### 5. Significance Components
|
| 133 |
+
- **6 colored lines** showing risk factors
|
| 134 |
+
- Glycemic deviation dominates during extremes
|
| 135 |
+
- Velocity spikes during rapid changes
|
| 136 |
+
- IOB/COB after meals
|
| 137 |
+
|
| 138 |
+
### 6. Alerts Table
|
| 139 |
+
Look for warnings around:
|
| 140 |
+
- 7:15 AM (morning hypo approach)
|
| 141 |
+
- 1:00 PM (post-lunch hyper)
|
| 142 |
+
- 10:05-10:20 PM (critical hypo)
|
| 143 |
+
|
| 144 |
+
### 7. Bootstrap Confidence Intervals
|
| 145 |
+
- F1 Score with 95% CI
|
| 146 |
+
- Precision with 95% CI
|
| 147 |
+
- Recall with 95% CI
|
| 148 |
+
- Check that CI ranges are reasonable
|
| 149 |
+
|
| 150 |
+
---
|
| 151 |
+
|
| 152 |
+
## ๐ Advanced Analysis
|
| 153 |
+
|
| 154 |
+
### Export Telemetry
|
| 155 |
+
1. Check "Export Telemetry JSON"
|
| 156 |
+
2. Download `sundew_diabetes_telemetry.json`
|
| 157 |
+
3. Contains all 200 events with full details
|
| 158 |
+
4. Use for:
|
| 159 |
+
- Hardware power measurement correlation
|
| 160 |
+
- Detailed analysis in Excel/Python
|
| 161 |
+
- Custom visualizations
|
| 162 |
+
- Research papers
|
| 163 |
+
|
| 164 |
+
### Compare Presets
|
| 165 |
+
Try different Sundew configurations:
|
| 166 |
+
|
| 167 |
+
**`custom_health_hd82`** (Recommended for diabetes)
|
| 168 |
+
- 82% energy savings target
|
| 169 |
+
- Healthcare-optimized
|
| 170 |
+
- Expect: High recall, lower precision
|
| 171 |
+
|
| 172 |
+
**`tuned_v2`** (Balanced)
|
| 173 |
+
- General purpose
|
| 174 |
+
- Good balance
|
| 175 |
+
- Expect: Medium recall/precision
|
| 176 |
+
|
| 177 |
+
**`conservative`** (Maximum savings)
|
| 178 |
+
- Minimal activations
|
| 179 |
+
- Expect: Lower recall, higher savings
|
| 180 |
+
|
| 181 |
+
**`aggressive`** (Maximum safety)
|
| 182 |
+
- More activations
|
| 183 |
+
- Expect: Higher recall, lower savings
|
| 184 |
+
|
| 185 |
+
---
|
| 186 |
+
|
| 187 |
+
## ๐ Data Format
|
| 188 |
+
|
| 189 |
+
**Columns:**
|
| 190 |
+
- `timestamp`: DateTime in ISO format
|
| 191 |
+
- `glucose_mgdl`: Blood glucose in mg/dL (40-400 range)
|
| 192 |
+
- `carbs_g`: Carbohydrate intake in grams (0-60)
|
| 193 |
+
- `insulin_units`: Insulin dosage in units (0-6)
|
| 194 |
+
- `steps`: Cumulative step count (0-1065)
|
| 195 |
+
- `hr`: Heart rate in BPM (48-130)
|
| 196 |
+
|
| 197 |
+
**Frequency**: 5-minute intervals (standard CGM)
|
| 198 |
+
|
| 199 |
+
**Duration**: 18 hours (6 AM - 12 AM)
|
| 200 |
+
|
| 201 |
+
---
|
| 202 |
+
|
| 203 |
+
## ๐ฏ Challenge Yourself
|
| 204 |
+
|
| 205 |
+
### Can You Spot:
|
| 206 |
+
1. The exact time glucose crosses below 70 mg/dL?
|
| 207 |
+
2. How long it takes to recover from the severe hypo?
|
| 208 |
+
3. Which meal caused the highest glucose spike?
|
| 209 |
+
4. When the PI controller adjusts threshold most dramatically?
|
| 210 |
+
5. The period with lowest energy consumption?
|
| 211 |
+
|
| 212 |
+
### Experiment With:
|
| 213 |
+
- Different target activation rates (5%, 15%, 30%)
|
| 214 |
+
- Different energy pressure values
|
| 215 |
+
- Different hypo/hyper thresholds
|
| 216 |
+
- Different Sundew presets
|
| 217 |
+
|
| 218 |
+
---
|
| 219 |
+
|
| 220 |
+
## ๐ Pro Tips
|
| 221 |
+
|
| 222 |
+
1. **Enable all visualizations** for full effect
|
| 223 |
+
2. **Watch the threshold adapt** in real-time (Significance vs Threshold chart)
|
| 224 |
+
3. **Check the 10 PM hypo** - algorithm should light up!
|
| 225 |
+
4. **Export telemetry** to see component breakdown
|
| 226 |
+
5. **Try bootstrap CI** for statistical rigor
|
| 227 |
+
|
| 228 |
+
---
|
| 229 |
+
|
| 230 |
+
## ๐ Learning Outcomes
|
| 231 |
+
|
| 232 |
+
After testing with this data, you'll understand:
|
| 233 |
+
|
| 234 |
+
โ
How Sundew adapts threshold to maintain target activation
|
| 235 |
+
โ
How 6-factor significance scoring works
|
| 236 |
+
โ
How energy regeneration creates sustainable monitoring
|
| 237 |
+
โ
How bootstrap CI provides statistical confidence
|
| 238 |
+
โ
How ensemble models improve predictions
|
| 239 |
+
โ
How alerts trigger during real risk events
|
| 240 |
+
|
| 241 |
+
---
|
| 242 |
+
|
| 243 |
+
## ๐ Next Steps
|
| 244 |
+
|
| 245 |
+
1. **Test with this data** to verify app works
|
| 246 |
+
2. **Create your own data** with different patterns
|
| 247 |
+
3. **Compare results** across different presets
|
| 248 |
+
4. **Export telemetry** for deeper analysis
|
| 249 |
+
5. **Share results** with your network!
|
| 250 |
+
|
| 251 |
+
---
|
| 252 |
+
|
| 253 |
+
**This data showcases the algorithm at its finest!** ๐ฟโจ
|
| 254 |
+
|
| 255 |
+
The severe hypo at 10 PM will really make Sundew **SHINE**!
|