# RodentCGMTel (로덴트씨지엠텔)

> ⚠️ **의학적 디스클레이머**: 본 도구는 **연구·참고용**이며 **임상의사결정용이 아닙니다**. IACUC 승인 동물실험 데이터의 **사후 분석**에만 사용하십시오. 결과는 IRB/IACUC 의무를 대체하지 않습니다.

## 1. 목적
설치류(rodent) 연속 혈당 telemetry raw 데이터(Ponemah, Empatica, Medtronic Guardian rodent variant, Eversense rodent, Dexcom G6 rodent)를 **species/model-specific reference range**와 **animal-adapted metric**으로 자동 분석하는 standalone Streamlit 도구.

- **도메인**: DM (당뇨병, 전임상)
- **카테고리**: 동물실험 도구 — *in vivo continuous physiologic signal raw → 자동 분석*
- **빌드일**: 2026-05-11

## 2. 5개 핵심 기능
1. **Multi-format raw ingest + 표준 schema**
   Ponemah `.pnm/.txt`, Empatica `.csv`(2-row header), Medtronic Guardian rodent, Eversense rodent (mmol/L), Dexcom G6 rodent → 표준 schema `[timestamp, animal_id, model, bg_mgdl, group, source_format]`.
2. **Species/model-specific reference range library**
   C57BL/6J, db/db, ob/ob, STZ T1DM, NZO, KK-Ay, SD, Wistar, ZDF, GK, DIO HFD 11종. 각 모델 fasted/fed/random/TIR target/hypo/hyper 컷오프.
3. **Animal-adapted metrics**
   TIR/TAR/TBR (model 컷오프 기반), MAGE, CV%, MODD, dawn phenomenon (4-8AM Δ), nocturnal/diurnal split (12:12 light cycle), drug action window, GMI(참고용).
4. **Challenge mode (GTT/ITT/MTT)**
   IPGTT/OGTT (2g/kg, 6h fast), ITT (0.75U/kg), MTT — AUC(total), iAUC(incremental), peak BG, Tmax, Tlate, recovery slope, returned-to-baseline flag.
5. **Cohort heat map + 한국어 manuscript-ready export**
   동물 × 30분 bin BG heat map, 그룹 간 ANOVA + pairwise Welch t-test (Bonferroni), Diabetes/Cell Metabolism format Korean summary `.md` + metrics `.csv` 다운로드.

## 3. 기술 스택
- Python 3.9+ (개발: 3.9.6 확인)
- 필수: `numpy`, `pandas`, `scipy`, `streamlit`, `matplotlib`
- 선택: `plotly`, `statsmodels` (없으면 matplotlib + scipy ANOVA fallback로 자동 동작 — 본 환경에서는 fallback 사용)
- 모두 표준 wheel. 외부 네트워크/API 호출 없음.

## 4. 디렉토리 구조
```
2026-05-11-1-rodent-cgm-tel/
├── README.md
├── QA.md
├── main.py                       # Streamlit + CLI 진입점
├── analysis.py                   # 핵심 metric/ingest/challenge (Streamlit 독립)
├── species_reference.py          # 모델별 reference range 라이브러리
└── data/
    ├── synthetic_generator.py
    └── synthetic/
        ├── cohort_control.csv
        ├── cohort_T2DM_db.csv
        ├── cohort_T2DM_ob.csv
        ├── cohort_T1DM_stz.csv
        ├── cohort_DIO_HFD.csv
        └── cohort_T2DM_zdf.csv
```

## 5. 실행법
```bash
# (1) 합성 데이터 생성 (재현 가능, seed=42)
cd "/Users/sangjoonpark/claude daily project/2026 metabolic daily idea/projects/2026-05-11-1-rodent-cgm-tel"
python3 data/synthetic_generator.py

# (2) CLI demo (서버 preview/캡처용 stdout)
python3 main.py --demo

# (3) 등록된 모델 목록
python3 main.py --list-models

# (4) Streamlit 웹 UI
streamlit run main.py
```

## 6. 검수 체크리스트
- [x] `python3 -c "import ast; ast.parse(open('main.py').read())"` 통과
- [x] `python3 -c "import ast; ast.parse(open('analysis.py').read())"` 통과
- [x] `python3 -c "import ast; ast.parse(open('species_reference.py').read())"` 통과
- [x] `python3 -c "import ast; ast.parse(open('data/synthetic_generator.py').read())"` 통과
- [x] `data/synthetic/*.csv` 6개 head 로드 가능
- [x] `python3 main.py --demo` stdout 한국어 요약 정상 출력
- [x] 외부 네트워크 호출 없음 / 전역 패키지 설치 없음
- [x] 의학적 디스클레이머 README 최상단 포함

자세한 내용은 `QA.md`.

## 7. 출처 / 참고
- Andrikopoulos S et al., *Am J Physiol Endocrinol Metab* 2008 (mouse GTT 권고)
- Berglund ED et al., *Diabetes* 2008 (C57BL/6 baseline)
- Leiter EH, *Diabetes* 1981 (db/db, ob/ob)
- Furman BL, *Curr Protoc Pharmacol* 2015 (STZ T1DM 모델)
- Bergenstal RM et al., *Diabetes Care* 2018 (GMI; 인간 데이터, 동물에서는 참고치)
- Service FJ et al., *Diabetes* 1970 (MAGE 원전)
- Speakman JR, *Cell Metab* 2019 (DIO HFD)
- DSI Ponemah Software v6 manual / Dexcom G6 / Eversense rodent application notes (참고)

## 8. 라이선스/사용 범위
- 본 도구는 합성 데이터로 검증되었으며, 실 telemetry 적용 시 사용자 책임으로 검증 필요.
- 임상의사결정/처방/약물 dosing 결정에 사용 금지.
- IACUC 승인된 동물실험 사후 분석 한정.
