Skip to content

HouIP/SoliSleep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŒ™ SoliSleep: Nest Hub 2 Sleep Analysis

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

πŸ›‘ Disclaimer

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).

πŸ› οΈ Setup & Installation

  1. Clone & Install:
    pip install -r requirements.txt
  2. Configure Credentials:
    • Recommended: Create a .env file 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.

πŸ“ˆ Running the Pipeline

  1. Extract: python get_data.py (Downloads raw segments from Google Fit).
  2. Analyze: python analyze_sleep.py --merge-by-date --timezone America/Los_Angeles.
  3. Explore: streamlit run dashboard.py (Launches the personal dashboard).

πŸ”¬ Methodology & Sources

Normative Data

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.

Sleep Fragmentation Index (SFI)

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)

Analysis

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.


Environment Variables

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

About

Nest Hub 2 Sleep Analysis

Resources

Stars

Watchers

Forks

Languages