iwatch health data analysis

Apple Health 数据全景分析。从 export.zip 流式解析 XML(支持 1-2GB 大文件),提取 RHR/HRV/VO₂Max/睡眠/步数/血氧等核心指标,基于用户个人信息(年龄/性别/身高/体重/病史)动态校准参考范围,生成个性化交互式 HTML 报告(含 6 张 Chart.js 图表)。...

MIT-0 · Free to use, modify, and redistribute. No attribution required.
0 · 11 · 0 current installs · 0 all-time installs
MIT-0
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description match the provided code and instructions: parse Apple Health export.zip, extract RHR/HRV/VO₂Max/steps/sleep/spO2, aggregate monthly data and render an HTML report. No unrelated env vars, binaries, or installs are requested.
Instruction Scope
SKILL.md instructs the agent to ask for a user profile and to have the user provide export.zip; scripts parse the ZIP and generate chart_data.json and an HTML report. All operations are file I/O and in-process parsing. Note: the skill requires users to upload highly sensitive health data (export.zip) — that is expected for this purpose but is a privacy risk that the user must accept.
Install Mechanism
No install spec; code uses only Python standard library modules (zipfile, re, json, statistics, pathlib). No downloads or external packages are required.
Credentials
No credentials, env vars, or config paths are requested. The data the skill needs (export.zip and user profile) are directly relevant to the stated purpose.
Persistence & Privilege
The skill is not always-enabled and allows model invocation. It performs local file writes (e.g., /tmp/chart_data.json and the HTML output) which is expected for report generation; it does not modify other skills or request persistent elevated privileges.
Assessment
This skill appears to do exactly what it says: locally parse an Apple Health export and produce a personalized HTML report. Before using it: 1) Only run it if you trust the skill/source — the repository/source is unknown. 2) Be aware export.zip contains very sensitive personal health data; prefer running the included scripts locally (not sending the ZIP to a remote service). 3) Check where files are written (e.g., /tmp/chart_data.json, health_report.html) and securely delete the export.zip and any outputs when finished if you don't want them retained. 4) If you require stronger guarantees that data never leaves your machine or platform logs, review the hosting platform's privacy/log retention policies or run the scripts on a local isolated environment. 5) If you want additional assurance, inspect the included scripts yourself (they are short, standard Python) to confirm there are no network calls or hidden uploads before executing.

Like a lobster shell, security has layers — review code before you run it.

Current versionv1.0.0
Download zip
health carevk976byzy830s4w0px9z2hhpmrs83zqnmlatestvk976byzy830s4w0px9z2hhpmrs83zqnmpersonalizedvk976byzy830s4w0px9z2hhpmrs83zqnmstablevk976byzy830s4w0px9z2hhpmrs83zqnm

License

MIT-0
Free to use, modify, and redistribute. No attribution required.

SKILL.md

apple-health-analysis v2.0

目录结构

scripts/
  parse_health.py      # 流式解析 export.zip → chart_data.json
  generate_report.py   # chart_data.json + 用户画像 → 个性化 HTML 报告

用户数据导出指南

步骤(iOS):

  1. 打开「健康」App → 右上角头像
  2. 向下滚动 → 「导出所有健康数据」
  3. 等待打包(约 1-5 分钟)→ 保存或分享 export.zip
  4. 将 zip 文件发给 AI

数据规模参考:

  • 使用 1 年:~200MB-500MB
  • 使用 2-3 年:~1-2GB
  • 解析时间:约 30-60 秒(流式,无需解压)

核心依赖

标准库(zipfile, re, json, statistics),无需额外安装。


工作流(v2.0 标准流程)

Step 0:收集用户画像

收到 export.zip 后,必须先向用户询问以下信息,再进行分析:

为了给你提供个性化的健康基准,我需要了解几个基本信息:

1. 性别(影响 RHR/HRV/VO₂Max/体脂参考范围)
2. 年龄或出生年份(参考范围随年龄变化显著)
3. 身高(计算 BMI,校准体重意义)
4. 体重单位(Apple Health 体重默认为 lb,需确认)
5. 有无已知慢性病/服药史(如甲亢、高血压、心律失常等)
6. 运动习惯(日常久坐/轻度活动/规律运动/专业训练)

以上信息不会离开对话,分析完成后不会保存。

将收到的信息存入 user_profile 字典,传给解析和报告脚本。

Step 1:解析数据

python3 scripts/parse_health.py /path/to/export.zip /tmp/chart_data.json

Step 2:加载用户画像,动态确定参考范围

根据 Step 0 收集的信息,调用 scripts/generate_report.py 中的 build_reference() 函数:

