Abstract:The diagnosis of depression is an important research direction in the medical field. However, existing methods for diagnosing depression face problems such as high cost, low efficiency, low accuracy, and weak interpretability. To solve these problems, this study proposes an automatic algorithm for depression diagnosis based on sleep EEG signals, combined with sleep staging. This method first combines convolutional neural networks with bidirectional long short-term memory neural networks to extract advanced features of sleep signals. At the same time, it analyzes the correlation among different sleep stages, improving the accuracy and interpretability of sleep staging. The experimental results show that this method achieves the highest accuracy of 95.82% on the public dataset Sleep-EDF, surpassing most existing methods. Subsequently, based on the results of sleep staging, the compression net 2 dimension (DepNet2D) model combined with convolutional neural networks is proposed to extract features and classify EEG data during the REM phase. This model can effectively learn the spatiotemporal dependencies of sleep EEG, capture the feature patterns of brain activity in patients with depression, and improve the accuracy of identifying the spectral features of patients. The experimental results show that in the diagnosis of depression, the proposed method in this study reaches accuracy of 88.82%, which is higher than that of traditional models. The proposed method enhances the interpretability of depression diagnosis and has practical value for modern depression research and analysis, providing new ideas and methods for research and clinical practice in the field of mental health.