Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature omniring #408

Open
wants to merge 14 commits into
base: scheduling-bugs
Choose a base branch
from
89 changes: 49 additions & 40 deletions constants/data_processing_constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## Chunks
# This value is in seconds, it sets the time period that chunked files will be sliced into.
from constants.data_stream_constants import (ACCELEROMETER, ANDROID_LOG_FILE, BLUETOOTH, CALL_LOG,
DEVICE_IDENTIFIERS_HEADER, DEVICEMOTION, GPS, GYRO, IDENTIFIERS, IOS_LOG_FILE, MAGNETOMETER,
POWER_STATE, PROXIMITY, REACHABILITY, SURVEY_TIMINGS, TEXTS_LOG, WIFI)
from constants.data_stream_constants import (ACCELEROMETER, ANDROID_LOG_FILE, BLUETOOTH, OMNIRING, CALL_LOG,
DEVICE_IDENTIFIERS_HEADER, DEVICEMOTION, GPS, GYRO, IDENTIFIERS,
IOS_LOG_FILE, MAGNETOMETER,
POWER_STATE, PROXIMITY, REACHABILITY, SURVEY_TIMINGS, TEXTS_LOG, WIFI)
from constants.user_constants import ANDROID_API, IOS_API


CHUNK_TIMESLICE_QUANTUM = 3600