profile = {
    "gender": "female",      # male / female / other
    "age": 26,               # 岁
    "height_cm": 170,        # 厘米
    "weight_unit": "lb",     # lb / kg
    "conditions": ["hyperthyroidism"],  # 已知病史,影响异常标注
    "activity_level": "active"  # sedentary / light / active / athlete
}

Step 3:执行分析(AI 执行,基于动态参考范围)

心血管系统

  • RHR:与同龄同性别参考范围对比(见下方参考表)
  • HRV SDNN:个体化趋势分析优先于绝对值
  • VO₂Max:对应年龄/性别分级(差/一般/良好/优秀/精英)

神经系统(自主神经)

  • HRV < ref.hrv_low → 交感亢奋
  • HRV > ref.hrv_high → 副交感主导(迷走张力高者不追求过高)

睡眠

  • Deep Sleep 占比 < 10% 关注;REM 占比 < 15% 关注
  • Awake 次数与 RHR 同向波动 → 睡眠质量与自主神经相互印证

代谢

  • BMI = 体重kg ÷ 身高m²(体重单位自动换算)
  • 体脂参考范围按性别/年龄分级
  • 步数目标:久坐人群 6000+,一般成人 8000+,健康目标 10000+

异常检测

  • 连续 3+ 个月 RHR 上升 + HRV 下降 → 系统性应激(疾病/压力),建议就医
  • 血氧月均 < 95% → 建议筛查
  • 步数骤降持续 2+ 个月 → 生活方式变化

Step 4:生成报告

python3 scripts/generate_report.py \
  /tmp/chart_data.json \
  health_report.html \
  --gender female \
  --age 26 \
  --height 170 \
  --weight-unit lb \
  --conditions "hyperthyroidism" \
  --activity active \
  --verdict "整体判断:亚健康恢复期..."

动态参考范围表

静息心率 RHR(bpm)

性别年龄优秀良好正常偏高过高
18-25<5454-6061-7374-82>82
26-35<5555-6162-7475-83>83
36-45<5656-6263-7576-84>84
18-25<4949-5556-6869-77>77
26-35<5050-5657-6970-78>78
36-45<5151-5758-7071-79>79

VO₂Max 分级(mL/kg/min)

性别年龄一般良好优秀精英
20-29<2929-3435-4344-48>48
30-39<2828-3334-4142-46>46
20-29<3838-4344-5152-56>56
30-39<3535-4142-4950-53>53

HRV SDNN 参考(ms,Apple Watch 连续监测)

年龄低(需关注)正常良好
20-30<2525-50>50
30-40<2020-45>45
40-50<1515-40>40

体脂率参考

性别18-30岁31-40岁
21-32%23-34%
8-20%11-22%

病史对分析的影响

病史影响的指标分析调整
甲亢/甲减RHR、HRV、VO₂Max、体重RHR偏高/偏低时先排除甲状腺因素;标注治疗前后对比
高血压RHR、血氧加入血压数据(如有)分析;RHR目标更严格(<70)
心律失常(早搏)RHR、HRVHRV数据可能失真;日常心率偏高有代偿机制解释
血管迷走性晕厥HRV不追求HRV越高越好;避免过高迷走张力风险
低血压RHR心率轻度代偿(75-85bpm)属正常,不作为异常标注
贫血RHR、VO₂Max、活动卡路里RHR偏高/VO₂Max偏低时排除贫血因素
糖尿病步数、卡路里步数目标提升至10000+;关注活动消耗稳定性

数据质量说明

  • 体重单位:Apple Health 体重默认 lb(磅),换算:kg = lb × 0.4536必须向用户确认单位
  • HRV 数据源:旧设备 HRV 条目极少(每月1-2条)且量级差异大,不可与新设备数据混合对比;自动检测 sourceName 字段分段处理
  • 睡眠格式:旧格式只有 InBed/Asleep,无分期;Series 6+ 才有 Deep/REM/Core;报告分段显示
  • 血氧:Apple Watch Series 6(2020年)起才有,早期数据缺失属正常
  • 步数多设备重复:已用日汇总方式处理
  • 隐私提示:数据含完整健康信息,分析完成后建议删除 export.zip

常见 Q&A

Q: 没有 HRV 数据? A: 需要 Apple Watch 且设置中开启「心率通知」。无 HRV 时跳过自主神经分析,其余正常生成。

Q: 为什么 HRV 早期数值异常高(80-160ms)? A: 旧 Apple Watch 测量 HRV 频率极低(每月1-2次),且算法不同,不可与新版连续监测数据对比。脚本会自动识别设备名称分段处理。

Q: XML 太大内存不足? A: parse_health.py 流式解析,512KB 分块,1GB+ 文件正常。

Q: 分析多少时间跨度合适? A: 理论无限。月度聚合后每年12个数据点,图表不会过密。建议至少6个月才能做趋势分析。

Files

3 total
Select a file
Select a file to preview.

Comments

Loading comments…