Code: Difference between revisions
Line 21: | Line 21: | ||
== explanation MATLAB-scripts == | == explanation MATLAB-scripts == | ||
For the processing of data and determining the ideal moment to wake up the user MATLAB is used. Three scripts were created. The first script, | For the processing of data and determining the ideal moment to wake up the user MATLAB is used. Three scripts were created. The first script, runscript.m, is used for determining when to call the other two scripts and contains all the alarm-clock settings. Every four minutes, the second script is called, based on its return value, the user is awakend or MATLAB waits another four minutes and tries again. | ||
The second script calculates when it's time to wake up the user. It starts with importing recorded data and fixing bad samples, then the respiration frequency is calculated. Finally, the script checks whether it's time to wake up the user and returns this as a boolean value. | The second script calculates when it's time to wake up the user. It starts with importing recorded data and fixing bad samples, then the respiration frequency is calculated. Finally, the script checks whether it's time to wake up the user and returns this as a boolean value. | ||
Line 27: | Line 27: | ||
The third and last script contains the wake up cycle. From this script, a sound is played with increasing volume and the LED's on the Arduino are controlled. | The third and last script contains the wake up cycle. From this script, a sound is played with increasing volume and the LED's on the Arduino are controlled. | ||
runscript.m |
Revision as of 15:39, 31 March 2016
Back to main page: PRE2015_3_Groep4
To the input: Input
To the output: Output
to the experiments: Experiments
Determining moment of waking up
From our measurements we got information about respiration during your sleep. Out of this information, we get a global line of of your sleepphase throughout the night. Out of these line, we have to determine what's the best moment to wake someone between a given interval. The best moment to wake someone is just after the REM-sleep. So this is the first or second nREM-sleep stage. (see literature, add reference).
In our algorithm we have developed two methods which can determine at which moment the app should wake you. The first method is looking at the slope of the line. During REM-sleep, the respiration frequency is at its highest. So we can detect the end of the REM-phase with a drop in frequency. Another method is looking at the current frequency relative to the mean frequency of the night. With this method, we can detect a 'good' moment, i.e. when the frequency is below the mean of the past night. But the mean is probably too low, so we have to increase the value with a small factor of the variation.
However, during the REM-sleep, the respiration frequency varies a lot (see literature, add reference), so we need to be sure that a decline, or a value below the mean, is really the end of the REM-sleep and not just a variation during the REM-sleep. This can be done by looking for two or three consecutive decreasing frames. (two/three frames is around 8/12 minutes).
In the coming days, we will test both methods before we choose the best one. Another option is to combine the two methods. So we could call it a good moment of waking up when the line is declining and below the frequency threshold.
For the complete matlab-script and more information about the output-form look at the Experiments page.
explanation MATLAB-scripts
For the processing of data and determining the ideal moment to wake up the user MATLAB is used. Three scripts were created. The first script, runscript.m, is used for determining when to call the other two scripts and contains all the alarm-clock settings. Every four minutes, the second script is called, based on its return value, the user is awakend or MATLAB waits another four minutes and tries again.
The second script calculates when it's time to wake up the user. It starts with importing recorded data and fixing bad samples, then the respiration frequency is calculated. Finally, the script checks whether it's time to wake up the user and returns this as a boolean value.
The third and last script contains the wake up cycle. From this script, a sound is played with increasing volume and the LED's on the Arduino are controlled.
runscript.m