# These reference dicts contain the output headers that should exist for each data stream, per-os.
Expand All @@ -19,145 +19,154 @@
REFERENCE_CHUNKREGISTRY_HEADERS = {
ACCELEROMETER: {
ANDROID_API: b'timestamp,UTC time,accuracy,x,y,z',
IOS_API: b'timestamp,UTC time,accuracy,x,y,z',
IOS_API: b'timestamp,UTC time,accuracy,x,y,z',
},
ANDROID_LOG_FILE: {
ANDROID_API: b'timestamp,UTC time,event',
IOS_API: b'timestamp,UTC time,event',
IOS_API: b'timestamp,UTC time,event',
},
BLUETOOTH: {
ANDROID_API: b'timestamp,UTC time,hashed MAC,RSSI',
IOS_API: b'timestamp,UTC time,hashed MAC,RSSI', # android-only data stream
IOS_API: b'timestamp,UTC time,hashed MAC,RSSI', # android-only data stream
},
OMNIRING: {
ANDROID_API: b'timestamp,UTC time,PPG_red,PPG_IR,PPG_Green,IMU_Accel_x,IMU_Accel_y,IMU_Accel_z,IMU_Gyro_x,IMU_Gyro_y,IMU_Gyro_z,IMU_Mag_x,IMU_Mag_y,IMU_Mag_z,temperature,timestamp',
IOS_API: b'timestamp,UTC time,PPG_red,PPG_IR,PPG_Green,IMU_Accel_x,IMU_Accel_y,IMU_Accel_z,IMU_Gyro_x,IMU_Gyro_y,IMU_Gyro_z,IMU_Mag_x,IMU_Mag_y,IMU_Mag_z,temperature,timestamp',
},
CALL_LOG: {
ANDROID_API: b'timestamp,UTC time,hashed phone number,call type,duration in seconds',
IOS_API: b'timestamp,UTC time,hashed phone number,call type,duration in seconds', # android-only data stream
IOS_API: b'timestamp,UTC time,hashed phone number,call type,duration in seconds', # android-only data stream
},
DEVICEMOTION: {
ANDROID_API: b'timestamp,UTC time,roll,pitch,yaw,rotation_rate_x,rotation_rate_y,rotation_rate_z,gravity_x,gravity_y,gravity_z,user_accel_x,user_accel_y,user_accel_z,magnetic_field_calibration_accuracy,magnetic_field_x,magnetic_field_y,magnetic_field_z', # ios-only data stream
IOS_API: b'timestamp,UTC time,roll,pitch,yaw,rotation_rate_x,rotation_rate_y,rotation_rate_z,gravity_x,gravity_y,gravity_z,user_accel_x,user_accel_y,user_accel_z,magnetic_field_calibration_accuracy,magnetic_field_x,magnetic_field_y,magnetic_field_z',
ANDROID_API: b'timestamp,UTC time,roll,pitch,yaw,rotation_rate_x,rotation_rate_y,rotation_rate_z,gravity_x,gravity_y,gravity_z,user_accel_x,user_accel_y,user_accel_z,magnetic_field_calibration_accuracy,magnetic_field_x,magnetic_field_y,magnetic_field_z',
# ios-only data stream
IOS_API: b'timestamp,UTC time,roll,pitch,yaw,rotation_rate_x,rotation_rate_y,rotation_rate_z,gravity_x,gravity_y,gravity_z,user_accel_x,user_accel_y,user_accel_z,magnetic_field_calibration_accuracy,magnetic_field_x,magnetic_field_y,magnetic_field_z',
},
GPS: {
ANDROID_API: b'timestamp,UTC time,latitude,longitude,altitude,accuracy',
IOS_API: b'timestamp,UTC time,latitude,longitude,altitude,accuracy',
IOS_API: b'timestamp,UTC time,latitude,longitude,altitude,accuracy',
},
GYRO: {
ANDROID_API: b'timestamp,UTC time,accuracy,x,y,z',
IOS_API: b'timestamp,UTC time,x,y,z',
IOS_API: b'timestamp,UTC time,x,y,z',
},
IDENTIFIERS: {
ANDROID_API: b'timestamp,UTC time,patient_id,MAC,phone_number,device_id,device_os,os_version,product,brand,hardware_id,manufacturer,model,beiwe_version',
IOS_API: b'timestamp,UTC time,patient_id,MAC,phone_number,device_id,device_os,os_version,product,brand,hardware_id,manufacturer,model,beiwe_version',
IOS_API: b'timestamp,UTC time,patient_id,MAC,phone_number,device_id,device_os,os_version,product,brand,hardware_id,manufacturer,model,beiwe_version',
},
IOS_LOG_FILE: {
ANDROID_API: b'timestamp,UTC time,launchId,memory,battery,event,msg,d1,d2,d3,d4', # ios-only datastream
IOS_API: b'timestamp,UTC time,launchId,memory,battery,event,msg,d1,d2,d3,d4',
IOS_API: b'timestamp,UTC time,launchId,memory,battery,event,msg,d1,d2,d3,d4',
},
MAGNETOMETER: {
ANDROID_API: b'timestamp,UTC time,x,y,z', # ios-only datastream
IOS_API: b'timestamp,UTC time,x,y,z',
IOS_API: b'timestamp,UTC time,x,y,z',
},
POWER_STATE: {
ANDROID_API: b'timestamp,UTC time,event',
IOS_API: b'timestamp,UTC time,event,level',
IOS_API: b'timestamp,UTC time,event,level',
},
PROXIMITY: {
ANDROID_API: b'timestamp,UTC time,event', # ios-only datastream
IOS_API: b'timestamp,UTC time,event',
IOS_API: b'timestamp,UTC time,event',
},
REACHABILITY: {
ANDROID_API: b'timestamp,UTC time,event', # ios-only datastream
IOS_API: b'timestamp,UTC time,event',
IOS_API: b'timestamp,UTC time,event',
},
# SURVEY_ANSWERS: { # we don't chunk survey answers...
# ANDROID_API: b'question id,question type,question text,question answer options,answer',
# IOS_API: b'question id,question type,question text,question answer options,answer',
# },
SURVEY_TIMINGS: {
ANDROID_API: b'timestamp,UTC time,question id,survey id,question type,question text,question answer options,answer',
IOS_API: b'timestamp,UTC time,question id,survey id,question type,question text,question answer options,answer,event',
IOS_API: b'timestamp,UTC time,question id,survey id,question type,question text,question answer options,answer,event',
},
TEXTS_LOG: {
ANDROID_API: b'timestamp,UTC time,hashed phone number,sent vs received,message length,time sent',
IOS_API: b'timestamp,UTC time,hashed phone number,sent vs received,message length,time sent', # android-only datastream
IOS_API: b'timestamp,UTC time,hashed phone number,sent vs received,message length,time sent',
# android-only datastream
},
WIFI: {
ANDROID_API: b'timestamp,UTC time,hashed MAC,frequency,RSSI',
IOS_API: b'timestamp,UTC time,hashed MAC,frequency,RSSI',
IOS_API: b'timestamp,UTC time,hashed MAC,frequency,RSSI',
}
}


