sleep-analyzer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese睡眠分析器技能
Sleep Analyzer Skill
分析睡眠数据,识别睡眠模式,评估睡眠质量,并提供个性化睡眠改善建议。
Analyze sleep data, identify sleep patterns, evaluate sleep quality, and provide personalized sleep improvement recommendations.
功能
Features
1. 睡眠趋势分析
1. Sleep Trend Analysis
分析睡眠时长、质量、效率的变化趋势,识别改善或需要关注的方面。
分析维度:
- 睡眠时长趋势(平均睡眠时长变化)
- 睡眠效率趋势(睡眠效率百分比变化)
- 入睡时间模式(上床时间、入睡时间、起床时间)
- 作息规律性评分(sleep consistency score)
- 周末vs工作日对比(social jetlag)
输出:
- 趋势方向(改善/稳定/下降)
- 变化幅度和百分比
- 趋势显著性评估
- 最佳睡眠时间窗口识别
- 改进建议
Analyze the changing trends of sleep duration, quality, and efficiency, and identify areas for improvement or attention.
Analysis Dimensions:
- Sleep Duration Trend (changes in average sleep duration)
- Sleep Efficiency Trend (changes in sleep efficiency percentage)
- Sleep Onset Pattern (bedtime, sleep onset time, wake-up time)
- Sleep Consistency Score
- Weekend vs. Workday Comparison (social jetlag)
Output:
- Trend Direction (improving/stable/declining)
- Magnitude and percentage of change
- Trend Significance Assessment
- Optimal Sleep Time Window Identification
- Improvement Recommendations
2. 睡眠质量评估
2. Sleep Quality Evaluation
综合评估睡眠质量,识别影响睡眠质量的关键因素。
评估内容:
- PSQI分数追踪和趋势
- 主观睡眠质量分布(好/中/差)
- 夜间觉醒分析(次数、时长、原因)
- 睡眠阶段分析(深睡、浅睡、REM比例)
- 睡后恢复感评估
输出:
- 睡眠质量等级(优秀/良好/一般/较差)
- 质量变化趋势
- 主要影响因素识别
- 质量改善优先级建议
Comprehensively evaluate sleep quality and identify key factors affecting sleep quality.
Evaluation Content:
- PSQI Score Tracking and Trend
- Subjective Sleep Quality Distribution (good/fair/poor)
- Nighttime Awakening Analysis (frequency, duration, causes)
- Sleep Stage Analysis (proportion of deep sleep, light sleep, REM)
- Post-sleep Rested Feeling Assessment
Output:
- Sleep Quality Level (excellent/good/fair/poor)
- Quality Change Trend
- Identification of Main Influencing Factors
- Priority Recommendations for Quality Improvement
3. 睡眠问题识别
3. Sleep Problem Identification
识别常见的睡眠问题和风险因素。
识别内容:
-
失眠模式:
- 入睡困难(sleep latency >30分钟)
- 睡眠维持困难(夜间觉醒>2次或总觉醒时间>30分钟)
- 早醒(比预期提前醒来>30分钟)
- 混合型失眠
-
呼吸暂停风险:
- STOP-BANG问卷评分
- 症状分析(打鼾、憋醒、白天嗜睡)
- 风险等级(低/中/高)
-
其他问题:
- 作息不规律检测
- 睡眠债计算(理想时长vs实际时长)
- 社交时差评估
输出:
- 问题存在与否
- 问题类型和严重程度
- 风险因素列表
- 是否需要就医建议
Identify common sleep problems and risk factors.
Identification Content:
-
Insomnia Patterns:
- Difficulty Falling Asleep (sleep latency >30 minutes)
- Difficulty Maintaining Sleep (nighttime awakenings >2 times or total awakening time >30 minutes)
- Early Awakening (waking up >30 minutes earlier than expected)
- Mixed Insomnia
-
Sleep Apnea Risk:
- STOP-BANG Questionnaire Score
- Symptom Analysis (snoring, awakening from breath holding, daytime sleepiness)
- Risk Level (low/medium/high)
-
Other Problems:
- Irregular Sleep Schedule Detection
- Sleep Debt Calculation (ideal duration vs. actual duration)
- Social Jetlag Assessment
Output:
- Presence of Problems
- Problem Type and Severity
- List of Risk Factors
- Recommendations for Medical Consultation (if needed)
4. 相关性分析
4. Correlation Analysis
分析睡眠与其他健康指标的相关性。
支持的相关性分析:
-
睡眠 ↔ 运动:
- 运动日vs休息日的睡眠差异
- 运动时间对睡眠的影响(早晨/下午/晚间运动)
- 运动强度与睡眠质量的相关性
-
睡眠 ↔ 饮食:
- 咖啡因摄入与睡眠时长、入睡时间的关系
- 酒精摄入对睡眠结构的影响
- 晚餐时间与睡眠质量的关系
-
睡眠 ↔ 情绪:
- 睡眠与情绪的双向关系分析
- 压力水平对睡眠质量的影响
- 睡眠剥夺对日间情绪的影响
-
睡眠 ↔ 慢性病:
- 睡眠与高血压的关系
- 睡眠与血糖控制的关联
- 睡眠与体重变化的关系
输出:
- 相关系数(-1到1)
- 相关性强度(弱/中/强)
- 统计显著性
- 因果关系推断
- 实践建议
Analyze the correlation between sleep and other health indicators.
Supported Correlation Analysis:
-
Sleep ↔ Exercise:
- Sleep differences between exercise days and rest days
- Impact of exercise timing on sleep (morning/afternoon/evening exercise)
- Correlation between exercise intensity and sleep quality
-
Sleep ↔ Diet:
- Relationship between caffeine intake and sleep duration, sleep onset time
- Impact of alcohol intake on sleep structure
- Relationship between dinner time and sleep quality
-
Sleep ↔ Mood:
- Analysis of bidirectional relationship between sleep and mood
- Impact of stress level on sleep quality
- Impact of sleep deprivation on daytime mood
-
Sleep ↔ Chronic Diseases:
- Relationship between sleep and hypertension
- Correlation between sleep and blood glucose control
- Relationship between sleep and weight changes
Output:
- Correlation Coefficient (-1 to 1)
- Correlation Strength (weak/medium/strong)
- Statistical Significance
- Causal Inference
- Practical Recommendations
5. 个性化建议生成
5. Personalized Recommendation Generation
基于用户数据生成个性化睡眠改善建议。
建议类型:
-
作息调整建议:
- 最佳上床/起床时间
- 作息一致性改善方案
- 午睡管理建议
-
睡前准备建议:
- 睡前例行程序设计
- 放松技巧推荐
- 屏幕时间管理
-
睡眠环境优化:
- 温度、湿度、光线、噪音优化
- 床品舒适度建议
-
生活方式调整:
- 运动、饮食、咖啡因、酒精管理
- 压力管理建议
-
CBT-I元素:
- 刺激控制建议
- 睡眠限制建议
- 认知重构建议
输出:
- 优先级排序的建议列表
- 具体实施步骤
- 预期效果说明
- 实施时间线
Generate personalized sleep improvement recommendations based on user data.
Recommendation Types:
-
Sleep Schedule Adjustment Recommendations:
- Optimal bedtime/wake-up time
- Sleep consistency improvement plan
- Nap management recommendations
-
Pre-sleep Preparation Recommendations:
- Pre-sleep routine design
- Relaxation technique recommendations
- Screen time management
-
Sleep Environment Optimization:
- Optimization of temperature, humidity, light, and noise
- Bedding comfort recommendations
-
Lifestyle Adjustment:
- Management of exercise, diet, caffeine, and alcohol
- Stress management recommendations
-
CBT-I Elements:
- Stimulus Control Recommendations
- Sleep Restriction Recommendations
- Cognitive Restructuring Recommendations
Output:
- Priority-ranked recommendation list
- Specific implementation steps
- Expected effect description
- Implementation timeline
使用说明
Usage Instructions
触发条件
Trigger Conditions
当用户请求以下内容时触发本技能:
- 睡眠趋势分析
- 睡眠质量评估
- 睡眠问题识别
- 睡眠改善建议
- 睡眠与其他健康指标的关联分析
This skill is triggered when users request the following:
- Sleep trend analysis
- Sleep quality evaluation
- Sleep problem identification
- Sleep improvement recommendations
- Correlation analysis between sleep and other health indicators
执行步骤
Execution Steps
步骤 1: 确定分析范围
Step 1: Determine Analysis Scope
明确用户请求的分析类型和时间范围:
- 分析类型:趋势/质量/问题/相关性/建议
- 时间范围:周/月/季度/自定义
Clarify the analysis type and time range requested by the user:
- Analysis Type: trend/quality/problem/correlation/recommendations
- Time Range: week/month/quarter/custom
步骤 2: 读取数据
Step 2: Read Data
主要数据源:
- - 睡眠追踪主数据
data-example/sleep-tracker.json - - 每日睡眠记录
data-example/sleep-logs/YYYY-MM/YYYY-MM-DD.json
关联数据源:
- - 运动数据
data-example/fitness-tracker.json - - 血压数据
data-example/hypertension-tracker.json - - 血糖数据
data-example/diabetes-tracker.json - - 饮食记录
data-example/diet-records/ - - 情绪数据
data-example/mood-tracker.json
Main Data Sources:
- - Main sleep tracking data
data-example/sleep-tracker.json - - Daily sleep records
data-example/sleep-logs/YYYY-MM/YYYY-MM-DD.json
Associated Data Sources:
- - Exercise data
data-example/fitness-tracker.json - - Blood pressure data
data-example/hypertension-tracker.json - - Blood glucose data
data-example/diabetes-tracker.json - - Diet records
data-example/diet-records/ - - Mood data
data-example/mood-tracker.json
步骤 3: 数据分析
Step 3: Data Analysis
根据分析类型执行相应的分析算法:
趋势分析算法:
- 线性回归计算趋势斜率
- 移动平均平滑波动
- 统计显著性检验
相关性分析算法:
- Pearson相关系数计算
- 滞后相关性分析(考虑时间延迟效应)
- 多变量回归分析
模式识别算法:
- 时间序列模式识别
- 异常值检测
- 周期性分析
Execute corresponding analysis algorithms based on the analysis type:
Trend Analysis Algorithms:
- Linear regression to calculate trend slope
- Moving average to smooth fluctuations
- Statistical significance test
Correlation Analysis Algorithms:
- Pearson correlation coefficient calculation
- Lag correlation analysis (considering time delay effects)
- Multivariate regression analysis
Pattern Recognition Algorithms:
- Time series pattern recognition
- Outlier detection
- Periodicity analysis
步骤 4: 生成报告
Step 4: Generate Report
按照标准格式输出分析报告(见"输出格式"部分)
Output analysis report in standard format (see "Output Format" section)
输出格式
Output Format
睡眠质量分析报告
Sleep Quality Analysis Report
markdown
undefinedmarkdown
undefined睡眠质量分析报告
Sleep Quality Analysis Report
分析周期
Analysis Period
2025-03-20 至 2025-06-20(3个月)
March 20, 2025 to June 20, 2025 (3 months)
睡眠时长趋势
Sleep Duration Trend
- 趋势:⬆️ 改善
- 开始:平均6.2小时/晚
- 当前:平均7.1小时/晚
- 变化:+0.9小时 (+14.5%)
- 解读:睡眠时长显著增加,接近理想目标(7.5小时)
趋势线:
6.5h ┤ ╭╮
6.0h ┤ ╭─╯╰╮
5.5h ┤ ╭─╯ ╰─╮
5.0h ┼─┘ ╰─
└───────────
3月 4月 5月 6月- Trend: ⬆️ Improving
- Start: Average 6.2 hours/night
- Current: Average 7.1 hours/night
- Change: +0.9 hours (+14.5%)
- Interpretation: Sleep duration has increased significantly, approaching the ideal target (7.5 hours)
Trend Line:
6.5h ┤ ╭╮
6.0h ┤ ╭─╯╰╮
5.5h ┤ ╭─╯ ╰─╮
5.0h ┼─┘ ╰─
└───────────
Mar Apr May Jun睡眠效率
Sleep Efficiency
- 平均睡眠效率:85.3%
- 效率范围:78%-92%
- 达标率:63%(>85%为达标)
- 解读:睡眠效率正常,仍有提升空间
效率分布:
- 优秀(>90%):15晚
- 良好(85-90%):28晚
- 需改善(<85%):47晚
- Average Sleep Efficiency: 85.3%
- Efficiency Range: 78%-92%
- Compliance Rate: 63% (>85% is compliant)
- Interpretation: Sleep efficiency is normal, with room for improvement
Efficiency Distribution:
- Excellent (>90%): 15 nights
- Good (85-90%): 28 nights
- Needs Improvement (<85%): 47 nights
作息规律性
Sleep Schedule Regularity
- 平均上床时间:23:15(范围:22:30-01:00)
- 平均起床时间:07:05(范围:06:30-08:30)
- 作息一致性评分:72/100
- 社交时差:45分钟(周末比工作日晚睡晚起)
- 解读:作息基本规律,但周末波动较大
建议:
- 🎯 保持一致的起床时间,包括周末
- 🎯 逐步调整上床时间,避免周末过度延迟
- Average Bedtime: 23:15 (range: 22:30-01:00)
- Average Wake-up Time: 07:05 (range: 06:30-08:30)
- Sleep Consistency Score: 72/100
- Social Jetlag: 45 minutes (later bedtime and wake-up time on weekends than workdays)
- Interpretation: Sleep schedule is generally regular, but with significant fluctuations on weekends
Recommendations:
- 🎯 Maintain a consistent wake-up time, including weekends
- 🎯 Gradually adjust bedtime to avoid excessive delays on weekends
睡眠质量分布
Sleep Quality Distribution
| 质量等级 | 天数 | 占比 | 趋势 |
|---|---|---|---|
| 优秀 | 8 | 9% | ⬆️ |
| 很好 | 12 | 13% | ➡️ |
| 好 | 15 | 17% | ⬆️ |
| 一般 | 42 | 47% | ⬇️ |
| 差 | 10 | 11% | ⬇️ |
| 很差 | 3 | 3% | ➡️ |
解读:睡眠质量以"一般"为主,但"好"及以上质量的天数在增加
| Quality Level | Days | Percentage | Trend |
|---|---|---|---|
| Excellent | 8 | 9% | ⬆️ |
| Very Good | 12 | 13% | ➡️ |
| Good | 15 | 17% | ⬆️ |
| Fair | 42 | 47% | ⬇️ |
| Poor | 10 | 11% | ⬇️ |
| Very Poor | 3 | 3% | ➡️ |
Interpretation: Sleep quality is mainly "fair", but the number of days with "good" or higher quality is increasing
夜间觉醒分析
Nighttime Awakening Analysis
- 平均觉醒次数:1.8次/晚
- 平均觉醒时长:18分钟
- 主要原因:
- 尿意(45%)
- 噪音(25%)
- 温度过热(15%)
- 其他(15%)
建议:
- 🎯 睡前2小时限制液体摄入
- 🎯 优化卧室温度(18-22℃)
- 🎯 使用白噪音机器遮蔽背景噪音
- Average Awakening Frequency: 1.8 times/night
- Average Awakening Duration: 18 minutes
- Main Causes:
- Urination (45%)
- Noise (25%)
- Overheating (15%)
- Other (15%)
Recommendations:
- 🎯 Limit fluid intake 2 hours before bedtime
- 🎯 Optimize bedroom temperature (18-22℃)
- 🎯 Use a white noise machine to mask background noise
PSQI 评估趋势
PSQI Evaluation Trend
- 最新分数:8分(睡眠质量一般)
- 上次分数:10分(2025-03-20)
- 变化:-2分(改善)
- 趋势:⬆️ 持续改善
历史趋势:
12 ┤ ●
10 ┤ ●
8 ┤ ●
6 ┤
└──────
12月 3月 6月各成分变化:
- 主观睡眠质量:2→2(稳定)
- 入睡时间:2→2(稳定)
- 睡眠时长:2→1(改善)
- 睡眠效率:2→1(改善)
- 睡眠障碍:2→1(改善)
- Latest Score: 8 points (fair sleep quality)
- Previous Score: 10 points (March 20, 2025)
- Change: -2 points (improving)
- Trend: ⬆️ Continuous improvement
Historical Trend:
12 ┤ ●
10 ┤ ●
8 ┤ ●
6 ┤
└──────
Dec Mar JunComponent Changes:
- Subjective Sleep Quality: 2→2 (stable)
- Sleep Onset Time: 2→2 (stable)
- Sleep Duration: 2→1 (improving)
- Sleep Efficiency: 2→1 (improving)
- Sleep Disorders: 2→1 (improving)
睡眠问题识别
Sleep Problem Identification
失眠评估
Insomnia Assessment
-
类型:混合型失眠
-
频率:4-5晚/周
-
持续时间:18个月
-
主要症状:
- ✗ 入睡困难(潜伏期>30分钟)
- ✗ 睡眠维持困难(夜间觉醒>2次)
- ✓ 无早醒问题
-
影响:
- 白天疲劳:中度
- 情绪烦躁:是
- 注意力困难:是
- 工作表现:轻度影响
-
建议:🏥 持续>3个月,建议就医咨询睡眠专科
-
Type: Mixed Insomnia
-
Frequency: 4-5 nights/week
-
Duration: 18 months
-
Main Symptoms:
- ✗ Difficulty Falling Asleep (latency >30 minutes)
- ✗ Difficulty Maintaining Sleep (nighttime awakenings >2 times)
- ✓ No early awakening issue
-
Impacts:
- Daytime Fatigue: Moderate
- Mood Irritability: Yes
- Attention Difficulty: Yes
- Work Performance: Mild impact
-
Recommendation: 🏥 Persists for >3 months, consult a sleep specialist
呼吸暂停筛查(STOP-BANG)
Sleep Apnea Screening (STOP-BANG)
-
评分:3/8
-
风险等级:中等风险
-
阳性项目:
- ✗ Snoring(打鼾)
- ✗ Tired(白天疲劳)
- ✓ Observed apnea(未观察到呼吸暂停)
- ✗ Pressure(高血压)
- ✓ BMI > 28
- ✓ Age > 50
- ✗ Neck size > 40cm
- ✓ Gender = male
-
建议:⚠️ 建议进行睡眠检查(PSG)
-
Score: 3/8
-
Risk Level: Medium Risk
-
Positive Items:
- ✗ Snoring
- ✗ Tired
- ✓ Observed apnea (not observed)
- ✗ Pressure (hypertension)
- ✓ BMI > 28
- ✓ Age > 50
- ✗ Neck size > 40cm
- ✓ Gender = male
-
Recommendation: ⚠️ Recommend sleep study (PSG)
相关性分析
Correlation Analysis
睡眠 ↔ 运动
Sleep ↔ Exercise
运动日 vs 休息日:
- 运动日平均睡眠:7.3小时
- 休息日平均睡眠:6.8小时
- 差异:+0.5小时(+7.4%)
运动时间对睡眠的影响:
- 早晨运动:睡眠时长7.5小时,质量评分7.8/10
- 下午运动:睡眠时长7.2小时,质量评分7.5/10
- 晚间运动:睡眠时长6.8小时,质量评分6.8/10
相关性:中等正相关(r = 0.42)
结论:规律运动有助于改善睡眠,但应避免睡前2-3小时剧烈运动
建议:
- 🎯 保持规律运动习惯
- 🎯 将运动时间移至早晨或下午
- 🎯 睡前2-3小时避免剧烈运动
Exercise Days vs. Rest Days:
- Average sleep on exercise days: 7.3 hours
- Average sleep on rest days: 6.8 hours
- Difference: +0.5 hours (+7.4%)
Impact of Exercise Timing on Sleep:
- Morning Exercise: 7.5 hours sleep duration, quality score 7.8/10
- Afternoon Exercise: 7.2 hours sleep duration, quality score 7.5/10
- Evening Exercise: 6.8 hours sleep duration, quality score 6.8/10
Correlation: Moderate positive correlation (r = 0.42)
Conclusion: Regular exercise helps improve sleep, but avoid intense exercise 2-3 hours before bedtime
Recommendations:
- 🎯 Maintain regular exercise habits
- 🎯 Shift exercise time to morning or afternoon
- 🎯 Avoid intense exercise 2-3 hours before bedtime
睡眠 ↔ 咖啡因
Sleep ↔ Caffeine
咖啡因摄入时间分析:
- 下午2点前摄入:平均睡眠7.2小时,入睡潜伏期25分钟
- 下午2点后摄入:平均睡眠6.7小时,入睡潜伏期40分钟
- 差异:-0.5小时时长,+15分钟潜伏期
相关性:中等负相关(r = -0.38)
结论:下午2点后摄入咖啡因显著影响睡眠
建议:
- 🎯 避免下午2点后摄入咖啡因
- 🎯 睡前6小时完全避免咖啡因
Caffeine Intake Time Analysis:
- Intake before 2 PM: Average sleep 7.2 hours, sleep onset latency 25 minutes
- Intake after 2 PM: Average sleep 6.7 hours, sleep onset latency 40 minutes
- Difference: -0.5 hours duration, +15 minutes latency
Correlation: Moderate negative correlation (r = -0.38)
Conclusion: Caffeine intake after 2 PM significantly affects sleep
Recommendations:
- 🎯 Avoid caffeine intake after 2 PM
- 🎯 Completely avoid caffeine 6 hours before bedtime
睡眠 ↔ 情绪
Sleep ↔ Mood
睡眠质量对次日情绪的影响:
- 睡眠好:次日情绪积极概率82%
- 睡眠一般:次日情绪积极概率45%
- 睡眠差:次日情绪积极概率18%
睡前情绪对入睡的影响:
- 睡前压力高:入睡潜伏期45分钟
- 睡前压力低:入睡潜伏期20分钟
- 差异:+25分钟
相关性:强双向相关(r = 0.65)
结论:睡眠与情绪存在显著的相互影响
建议:
- 🎯 睡前进行压力管理(冥想、深呼吸)
- 🎯 建立放松的睡前例行程序
- 🎯 记录情绪日记,识别压力模式
Impact of Sleep Quality on Next Day's Mood:
- Good Sleep: 82% probability of positive mood next day
- Fair Sleep: 45% probability of positive mood next day
- Poor Sleep: 18% probability of positive mood next day
Impact of Pre-sleep Mood on Sleep Onset:
- High pre-sleep stress: 45 minutes sleep onset latency
- Low pre-sleep stress: 20 minutes sleep onset latency
- Difference: +25 minutes
Correlation: Strong bidirectional correlation (r = 0.65)
Conclusion: Sleep and mood have significant mutual influence
Recommendations:
- 🎯 Practice stress management before bedtime (meditation, deep breathing)
- 🎯 Establish a relaxing pre-sleep routine
- 🎯 Keep a mood journal to identify stress patterns
洞察与建议
Insights and Recommendations
关键洞察
Key Insights
-
作息不一致是主要问题
- 社交时差45分钟
- 周末作息显著偏离工作日
- 影响:生物钟紊乱,周一"时差反应"
-
晚间运动影响入睡
- 晚间运动日入睡潜伏期延长15分钟
- 建议:调整运动时间
-
睡眠环境可优化
- 噪音觉醒占25%
- 温度过热占15%
- 建议针对性改善
-
Inconsistent Sleep Schedule is the Main Issue
- 45 minutes of social jetlag
- Significant deviation of weekend schedule from workdays
- Impact: Circadian rhythm disruption, Monday "jetlag effect"
-
Evening Exercise Affects Sleep Onset
- 15 minutes longer sleep onset latency on evenings with exercise
- Recommendation: Adjust exercise time
-
Sleep Environment Can Be Optimized
- Noise-related awakenings account for 25%
- Overheating accounts for 15%
- Recommendation: Targeted improvements
优先级行动计划
Priority Action Plan
Priority 1:建立一致作息(2周)
Priority 1: Establish Consistent Sleep Schedule (2 Weeks)
目标:提高作息一致性评分至85分
具体行动:
- 固定起床时间07:00(包括周末)
- 固定上床时间23:00
- 限制午睡<30分钟,且下午3点前
- 逐步调整周末作息(每次提前15分钟)
预期效果:
- 作息一致性评分:72 → 85
- 睡眠效率提升:+3-5%
- 周一疲劳感减轻
Goal: Increase sleep consistency score to 85
Specific Actions:
- Fix wake-up time at 07:00 (including weekends)
- Fix bedtime at 23:00
- Limit naps to <30 minutes, and before 3 PM
- Gradually adjust weekend schedule (15 minutes earlier each time)
Expected Effects:
- Sleep Consistency Score: 72 → 85
- Sleep Efficiency Improvement: +3-5%
- Reduced Monday fatigue
Priority 2:创建睡前例行程序(3周)
Priority 2: Create Pre-sleep Routine (3 Weeks)
目标:建立稳定的睡前例行程序
具体行动:
- 提前1小时开始例行程序(22:00)
- 关闭电子设备(22:30)
- 调暗卧室灯光
- 进行放松活动(阅读、冥想、温水澡)
- 保持卧室安静、黑暗、凉爽(18-22℃)
预期效果:
- 入睡潜伏期缩短:30 → 20分钟
- 睡眠质量提升:一般 → 好
- 睡前压力降低
Goal: Establish a stable pre-sleep routine
Specific Actions:
- Start routine 1 hour before bedtime (22:00)
- Turn off electronic devices (22:30)
- Dim bedroom lights
- Engage in relaxing activities (reading, meditation, warm bath)
- Keep bedroom quiet, dark, and cool (18-22℃)
Expected Effects:
- Sleep Onset Latency Reduction: 30 → 20 minutes
- Sleep Quality Improvement: Fair → Good
- Reduced pre-sleep stress
Priority 3:优化睡眠环境(1周)
Priority 3: Optimize Sleep Environment (1 Week)
目标:消除环境对睡眠的干扰
具体行动:
- 安装遮光窗帘
- 使用白噪音机器遮蔽背景噪音
- 优化温度至18-22℃
- 移除卧室时钟
- 更换舒适的枕头和床垫
预期效果:
- 夜间觉醒减少:1.8 → 1.2次/晚
- 睡眠连续性提升
- 晨起状态改善
Goal: Eliminate environmental disturbances to sleep
Specific Actions:
- Install blackout curtains
- Use a white noise machine to mask background noise
- Optimize temperature to 18-22℃
- Remove bedroom clock
- Replace with comfortable pillows and mattress
Expected Effects:
- Reduction in Nighttime Awakenings: 1.8 → 1.2 times/night
- Improved sleep continuity
- Better morning state
Priority 4:生活方式调整(4周)
Priority 4: Lifestyle Adjustment (4 Weeks)
目标:消除影响睡眠的生活习惯
具体行动:
- 将运动移至早晨或下午
- 下午2点后停止咖啡因摄入
- 睡前3小时避免酒精
- 睡前2小时避免大餐
- 睡前1小时避免工作相关讨论
预期效果:
- 睡眠时长增加:+0.3小时
- 睡眠质量评分提升:+1分
- PSQI分数改善:8 → 6
Goal: Eliminate lifestyle habits affecting sleep
Specific Actions:
- Shift exercise to morning or afternoon
- Stop caffeine intake after 2 PM
- Avoid alcohol 3 hours before bedtime
- Avoid heavy meals 2 hours before bedtime
- Avoid work-related discussions 1 hour before bedtime
Expected Effects:
- Increase in Sleep Duration: +0.3 hours
- Sleep Quality Score Improvement: +1 point
- PSQI Score Improvement: 8 → 6
长期目标
Long-term Goals
- 睡眠时长:达到7.5小时/晚(当前7.1小时)
- 睡眠效率:提升至>90%(当前85%)
- PSQI分数:降至≤5分(当前8分)
- 作息一致性:提升至≥85分(当前72分)
- 入睡潜伏期:缩短至<20分钟(当前28分钟)
- Sleep Duration: Reach 7.5 hours/night (current 7.1 hours)
- Sleep Efficiency: Improve to >90% (current 85%)
- PSQI Score: Reduce to ≤5 points (current 8 points)
- Sleep Consistency: Increase to ≥85 points (current 72 points)
- Sleep Onset Latency: Reduce to <20 minutes (current 28 minutes)
医学安全提醒
Medical Safety Reminder
⚠️ 就医建议:
- 🏥 失眠持续>3个月,建议咨询睡眠专科
- 🏥 STOP-BANG≥3分,建议进行睡眠检查(PSG)
- 🏥 严重嗜睡影响驾驶安全,需立即就医
报告生成时间:2025-06-20
分析周期:2025-03-20 至 2025-06-20(90天)
数据记录数:90晚
睡眠分析器版本:v1.0
---⚠️ Medical Consultation Recommendations:
- 🏥 Insomnia persists for >3 months, consult a sleep specialist
- 🏥 STOP-BANG ≥3, recommend sleep study (PSG)
- 🏥 Severe sleepiness affecting driving safety, seek immediate medical attention
- 🏥 Sudden severe sleep problems
Report Generation Time: June 20, 2025
Analysis Period: March 20, 2025 to June 20, 2025 (90 days)
Number of Data Records: 90 nights
Sleep Analyzer Version: v1.0
---数据结构
Data Structure
睡眠记录数据
Sleep Record Data
json
{
"sleep_records": [
{
"id": "sleep_20250620001",
"date": "2025-06-20",
"sleep_times": {
"bedtime": "23:00",
"sleep_onset_time": "23:30",
"wake_time": "07:00",
"out_of_bed_time": "07:15"
},
"sleep_metrics": {
"sleep_duration_hours": 7.0,
"time_in_bed_hours": 8.25,
"sleep_latency_minutes": 30,
"sleep_efficiency": 84.8
},
"sleep_quality": {
"subjective_quality": "fair",
"quality_score": 5,
"rested_feeling": "somewhat"
},
"factors": {
"exercise": true,
"exercise_time": "evening",
"caffeine_after_2pm": false,
"screen_time_before_bed_minutes": 60
}
}
]
}json
{
"sleep_records": [
{
"id": "sleep_20250620001",
"date": "2025-06-20",
"sleep_times": {
"bedtime": "23:00",
"sleep_onset_time": "23:30",
"wake_time": "07:00",
"out_of_bed_time": "07:15"
},
"sleep_metrics": {
"sleep_duration_hours": 7.0,
"time_in_bed_hours": 8.25,
"sleep_latency_minutes": 30,
"sleep_efficiency": 84.8
},
"sleep_quality": {
"subjective_quality": "fair",
"quality_score": 5,
"rested_feeling": "somewhat"
},
"factors": {
"exercise": true,
"exercise_time": "evening",
"caffeine_after_2pm": false,
"screen_time_before_bed_minutes": 60
}
}
]
}算法说明
Algorithm Explanation
睡眠质量评分算法
Sleep Quality Score Algorithm
python
def calculate_sleep_quality_score(record):
"""
计算睡眠质量评分(0-10分)
因素权重:
- 睡眠时长:30%
- 睡眠效率:25%
- 入睡潜伏期:20%
- 夜间觉醒:15%
- 主观质量:10%
"""
score = 0
# 睡眠时长评分(理想7-9小时)
duration = record['sleep_duration_hours']
if 7 <= duration <= 9:
duration_score = 10
elif 6 <= duration < 7 or 9 < duration <= 10:
duration_score = 7
else:
duration_score = 4
score += duration_score * 0.30
# 睡眠效率评分(>90%优秀)
efficiency = record['sleep_efficiency']
efficiency_score = min(efficiency / 90 * 10, 10)
score += efficiency_score * 0.25
# 入睡潜伏期评分(<15分钟优秀)
latency = record['sleep_latency_minutes']
if latency <= 15:
latency_score = 10
elif latency <= 30:
latency_score = 7
elif latency <= 45:
latency_score = 4
else:
latency_score = 1
score += latency_score * 0.20
# 夜间觉醒评分(0次优秀)
awakenings = record['awakenings']['count']
awakening_score = max(10 - awakenings * 2, 0)
score += awakening_score * 0.15
# 主观质量评分
quality_map = {
'excellent': 10,
'very_good': 8,
'good': 7,
'fair': 5,
'poor': 3,
'very_poor': 1
}
subjective_score = quality_map.get(
record['sleep_quality']['subjective_quality'],
5
)
score += subjective_score * 0.10
return round(score, 1)python
def calculate_sleep_quality_score(record):
"""
Calculate sleep quality score (0-10 points)
Factor Weights:
- Sleep Duration: 30%
- Sleep Efficiency: 25%
- Sleep Onset Latency: 20%
- Nighttime Awakenings: 15%
- Subjective Quality: 10%
"""
score = 0
# Sleep Duration Score (ideal 7-9 hours)
duration = record['sleep_duration_hours']
if 7 <= duration <= 9:
duration_score = 10
elif 6 <= duration < 7 or 9 < duration <= 10:
duration_score = 7
else:
duration_score = 4
score += duration_score * 0.30
# Sleep Efficiency Score (>90% excellent)
efficiency = record['sleep_efficiency']
efficiency_score = min(efficiency / 90 * 10, 10)
score += efficiency_score * 0.25
# Sleep Onset Latency Score (<15 minutes excellent)
latency = record['sleep_latency_minutes']
if latency <= 15:
latency_score = 10
elif latency <= 30:
latency_score = 7
elif latency <= 45:
latency_score = 4
else:
latency_score = 1
score += latency_score * 0.20
# Nighttime Awakening Score (0 times excellent)
awakenings = record['awakenings']['count']
awakening_score = max(10 - awakenings * 2, 0)
score += awakening_score * 0.15
# Subjective Quality Score
quality_map = {
'excellent': 10,
'very_good': 8,
'good': 7,
'fair': 5,
'poor': 3,
'very_poor': 1
}
subjective_score = quality_map.get(
record['sleep_quality']['subjective_quality'],
5
)
score += subjective_score * 0.10
return round(score, 1)作息规律性评分算法
Sleep Consistency Score Algorithm
python
def calculate_sleep_consistency_score(records):
"""
计算作息规律性评分(0-100分)
因素:
- 上床时间标准差
- 起床时间标准差
- 睡眠时长标准差
- 工作日vs周末差异
"""
# 提取时间数据
bedtimes = [r['bedtime'] for r in records]
wake_times = [r['wake_time'] for r in records]
durations = [r['sleep_duration_hours'] for r in records]
# 计算标准差(分钟)
bedtime_std = time_to_minutes_std(bedtimes)
wake_std = time_to_minutes_std(wake_times)
duration_std = statistics.stdev(durations)
# 计算工作日vs周末差异
weekday_avg = avg([r['sleep_duration_hours']
for r in records if is_weekday(r)])
weekend_avg = avg([r['sleep_duration_hours']
for r in records if is_weekend(r)])
diff = abs(weekday_avg - weekend_avg)
# 综合评分
score = 100
score -= bedtime_std * 0.5 # 上床时间标准差影响
score -= wake_std * 0.5 # 起床时间标准差影响
score -= duration_std * 2 # 睡眠时长标准差影响
score -= diff * 10 # 工作日周末差异影响
return max(0, min(100, round(score)))python
def calculate_sleep_consistency_score(records):
"""
Calculate sleep consistency score (0-100 points)
Factors:
- Bedtime standard deviation
- Wake-up time standard deviation
- Sleep duration standard deviation
- Weekday vs. weekend difference
"""
# Extract time data
bedtimes = [r['bedtime'] for r in records]
wake_times = [r['wake_time'] for r in records]
durations = [r['sleep_duration_hours'] for r in records]
# Calculate standard deviation (minutes)
bedtime_std = time_to_minutes_std(bedtimes)
wake_std = time_to_minutes_std(wake_times)
duration_std = statistics.stdev(durations)
# Calculate weekday vs. weekend difference
weekday_avg = avg([r['sleep_duration_hours']
for r in records if is_weekday(r)])
weekend_avg = avg([r['sleep_duration_hours']
for r in records if is_weekend(r)])
diff = abs(weekday_avg - weekend_avg)
# Comprehensive score
score = 100
score -= bedtime_std * 0.5 # Impact of bedtime standard deviation
score -= wake_std * 0.5 # Impact of wake-up time standard deviation
score -= duration_std * 2 # Impact of sleep duration standard deviation
score -= diff * 10 # Impact of weekday-weekend difference
return max(0, min(100, round(score)))相关性分析算法
Correlation Analysis Algorithm
python
def calculate_correlation(sleep_data, other_data, lag_days=0):
"""
计算睡眠与其他指标的相关性
参数:
- sleep_data: 睡眠数据列表
- other_data: 其他指标数据列表
- lag_days: 滞后天数(考虑延迟效应)
返回:
- correlation_coefficient: 相关系数
- p_value: 统计显著性
- interpretation: 相关性解释
"""
# 对齐数据(考虑滞后)
aligned = align_data_with_lag(sleep_data, other_data, lag_days)
# 计算Pearson相关系数
from scipy import stats
corr, p_value = stats.pearsonr(
aligned['sleep_values'],
aligned['other_values']
)
# 解释相关性
if abs(corr) < 0.3:
strength = "弱"
elif abs(corr) < 0.7:
strength = "中等"
else:
strength = "强"
direction = "正相关" if corr > 0 else "负相关"
significant = p_value < 0.05
interpretation = f"{strength}{direction}"
if significant:
interpretation += "(统计学显著)"
return {
'correlation_coefficient': round(corr, 3),
'p_value': round(p_value, 4),
'interpretation': interpretation,
'significant': significant
}python
def calculate_correlation(sleep_data, other_data, lag_days=0):
"""
Calculate correlation between sleep and other indicators
Parameters:
- sleep_data: List of sleep data
- other_data: List of other indicator data
- lag_days: Number of lag days (considering delay effects)
Returns:
- correlation_coefficient: Correlation coefficient
- p_value: Statistical significance
- interpretation: Correlation explanation
"""
# Align data (considering lag)
aligned = align_data_with_lag(sleep_data, other_data, lag_days)
# Calculate Pearson correlation coefficient
from scipy import stats
corr, p_value = stats.pearsonr(
aligned['sleep_values'],
aligned['other_values']
)
# Interpret correlation
if abs(corr) < 0.3:
strength = "Weak"
elif abs(corr) < 0.7:
strength = "Moderate"
else:
strength = "Strong"
direction = "Positive Correlation" if corr > 0 else "Negative Correlation"
significant = p_value < 0.05
interpretation = f"{strength} {direction}"
if significant:
interpretation += " (Statistically Significant)"
return {
'correlation_coefficient': round(corr, 3),
'p_value': round(p_value, 4),
'interpretation': interpretation,
'significant': significant
}医学安全声明
Medical Safety Statement
本技能提供的分析和建议仅供参考,不构成医疗诊断或治疗方案。
本技能能够做到的:
- ✅ 分析睡眠数据和模式
- ✅ 识别睡眠问题风险
- ✅ 提供睡眠卫生建议
- ✅ 评估与其他健康指标的相关性
本技能不能做的:
- ❌ 诊断失眠、睡眠呼吸暂停等疾病
- ❌ 开具助眠药物或治疗
- ❌ 替代专业睡眠医学治疗
- ❌ 处理严重睡眠障碍
何时需要就医:
- 🏥 失眠持续>3个月
- 🏥 疑似睡眠呼吸暂停(STOP-BANG≥3)
- 🏥 严重嗜睡影响安全
- 🏥 突发严重睡眠问题
The analysis and recommendations provided by this skill are for reference only and do not constitute medical diagnosis or treatment plans.
What this skill can do:
- ✅ Analyze sleep data and patterns
- ✅ Identify sleep problem risks
- ✅ Provide sleep hygiene recommendations
- ✅ Evaluate correlation with other health indicators
What this skill cannot do:
- ❌ Diagnose insomnia, sleep apnea, or other diseases
- ❌ Prescribe sleep aids or treatments
- ❌ Replace professional sleep medical treatment
- ❌ Handle severe sleep disorders
When to seek medical attention:
- 🏥 Insomnia persists for >3 months
- 🏥 Suspected sleep apnea (STOP-BANG≥3)
- 🏥 Severe sleepiness affecting safety
- 🏥 Sudden severe sleep problems
参考资源
Reference Resources
- AASM 睡眠评分标准:https://aasm.org/
- PSQI 量表:https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3455216/
- STOP-BANG 问卷:https://www.stopbang.ca/
- CBT-I 治疗:https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3455216/
技能版本: v1.0
创建日期: 2026-01-02
维护者: WellAlly Tech
- AASM Sleep Scoring Standards: https://aasm.org/
- PSQI Scale: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3455216/
- STOP-BANG Questionnaire: https://www.stopbang.ca/
- CBT-I Therapy: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3455216/
Skill Version: v1.0
Creation Date: January 02, 2026
Maintainer: WellAlly Tech