Abstract Introduction Actigraphy enables cost-effective, long-term sleep monitoring; however, accurate sleep scoring based on activity counts remains challenging. Existing algorithms (e.g., the Cole-Kripke and Actiware) depend strongly on absolute activity-count levels without considering the temporal activity patterns during sleep-wake transition, making them sensitive to device-specific differences and limiting cross-device implementation. Methods We developed a novel deep learning algorithm with a Transformer-based architecture that leveraged self-attention mechanisms to capture complex sleep/wake transition patterns in activity counts and tested the performance for sleep/wake classification per 30-sec epoch. Positional embeddings preserve temporal order while self-attention captures local dependencies (30 minutes), such as sustained quiescence preceding sleep onset. Attended features are aggregated via global average pooling for binary classification. Training and internal validation were evaluated using the Multi-Ethnic Study of Atherosclerosis (MESA) datasets (n=1,404). Generalizability of the transformer-based model was assessed using external Out-of-Sample (OOS) datasets (n=25) collected in an in-laboratory study of daytime and nighttime workers, which involved sleep during nighttime and simulated daytime sleep schedules. For both training/validation and testing datasets, sleep/wake status was determined using polysomnography-based sleep scoring. Results In MESA, the model achieved an average accuracy of 0.79 +/- 0.01, an average AUC of 0.82 +/- 0.01, and an average F1 score of 0.82 +/- 0.01 across participants, effectively distinguishing between sleep and wakefulness. The model demonstrated a high stability on the external OOS datasets, achieving an average accuracy of 0.95 +/- 0.01, AUC of 0.97 +/- 0.01, and F1 score of 0.84 +/- 0.02. Conclusion Our results demonstrate that a streamlined, attention-based Transformer model achieves robust sleep/wake classification using actigraphy. Future work will further evaluate its performance in larger, independent datasets and assess its capability in detecting sleep events outside the primary window (e.g., naps). Support (if any) R01AG083799
Moguilner et al. (Fri,) studied this question.