REFERENCE_UPLOAD_HEADERS = {
ACCELEROMETER: {
ANDROID_API: b'timestamp,accuracy,x,y,z',
IOS_API: b'timestamp,accuracy,x,y,z',
IOS_API: b'timestamp,accuracy,x,y,z',
},
ANDROID_LOG_FILE: {
ANDROID_API: b'THIS LINE IS A LOG FILE HEADER',
IOS_API: b'THIS LINE IS A LOG FILE HEADER', # android-only datastream
IOS_API: b'THIS LINE IS A LOG FILE HEADER', # android-only datastream
},
BLUETOOTH: {
ANDROID_API: b'timestamp, hashed MAC, RSSI',
IOS_API: b'timestamp, hashed MAC, RSSI', # android-only datastream
IOS_API: b'timestamp, hashed MAC, RSSI', # android-only datastream
},
OMNIRING: {
ANDROID_API: b'PPG_red,PPG_IR,PPG_Green,IMU_Accel_x,IMU_Accel_y,IMU_Accel_z,IMU_Gyro_x,IMU_Gyro_y,IMU_Gyro_z,IMU_Mag_x,IMU_Mag_y,IMU_Mag_z,temperature,timestamp',
IOS_API: b'PPG_red,PPG_IR,PPG_Green,IMU_Accel_x,IMU_Accel_y,IMU_Accel_z,IMU_Gyro_x,IMU_Gyro_y,IMU_Gyro_z,IMU_Mag_x,IMU_Mag_y,IMU_Mag_z,temperature,timestamp',
},
CALL_LOG: {
ANDROID_API: b'hashed phone number,call type,timestamp,duration in seconds',
IOS_API: b'hashed phone number,call type,timestamp,duration in seconds', # android-only datastream
IOS_API: b'hashed phone number,call type,timestamp,duration in seconds', # android-only datastream
},
DEVICEMOTION: {
ANDROID_API: b'timestamp,roll,pitch,yaw,rotation_rate_x,rotation_rate_y,rotation_rate_z,gravity_x,gravity_y,gravity_z,user_accel_x,user_accel_y,user_accel_z,magnetic_field_calibration_accuracy,magnetic_field_x,magnetic_field_y,magnetic_field_z', # ios-only datastream
IOS_API: b'timestamp,roll,pitch,yaw,rotation_rate_x,rotation_rate_y,rotation_rate_z,gravity_x,gravity_y,gravity_z,user_accel_x,user_accel_y,user_accel_z,magnetic_field_calibration_accuracy,magnetic_field_x,magnetic_field_y,magnetic_field_z',
ANDROID_API: b'timestamp,roll,pitch,yaw,rotation_rate_x,rotation_rate_y,rotation_rate_z,gravity_x,gravity_y,gravity_z,user_accel_x,user_accel_y,user_accel_z,magnetic_field_calibration_accuracy,magnetic_field_x,magnetic_field_y,magnetic_field_z',
# ios-only datastream
IOS_API: b'timestamp,roll,pitch,yaw,rotation_rate_x,rotation_rate_y,rotation_rate_z,gravity_x,gravity_y,gravity_z,user_accel_x,user_accel_y,user_accel_z,magnetic_field_calibration_accuracy,magnetic_field_x,magnetic_field_y,magnetic_field_z',
},
GPS: {
ANDROID_API: b'timestamp, latitude, longitude, altitude, accuracy',
IOS_API: b'timestamp,latitude,longitude,altitude,accuracy',
IOS_API: b'timestamp,latitude,longitude,altitude,accuracy',
},
GYRO: {
ANDROID_API: b'timestamp,accuracy,x,y,z',
IOS_API: b'timestamp,x,y,z',
IOS_API: b'timestamp,x,y,z',
},
IDENTIFIERS: {
ANDROID_API: DEVICE_IDENTIFIERS_HEADER,
IOS_API: DEVICE_IDENTIFIERS_HEADER,
},
IOS_LOG_FILE: {
ANDROID_API: b'timestamp,launchId,memory,battery,event,msg,d1,d2,d3,d4', # ios-only datastream
IOS_API: b'timestamp,launchId,memory,battery,event,msg,d1,d2,d3,d4',
IOS_API: b'timestamp,launchId,memory,battery,event,msg,d1,d2,d3,d4',
},
MAGNETOMETER: {
ANDROID_API: b'timestamp,x,y,z', # ios-only datastream
IOS_API: b'timestamp,x,y,z',
IOS_API: b'timestamp,x,y,z',
},
POWER_STATE: {
ANDROID_API: b'timestamp, event',
IOS_API: b'timestamp,event,level',
IOS_API: b'timestamp,event,level',
},
PROXIMITY: {
ANDROID_API: b'timestamp,event', # ios-only datastream
IOS_API: b'timestamp,event',
IOS_API: b'timestamp,event',
},
REACHABILITY: {
ANDROID_API: b'timestamp,event', # ios-only datastream
IOS_API: b'timestamp,event',
IOS_API: b'timestamp,event',
},
# SURVEY_ANSWERS: { # we don't chunk survey answers...
# ANDROID_API: b'question id,question type,question text,question answer options,answer',
# IOS_API: b'question id,question type,question text,question answer options,answer',
# },
SURVEY_TIMINGS: {
ANDROID_API: b'timestamp,question id,question type,question text,question answer options,answer',
IOS_API: b'timestamp,question id,question type,question text,question answer options,answer,event',
IOS_API: b'timestamp,question id,question type,question text,question answer options,answer,event',
},
TEXTS_LOG: {
ANDROID_API: b'timestamp,hashed phone number,sent vs received,message length,time sent',
IOS_API: None, # ios-only datastream
IOS_API: None, # ios-only datastream
},
WIFI: {
ANDROID_API: b'hashed MAC, frequency, RSSI',
IOS_API: b'hashed MAC, frequency, RSSI', # android-only datastream
IOS_API: b'hashed MAC, frequency, RSSI', # android-only datastream
}
}


