-
Notifications
You must be signed in to change notification settings - Fork 4
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
Spike: Classify sleep windows as non-wear or sleep #106
Comments
No rush on this but just some thoughts I had as we go through the Kaggle comp implementation. Since our current sleep detection is actually pretty good, the more time-sensitive, simple question is separating non-wear time from it. |
If the goal is not to mimick GGIR, I think conceptually non-wear should be regarded as missing data and (if necessary) either imputed or processed by a model that can handle missing data. |
I also realize this falls more in the "analysis" branch and not really "wristpy for processing actigraphy data" |
I should start looking into using the capsense data and see how we can take advantage of that. |
I agree that the capsense/temperature data would be very useful for distinguishing non-wear from sleep. Otherwise, I agree the two seem hard to distinguish. I think the ideal approach would be a model/algorithm that takes as input all available raw data, and produces separate predictions for sleep and non-wear. Any pre-processing/feature-engineering/heuristics would be internal to the model. Ofc, it is also fine to have simple heuristics for detecting non-wear/sleep that work fine in most cases. But I would discourage having any of these be upstream of a sleep detection model. Anything you do upstream of the model removes information and limits the model's performance. In particular, I would discourage trying to detect and code non-wear as missing/NaN before feeding to a sleep detection model. I agree with @nx10 that non-wear is fundamentally missing data. I just think it should be the model's job to detect it. |
Just to clarify: non-wear and sleep are currently completely separate algorithms (see Basically the point of my thought process is essentially a second stage that would try to filter out false-positives. But I agree an all-encompassing model would be better. This is almost more of a stop gap idea that I thought is both easier and quicker to implement while we wait for something more robust/nicer. Does that help clarify a bit? I guess this was better for a meeting and not a forum discussion ha |
Reclassified to spike, time-boxed to 3 days. |
UPDATE: After the agreed 3 days these are my current thoughts:
I have created methods to move SleepWindow to a Measurement, which allows us to easily remove the non-wear overlap and then remove any short sleep windows that may be left over (less than 15min). This functionality can be called in the future after we have improved non-wear detection/ after the non-wear classification project, it is in this branch. I will leave this task up in case there is a further desire to investigate using other features to re-classify sleep, but at the moment I do not see the benefit. Improved non-wear detection and, potentially, improved sleep detection would solve all these issue without adding a second classification stage. |
@vitoetc This issue is blocked until annotated data exists. |
Description
Currently, the detection of sleep will also serve as non-wear detection (most non-wear periods will also be detected as sleep, as from an accelerometer point of view they are the same, the inverse is of course-not true, not all sleep periods are detected as non-wear). The current implementation of the Van Hees algorithm for sleep only relies on angle-z (looking the changes in the rolling std of angle-z metric, essentially). As a solution to separate sleep windows from non-wear times, a simple filtering method has been implemented in
analytics.remove_nonwear_from_sleep
.However, what if we were to apply some simple classification looking at a few features of both enmo and angle-z during a defined sleep window. Notably:
Some examples highlighting the differences between sleep and non-wear are shown below (blue indicates sleep, red enmo, green anglez, black non-wear)
This is an especially difficult case, non-wear immediately before bed with only a very short window of activity separating the two. Merged into one sleep window (but it has two distinct sleep periods, SIBs) since the activity time is less than the threshold.
![Screenshot 2024-09-18 at 12 29 04 PM](https://private-user-images.githubusercontent.com/148909356/368660205-dce49960-f60d-42f3-8534-1fe13deba8a4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDQ4MzAsIm5iZiI6MTczODk0NDUzMCwicGF0aCI6Ii8xNDg5MDkzNTYvMzY4NjYwMjA1LWRjZTQ5OTYwLWY2MGQtNDJmMy04NTM0LTFmZTEzZGViYThhNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxNjA4NTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xYTVmNWIwOTljMzhiMTY4Y2FkOWEyYzBmZWZjMGM1NzIxNWZkNzNhOWFkNTFjZjgxNmRhODk2MGRiZWRlYWE2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.vKlCUrFd6B5mJ5EvlJoDIkzb-6XzARUhEZgdwCGwI_M)
Tasks
Freeform Notes
No response
The text was updated successfully, but these errors were encountered: