-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconstants.py
More file actions
50 lines (45 loc) · 2.94 KB
/
constants.py
File metadata and controls
50 lines (45 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#
# SPDX-FileCopyrightText: 2026 Stanford University, ETH Zurich, and the project authors (see CONTRIBUTORS.md)
# SPDX-FileCopyrightText: 2026 This source file is part of the SensorTSLM open-source project.
#
# SPDX-License-Identifier: MIT
#
import os
import pathlib
from extractors import ChannelConfig
from aggregators import NonZeroAggregator
from detectors.trend import TrendDetector
from detectors.spike import SpikeDetector
from mhc.constants import ACTIVITY_CHANNELS, CHANNEL_NAMES, CONTINUOUS_CHANNELS, SLEEP_CHANNELS
HOURLY_TEMPLATES_PATH = pathlib.Path(__file__).resolve().parent.parent / "templates" / "templates_hourly.json"
WEEKLY_CHANNEL_META = {
"hk_iphone:HKQuantityTypeIdentifierStepCount": ("iPhone step count", "steps/hr", 0),
"hk_iphone:HKQuantityTypeIdentifierDistanceWalkingRunning": ("iPhone distance", "m/hr", 1),
"hk_iphone:HKQuantityTypeIdentifierFlightsClimbed": ("flights climbed (iPhone)", "count/hr", 1),
"hk_watch:HKQuantityTypeIdentifierStepCount": ("Apple Watch step count", "steps/hr", 0),
"hk_watch:HKQuantityTypeIdentifierDistanceWalkingRunning": ("Apple Watch distance", "m/hr", 1),
"hk_watch:HKQuantityTypeIdentifierHeartRate": ("heart rate", "bpm", 1),
"hk_watch:HKQuantityTypeIdentifierActiveEnergyBurned": ("active energy", "cal/hr", 0),
}
WEEKLY_CHANNEL_CONFIG = ChannelConfig(
names=CHANNEL_NAMES,
meta=WEEKLY_CHANNEL_META,
continuous=CONTINUOUS_CHANNELS,
groups={
"activity": frozenset(ACTIVITY_CHANNELS),
"sleep": frozenset(SLEEP_CHANNELS),
},
templates_path=HOURLY_TEMPLATES_PATH,
time_unit="hours",
aggregators={"hk_watch:HKQuantityTypeIdentifierHeartRate": NonZeroAggregator()},
detectors={
"hk_iphone:HKQuantityTypeIdentifierStepCount": [TrendDetector(), SpikeDetector(min_height=1000.0, min_distance=1, top_k=10)],
"hk_iphone:HKQuantityTypeIdentifierDistanceWalkingRunning": [TrendDetector(), SpikeDetector(min_height=720.0, min_distance=1, top_k=10)],
"hk_iphone:HKQuantityTypeIdentifierFlightsClimbed": [TrendDetector(), SpikeDetector(min_height=1.0, min_distance=1, top_k=10)],
"hk_watch:HKQuantityTypeIdentifierStepCount": [TrendDetector(), SpikeDetector(min_height=1000.0, min_distance=1, top_k=10)],
"hk_watch:HKQuantityTypeIdentifierDistanceWalkingRunning": [TrendDetector(), SpikeDetector(min_height=720.0, min_distance=1, top_k=10)],
"hk_watch:HKQuantityTypeIdentifierHeartRate": [TrendDetector(filter_zeros=True), SpikeDetector(filter_zeros=True, min_height=100.0, min_prominence=5.0, min_distance=1, top_k=10)],
"hk_watch:HKQuantityTypeIdentifierActiveEnergyBurned": [TrendDetector(), SpikeDetector(min_height=500.0, min_distance=1, top_k=10)],
},
)
WEEKLY_DATASET_DIR = os.environ.get("MHC_WEEKLY_DATASET_DIR", "data/mhc_weekly")