CHUNK_EXISTS_CASE = "chunk_exists_case"
CHUNK_EXISTS_CASE = "chunk_exists_case"
11 changes: 8 additions & 3 deletions constants/data_stream_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
AMBIENT_AUDIO = "ambient_audio"
ANDROID_LOG_FILE = "app_log"
BLUETOOTH = "bluetooth"
OMNIRING = "omniring"
CALL_LOG = "calls"
DEVICEMOTION = "devicemotion"
GPS = "gps"
Expand All @@ -19,12 +20,12 @@
VOICE_RECORDING = "audio_recordings"
WIFI = "wifi"


ALL_DATA_STREAMS = [
ACCELEROMETER,
AMBIENT_AUDIO,
ANDROID_LOG_FILE,
BLUETOOTH,
OMNIRING,
CALL_LOG,
DEVICEMOTION,
GPS,
Expand All @@ -47,6 +48,7 @@
UPLOAD_FILE_TYPE_MAPPING = {
"accel": ACCELEROMETER,
"bluetoothLog": BLUETOOTH,
"omniRingLog": OMNIRING,
"callLog": CALL_LOG,
"devicemotion": DEVICEMOTION,
"gps": GPS,
Expand All @@ -73,6 +75,7 @@
DATA_STREAM_TO_S3_FILE_NAME_STRING = {
ACCELEROMETER: "accel",
BLUETOOTH: "bluetoothLog",
OMNIRING: "omniring",
CALL_LOG: "callLog",
GPS: "gps",
IDENTIFIERS: "identifiers",
Expand All @@ -95,6 +98,7 @@
CHUNKABLE_FILES = {
ACCELEROMETER,
BLUETOOTH,
OMNIRING,
CALL_LOG,
GPS,
IDENTIFIERS,
Expand All @@ -115,14 +119,14 @@
DEVICE_IDENTIFIERS_HEADER = \
"patient_id,MAC,phone_number,device_id,device_os,os_version,product,brand,hardware_id,manufacturer,model,beiwe_version\n"


## Dashboard constants

DASHBOARD_DATA_STREAMS = [
ACCELEROMETER,
AMBIENT_AUDIO,
ANDROID_LOG_FILE,
BLUETOOTH,
OMNIRING,
CALL_LOG,
DEVICEMOTION,
GPS,
Expand All @@ -145,6 +149,7 @@
AMBIENT_AUDIO: "Ambient Audio Recording (bytes)",
ANDROID_LOG_FILE: "Android Log File (bytes)",
BLUETOOTH: "Bluetooth (bytes)",
OMNIRING: "Omniring (bytes)",
CALL_LOG: "Call Log (bytes)",
DEVICEMOTION: "Device Motion (bytes)",
GPS: "GPS (bytes)",
Expand All @@ -160,4 +165,4 @@
TEXTS_LOG: "Text Log (bytes)",
VOICE_RECORDING: "Audio Recordings (bytes)",
WIFI: "Wifi (bytes)",
}
}
15 changes: 4 additions & 11 deletions constants/forest_constants.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# trunk-ignore-all(ruff/F405)

from django.db.models.fields import (BooleanField, CharField, DateField, DateTimeField, FloatField,
IntegerField, TextField)
IntegerField, TextField)

# trunk-ignore(ruff/F403)
from constants.data_stream_constants import *
from constants import DjangoDropdown

from forest.constants import Frequency


# the canonical location where any files are allocated for forest tasks.
ROOT_FOREST_TASK_PATH = "/tmp/forest/"

Expand Down Expand Up @@ -91,7 +90,6 @@ class ForestTree(DjangoDropdown):
},
}


