terra.models.v2.sleep
1# Copyright 2022 Terra Enabling Developers Limited 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14import dataclasses 15import typing 16 17from terra.models import base_model 18from terra.models.v2 import samples as samples_ 19from terra.models.v2.activity import DeviceData 20 21__all__ = [ 22 "Sleep", 23 "Metadata", 24 "ReadinessData", 25 "TemperatureData", 26 "HeartRateDataSummary", 27 "HeartRateDataDetailed", 28 "HeartRateData", 29 "SleepDurationsAwakeData", 30 "SleepDurationsAsleepData", 31 "SleepDurationsOtherData", 32 "SleepDurationsData", 33 "OxygenSaturationData", 34 "BreathsData", 35 "SnoringData", 36 "RespirationData", 37] 38 39 40@dataclasses.dataclass 41class Metadata(base_model.TerraDataModel): 42 start_time: typing.Optional[str] = dataclasses.field(default=None) 43 end_time: typing.Optional[str] = dataclasses.field(default=None) 44 upload_type: typing.Optional[int] = dataclasses.field(default=None) 45 is_nap: bool = dataclasses.field(default=False) 46 47 48@dataclasses.dataclass 49class ReadinessData(base_model.TerraDataModel): 50 readiness: typing.Optional[float] = dataclasses.field(default=None) 51 recovery_level: typing.Optional[int] = dataclasses.field(default=None) 52 53 54@dataclasses.dataclass 55class TemperatureData(base_model.TerraDataModel): 56 delta: typing.Optional[float] = dataclasses.field(default=None) 57 58 59@dataclasses.dataclass 60class HeartRateDataSummary(base_model.TerraDataModel): 61 avg_hr_bpm: typing.Optional[int] = dataclasses.field(default=None) 62 max_hr_bpm: typing.Optional[int] = dataclasses.field(default=None) 63 min_hr_bpm: typing.Optional[int] = dataclasses.field(default=None) 64 avg_hrv_rmssd: typing.Optional[int] = dataclasses.field(default=None) 65 avg_hrv_sdnn: typing.Optional[int] = dataclasses.field(default=None) 66 user_max_hr_bpm: typing.Optional[int] = dataclasses.field(default=None) 67 resting_hr_bpm: typing.Optional[float] = dataclasses.field(default=None) 68 69 70@dataclasses.dataclass 71class HeartRateDataDetailed(base_model.TerraDataModel): 72 hr_samples: typing.List[samples_.HeartRateDataSample] = dataclasses.field(default_factory=list) 73 hrv_samples_rmssd: typing.List[samples_.HeartRateVariabilityDataSampleRMSSD] = dataclasses.field( 74 default_factory=list 75 ) 76 hrv_samples_sdnn: typing.List[samples_.HeartRateVariabilityDataSampleSDNN] = dataclasses.field(default_factory=list) 77 78 79@dataclasses.dataclass 80class HeartRateData(base_model.TerraDataModel): 81 summary: HeartRateDataSummary = dataclasses.field(default_factory=HeartRateDataSummary) 82 detailed: HeartRateDataDetailed = dataclasses.field(default_factory=HeartRateDataDetailed) 83 84 85@dataclasses.dataclass 86class SleepDurationsAwakeData(base_model.TerraDataModel): 87 sleep_latency_seconds: typing.Optional[float] = dataclasses.field(default=None) 88 wake_up_latency_seconds: typing.Optional[float] = dataclasses.field(default=None) 89 duration_awake_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 90 duration_short_interruption_seconds: typing.Optional[float] = dataclasses.field(default=None) 91 duration_long_interruption_seconds: typing.Optional[float] = dataclasses.field(default=None) 92 num_out_of_bed_events: typing.Optional[int] = dataclasses.field(default=None) 93 num_wakeup_events: typing.Optional[int] = dataclasses.field(default=None) 94 95 96@dataclasses.dataclass 97class SleepDurationsAsleepData(base_model.TerraDataModel): 98 duration_asleep_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 99 duration_deep_sleep_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 100 duration_light_sleep_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 101 duration_REM_sleep_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 102 num_REM_events: typing.Optional[int] = dataclasses.field(default=None) 103 104 105@dataclasses.dataclass 106class SleepDurationsOtherData(base_model.TerraDataModel): 107 duration_unmeasurable_sleep_seconds: typing.Optional[float] = dataclasses.field(default=None) 108 duration_in_bed_seconds: typing.Optional[float] = dataclasses.field(default=None) 109 110 111@dataclasses.dataclass 112class SleepDurationsData(base_model.TerraDataModel): 113 sleep_efficiency: typing.Optional[float] = dataclasses.field(default=None) 114 awake: SleepDurationsAwakeData = dataclasses.field(default_factory=SleepDurationsAwakeData) 115 asleep: SleepDurationsAsleepData = dataclasses.field(default_factory=SleepDurationsAsleepData) 116 other: SleepDurationsOtherData = dataclasses.field(default_factory=SleepDurationsOtherData) 117 hypnogram_samples: typing.List[samples_.SleepHypnogramSample] = dataclasses.field(default_factory=list) 118 119 120@dataclasses.dataclass 121class OxygenSaturationData(base_model.TerraDataModel): 122 start_time: typing.Optional[str] = dataclasses.field(default=None) 123 end_time: typing.Optional[str] = dataclasses.field(default=None) 124 avg_saturation_percentage: typing.Optional[float] = dataclasses.field(default=None) 125 samples: typing.List[samples_.OxygenSaturationSample] = dataclasses.field(default_factory=list) 126 127 128@dataclasses.dataclass 129class BreathsData(base_model.TerraDataModel): 130 start_time: typing.Optional[str] = dataclasses.field(default=None) 131 end_time: typing.Optional[str] = dataclasses.field(default=None) 132 on_demand_reading: typing.Optional[bool] = dataclasses.field(default=None) 133 avg_breaths_per_min: typing.Optional[float] = dataclasses.field(default=None) 134 max_breaths_per_min: typing.Optional[float] = dataclasses.field(default=None) 135 min_breaths_per_min: typing.Optional[float] = dataclasses.field(default=None) 136 samples: typing.List[samples_.BreathSample] = dataclasses.field(default_factory=list) 137 138 139@dataclasses.dataclass 140class SnoringData(base_model.TerraDataModel): 141 start_time: typing.Optional[str] = dataclasses.field(default=None) 142 end_time: typing.Optional[str] = dataclasses.field(default=None) 143 total_snoring_duration_seconds: typing.Optional[float] = dataclasses.field(default=None) 144 num_snoring_events: typing.Optional[int] = dataclasses.field(default=None) 145 samples: typing.List[samples_.SnoringSample] = dataclasses.field(default_factory=list) 146 147 148@dataclasses.dataclass 149class RespirationData(base_model.TerraDataModel): 150 oxygen_saturation_data: OxygenSaturationData = dataclasses.field(default_factory=OxygenSaturationData) 151 breaths_data: BreathsData = dataclasses.field(default_factory=BreathsData) 152 snoring_data: SnoringData = dataclasses.field(default_factory=SnoringData) 153 154 155@dataclasses.dataclass 156class Sleep(base_model.TerraDataModel): 157 metadata: Metadata = dataclasses.field(default_factory=Metadata) 158 temperature_data: TemperatureData = dataclasses.field(default_factory=TemperatureData) 159 readiness_data: ReadinessData = dataclasses.field(default_factory=ReadinessData) 160 heart_rate_data: HeartRateData = dataclasses.field(default_factory=HeartRateData) 161 sleep_durations_data: SleepDurationsData = dataclasses.field(default_factory=SleepDurationsData) 162 respiration_data: RespirationData = dataclasses.field(default_factory=RespirationData) 163 device_data: DeviceData = dataclasses.field(default_factory=DeviceData)
156@dataclasses.dataclass 157class Sleep(base_model.TerraDataModel): 158 metadata: Metadata = dataclasses.field(default_factory=Metadata) 159 temperature_data: TemperatureData = dataclasses.field(default_factory=TemperatureData) 160 readiness_data: ReadinessData = dataclasses.field(default_factory=ReadinessData) 161 heart_rate_data: HeartRateData = dataclasses.field(default_factory=HeartRateData) 162 sleep_durations_data: SleepDurationsData = dataclasses.field(default_factory=SleepDurationsData) 163 respiration_data: RespirationData = dataclasses.field(default_factory=RespirationData) 164 device_data: DeviceData = dataclasses.field(default_factory=DeviceData)
Sleep(metadata: terra.models.v2.sleep.Metadata =
Inherited Members
41@dataclasses.dataclass 42class Metadata(base_model.TerraDataModel): 43 start_time: typing.Optional[str] = dataclasses.field(default=None) 44 end_time: typing.Optional[str] = dataclasses.field(default=None) 45 upload_type: typing.Optional[int] = dataclasses.field(default=None) 46 is_nap: bool = dataclasses.field(default=False)
Metadata(start_time: Optional[str] = None, end_time: Optional[str] = None, upload_type: Optional[int] = None, is_nap: bool = False)
Inherited Members
49@dataclasses.dataclass 50class ReadinessData(base_model.TerraDataModel): 51 readiness: typing.Optional[float] = dataclasses.field(default=None) 52 recovery_level: typing.Optional[int] = dataclasses.field(default=None)
ReadinessData(readiness: Optional[float] = None, recovery_level: Optional[int] = None)
Inherited Members
55@dataclasses.dataclass 56class TemperatureData(base_model.TerraDataModel): 57 delta: typing.Optional[float] = dataclasses.field(default=None)
TemperatureData(delta: Optional[float] = None)
Inherited Members
60@dataclasses.dataclass 61class HeartRateDataSummary(base_model.TerraDataModel): 62 avg_hr_bpm: typing.Optional[int] = dataclasses.field(default=None) 63 max_hr_bpm: typing.Optional[int] = dataclasses.field(default=None) 64 min_hr_bpm: typing.Optional[int] = dataclasses.field(default=None) 65 avg_hrv_rmssd: typing.Optional[int] = dataclasses.field(default=None) 66 avg_hrv_sdnn: typing.Optional[int] = dataclasses.field(default=None) 67 user_max_hr_bpm: typing.Optional[int] = dataclasses.field(default=None) 68 resting_hr_bpm: typing.Optional[float] = dataclasses.field(default=None)
HeartRateDataSummary(avg_hr_bpm: Optional[int] = None, max_hr_bpm: Optional[int] = None, min_hr_bpm: Optional[int] = None, avg_hrv_rmssd: Optional[int] = None, avg_hrv_sdnn: Optional[int] = None, user_max_hr_bpm: Optional[int] = None, resting_hr_bpm: Optional[float] = None)
Inherited Members
71@dataclasses.dataclass 72class HeartRateDataDetailed(base_model.TerraDataModel): 73 hr_samples: typing.List[samples_.HeartRateDataSample] = dataclasses.field(default_factory=list) 74 hrv_samples_rmssd: typing.List[samples_.HeartRateVariabilityDataSampleRMSSD] = dataclasses.field( 75 default_factory=list 76 ) 77 hrv_samples_sdnn: typing.List[samples_.HeartRateVariabilityDataSampleSDNN] = dataclasses.field(default_factory=list)
HeartRateDataDetailed(hr_samples: List[terra.models.v2.samples.HeartRateDataSample] =
Inherited Members
80@dataclasses.dataclass 81class HeartRateData(base_model.TerraDataModel): 82 summary: HeartRateDataSummary = dataclasses.field(default_factory=HeartRateDataSummary) 83 detailed: HeartRateDataDetailed = dataclasses.field(default_factory=HeartRateDataDetailed)
HeartRateData(summary: terra.models.v2.sleep.HeartRateDataSummary =
Inherited Members
86@dataclasses.dataclass 87class SleepDurationsAwakeData(base_model.TerraDataModel): 88 sleep_latency_seconds: typing.Optional[float] = dataclasses.field(default=None) 89 wake_up_latency_seconds: typing.Optional[float] = dataclasses.field(default=None) 90 duration_awake_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 91 duration_short_interruption_seconds: typing.Optional[float] = dataclasses.field(default=None) 92 duration_long_interruption_seconds: typing.Optional[float] = dataclasses.field(default=None) 93 num_out_of_bed_events: typing.Optional[int] = dataclasses.field(default=None) 94 num_wakeup_events: typing.Optional[int] = dataclasses.field(default=None)
SleepDurationsAwakeData(sleep_latency_seconds: Optional[float] = None, wake_up_latency_seconds: Optional[float] = None, duration_awake_state_seconds: Optional[float] = None, duration_short_interruption_seconds: Optional[float] = None, duration_long_interruption_seconds: Optional[float] = None, num_out_of_bed_events: Optional[int] = None, num_wakeup_events: Optional[int] = None)
Inherited Members
97@dataclasses.dataclass 98class SleepDurationsAsleepData(base_model.TerraDataModel): 99 duration_asleep_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 100 duration_deep_sleep_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 101 duration_light_sleep_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 102 duration_REM_sleep_state_seconds: typing.Optional[float] = dataclasses.field(default=None) 103 num_REM_events: typing.Optional[int] = dataclasses.field(default=None)
SleepDurationsAsleepData(duration_asleep_state_seconds: Optional[float] = None, duration_deep_sleep_state_seconds: Optional[float] = None, duration_light_sleep_state_seconds: Optional[float] = None, duration_REM_sleep_state_seconds: Optional[float] = None, num_REM_events: Optional[int] = None)
Inherited Members
106@dataclasses.dataclass 107class SleepDurationsOtherData(base_model.TerraDataModel): 108 duration_unmeasurable_sleep_seconds: typing.Optional[float] = dataclasses.field(default=None) 109 duration_in_bed_seconds: typing.Optional[float] = dataclasses.field(default=None)
SleepDurationsOtherData(duration_unmeasurable_sleep_seconds: Optional[float] = None, duration_in_bed_seconds: Optional[float] = None)
Inherited Members
112@dataclasses.dataclass 113class SleepDurationsData(base_model.TerraDataModel): 114 sleep_efficiency: typing.Optional[float] = dataclasses.field(default=None) 115 awake: SleepDurationsAwakeData = dataclasses.field(default_factory=SleepDurationsAwakeData) 116 asleep: SleepDurationsAsleepData = dataclasses.field(default_factory=SleepDurationsAsleepData) 117 other: SleepDurationsOtherData = dataclasses.field(default_factory=SleepDurationsOtherData) 118 hypnogram_samples: typing.List[samples_.SleepHypnogramSample] = dataclasses.field(default_factory=list)
SleepDurationsData(sleep_efficiency: Optional[float] = None, awake: terra.models.v2.sleep.SleepDurationsAwakeData =
Inherited Members
121@dataclasses.dataclass 122class OxygenSaturationData(base_model.TerraDataModel): 123 start_time: typing.Optional[str] = dataclasses.field(default=None) 124 end_time: typing.Optional[str] = dataclasses.field(default=None) 125 avg_saturation_percentage: typing.Optional[float] = dataclasses.field(default=None) 126 samples: typing.List[samples_.OxygenSaturationSample] = dataclasses.field(default_factory=list)
OxygenSaturationData(start_time: Optional[str] = None, end_time: Optional[str] = None, avg_saturation_percentage: Optional[float] = None, samples: List[terra.models.v2.samples.OxygenSaturationSample] =
Inherited Members
129@dataclasses.dataclass 130class BreathsData(base_model.TerraDataModel): 131 start_time: typing.Optional[str] = dataclasses.field(default=None) 132 end_time: typing.Optional[str] = dataclasses.field(default=None) 133 on_demand_reading: typing.Optional[bool] = dataclasses.field(default=None) 134 avg_breaths_per_min: typing.Optional[float] = dataclasses.field(default=None) 135 max_breaths_per_min: typing.Optional[float] = dataclasses.field(default=None) 136 min_breaths_per_min: typing.Optional[float] = dataclasses.field(default=None) 137 samples: typing.List[samples_.BreathSample] = dataclasses.field(default_factory=list)
BreathsData(start_time: Optional[str] = None, end_time: Optional[str] = None, on_demand_reading: Optional[bool] = None, avg_breaths_per_min: Optional[float] = None, max_breaths_per_min: Optional[float] = None, min_breaths_per_min: Optional[float] = None, samples: List[terra.models.v2.samples.BreathSample] =
Inherited Members
140@dataclasses.dataclass 141class SnoringData(base_model.TerraDataModel): 142 start_time: typing.Optional[str] = dataclasses.field(default=None) 143 end_time: typing.Optional[str] = dataclasses.field(default=None) 144 total_snoring_duration_seconds: typing.Optional[float] = dataclasses.field(default=None) 145 num_snoring_events: typing.Optional[int] = dataclasses.field(default=None) 146 samples: typing.List[samples_.SnoringSample] = dataclasses.field(default_factory=list)
SnoringData(start_time: Optional[str] = None, end_time: Optional[str] = None, total_snoring_duration_seconds: Optional[float] = None, num_snoring_events: Optional[int] = None, samples: List[terra.models.v2.samples.SnoringSample] =
Inherited Members
149@dataclasses.dataclass 150class RespirationData(base_model.TerraDataModel): 151 oxygen_saturation_data: OxygenSaturationData = dataclasses.field(default_factory=OxygenSaturationData) 152 breaths_data: BreathsData = dataclasses.field(default_factory=BreathsData) 153 snoring_data: SnoringData = dataclasses.field(default_factory=SnoringData)
RespirationData(oxygen_saturation_data: terra.models.v2.sleep.OxygenSaturationData =