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

Possibility of detect the sleep stages on less than 5min of data #158

Closed
nabilalibou opened this issue Feb 5, 2024 · 4 comments · Fixed by #160
Closed

Possibility of detect the sleep stages on less than 5min of data #158

nabilalibou opened this issue Feb 5, 2024 · 4 comments · Fixed by #160

Comments

@nabilalibou
Copy link
Contributor

Hello,

I am using the automatic sleep staging module to detect sleeping subjects on 5 minutes of data (i know the model has been trained on long night sleep but the accuracy looks good enough in my case) but sometimes because of some cropping I have subjects with 4min58 of data and so they are left out.

Is there a reason why SleepStaging() cannot be instantiated on raw instance containing less than 5 minutes of data ?

I was wondering if it was possible to turn the 'not enough data' error into a warning but maybe there are technical issues (for example some smoothing windows with an hardcoded minimum length etc) that would make the possibility tedious to enable ?

@raphaelvallat
Copy link
Owner

Hi @nabilalibou,

Your intuition was right: the main reason for such a duration threshold is that YASA uses 7:30 min smoothing windows. I don't think we want to completely disable this duration threshold in YASA, but you can manually do it by to cloning YASA, installing it from the source (python setup.py develop) and then disabling this line:

assert duration_minutes >= 5, "At least 5 minutes of data is required."

@nabilalibou
Copy link
Contributor Author

Ok so removing the assertion allows yasa to function without any other errors on <5min data even if there is a 7:30 min smoothing windows that will be applied ?

Thx for the tips but I admit that if the only blocker is the assertion, I'd be very happy if this was replaced by a warning so that I can use the source version of yasa directly on data less than 5 minutes old 😁.
Is it a matter of restricting yasa scope to long night of sleep because you're really not sure about the model's performance on nap data ?

@raphaelvallat
Copy link
Owner

Ok so removing the assertion allows yasa to function without any other errors on <5min data even if there is a 7:30 min smoothing windows that will be applied ?

I actually have never tried it so I don't know, but I think most likely yes, although the output might be unreliable.

Is it a matter of restricting yasa scope to long night of sleep because you're really not sure about the model's performance on nap data ?

Indeed, but feel free to submit a PR to replace the assertion by a warning 👍

@nabilalibou
Copy link
Contributor Author

nabilalibou commented Feb 7, 2024

Indeed, but feel free to submit a PR to replace the assertion by a warning 👍

Will do!

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 a pull request may close this issue.

2 participants