/ee4-mhml

Imperial College EEE 4th Year MHML

Primary LanguageSwift

Sleepify logo

ee4-mhml (2016-2017) Coursework

Final Report

Link to website

Promotional Video

Presentation


Abstract

Given the rapid adoption of smartphones, mobile healthcare is an area which deals with acquiring, transporting, storing, processing and securing data from sensors or the phone to improve the health of a user. This project aims to investigate the relationship between room temperature and human sleeping quality by developing a mobile healthcare system to improve sleeping quality based on the current body and room temperature of the user. Sleepify utilizes advanced machine learning techniques to classify the user’s sleep quality; this data is then fed to HomeKit compatible devices to control the heating of the user during their sleep. Both an app and web interface are offered. Initial testing and evaluation show positive feedback.


Usage

  1. Clone the github repository using git clone https://github.com/jeremych1000/ee4-mhml
  2. Download the Sleepify App from <not available at the moment on the app store> or compile it yourself.
  3. OPTIONAL: Create a user account using http://sleepify.zapto.org/accounts/signup/

This can be done later using the mobile app too.


API Reference

All API links should be pre-pended with http://sleepify.zapto.org/api/. POST requests should have a CSRF token in the header/cookies to prevent Cross Site Request Forgery.

Link Available Methods Description Notes
/csrf/ GET Returns a CSRF token in the cookies for use when POSTing.
/auth/registration/ POST Register a new user.
  • username
  • email
  • password1
  • password2
/auth/login/ POST Login a user.
  • username
  • email
  • password
Returns token key.
/auth/logout/ POST Logout a user.
/auth/password/reset/ POST Reset a forgotten password.
  • email
/auth/user/ GET, PUT, PATCH Edit user details.
  • username
  • first_name
  • last_name
/raw_data/ POST Send raw sensor data to the database.
  • username
  • data
    • timestamp
    • HR
    • RR
    • GSR
    • mode
    • AccX
    • AccY
    • AccZ
/stats/last/<number_of_days>/feature/ GET Returns a JSON object of the logged in user's raw data for the past X days.
/stats/last/<number_of_days>/feature/graph/ GET Returns a 640x480 graph plotted by matplotlib
/stats/from/<timestamp>/to/<timestamp>/feature/ GET Returns a JSON object of the logged in user's raw data from timestamp to timestamp.
/make_default/ GET Make a default user model. For development.
/migrate_feature/ GET Put raw data in CSV files to database. For development.
/get_cal_events/ GET Get a list of calendar events for the logged in user for the next day.
/import_cal_events/ GET Import the logged in user's calendar into the database. Calling this URL will update the database, deleting all previous entries of the user's events.
/dummy/ POST Show whatever you have sent in the POST request. For debugging purposes.

Development

You are welcome to clone the repository and develop Sleepify yourself. Please give credit where credit is due.

Web server

Sleepify runs at the following URL: http://sleepify.zapto.org. However, this is dependent on the host. If you want to develop Sleepify locally, or run Sleepify using your own web server, follow these instructions.

  1. Assuming you already have cloned the repository, install the required libraries using

Windows ee4-mhml/software/web_interface/get_pip_stuff.cmd

UNIX ee4-mhml/software/web_interface/get_pip_stuff.sh

  1. Decide on a port to run the webserver on, and forward that port to your hosting server/PC. Detailed instructions depending on your router can be found here.

HTTP server default: 80

Django development server default: 8000

  1. Setup the Django databases using python manage.py makemigrations; python manage.py migrate
  2. Run the webserver with the following command: python manage.py runserver 0.0.0.0:80 and verify that the server is running by visiting http://<your-ip>/, http://localhost:80/, or http://127.0.0.1:80/.

To run the server just locally, python manage.py runserver localhost:8000 or python manage.py runserver 127.0.0.1:8000.

Replace 8000 with whatever port you have forwarded.

iOS Application

At the moment, the application development is still at a provisional stage where the mobile application is only tested by a few specific users of specific iOS devices. In order for it to be available on the App Store for distrubtion., the app has to be submitted for publication to the App Store. This involves review process by Apple to insure the app meets their guidelines for quality and content.

In order to try out our app as a beta user, we would need to download the app directly to your iOS devices, this involves us connecting your devices to our Macs.

To develop it yourself, follow these instructions (macOS only):

  1. Assuming you have cloned the repository, install Cocoapods using sudo gem install cocoapods
  2. Go to the app folder, ee4-mhml/software/mhml_withbackground/, and run pod install. It should automatically pick out the Podfile inside the app folder and install the required dependencies.
  3. Open the workspace using XCode, not the project - mhml.xcworkspace

Development

You are welcome to issue pull requests, the Sleepify team will be on hand to deal with that, alongside issues. We aim to provide a response within 7 working days.