# special tree parameters
PARAMETER_ALL_BV_SET = "all_bv_set"
PARAMETER_ALL_MEMORY_DICT = "all_memory_dict"
Expand All @@ -108,7 +106,6 @@ class ForestTree(DjangoDropdown):
PARAMETER_INTERVENTIONS_FILEPATH,
]


# documented at https://forest.beiwe.org/en/latest/#forest-trees
# Don't forget about FOREST_TREE_TO_SERIALIZABLE_FIELD_NAMES in tableau_api_constants.py
FOREST_TREE_REQUIRED_DATA_STREAMS = {
Expand All @@ -119,7 +116,6 @@ class ForestTree(DjangoDropdown):
ForestTree.willow: [CALL_LOG, TEXTS_LOG],
}


## The following dictionary is a mapping of output CSV fields from various Forest Trees to their
# summary statistic names. Note that this data structure is imported and used in tableau constants.

Expand Down Expand Up @@ -185,7 +181,6 @@ class ForestTree(DjangoDropdown):
"cadence": "oak_cadence",
}


# Metadata
SUMMARY_METADATA_FIELD_NAMES = [
"date",
Expand All @@ -204,6 +199,7 @@ class ForestTree(DjangoDropdown):
AMBIENT_AUDIO: "beiwe_ambient_audio_bytes",
ANDROID_LOG_FILE: "beiwe_app_log_bytes",
BLUETOOTH: "beiwe_bluetooth_bytes",
OMNIRING: "beiwe_omniring_bytes",
CALL_LOG: "beiwe_calls_bytes",
DEVICEMOTION: "beiwe_devicemotion_bytes",
GPS: "beiwe_gps_bytes",
Expand Down Expand Up @@ -252,7 +248,6 @@ class ForestTree(DjangoDropdown):
name.replace("jasmine_", "").replace("_", " ").title() for name in JASMINE_FIELDS
]


WILLOW_FIELDS = [
# Willow, Texts
"willow_incoming_text_count",
Expand Down Expand Up @@ -308,12 +303,11 @@ class ForestTree(DjangoDropdown):
]

SERIALIZABLE_FIELD_NAMES = SUMMARY_METADATA_FIELD_NAMES + DATA_QUANTITY_FIELD_NAMES \
+ JASMINE_FIELDS + WILLOW_FIELDS + SYCAMORE_FIELDS + OAK_FIELDS
+ JASMINE_FIELDS + WILLOW_FIELDS + SYCAMORE_FIELDS + OAK_FIELDS

# SERIALIZABLE_FIELD_NAMES.extend(TREE_COLUMN_NAMES_TO_SUMMARY_STATISTICS.values())
NICE_SERIALIZABLE_FIELD_NAMES = NICE_SUMMARY_METADATA_FIELD_NAMES + NICE_BEIWE_DATA_QUANTITY_FIELD_NAMES \
+ NICE_JASMINE_FIELDS + NICE_WILLOW_FIELDS + NICE_SYCAMORE_FIELDS + NICE_OAK_FIELDS

+ NICE_JASMINE_FIELDS + NICE_WILLOW_FIELDS + NICE_SYCAMORE_FIELDS + NICE_OAK_FIELDS

FOREST_TREE_TO_SERIALIZABLE_FIELD_NAMES = {
ForestTree.jasmine: JASMINE_FIELDS,
Expand All @@ -322,7 +316,6 @@ class ForestTree(DjangoDropdown):
ForestTree.oak: OAK_FIELDS,
}


SERIALIZABLE_FIELD_NAMES_DROPDOWN = [(f, f) for f in SERIALIZABLE_FIELD_NAMES]

VALID_QUERY_PARAMETERS = [
Expand Down
4 changes: 3 additions & 1 deletion constants/study_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"texts",
"wifi",
"bluetooth",
"omniring",
"power_state",
"proximity",
"gyro",
Expand All @@ -80,6 +81,8 @@
"bluetooth_on_duration_seconds",
"bluetooth_total_duration_seconds",
"bluetooth_global_offset_seconds",
"omniring_off_duration_seconds",
"omniring_on_duration_seconds",
"check_for_new_surveys_frequency_seconds",
"create_new_data_files_frequency_seconds",
"gps_off_duration_seconds",
Expand All @@ -97,7 +100,6 @@
"heartbeat_timer_minutes",
]


# Surveys have several types of questions and some special symbols

# Survey Question Types
Expand Down
Loading