Algorithm for Eating Detection

The eating detection mechanism is contained in the Eating Detector class of the Python module Eating Detector. This class is responsible for detecting the eating activity of the patient in the home A change in state is required of all the sensors in the system configured for eating detection in order for the system to detect an eating pattern. The resultant detection of an eating pattern is simply a high probability that the patient is eating. As there is no mechanism in place to detect the activity of eating itself, it is not

Figure 1: Flowchart of the algorithm used by the eating detection mechanism.

Figure 1: Flowchart of the algorithm used by the eating detection mechanism.

 

a certainty. The system detects activity that commonly leads to eating, and thus can only infer that the patient has eaten. Figure1 shows a flowchart depicting the eating detection algorithm.Upon instantiation of an Eating Detector object the constructor builds a list of sensors that are configured for the eating detection mechanism in the system. These are any records in the sensor table that have a reference to the string “eating detection” in the mechanism column of the table. This list of sensors is retrieved via a method of the DBManager object instantiated by the class’s constructor. A Sensor object is instantiated and its members populated with the results of this query and inserted into a Python data structure called the dict (short for dictionary). In Python, a dict is a hash map that can store any hashable value with a key of any hashable value.

Run algoritm with Python

Here, the key in the Python dict is the primary key of the sensor and the stored value is the created Sensor object. The constructor then determines the appropriate time from after which to pull sensor data. The user must enter this time in a pre-specified format if the user desires to use data previously captured by the system. Otherwise, the system will use the current UTC time for this purpose, making only live data subject to the eating detection mechanism. A Patient object is instantiated and used to store this time. The time value is updated every time a “detected change” in sensor state is retrieved from the database. Before performing any eating detection the sensor values of interest must be extracted from the sensor_state table in the database. This table contains the states of all sensors connected to a sensor node when a transmission is received, regardless of which sensor triggered the transmission. The system must first filter out the data that is not of interest. These are sensor states that have not changed value from the last-known state. These changes are detected by an aptlynamed method of the class: detectChanges(). These “detected changes” are then called an “activity” and are recorded in the activity database table. To detect the sensor activities, the detectChanges() method must first determine the calibration value for the analog sensors in the system, which are the force sensors used to detect the patient’s retrieval of prepared food and placement of the food at the eating location. The calibration value for the analog sensors is simply the first sensor state it detects for a given analog sensor. Ideally, the environment would be first set up and then the system activated, causing this initial environment state to be recorded as the calibration value. The calibration value for digital sensors is the value of the sensor in a resting state, a value that is static and known for each digital sensor type. For the door sensors used on the refrigerator door and the silverware drawer this value is a digital 0. Knowing the calibration value the method then iterates through the dict of previously-initialized Sensor objects and retrieves from the database a list of all recorded sensor states for that sensor ID. For each sensor state the system determines if a change has occurred

two conditions for this algoritm

  1. The time delta between two consecutive sensor changes is no greater than 5 min.
    2. A change has been detected in all configured eating detection sensors in the system.
    • For digital door sensors, the sensor status has changed from the calibration value to
    the inverse of the calibration value.
    • For analog force sensors, the sensor status has changed by 51 from the last-known
    value.

 

http://scholarcommons.usf.edu/etd/5546/