350 likes | 373 Views
Automated Sleep Tracking. using Wearable, Mobile Phone Coupled Sensors. Dr Amos Folarin. BBC Horizon: Monitor Me Blaine price, Open Uni, Gadgets Eric Topol http://vimeo.com/72575830. Preamble. Mobile Physiological Monitoring.
E N D
Automated Sleep Tracking using Wearable, Mobile Phone Coupled Sensors Dr Amos Folarin
BBC Horizon: Monitor Me Blaine price, Open Uni, Gadgets Eric Topol http://vimeo.com/72575830 Preamble... Mobile Physiological Monitoring • Sleep tracking is clinically useful for a range of Mental Health disorders • Clinical activity monitoring devices (e.g. Actiwatch) • expensive and have limited numbers of sensors, manual data offload, technology largely behind the curve • Consumer activity monitoring devices (e.g. Fitbit, Jawbone) • cheap, wireless data offload, shorter battery life • Mobile phones • wide range of sensors • Mobile Phone linked wearable monitors could be used for: • self-monitoring • measuring response to treatment/adverse drug reactions • triggering intervention • stratifying patients e.g. clinical trials ihealthlabs.com
Schizophrenia Relapse • Schizophrenia is a severe, chronic, relapsing condition • Mainly managed in the community • Prompt intervention required to avoid lengthy hospital admissions • Est. annual costs £3.9 billion to the NHS1 • Sleep dysregulation is widely recognised early sign of relapse in psychosis (often in hindsight) so monitoring of sleep-wake activity shows promise as an early relapse marker
Aims - Quantify Sleep Manual sleep logging is hard to do accurately and sustain!! • delay between sleep log and actual sleep • forgetting to log on/off • burdensome Goals: • Automate prediction of sleep and wake states to improve utility of clinical applications • "wear-and-forget" • Measure sleep quantity (duration) & quality (restless, interruption) • Create a flexible software platform for: • building use case specific mobile apps • integrating newly available monitors • processing and reporting data
Activity phases high activity, dynamic location low activity, static location low activity, static location inactive, static location Moving or Active Work Sedentary Work Restless Zzzzz... Hard to differentiate purely based on activity
Devices GALAXY S4 sensors - GPS location - Accelerometer - Gyroscope - Steps - Barometer - Proximity - Humidity - Temperature - Light Fitbit Accelerometer - Steps - Activity types [light, fair, very] - Sedentary - Sleep start/end [manual marked] - Sleep Quality [restless, awake] Has a mature API for programmatic data access! Fitibit Site http://www.fitbit.com/uk Fitbit API https://www.fitbit.com/dev/dev Fitbit Wiki https://wiki.fitbit.com/display/API/Fitbit+API PR App: https://play.google.com/store/apps/details?id=edu.northwestern.cbits.purple_robot_manager Purple Robot Docs. http://tech.cbits.northwestern.edu/2013/10/purple-robot-importer-purple-robot-warehouse/
Fitbit Data Catalogue (Accelerometer Probe) Fitbit "always worn" ⇒ continuous measure of activity vs. patchy phone accelerometer
Purple Robot Probes Catalogue probes provided with purple robot are quite diverse (phone dependant). e.g. LocationProbe table includes these columns: id, timestamp, eventDateTime, insertedTime, ACCURACY, GPS_AVAILABLE, GUID, LATITUDE, LONGITUDE, NETWORK_AVAILABLE, PROVIDER, TIMESTAMP, TIME_FIX, ALTITUDE, BEARING, SPEED, CLUSTER With all probes 'on', a GS4 handset would generate > 1GB /day
Fitbit Server Purple Robot Warehouse Process, Sleep Classifier, Reports, Dashboard OAuth ingest Android Phone Purple Robot App Fitbit Device Fitbit App <configures> SLaM Sleep App config.scm Fitbit data flow Purple Robot data flow
Purple Robot (PRI/PRW) Data Flow Analysis & Visualization SQL query R, MATLAB, SAS, Dashboard, Custom App etc cache Purple Robot App emit Sample Set (JSON) Purple Warehouse (PostgreSQL) Purple Robot Importer one postgres database per user id-hash SQL ingest
PR App Dev Framework Framework: • Mobile App development tools (PhoneGap) • "talk to" PR app, e.g modify probe config. • Probe (i.e. sensor) interface mechanisms Trigger an Action e.g. questionnaire • Date -- fire at preselected intervals (specified in standard iCalendar format) • Sensors -- fire on matching predefined pattern (or learned model)
SLaM Sleep App northwestern.edu Purple Robot Warehouse for current testing Future core.brc.iop.kcl.ac.uk Purple Robot Warehouse even packaged into an Amazon EC2 AMI image https://github.com/KHP-Informatics/slam_sleep_test
Toy Dataset • From two group members, ~1 month • Data was collected using Purple Robot and the Fitbit • Manually log each night start of sleep and end of sleep • Attempt to see if we can classify the manually marked sleep state.
Fitbit a 24hr slice Sleep Start (manual) Awake Start (manual)
PR → R 1. sort by timestamp 2. timestamp → as.POSIXct date Purple Robot Warehouse RPostgreSQL Sensor Table dataframes Sensor Table dataframes 3. merge on "timestamp", "event_Date" Machine Learning Classification etc... merged Sensor Table dataframes interpolated Sensor Table timeseries 4. zoo package na.approx for interpolation (handy time series object too) 5. runmed for median filter (?) https://github.com/KHP-Informatics/slam_sleep_r
Pre-processing • Epoch alignment each table • Only fitbit and location probe for now • JOIN tables on timestamp • Interpolation • Probes not synchronised, so interpolation required • However, interpolation may smudge boundaries of SLEEP_MEASUREMENTS_DT_DURATION (our sleep log) • Wake|sleep state overrun • stripped out with heuristic filter
Sleep Log Variable • Double tap on fitbit to log sleep start & end • SLEEP_MEASUREMENTS_DT_DURATION (total millisecs) for last sleep period (0 or >>0) • k-means, cluster into 2 classes sleep=0, wake=1
SleepWake sedentary mins lightly active mins moderate active mins highly active mins Latitude Speed
GPS ?
Data: Data from 2 group members wearing fitbits and galaxy S4 + purple robot app upto ~1 month of data in each case Subset of probe data used (fitbit and location) Analysis Goals: • Construct a predictor that classifies sleep or wake states, based on the range of signals collected • automate est. of duration of sleep • Look at the quality of sleep measures (restlessness, interruptions)
Sleep-Wake classifier n = random 10,000 timepoints from person 1 classifier <- train(x,y,'nb', trControl=trainControl(method='cv', number=10)) Resampling: Cross-Validation (10 fold) Resampling results across tuning parameters: usekernel Accuracy Kappa Accuracy SD Kappa SD FALSE 0.833 0.658 0.00984 0.0202 TRUE 0.958 0.915 0.0069 0.0141 n = random 2,000 timepoints from person 2 classifier <- train(x,y,'nb', trControl=trainControl(method='cv', number=10)) Resampling: Cross-Validation (10 fold) Resampling results across tuning parameters: usekernel Accuracy Kappa Accuracy SD Kappa SD FALSE 0.819 0.627 0.0249 0.0501 TRUE 0.932 0.848 0.0244 0.0544
sleep-wake classification Actual Predicted person 1 person 2
Some Early Thoughts • Improve classifier • move beyond a toy training dataset • errors clustered around Sleep-Wake boundary • problem with sleep log accuracy or interpolation effect? • Can probably improve by considering a time-series window rather than instantaneous classification • GPS data can periodically be noisy -- why? • location of sleeping typically constrained geographically so quite useful • look at GPS "accuracy" metric provided in LocationProbe table • changed GPS sensor from: moderate → high accuracy (gps + wi-fi + mobile-network) • Incorporate other sensor values
Next Steps other devices and signals
Basis Monitor: advanced sleep analysis New monitors now regularly appearing on market - heartrate - skin temperature - perspiration - actigraphy → Automated sleep classification → REM, Light, Deep, interruption however Basis does not have a Formal API….at the moment anyway "Advanced Sleep Analysis" http://www.mybasis.com/
a Portable Sleep Lab? Polysomnography Traces
Basis vs Polysomnography correlation (r = 0.92) Light Deep REM http://www.mybasis.com/wp-content/uploads/2014/04/Validation-of-Basis-Science-Advanced-Sleep-Analysis.pdf http://www.huffingtonpost.com/dr-christopher-winter/sleep-tips_b_4792760.html
Schizophrenia Relapse and Sleep We now want to properly test some Mobile Monitor use cases: 1) First, some feasibility and validation studies • Will patients wear these things..? • Validate against current gold standards (actiwatch, polysomnography) 2) Clinical utility • Clinical detection of relapse based on sleep monitoring • Monitoring in the community • Patient self-monitoring • Targeted intervention for clinical teams
Clinical Dr Nick Meyer Prof. Till Wykes Prof. James MacCabe Acknowledgmentshttp://core.brc.iop.kcl.ac.uk Informatics App Development Dr Stephen NewhouseDr Caroline JohnstonDr Zina Ibrahim Dr Richard J Dobson Mark Begale Christopher Karr Prof. David Mohr Center for Behavioural Intervention Technologies CBITs
References [1] Andrews A, ; Knapp, M.; McCrone, P.; Parsonage, M.; Tractenberg, M. Effective interventions in schizophrenia the economic case: A report prepared for the Schizophrenia Commission. London: Rethink Mental Illness, 2012.