M., Hirshkowitz, M., Kapen, S., Keenan, S. The AASM manual for the scoring of sleep andĪssociated events: rules, terminology and technical specifications. TST is calculated as the sum of all REM and NREM sleep in SPT. * Sleep stages amount and proportion of TSTĪrtefact and Unscored epochs are excluded from the calculation of the * Sleep Fragmentation Index: number of transitions from sleep to wake / hours of TST * Sleep Maintenance Efficiency (SME): TST / SPT * 100 (%). * Sleep Efficiency (SE): TST / TIB * 100 (%). * REM latency: latency to first REM sleep. * SOL 5min: Latency to 5 minutes of persistent sleep (any stage). * Sleep Onset Latency (SOL): Latency to first epoch of any sleep. * Total Sleep Time (TST): total sleep duration in SPT. * Wake After Sleep Onset (WASO): duration of wake periods within SPT. * Sleep Period Time (SPT): duration from first to last period of sleep. * Time in Bed (TIB): total duration of the hypnogram. YASA follows the AASM guidelines to calculate these parameters: "lights out" to "lights on").Īll values except SE, SME, SFI and the percentage of each stage are expressed in minutes. Hypnogram, assumed to be already cropped to time in bed (TIB, also referred to as mapping_int)Ĭompute standard sleep statistics from an hypnogram. astype( int)Ĭounts, probs = transition_matrix( self. Series))Īssert isinstance( start, ( type( None), str, pd. """Main class for manipulation of hypnogram in YASA.""" def _init_( self, values, n_stages = 5, *, freq = "30s", start = None):Īssert isinstance( values, ( list, np. If you want to wait, we can leave it sitting there until the Hypnogram class is ready. Actually I was thinking about submitting that PR some time this coming week, so maybe the simplest course of action would be for me to go ahead and submit that PR, then you can see it in more detail and decide whether you think we should wait for the Hypnogram class to merge it or not. If so, the evaluation stuff could merge soon and then just get modified whenever the Hypnogram class happens. So again it probably comes down to whether you are okay with the n_stages implementation having a temporary presence. It's minimal, but still maybe less than ideal. That was almost the only reason I needed to modify a few existing functions (eg, sleep_statistics). Plus I was nervous that n_stages was starting to spread too far into the rest of the codebase anyways. So waiting to implement it wouldn't solve any work burden, but you might want to wait just to avoid having n_stages in a few new places only to be removed shortly after. Well I have it all working at this point (w/ the n_stages argument scattered in a few places). Also the EpochByEpoch evaluation class I'm working on for the same PR could eventually be switch to something like hypno.evaluate_against(hypno). ![]() This hypnogram class would be a great solution to that. Right now I've added n_stages as a keyword arg to a few functions, which I fear might confuse some users unfamiliar with wearables/actigraphy. It really puts hypnograms at the center of the package, which I think is appropriate since they are really what makes sleep analyses unique.Īfter I finish working on the evaluation classes in #78 this is going to be all the more important, because it introduces the concept of hypnograms with different numbers of possible stages. The class idea is a better solution to all these problems. The more consistent checks would allow for more explicit errors (though they'd probably become obsolete anyways). The str/int difference seems trivial, but in my experience it trips up a lot of new students, especially since YASA currently is not always explicit about the root of the error.I was thinking there should at least be a check_hypno() utility function. Checking hypnogram inputs for all the different functions entails lots of repeated code.I was thinking each function could have an automatic conversion section if necessary. Of course there are the conversion functions, but it seems like tracking that needn't be on the user. The difference in str/int hypnograms can be confusing, mostly because SleepStaging.predict() returns strings, and most other functions require ints.The class would also solve these issues I'd come across: Great idea!! I've also been thinking hypnograms could be handled better, but hadn't thought of making a hypnogram class.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |