This repository contains the data calculation scripts and heatmap generators used for the HyperSense research project.
All scripts expect participant exports in ~/Downloads/Exports, with one folder per participant named like P001, P002, and so on.
Raw Apple Health export files should also be present at the exports root, such as P001export.csv, along with the schedule CSVs used to label classroom periods.
For the heatmap scripts, the expected participant data layout is the Apple Health / HealthApp export structure, such as P001/HealthApp/Labeled/Record/**/*.csv or the raw export file P001export.csv.
The heatmap scripts default to US/Pacific for naive timestamps, but you can override that with --timezone if your export files were generated in a different local timezone.
Heatmap outputs are written under Heatmaps/Graphs/<Datatype>/, and each datatype folder contains all figures and CSVs for that datatype.
The coverage stratification script prints Table 6 values directly to the console instead of writing files.
Heatmaps/apple_watch_hr_heatmaps.pygenerates heart-rate coverage and valid scheduled-bin heatmaps.Heatmaps/apple_watch_active_energy_heatmaps.pygenerates active energy burned coverage and valid scheduled-bin heatmaps.Heatmaps/apple_watch_basal_energy_heatmaps.pygenerates basal energy burned coverage and valid scheduled-bin heatmaps.Heatmaps/apple_watch_exercise_time_heatmaps.pygenerates Apple exercise time coverage and valid scheduled-bin heatmaps.
Each of those scripts uses the same fixed weekday, class, and 30-minute time windows, the same participant naming conventions, and a valid-bin count summary by weekday.
BoxPlots/apple_watch_activity_boxplots.pygenerates one horizontal boxplot per Apple Watch datatype, saving the PNGs directly inBoxPlots/Graphs/.BoxPlots/apple_watch_hr_participant_small_multiples.pygenerates a Figure 11-style heart-rate small-multiples grid: one panel per classroom activity with participant-level boxplots, saving toBoxPlots/Graphs/heart_rate_participant_small_multiples.png.
Coverage/calculate_heart_rate.pycalculates heart-rate expected, observed, valid, and invalid 5-minute bins using point-sample placement.Coverage/calculate_active_energy_burned.pycalculates active energy burned bins by mapping datapoint intervals onto schedule bins.Coverage/calculate_basal_energy_burned.pycalculates basal energy burned bins by mapping datapoint intervals onto schedule bins.Coverage/calculate_apple_exercise_time.pycalculates Apple Exercise Time bins using discrete event placement.Coverage/calculate_participant_coverage.pyprints per-participant expected bins and coverage percentages for HR, active energy, BMR, and logged exercise.Coverage/audit_binned_common.pyprovides shared helpers used by the calculation scripts.
Coverage/calculate_coverage_stratification.pycalculates Paper Table 6 Apple Watch coverage values stratified by classroom context, day of week, and time of day.Coverage/coverage_stratification_common.pyprovides the shared schedule-binning and coverage logic used by the stratification script.
The stratification script reports, for each row category:
- Expected 5-minute bins from the school schedule
- Apple Watch HR coverage (40–180 bpm)
- Active Energy coverage
- BMR coverage
- Logged Exercise coverage
It also prints participant summary rows with mean ± SD and min–max across the 12 participants. Stratifier rows pool valid and expected bins across all participants; the participant summary rows average each participant's overall coverage percentage.
Run the heatmap scripts from the repository root:
python3 Heatmaps/apple_watch_hr_heatmaps.py --root ~/Downloads/Exports
python3 Heatmaps/apple_watch_active_energy_heatmaps.py --root ~/Downloads/Exports
python3 Heatmaps/apple_watch_basal_energy_heatmaps.py --root ~/Downloads/Exports
python3 Heatmaps/apple_watch_exercise_time_heatmaps.py --root ~/Downloads/ExportsRun the boxplot scripts from the repository root:
python3 BoxPlots/apple_watch_activity_boxplots.py --root ~/Downloads/Exports
python3 BoxPlots/apple_watch_hr_participant_small_multiples.py --root ~/Downloads/ExportsRun the calculation scripts from the repository root:
PYTHONPATH=. python3 Coverage/calculate_heart_rate.py
PYTHONPATH=. python3 Coverage/calculate_active_energy_burned.py
PYTHONPATH=. python3 Coverage/calculate_basal_energy_burned.py
PYTHONPATH=. python3 Coverage/calculate_apple_exercise_time.py
python3 Coverage/calculate_participant_coverage.py --root ~/Downloads/ExportsRun the Table 6 coverage stratification script from the repository root:
python3 Coverage/calculate_coverage_stratification.py --root ~/Downloads/Exports