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

new sleep disturbance event #1861

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

new sleep disturbance event #1861

wants to merge 10 commits into from

Conversation

jarred-h
Copy link
Contributor

New event to label possible wake events during sleep based on heuristic classifier.
https://hello.hackpad.com/Sleep-Disturbance-Event-igLaLwPeAqE

  • added sleep disturbance event
  • added sleep_disturbance heuristic
  • added FF for new event

@@ -18,7 +18,8 @@
GOT_OUT_OF_BED(13),
WOKE_UP(14),
ALARM_RANG(15),
UNKNOWN(16);
SLEEP_DISTURBANCE(16),
UNKNOWN(17);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't change the enum values if you can avoid it.

@@ -28,9 +28,11 @@
public final static String ALARM_NOT_SO_SMART_MESSAGE = "Your Smart Alarm rang at **%s**.";
public final static String ALARM_SMART_MESSAGE = "Your Smart Alarm rang at **%s**.\nYou set it to wake you up by **%s**.";
public final static String NOISE_MESSAGE = "There was a noise disturbance.";
public final static String SLEEP_DISTURBANCE_MESSAGE = "Your sleep was interrupted.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this been approved by product/copy/james?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked it with copy/product. Consulting with Matt Walker following James' advices

}

//Finds intances where the pill recorded 15seconds + of motion within a 4 minute window
public HashMap<Long, Long> getSleepDisturbances(final List<TrackerMotion> trackerMotions){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Map<Long, Long> instead of the more specific HashMap

long previousMotionTS = 0L;

List<TrackerMotion> trackerMotionWindowCurrent = new ArrayList<>();
final HashMap<Long,Integer> sleepDisturbances = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


currentDisturbanceEndTS = currentTS;
int onDurationSum = trackerMotionCurrent.onDurationInSeconds.intValue();
if (!trackerMotionWindowPrevious.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that some of this would benefit from being refactored. It's a little too much of twisted logic to be easily readable.

@jarred-h jarred-h changed the title new sleep disturbance event WIP new sleep disturbance event Feb 10, 2017
@@ -161,7 +163,11 @@ public Integer categorizeSleepDepth(final Integer sleepDepth) {
return positiveMotions;
}

public List<MotionEvent> generateMotionEvents(final List<TrackerMotion> trackerMotions) {
public List<MotionEvent> generateMotionEvents(final List<TrackerMotion> trackerMotions, final boolean hasSleepDisturbance) {
int minSleepDepth = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put comments about why min sleep depth is added

@@ -476,6 +482,37 @@ public Integer getMaxSVM(final List<TrackerMotion> amplitudes){
return result;
}

public List<Event> cleanEventWindow(final List<Event> eventList){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments for what this does and why it's here

@@ -1457,6 +1492,109 @@ public Insight generateInSleepSoundInsight(final int soundEventCount) {
return events;
}

public List<Event> getSleepDisturbanceEvents(final OneDaysTrackerMotion oneDaysTrackerMotion, final Long sleepTime, final Long wakeTime, final TimeZoneOffsetMap timeZoneOffsetMap){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe algo briefly in comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants