Stanford-STAGES / stanford-stages

Automated sleep staging scoring and narcolepsy identification
76 stars 26 forks source link

Exploring shorter epoch lengths #18

Closed Mensen closed 4 years ago

Mensen commented 4 years ago

According the accompanying peer-reviewed paper, your team tried several different lengths of scoring window and found that 15s was generally optimal.

Our team does sleep scoring a little differently with flexible epoch lengths. So we were very keen on trying the algorithm with shorter windows of 5 seconds to see whether this would matchup well with our "continuous" scoring approach.

I couldn't find a place in the code that indicated these 15 seconds... would you be able to indicate what part of the code I might be able to edit in order to deliver shorter 5 second epochs?

Thanks for any info!

informaton commented 4 years ago

Hi Mensen. Yes, this is correct. The issue of epoch lengths in the code and where to examine them is discussed in issue #8 (Query Epoching Process). Can you let me know if that resolves your question still? Essentially, you can adjust the segment size there which in turn determines the scoring window. However, the models we have included here are only trained for 15 s epochs. If you have other models, this may work well.

Mensen commented 4 years ago

So to confirm... I could change the segment size from the "60" value you explained in issue #8 ... to "20" to get the output in 5s windows... (I couldn't find a single "segment_size" variable to change though so it seems I would need to play around with multiple sections of code)...

But even if I did do that, I shouldn't expect good results because the currently available models are built for 15 seconds... and I would need to re-train some models to get a more accurate measure for 5 second windows... which I can't really do since I don't have the 1000s of recordings for a good re-training.

Just let me know if all that is correctly understood, and we can close the topic.

informaton commented 4 years ago

That is a good summary. My apologies on the "segment_size" reference, it seems that the actual variable name (at least now) is segsize. You can adjust this by editing the inf_config.py file's __init__ method of the ACConfig class. The variable you want to change is segsize in the location here:

        if model_name[6:8] == 'ls':
            segsize = 60

The segsize variable refers to the epoch duration produced, it is the number of 0.25 s segments that are grouped together in determining the likelihood of the different sleep stages within that time period (i.e. 15 s epochs here). This could be changed to "20" for 5s output windows, like you stated.

I have not examined how close the results are this way to the 15s output windows the models were trained with, but this is something that could be looked into (i.e. by a motivated individual or group). Unfortunately, I am not able to retrain the models for 5s output windows at this point.

Mensen commented 4 years ago

No problem at all. At the moment this is something we're also just exploring and it may not work out from our end.

Thanks for the help!