raphaelvallat/yasa

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

nabilalibou opened this issue ยท 4 comments

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 ?

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."

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 ?

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 ๐Ÿ‘

Indeed, but feel free to submit a PR to replace the assertion by a warning ๐Ÿ‘

Will do!