This project explores sleep through the contactless sensing capabilities of the Google Nest Hub 2 (Soli Radar). By extracting raw data from the Google Fit API and applying the YASA (Yet Another Spindle Algorithm) engine, the pipeline reveals insights that often remain hidden in Google Fit.
Caution
This project is for personal educational and informational purposes only. It is not a medical device, and the analysis provided should not be used to diagnose, treat, or prevent any sleep disorder or medical condition.
- Inaccuracies: Soli radar can be noisy and may misclassify sleep stages.
- Consult a Professional: If you are experiencing chronic fatigue, snoring, or other sleep-related issues, please consult a board-certified sleep specialist or physician for a clinical sleep study (PSG).
- Clone & Install:
pip install -r requirements.txt
- Configure Credentials:
- Recommended: Create a
.envfile and add your Google Fit credentials:GOOGLE_FIT_CLIENT_ID="your_client_id" GOOGLE_FIT_CLIENT_SECRET_KEY="your_client_secret"
- Alternative: Download your OAuth 2.0 Client ID JSON and place it in the project root. The script will auto-discover any file matching
client_secret_*.json.
- Recommended: Create a
- Extract:
python get_data.py(Downloads raw segments from Google Fit). - Analyze:
python analyze_sleep.py --merge-by-date --timezone America/Los_Angeles. - Explore:
streamlit run dashboard.py(Launches the personal dashboard).
The "interpretations" and Z-scores in the dashboard are based on meta-analysis data from Ohayon et al. (2004), which provides age-matched norms for healthy sleep.
Calculated using the Aubert-Tulkens (1987) methodology, adapted for the 1-minute resolution limits of the Nest Hub 2 sensor.
SFI = Movement Index (MI) + Fragmentation Index (FI)
Powered by YASA (Yet Another Spindle Algorithm), a state-of-the-art Python library for sleep analysis developed by the Walker Lab at UC Berkeley.
| Variable | Description | Default |
|---|---|---|
GOOGLE_FIT_CLIENT_ID |
OAuth Client ID (bypasses JSON file) | N/A |
GOOGLE_FIT_CLIENT_SECRET_KEY |
OAuth Client Secret (bypasses JSON file) | N/A |
GOOGLE_FIT_TOKEN_FILE |
Path to store user tokens | token.json |
GOOGLE_FIT_CLIENT_SECRET |
Path to OAuth client secret JSON | client_secret_*.json |