A comprehensive Python toolkit for analyzing Apple Health export data, providing insights into various health metrics including heart rate, sleep patterns, activity levels, and more.
- Resting Heart Rate Analysis - Track trends and patterns in your resting heart rate
- Heart Rate Variability (HRV) - Monitor stress and recovery through HRV metrics
- Sleep Pattern Analysis - Understand your sleep duration and quality over time
- Oxygen Saturation Tracking - Monitor SpO2 levels and identify potential issues
- Activity Metrics - Analyze daily steps, calories burned, and exercise patterns
- Blood Pressure Monitoring - Track systolic/diastolic trends and identify hypertension risks
- Comprehensive Health Dashboard - Generate combined visualizations of all health metrics
- Python 3.7+
- Apple Health data export (XML format)
- Clone this repository:
git clone https://github.com/yourusername/apple-health-data-analysis.git
cd apple-health-data-analysis- Install required dependencies:
pip install -r requirements.txt- Open the Health app on your iPhone
- Tap your profile picture in the top right
- Scroll down and tap "Export All Health Data"
- Choose "Export" and save the ZIP file
- Extract the ZIP file - you'll need the
export.xmlfile - Rename it to
apple_health_export.xml(or update the filename in scripts)
Analyze all health metrics at once:
python example_usage.py --input apple_health_export.xml --analysis allRun specific analyses:
# Sleep analysis
python analyze_sleep_patterns.py
# Heart rate variability
python analyze_hrv.py
# Oxygen saturation
python analyze_oxygen_saturation.py
# Activity and energy
python analyze_activity_energy.py
# Blood pressure
python analyze_blood_pressure.pyFor a quick overview of all your health data:
python extract_key_statistics.pyCreate a combined visualization of all metrics:
python create_combined_dashboard.pyEdit config.py to customize:
- Default file paths
- Health metric thresholds
- Chart appearance settings
- Date ranges for analysis
All scripts generate:
- PNG charts - High-resolution visualizations saved in the current directory
- Console output - Statistical summaries and insights
- CSV exports - Some scripts export processed data for further analysis
The toolkit generates various charts including:
- Time series plots with moving averages
- Distribution histograms
- Correlation matrices
- Yearly/monthly aggregations
- Trend analysis with regression lines
- No data leaves your computer - All analysis is performed locally
- Add
.gitignore- The included.gitignorefile prevents accidental upload of personal health data - Review before sharing - Always check generated images before sharing to ensure no sensitive information is visible
apple-health-data-analysis/
├── README.md # This file
├── requirements.txt # Python dependencies
├── config.py # Configuration settings
├── example_usage.py # Example script with CLI interface
├── .gitignore # Prevents uploading personal data
│
├── analyze_health_data_types.py # Discover available data types
├── extract_key_statistics.py # Quick statistical overview
│
├── analyze_sleep_patterns.py # Sleep analysis
├── analyze_oxygen_saturation.py # Blood oxygen analysis
├── analyze_hrv.py # Heart rate variability
├── analyze_blood_pressure.py # Blood pressure tracking
├── analyze_activity_energy.py # Activity and calorie analysis
├── analyze_resting_heart_rate.py # Resting heart rate trends
│
└── create_combined_dashboard.py # Generate comprehensive dashboard
- Normal resting HR: 60-100 BPM (lower is generally better)
- Athletes: May have resting HR as low as 40-60 BPM
- Higher HRV: Generally indicates better stress resilience
- Normal range: 20-100ms (varies by age and fitness)
- Normal: 95-100%
- Concerning: Below 95% (consult healthcare provider)
- Recommended: 7-9 hours per night for adults
- Quality matters: Consistency is as important as duration
- Steps target: 8,000-10,000 steps per day
- Active calories: Aim for 500+ kcal from activity daily
If processing times out due to large files:
- Use
extract_key_statistics.pyfor a sampled analysis - Modify scripts to process specific date ranges
- Increase the sampling rate in configuration
Not all analyses will work if you haven't been tracking certain metrics. The scripts will indicate if data is missing.
For very large exports (>1GB), consider:
- Running analyses one at a time
- Using a computer with more RAM
- Modifying scripts to process data in chunks
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is for informational purposes only and should not be used as a substitute for professional medical advice. Always consult with healthcare providers for medical decisions.
- Built with Python, pandas, and matplotlib
- Inspired by the quantified self movement
- Thanks to Apple for making health data exportable