Sleep detection method and system based on timing continuity optimization

By using a sleep detection method optimized based on temporal continuity, and utilizing a triaxial accelerometer, a multi-scale hollow residual enhancement unit, and a bidirectional long short-term memory network, the problem of insufficient feature extraction in existing sleep detection methods is solved, and more efficient and accurate sleep state monitoring is achieved.

CN120899181BActive Publication Date: 2026-05-29SOUTH CHINA UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SOUTH CHINA UNIV OF TECH
Filing Date
2025-08-13
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing sleep detection methods suffer from problems such as reliance on human design for feature extraction, insufficient dynamic temporal modeling capabilities, limited capture of local details, large training data requirements, and high model complexity, resulting in insufficient accuracy and practicality in sleep quality monitoring.

Method used

A sleep detection method based on temporal continuity optimization is adopted. Data is collected by a triaxial accelerometer, and after preprocessing, local and global features are extracted by fine-grained convolution operation. The feature is reconstructed and temporal smoothing is corrected by combining multi-scale dilated residual enhancement unit and bidirectional long short-term memory network to form a complete sleep state prediction.

Benefits of technology

It significantly improves the accuracy and stability of sleep state prediction, enhances the overall performance of sleep quality monitoring, and is suitable for everyday use in portable devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120899181B_ABST
    Figure CN120899181B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of sleep detection, and specifically discloses a sleep detection method and system based on time sequence continuity optimization, which comprises the following steps: collecting original wristband accelerometer data through a three-axis accelerometer and performing pretreatment to obtain an input tensor; inputting the input tensor into a feature extraction module to extract local features and global features of the input tensor and obtain a high-level feature tensor; inputting the high-level feature tensor into a feature reconstruction module, adopting a linear interpolation reconstruction strategy, performing up-sampling and feature skip connection on the high-level feature tensor, and obtaining a final data tensor; performing secondary fine-tuning and time sequence smoothing correction on the data tensor output by the feature reconstruction module to form complete one-day per-minute sleep state prediction and corresponding confidence score output. According to the technical scheme, the multi-scale hollow convolution is used to improve the residual unit, and through a bidirectional time sequence information processing mechanism, the prediction result of the sleep event is more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of sleep detection technology, and relates to a sleep detection method and system based on temporal continuity optimization. Background Technology

[0002] In today's fast-paced life, sleep problems (such as insomnia and sleep apnea) are becoming increasingly common, making the need for effective sleep state monitoring methods more urgent. Existing sleep monitoring algorithms include movement-based sleep monitoring methods, machine learning-based sleep monitoring methods, and deep learning-based sleep monitoring methods.

[0003] Movement-based sleep monitoring methods: Movement-based sleep apnea can achieve an accuracy rate of 75% to 95%, meeting basic sleep assessment requirements. This method has a simple algorithm, is easy to implement, processes data quickly, has low hardware requirements, and is suitable for real-time monitoring, but its accuracy is lower than polysomnography (PSG). It is commonly used in portable wearable devices (such as wristbands and watches).

[0004] A machine learning-based sleep monitoring method: A device that monitors sleep stages using a pulse oximeter and accelerometer is worn on the wrist to collect heart rate and acceleration signals. Features are extracted through fast Fourier transform and classified using support vector machine (SVM). The results show that it is efficient and accurate.

[0005] Deep learning-based sleep monitoring methods: Deep learning technology has demonstrated tremendous potential and effectiveness in sleep analysis, gradually surpassing traditional machine learning models. In particular, Long Short-Term Memory (LSTM) and Bidirectional LSTM (Bi-LSTM) are able to capture time dependencies and handle inputs of various lengths.

[0006] While existing methods for motion detection, machine learning, and deep learning have improved the portability and automation of sleep monitoring to some extent, they still generally suffer from problems such as reliance on human design for feature extraction, insufficient dynamic temporal modeling capabilities, limited capture of local details, large training data requirements, and high model complexity. There is an urgent need for a more efficient, accurate, and innovative method that is suitable for everyday environments to effectively improve the accuracy and practicality of sleep quality monitoring. Summary of the Invention

[0007] The purpose of this invention is to provide a sleep detection method and system based on temporal continuity optimization, which can effectively improve the accuracy of sleep quality monitoring.

[0008] To achieve the above objectives, the basic solution of the present invention is: a sleep detection method based on temporal continuity optimization, comprising the following steps:

[0009] Raw wristband accelerometer data is acquired using a triaxial accelerometer and preprocessed to obtain the input tensor.

[0010] The input tensor is fed into the feature extraction module, and fine-grained convolution operation is used to extract the local and global features of the input tensor to obtain a high-level feature tensor.

[0011] The high-level feature tensor is input into the feature reconstruction module. A linear interpolation reconstruction strategy is used to upsample and perform feature skip connections on the high-level feature tensor to obtain the final data tensor.

[0012] The data tensor output by the feature reconstruction module is fine-tuned and temporally smoothed to form a complete prediction of sleep state for each minute of the day and the corresponding confidence score output.

[0013] The working principle and beneficial effects of this basic solution are as follows: In the data preprocessing stage, raw data is collected using a triaxial accelerometer and preprocessed for subsequent use. Based on the feature extraction module, detailed and global features of the triaxial accelerometer at different time windows are extracted to improve the accuracy of sleep state prediction.

[0014] Feature reconstruction is performed using a feature reconstruction module, aiming to progressively reconstruct and fine-grained restore the high-level features compressed by the feature extraction module. A temporal prediction smoothing method is employed, using a bidirectional long short-term memory network structure to perform secondary optimization and smoothing of the initial prediction results. This significantly reduces short-term prediction fluctuations and misjudgments, capturing the temporal continuity of sleep state prediction more comprehensively and efficiently, thus improving overall prediction performance and stability in practical applications.

[0015] Furthermore, the method for preprocessing the original data to obtain the input tensor is as follows:

[0016] For the z-angle and ENMO activity in the original data, calculate their standard deviations separately and take their natural logarithms to obtain log_anglez and log_enmo.

[0017] Introduce a valid_flag label corresponding to each time step. When duplicate records or invalid data are detected, the valid_flag of the corresponding time step is set to 0, and the valid_flag of normal records is set to 1.

[0018] Thus, each time step contains three-dimensional features log_anglez, log_enmo, and valid_flag, which together form three-channel input data.

[0019] For the z-angle signal in the original features, its standard deviation is calculated and its natural logarithm is taken to enhance the ability to perceive minute angle changes. For the ENMO activity level features, a logarithmic transformation is also taken to compress the extreme value range and highlight the characteristics of low- to medium-intensity exercise.

[0020] Furthermore, a cross-day data splicing strategy is also provided: for each target day, the feature sequences of the last 3 hours of the previous day, the full data of the day, and the first 3 hours of the next day are extracted and spliced ​​to form a single 3×21600 feature matrix sample.

[0021] The batch size is set to 16, resulting in an input tensor of shape (16, 3, 21600).

[0022] The input tensor is fed into the preliminary feature extraction unit, and the number of feature channels is expanded from the original 3 to 72, resulting in an input tensor with the shape (16, 72, 21600).

[0023] Cross-day data stitching strategies can improve the ability to continuously identify sleep state transitions and more fully integrate contextual information from preceding and following time segments.

[0024] Furthermore, the input tensor is input into the feature extraction module, and fine-grained convolution operation is used to extract the local and global features of the input tensor. Specifically, the feature extraction module includes a standard feature extraction unit and a multi-scale dilated residual enhancement unit.

[0025] The standard feature extraction unit includes a one-dimensional convolutional layer, a batch normalization layer, and an activation function layer. The standard feature extraction unit uses convolutional kernel sizes of 12, 15, and 15, and strides of 12, 9, and 5, respectively, to initially extract features from the input tensor.

[0026] The multi-scale dilated residual enhancement unit includes three feature extraction sub-units. Each feature extraction sub-unit includes a one-dimensional dilated convolutional layer, a one-dimensional convolutional layer, and a residual connection layer. The dilation parameters of the multi-scale dilated residual enhancement unit increase sequentially to 1, 3, and 9, respectively. The length of the dilated convolutional kernel is 7. The input tensor is sequentially input into the three feature extraction sub-units, so that the time length of the input tensor is reduced from the initial 21600 to 1800, 200, and 40, respectively, and the output data is x[i].

[0027] In the first residual unit R1 of the feature extraction subunit, the kernel k of the dilated convolution is... d The length of [j] is 7, the dilation rate d is 1, and the output y of the one-dimensional dilated convolutional layer D1 is... D1 [i] is:

[0028] ;

[0029] in, Indicates the length of the convolution kernel. This represents the index in the convolution kernel, traversed from 0 to k-1, corresponding to the weight of each convolution kernel; This represents the value at the (i+j)th position in the input signal x, indicating that the sliding window samples the input.

[0030] The output of the first one-dimensional dilated convolution is then passed through a convolution kernel of length k. c A one-dimensional convolutional layer with [j] as 1 produces the output y. c1 [i] is:

[0031] ;

[0032] The residual connection is designed to connect the initial input to the output of the dilated convolution and one-dimensional convolutional layers, resulting in the output y of the first residual unit. R1 [i] is represented as:

[0033] ;

[0034] in, The values ​​at position i are used for direct summation in the residual join; It is the output feature at the (i+j)th position obtained from the previous dilated convolutional layer D1; It is the weight of the ordinary convolution kernel, the value at the j-th position;

[0035] The dilation parameters of the three improved multi-scale dilated convolutional residual units in each feature extraction subunit increase sequentially to 1, 3, and 9, respectively. The length k of the dilated convolutional kernel in each improved multi-scale dilated convolutional residual unit is... d The length of [j] is set to 7; the dilated convolution D2 of the second feature extraction subunit and the residual unit R2 output y D2 [i] and y R2 [i] are respectively:

[0036] ;

[0037] ;

[0038] The dilated convolution D3 of the third feature extraction subunit and the output y of the residual unit R3 are... D3 [i] and y R3 [i] are respectively:

[0039] ;

[0040] ;

[0041] The final output of the high-level feature tensor from the feature extraction module has a shape of (16, 72, 40).

[0042] Fine-grained convolution operations are employed to simultaneously capture local dynamic details and global sequence trends, expanding the number of feature channels from the original 3 to 72. While maintaining the time series length (21600), this greatly enriches the expressive power of the feature space, laying a high-quality input foundation for subsequent multi-scale feature extraction and temporal continuity optimization.

[0043] Furthermore, the high-level feature tensor is input into two feature reconstruction modules to obtain the final data tensor. The specific steps are as follows:

[0044] Upsampling is performed on the high-level feature tensor using linear interpolation, linearly interpolating between two known feature points. An upsampling scaling factor is set; the upsampling scaling factors for the two feature reconstruction modules are 5 and 9, respectively. The output y of the upsampling part... u1 for:

[0045] Where, b = , representing the interpolation point y u1 [a] corresponds to the index of y; the output data dimension is (16, 72, 200). This represents the output of the feature extraction module;

[0046] A scale-aligned skip connection mechanism is adopted to concatenate and splice the upsampled feature tensor with the feature tensor before downsampling at the corresponding scale in the feature extraction module along the channel dimension, thereby achieving efficient fusion of local detail information and high-level abstract features.

[0047] If the data dimension of the corresponding layer in the feature extraction module and the feature reconstruction module is (N, C) enc , L), (N, C dec After skip joins, the data dimension becomes (N, C). enc +C dec (, L); where N represents the batch size, i.e., the number of samples input at one time; C enc C represents the number of feature channels output by the feature extraction module. dec The number of feature channels output by the feature extraction module is indicated by L; L refers to the sequence length, representing the time step or spatial resolution.

[0048] In the first skip connection, the data dimensions of both the feature extraction module and the feature reconstruction module are (16, 72, 200), and the output data dimensions become (16, 144, 200).

[0049] The features after the skip connections are then compressed to restore the number of channels to 72. A one-dimensional convolutional structure with a kernel size of 15 and a stride of 1 is used, along with batch normalization and ReLU activation function, to extract the fused feature information.

[0050] The second feature reconstruction module processes data in the same way as the first feature reconstruction module. The final output data tensor dimension is (16, 72, 1800), which is equivalent to generating a sleep state prediction and corresponding confidence score every minute for the entire spliced ​​data.

[0051] The feature reconstruction module performs stepwise reconstruction and fine-grained restoration of the high-level features obtained by the feature extraction module through compression.

[0052] Furthermore, the data tensor output by the feature reconstruction module is fine-tuned and temporally smoothed to form a complete prediction of sleep state per minute of the day and the corresponding confidence score output. The specific steps are as follows:

[0053] The feature tensor (16, 72, 1800) output by the feature reconstruction module is used as input, that is, the preliminary prediction result at each time step is used as input to form the time series predict1—predict1800; let the initial input X1, and the outputs f1, i1, and o1 after passing through the forget gate, input gate, and output gate be respectively:

[0054] ;

[0055] ;

[0056] ;

[0057] in, This represents the input feature vector at the current moment; Represents the initial hidden state vector; , , This represents the weight matrix of the forget gate, input gate, and output gate. , , This indicates the bias terms corresponding to the forget gate, input gate, and output gate;

[0058] The state of memory cells is represented as follows:

[0059] ;

[0060] in, The weight matrix representing the state of memory cells; This represents the bias term corresponding to the state of memory cells;

[0061] Final memory cell state The state of the memory cells at the previous time step, the state of the provisional memory cells at the current time step, the output of the forget gate at the current time step, and the output of the input gate at the current time step are all determined by the memory cell state at the previous time step, and can be represented as follows:

[0062] ;

[0063] Hidden state of the current time step Determined by the output of the output gate at the current time step and the final state of the memory cell at the current time step, it is expressed as:

[0064] ;

[0065] The forward LSTM utilizes complete historical information from minute 1 to minute t to adjust the initial prediction at the current time step based on the global context.

[0066] The backward LSTM is symmetrical to the forward structure, processes the input sequence in reverse chronological order, and is fine-tuned using future context information. The output tensor dimension is also (16, 36, 1800). The outputs of the forward and backward LSTMs are concatenated along the channel dimension to fuse bidirectional temporal information, resulting in a comprehensive feature representation with a shape of (16, 72, 1800).

[0067] After passing through an output layer, the 72-dimensional features are compressed to 1 dimension to obtain the final sleep state prediction score per minute;

[0068] To ensure consistency between the predicted sequence and the original input data, 180 prediction points at the beginning and end were removed, and 1440 consecutive time steps in the middle were retained to form a complete prediction of sleep state per minute of a day and the corresponding confidence score output.

[0069] The sleep state predictions output by the feature reconstruction module are fine-tuned and temporally smoothed to improve the stability and continuity of the prediction sequence.

[0070] The present invention also provides a sleep detection system based on the method described in the present invention, comprising a data preprocessing module, a feature extraction module, a feature reconstruction module, and a sequence continuity optimization module connected in sequence;

[0071] The data preprocessing module is used to acquire raw data and perform preprocessing.

[0072] The feature extraction module is used to extract the local and global features of the input tensor output by the data preprocessing module to obtain a high-level feature tensor.

[0073] The feature reconstruction module receives the high-level feature tensor and uses a linear interpolation reconstruction strategy to upsample and perform feature skip connections on the high-level feature tensor to obtain the final data tensor.

[0074] The sequence continuity optimization module performs secondary fine-tuning and temporal smoothing correction on the data tensor output by the feature reconstruction module to form a complete prediction of sleep state per minute of a day and the corresponding confidence score output.

[0075] This system achieves more accurate wristband sleep detection based on improved multi-scale void residual feature extraction and temporal continuity optimization structure.

[0076] Furthermore, the data preprocessing module is connected to a wristband accelerometer, which is worn on the user's arm.

[0077] The data preprocessing module acquires and preprocesses the raw data, making it easier to use.

[0078] Furthermore, the feature extraction module includes a standard feature extraction unit and a multi-scale hole residual enhancement unit;

[0079] The standard feature extraction unit includes a first one-dimensional convolutional layer, a batch normalization layer, and a ReLU activation function layer connected in sequence. The standard feature extraction unit uses convolutional kernel sizes of 12, 15, and 15, and strides of 12, 9, and 5, respectively.

[0080] The multi-scale dilated residual enhancement unit includes three feature extraction sub-units. Each feature extraction sub-unit includes a one-dimensional dilated convolutional layer, a second one-dimensional convolutional layer, and a residual connection layer connected in sequence. The dilation parameters of the multi-scale dilated residual enhancement unit increase sequentially, namely 1, 3, and 9, and the length of the dilated convolutional kernel is 7.

[0081] The feature extraction module employs fine-grained convolution operations to simultaneously capture local dynamic details and global sequence trends.

[0082] Furthermore, the feature reconstruction module includes an upsampling layer, a skip connection layer, and a feature fusion layer connected in sequence. The upsampling layer is used to receive the high-level feature tensor output by the feature extraction module and perform upsampling. The feature fusion layer outputs the final data tensor to the sequence continuity optimization module.

[0083] The feature reconstruction module performs stepwise reconstruction and fine-grained restoration of the high-level features compressed by the feature extraction module, and accurately restores the temporal information with low computational complexity based on upsampling. Attached Figure Description

[0084] Figure 1 This is a flowchart illustrating the sleep detection method based on temporal continuity optimization according to the present invention.

[0085] Figure 2 This is a schematic diagram of the feature extraction module of the sleep detection method based on temporal continuity optimization of the present invention;

[0086] Figure 3 This is a schematic diagram of the feature reconstruction module of the sleep detection method based on temporal continuity optimization of the present invention;

[0087] Figure 4 This is a schematic diagram of the sequence continuity optimization module of the sleep detection method based on temporal continuity optimization of the present invention. Detailed Implementation

[0088] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0089] In the description of this invention, it should be understood that the terms "longitudinal", "lateral", "up", "down", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0090] In the description of this invention, unless otherwise specified and limited, it should be noted that the terms "installation", "connection" and "linking" should be interpreted broadly. For example, they can refer to mechanical or electrical connections, or internal connections between two components. They can be direct connections or indirect connections through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms according to the specific circumstances.

[0091] This invention discloses a sleep detection method based on temporal continuity optimization. Based on improved multi-scale cavitation residual feature extraction and temporal continuity optimization, it is designed for wrist-worn accelerometer data, abandoning the complex medical-grade staging methods that rely on electroencephalogram (EEG) signals, and focusing on meeting the needs of portable, high-precision sleep state monitoring in daily life. Figure 1 As shown, the sleep detection method based on temporal continuity optimization includes the following steps:

[0092] Raw wristband accelerometer data is acquired using a triaxial accelerometer and preprocessed to obtain the input tensor.

[0093] The input tensor is fed into the feature extraction module, and fine-grained convolution operation is used to extract the local and global features of the input tensor to obtain a high-level feature tensor.

[0094] The high-level feature tensor is input into the feature reconstruction module. A linear interpolation reconstruction strategy is used to upsample and perform feature skip connections on the high-level feature tensor to obtain the final data tensor.

[0095] The data tensor output by the feature reconstruction module is fine-tuned and temporally smoothed to form a complete prediction of sleep state for each minute of the day and the corresponding confidence score output.

[0096] In a preferred embodiment of the present invention, the method for preprocessing the original data to obtain the input tensor is as follows:

[0097] For the z-angle and ENMO activity levels in the original data, their standard deviations were calculated separately, and their natural logarithms were taken to obtain log_anglez and log_enmo; z-angle and ENMO activity levels. For the z-angle signal in the original features, its standard deviation was calculated and its natural logarithm was taken to enhance the perception of subtle angle changes; for the ENMO activity level feature, a logarithmic transformation was also taken to compress the extreme value range and highlight the characteristics of low- to medium-intensity motion.

[0098] The z-angle specifically represents the change in the relative angle between the arm wearing the wristband and the vertical axis of the body, while the ENMO activity is a specially processed value of the Euclidean norm of the triaxial accelerometer data. The data is recorded every 5 seconds to ensure the temporal continuity of the feature data and efficient processing capabilities.

[0099] To identify signal quality, a valid_flag label corresponding to each time step is introduced. When duplicate records or invalid data are detected, the valid_flag of the corresponding time step is set to 0, and the valid_flag of normal records is set to 1, thereby effectively improving the robustness of the subsequent modeling stage.

[0100] Thus, each time step contains three-dimensional features log_anglez, log_enmo, and valid_flag, which together form three-channel input data.

[0101] Preferably, to more fully integrate the contextual information of preceding and following time segments and improve the ability to continuously identify sleep state transitions, a cross-day data stitching strategy is also included:

[0102] For each target day, feature sequences are extracted from the last 3 hours of the previous day (2160 time steps), the entire day's data, and the first 3 hours of the next day (2160 time steps), and concatenated to form a single 3×21600 feature matrix sample; each sample thus possesses continuous contextual characteristics over a long period of time, greatly enhancing the ability to model changes in sleep patterns across nights.

[0103] The batch size is set to 16, resulting in an input tensor of shape (16, 3, 21600).

[0104] The input tensor is fed into the preliminary feature extraction unit, and the number of feature channels is expanded from the original 3 to 72, resulting in an input tensor with the shape (16, 72, 21600).

[0105] In a preferred embodiment of the present invention, the input tensor is input into the feature extraction module, and fine-grained convolution operation is used to extract the local and global features of the input tensor. Specifically, the method is as follows:

[0106] like Figure 2 As shown, the feature extraction module includes a standard feature extraction unit (ConvBNReLU module) and a multi-scale dilated residual enhancement unit (improved residual structure). In this stage, the number of feature channels is expanded from the original 3 to 72. While maintaining the time series length (21600), the feature space expression capability is greatly enriched, laying a high-quality input foundation for subsequent multi-scale feature extraction and temporal continuity optimization.

[0107] The standard feature extraction unit includes a one-dimensional convolutional layer, a batch normalization (BatchNorm) layer, and an activation function layer. It initially extracts features from the input tensor. The standard feature extraction unit uses convolutional kernel sizes of 12, 15, and 15, with strides of 12, 9, and 5, respectively.

[0108] The multi-scale dilated residual enhancement unit includes three feature extraction sub-units. Each feature extraction sub-unit includes a one-dimensional dilated convolutional layer, a one-dimensional convolutional layer, and a residual connection layer. The dilation parameters of the multi-scale dilated residual enhancement unit increase sequentially to 1, 3, and 9, respectively. The length of the dilated convolutional kernel is 7. The input tensor is sequentially input into the three feature extraction sub-units, so that the time length of the input tensor is reduced from the initial 21600 to 1800, 200, and 40, respectively, and the output data is x[i]. This stride and convolutional kernel design not only achieves feature compression but also effectively extracts local variation characteristics while maintaining the stable flow of sequence information.

[0109] To overcome the limitations of traditional convolutional units in modeling long-range dependencies, this invention innovatively introduces an improved multi-scale dilated convolutional residual unit (MSDR-Unit) to capture fine local features and global long-range dependencies in wristband data at multiple levels and scales.

[0110] This multi-scale dilated convolution residual unit consists of a one-dimensional dilated convolution layer, a one-dimensional convolution layer, and residual connections. One-dimensional dilated convolution is achieved by inserting dilations between the elements of the convolution kernel, based on standard convolution. For a given dilation rate d, the convolution kernel skips d-1 elements on the input signal to perform the convolution operation.

[0111] In the first residual unit R1 of the feature extraction subunit, the dilation convolution kernel k d The length of [j] is 7, the dilation rate d is 1, and the output y of the one-dimensional dilated convolutional layer D1 is... D1 [i] is:

[0112] ;

[0113] in, Indicates the length of the convolution kernel. This represents the index in the convolution kernel, traversed from 0 to k-1, corresponding to the weight of each convolution kernel; This represents the value at the (i+j)th position in the input signal x, indicating that the sliding window samples the input.

[0114] The output of the first one-dimensional dilated convolution is then passed through a convolution kernel of length k. c A one-dimensional convolutional layer with [j] as 1 produces the output y. c1 [i] is:

[0115] ;

[0116] To avoid the vanishing gradient problem during training, a residual connection is designed to connect the initial input with the output of the dilated convolution and one-dimensional convolutional layers, resulting in the output y of the first residual unit. R1 [i] is represented as:

[0117] ;

[0118] in, The values ​​at position i are used for direct summation in the residual join; It is the output feature at the (i+j)th position obtained from the previous dilated convolutional layer D1; It is the weight of the ordinary convolution kernel, the value at the j-th position;

[0119] The dilation parameters of the three improved multi-scale dilated convolutional residual units in each feature extraction subunit increase sequentially to 1, 3, and 9, respectively, to systematically cover time-dependent features at different scales, balancing fine-grained dynamic changes and long-term trend modeling. The dilated convolutional kernel length k in each improved multi-scale dilated convolutional residual unit is...d The length of [j] is set to 7; the dilated convolution D2 of the second feature extraction subunit and the residual unit R2 output y D2 [i] and y R2 [i] are respectively:

[0120] ;

[0121] ;

[0122] The dilated convolution D3 of the third feature extraction subunit and the output y of the residual unit R3 are... D3 [i] and y R3 [i] are respectively:

[0123] ;

[0124] ;

[0125] The final output of the high-level feature tensor from the feature extraction module has a shape of (16, 72, 40).

[0126] This unique residual unit design integrates information flows at different scales. The dilated convolutional part captures long-distance acceleration change patterns, such as the trend of posture changes throughout the night and the magnitude of changes in movement; while the standard one-dimensional convolutional part focuses on local details, such as drastic angle changes and the stability of high activity or static states within a short period of time. This multi-level, multi-scale feature fusion enables the model to comprehensively perceive sleep dynamics from local micro-changes to global trends, greatly improving classification accuracy and robustness.

[0127] The MSDR-Unit multi-scale dilated convolutional residual unit designed in this invention greatly enriches the expressive power of the feature space while maintaining the consistency of the input and output time series lengths. The dimensionality reduction operation inside the feature extraction module mainly relies on the stride control in the standard feature extraction unit, thereby ensuring the sequence integrity during the dilated feature extraction process.

[0128] This invention uniquely employs an innovatively designed multi-scale dilated convolution improved residual unit to significantly enhance the model's ability to capture features at different scales and preserve local details, overcoming the problem of insufficient accuracy in existing portable methods.

[0129] Multi-scale dilated convolutional residual units can simultaneously capture local detail features and long-range dependency features, and, in conjunction with skip connections, fuse information at different scales, significantly improving the depth and expressive power of feature learning, and fully recognizing and utilizing multi-level features in time series.

[0130] In a preferred embodiment of the present invention, such as Figure 3As shown, the high-level feature tensor is input into two feature reconstruction modules to obtain the final data tensor. The specific steps are as follows:

[0131] By using linear interpolation, an upsampling operation is performed on the high-level feature tensor (shape (16, 72, 40)). Unlike traditional deconvolution-based upsampling methods, this invention employs an efficient linear interpolation reconstruction strategy, performing linear interpolation between two known feature points to accurately recover temporal information with lower computational complexity. Regarding the stride setting in the feature extraction stage, this invention sets upsampling scaling factors one-to-one in the feature reconstruction module. The upsampling scaling factors for the two feature reconstruction modules are 5 and 9, respectively, ensuring strict structural correspondence and scale matching between the upsampling and downsampling processes. The output y of the upsampling part... u1 for:

[0132] );

[0133] Where b = , representing the interpolation point y u1 [a] corresponds to the index of y; the output data dimension is (16, 72, 200). This represents the output of the feature extraction module;

[0134] A scale-aligned skip connection mechanism is adopted to concatenate and splice the upsampled feature tensor with the feature tensor before downsampling at the corresponding scale in the feature extraction module along the channel dimension, thereby achieving efficient fusion of local detail information and high-level abstract features.

[0135] If the data dimension of the corresponding layer in the feature extraction module and the feature reconstruction module is (N, C) enc , L), (N, C dec After skip joins, the data dimension becomes (N, C). enc +C dec (, L); where N represents the batch size, i.e., the number of samples input at one time; C enc C represents the number of feature channels output by the feature extraction module. dec The number of feature channels output by the feature extraction module is represented by L; L refers to the sequence length, indicating the time step or spatial resolution.

[0136] In the first skip connection, the data dimensions of both the feature extraction module and the feature reconstruction module are (16, 72, 200), and the output data dimensions become (16, 144, 200).

[0137] The features after skip connections are then subjected to channel compression to restore the number of channels to 72, in order to maintain the consistency of the number of features and the stability of the network structure. A one-dimensional convolutional structure with a kernel size of 15 and a stride of 1 is used, along with batch normalization and ReLU activation function, to extract the fused feature information.

[0138] The second feature reconstruction module processes data in the same way as the first feature reconstruction module. The final output data tensor dimension is (16, 72, 1800), which is equivalent to generating a sleep state prediction and corresponding confidence score every minute for the entire spliced ​​data segment (three hours after the previous day, the entire day, and three hours before the next day).

[0139] Preferably, the feature reconstruction module designed in this invention has flexible and scalable multi-scale output capabilities:

[0140] If two feature reconstruction modules are set up, the prediction result can be output once per minute, which can effectively reduce the computational complexity while ensuring sufficient temporal resolution to capture key changes in the sleep state.

[0141] If the number of feature reconstruction modules is increased to three, fine-grained predictions can be made for each original time step, which is suitable for datasets with higher accuracy requirements or higher complexity.

[0142] This multi-scale flexible design fully embodies the optimized balance between performance and computational efficiency of this invention, which is different from the traditional fixed-scale reconstruction strategy and has significant potential for application and promotion.

[0143] In a preferred embodiment of the present invention, the data tensor output by the feature reconstruction module is subjected to secondary fine-tuning and temporal smoothing correction to form a complete prediction of sleep state per minute of a day and the corresponding confidence score output. The specific steps are as follows:

[0144] The feature tensor (16, 72, 1800) output by the feature reconstruction module is used as input, that is, the preliminary prediction result of each time step (corresponding to one minute) is used as input to form the time series predict1—predict1800; let the initial input X1, and the outputs f1, i1, and o1 after passing through the forget gate, input gate, and output gate be respectively:

[0145] ;

[0146] ;

[0147] ;

[0148] in, This represents the input feature vector at the current moment; Represents the initial hidden state vector; , , This represents the weight matrix of the forget gate, input gate, and output gate. , , This indicates the bias terms corresponding to the forget gate, input gate, and output gate;

[0149] The state of memory cells is represented as follows:

[0150] ;

[0151] in, The weight matrix representing the state of memory cells; This represents the bias term corresponding to the state of memory cells;

[0152] Final memory cell state The state of the memory cells at the previous time step, the state of the provisional memory cells at the current time step, the output of the forget gate at the current time step, and the output of the input gate at the current time step are all determined by the memory cell state at the previous time step, and can be represented as follows:

[0153] ;

[0154] Hidden state of the current time step Determined by the output of the output gate at the current time step and the final state of the memory cell at the current time step, it is expressed as:

[0155] ;

[0156] The forward LSTM utilizes complete historical information from minute 1 to minute t to adjust the initial prediction at the current time step based on the global context. For example, when 95% of the predictions within a certain time period indicate a "sleep" state, but there are 5% abnormal fluctuations in some areas, the forward LSTM can use long-term memory mechanisms to smoothly correct these abnormalities, improving the consistency and reliability of the overall prediction. The output tensor dimension of the forward LSTM is (16, 36, 1800).

[0157] The backward LSTM is symmetrical to the forward structure and processes the input sequence in reverse chronological order (from 1800 to 1). It is also fine-tuned using future context information, and the output tensor dimension is (16, 36, 1800). The outputs of the forward and backward LSTMs are concatenated in the channel dimension to fuse bidirectional temporal information and obtain a comprehensive feature representation with a shape of (16, 72, 1800).

[0158] After passing through an output layer (fully connected layer), the 72-dimensional features are compressed to 1 dimension to obtain the final sleep state prediction score per minute;

[0159] To ensure consistency between the predicted sequence and the original input data, 180 prediction points at the beginning and end (corresponding to the 3 hours before and after the data splicing) were removed, and 1440 consecutive time steps in the middle were retained to form a complete prediction of sleep state for each minute of a day (24 hours) and the corresponding confidence score output.

[0160] This invention significantly improves time series modeling capabilities through a specially designed sequence continuity optimization module. It performs secondary smoothing on the prediction results from the perspective of the entire sequence, thereby comprehensively optimizing the stability and continuity of the prediction.

[0161] In this invention, the design of the sequence continuity optimization module makes full use of historical and future information. Instead of directly generating preliminary predictions, it optimizes and calibrates the preliminary prediction results output by the feature reconstruction module based on the overall temporal evolution characteristics. This significantly improves the coherence and overall accuracy of the final sleep state sequence, which is different from the existing traditional methods that only rely on local convolution prediction.

[0162] The present invention also provides a sleep detection system based on the method described in the present invention, comprising a data preprocessing module, a feature extraction module, a feature reconstruction module, and a sequence continuity optimization module connected in sequence.

[0163] The data preprocessing module acquires and preprocesses the raw data. This module connects to a wristband accelerometer, which is worn on the user's arm. The overall architecture of this invention explicitly uses the wristband accelerometer signal as the sole input, unlike traditional methods that rely on complex multi-channel physiological signals such as EEG and EOG. The selection of the input data source, network architecture design, and optimization strategies are all systematically adapted to the resource-constrained environment of portable devices.

[0164] The feature extraction module is used to extract the local and global features of the input tensor output by the data preprocessing module to obtain a high-level feature tensor.

[0165] The feature reconstruction module receives high-level feature tensors and uses a linear interpolation reconstruction strategy to upsample and perform feature skip connections on the high-level feature tensors to obtain the final data tensor. The feature extraction module of this invention can systematically capture weak and scattered pattern changes in acceleration data during sleep without increasing the amount of computation, ensuring sensitivity and robustness to multi-scale dynamic features.

[0166] like Figure 4As shown, the sequence continuity optimization module performs secondary fine-tuning and temporal smoothing correction on the data tensor output by the feature reconstruction module, forming a complete prediction of sleep state per minute of the day and the corresponding confidence score output. Employing a specially designed sequence continuity optimization module, through a bidirectional temporal information processing mechanism (bidirectional long short-term memory network structure), it fully utilizes the contextual information in the sleep sequence to achieve smooth output of prediction results, effectively solving the problem of insufficient sequence continuity in existing methods.

[0167] Unlike traditional methods that directly perform classification prediction based on convolutional features, the temporal continuity optimization module designed in this invention is not used to generate preliminary prediction results, but rather serves as a post-processing unit. It is specifically designed to perform secondary fine-tuning and temporal smoothing correction on the sleep state predictions output by the feature reconstruction module every minute, thereby further improving the stability and continuity of the prediction sequence.

[0168] This invention, through lightweight convolutional extraction, multi-scale dilated structures, and an optimized bidirectional temporal smoothing module, significantly reduces model complexity and inference latency while maintaining high-precision sleep detection. It features low power consumption, good real-time performance, and user-friendly deployment. This design not only meets the needs of consumer applications such as daily health monitoring and continuous sleep assessment, but also has the potential to support a portable sleep health management system for a large user base, demonstrating broad practical application prospects and commercial value.

[0169] In a preferred embodiment of the present invention, the feature extraction module includes a standard feature extraction unit and a multi-scale hole residual enhancement unit.

[0170] The standard feature extraction unit consists of a first one-dimensional convolutional layer, a batch normalization layer, and a ReLU activation function layer connected in sequence. The standard feature extraction unit uses convolutional kernel sizes of 12, 15, and 15, with strides of 12, 9, and 5, respectively.

[0171] The multi-scale dilated residual enhancement unit comprises three feature extraction sub-units. Each sub-unit includes a sequentially connected one-dimensional dilated convolutional layer, a second one-dimensional convolutional layer, and a residual connection layer. The dilation parameters of the multi-scale dilated residual enhancement unit increase sequentially, being 1, 3, and 9 respectively, while the kernel length of the dilated convolution is 7 for all sub-units. This invention introduces a multi-scale dilated convolution to improve the residual unit, capturing richer and more refined temporal features through multi-scale receptive fields and dilated convolution operations, achieving more accurate sleep state prediction at each time step.

[0172] This invention innovatively proposes a multi-scale dilated convolutional augmented residual unit structure suitable for one-dimensional wristband accelerometer timing data, discovering and effectively leveraging the significant potential of the encoder-decoder architecture in temporal data feature extraction and reconstruction. By introducing a stacked design of one-dimensional dilated convolutions with different dilation rates, the receptive field is expanded while maintaining the integrity of temporal details. This effectively overcomes the limitations of traditional U-Net structures that rely solely on skip connections for local feature concatenation, greatly enhancing the hierarchy and expressive power of feature extraction. Through a specially designed multi-scale dilated convolutional residual structure, detailed and global features of the triaxial accelerometer under different time windows are systematically extracted, significantly improving the accuracy of sleep state prediction.

[0173] In a preferred embodiment of the present invention, the feature reconstruction module includes an upsampling layer, a skip connection layer and a feature fusion layer connected in sequence. The upsampling layer is used to receive the high-level feature tensor output by the feature extraction module and perform upsampling. The feature fusion layer outputs the final data tensor to the sequence continuity optimization module.

[0174] After feature reconstruction, the preliminary prediction results undergo secondary fine-tuning and smoothing. Unlike traditional methods that directly embed recurrent neural networks into the encoder path, this invention introduces an independent post-processing stage for global consistency optimization of the complete prediction sequence. This design fully utilizes forward and backward time-dependent information, significantly improving the elimination of short-term prediction noise and correction of local abnormal fluctuations. This results in a significant improvement in the stability, consistency, and confidence of the prediction results, making it particularly suitable for long-term continuous sleep monitoring tasks. This mechanism enables the model to maintain excellent continuous prediction performance even when faced with signal fluctuations in real-world wearing environments, enhancing the reliability of practical applications.

[0175] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0176] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims

1. A sleep detection method based on temporal continuity optimization, characterized in that, Includes the following steps: Raw wristband accelerometer data is acquired using a triaxial accelerometer and preprocessed to obtain the input tensor. The input tensor is fed into the feature extraction module, and fine-grained convolution operation is used to extract the local and global features of the input tensor to obtain a high-level feature tensor. The high-level feature tensor is input into the feature reconstruction module. A linear interpolation reconstruction strategy is used to upsample and perform feature skip connections on the high-level feature tensor to obtain the final data tensor. The data tensor output by the feature reconstruction module is fine-tuned and temporally smoothed to form a complete prediction of sleep state every minute of the day and the corresponding confidence score output. The data tensor output by the feature reconstruction module is then fine-tuned and subjected to temporal smoothing correction to generate a complete prediction of sleep state for each minute of the day, along with the corresponding confidence score. The specific steps are as follows: The feature tensor (16, 72, 1800) output by the feature reconstruction module is used as input, that is, the preliminary prediction result at each time step is used as input to form the time series predict1—predict1800; let the initial input X1, and the outputs f1, i1, and o1 after passing through the forget gate, input gate, and output gate be respectively: , , , in, This represents the input feature vector at the current moment; Represents the initial hidden state vector; , , This represents the weight matrix of the forget gate, input gate, and output gate. , , This indicates the bias terms corresponding to the forget gate, input gate, and output gate; Memory cell state Represented as: , in, The weight matrix representing the state of memory cells; This represents the bias term corresponding to the state of memory cells; Final memory cell state Based on the state of memory cells in the previous time step The current provisional memory cell state at the current time step Forget gate output at the current time step Input gate output of the current time step A joint decision, expressed as: ; Hidden state of the current time step Determined by the output of the output gate at the current time step and the final state of the memory cell at the current time step, it is expressed as: ; The forward LSTM uses complete historical information from minute 1 to minute t to adjust the initial prediction of the current time step based on the global context. The output tensor dimension of the forward LSTM is (16, 36, 1800). The backward LSTM is symmetrical to the forward structure, processes the input sequence in reverse chronological order, and is fine-tuned using future context information. The output tensor dimension is also (16, 36, 1800). The outputs of the forward and backward LSTMs are concatenated along the channel dimension to fuse bidirectional temporal information, resulting in a comprehensive feature representation with a shape of (16, 72, 1800). After passing through an output layer, the 72-dimensional features are compressed to 1 dimension to obtain the final sleep state prediction score per minute. To ensure consistency between the predicted sequence and the original input data, 180 prediction points at the beginning and end were removed, and 1440 consecutive time steps in the middle were retained to form a complete prediction of sleep state per minute of a day and the corresponding confidence score output. It also has a cross-day data splicing strategy: for each target day, extract the feature sequences of the last 3 hours of the previous day, the full data of the day, and the first 3 hours of the next day, and splice them to form a single 3×21600 feature matrix sample. The batch size is set to 16, resulting in an input tensor of shape (16, 3, 21600). The input tensor is fed into the preliminary feature extraction unit, and the number of feature channels is expanded from the original 3 to 72, resulting in an input tensor with the shape (16, 72, 21600).

2. The sleep detection method based on temporal continuity optimization as described in claim 1, characterized in that, The method for preprocessing the original data to obtain the input tensor is as follows: For the z-angle and ENMO activity in the original data, calculate their standard deviations separately and take their natural logarithms to obtain log_anglez and log_enmo. Introduce a valid_flag label corresponding to each time step. When duplicate records or invalid data are detected, the valid_flag of the corresponding time step is set to 0, and the valid_flag of normal records is set to 1. Thus, each time step contains three-dimensional features log_anglez, log_enmo, and valid_flag, which together form three-channel input data.

3. The sleep detection method based on temporal continuity optimization as described in claim 1, characterized in that, The input tensor is input into the feature extraction module, and fine-grained convolution operation is used to extract the local and global features of the input tensor. Specifically, the feature extraction module includes a standard feature extraction unit and a multi-scale dilated residual enhancement unit. The standard feature extraction unit includes a one-dimensional convolutional layer, a batch normalization layer, and an activation function layer. The standard feature extraction unit uses convolutional kernel sizes of 12, 15, and 15, and strides of 12, 9, and 5, respectively, to initially extract features from the input tensor. The multi-scale dilated residual enhancement unit includes three feature extraction sub-units. Each feature extraction sub-unit includes a one-dimensional dilated convolutional layer, a one-dimensional convolutional layer, and a residual connection layer. The dilation rate parameter of the multi-scale dilated residual enhancement unit increases sequentially to 1, 3, and 9, respectively. The length of the dilated convolutional kernel is 7. The input tensor is sequentially input into the three feature extraction sub-units, so that the time length of the input tensor is reduced from the initial 21600 to 1800, 200, and 40, respectively, and the output data is x[i]. In the first residual unit R1 of the feature extraction subunit, the kernel k of the dilated convolution is... d The length of [j] is 7, the dilation rate d is 1, and the output y of the one-dimensional dilated convolutional layer D1 is... D1 [i] is: , in, Indicates the length of the convolution kernel. This represents the index in the convolution kernel, traversed from 0 to k-1, corresponding to the weight of each convolution kernel; This represents the value at the (i+j)th position in the input signal x, indicating that the sliding window samples the input. The output of the first one-dimensional dilated convolution is then passed through a convolution kernel of length k. c A one-dimensional convolutional layer with [j] as 1 produces the output y. c1 [i] is: ; The residual connection is designed to connect the initial input to the output of the dilated convolution and one-dimensional convolutional layers, resulting in the output y of the first residual unit. R1 [i] is represented as: , in, The values ​​at position i are used for direct summation in the residual join; It is the output feature at the (i+j)th position obtained from the previous dilated convolutional layer D1; It is the weight of the ordinary convolution kernel, the value at the j-th position; The dilated convolution D2 of the second feature extraction subunit and the output y of the residual unit R2 are... D2 [i] and y R2 [i] are respectively: , ; The dilated convolution D3 of the third feature extraction subunit and the output y of the residual unit R3 are... D3 [i] and y R3 [i] are respectively: , ; The final output of the high-level feature tensor from the feature extraction module has a shape of (16, 72, 40).

4. The sleep detection method based on temporal continuity optimization as described in claim 3, characterized in that, The high-level feature tensor is input into two feature reconstruction modules to obtain the final data tensor. The specific steps are as follows: Upsampling is performed on the high-level feature tensor using linear interpolation, linear interpolation is performed between two known feature points, and an upsampling scaling factor is set. The upsampling scaling factors for the two feature reconstruction modules are 5 and 9, respectively. The output y of the upsampling part of the first feature reconstruction module is... u1 for: ), Where b = , representing the interpolation point y u1 The index of y corresponding to [a]; the output data dimension is (16, 72, 200); This represents the output of the feature extraction module; A scale-aligned skip connection mechanism is adopted to concatenate and splice the upsampled feature tensor with the feature tensor before downsampling at the corresponding scale in the feature extraction module along the channel dimension, thereby achieving efficient fusion of local detail information and high-level abstract features. If the data dimension of the corresponding layer in the feature extraction module and the feature reconstruction module is (N, C) enc , L), (N, C dec After skip joins, the data dimension becomes (N, C). enc +C dec (, L); where N represents the batch size, i.e., the number of samples input at one time; C enc C represents the number of feature channels output by the feature extraction module. dec The number of feature channels output by the feature extraction module is indicated by L; L refers to the sequence length, representing the time step or spatial resolution. In the first skip connection, the data dimensions of both the feature extraction module and the feature reconstruction module are (16, 72, 200), and the output data dimensions become (16, 144, 200). The features after the skip connections are then compressed to restore the number of channels to 72. A one-dimensional convolutional structure with a kernel size of 15 and a stride of 1 is used, along with batch normalization and ReLU activation function, to extract the fused feature information. The second feature reconstruction module processes data in the same way as the first feature reconstruction module, and the final output data tensor dimension is (16, 72, 1800).

5. A sleep detection system based on the method of any one of claims 1-4, characterized in that, It includes a data preprocessing module, a feature extraction module, a feature reconstruction module, and a sequence continuity optimization module connected in sequence; The data preprocessing module is used to acquire raw data and perform preprocessing. The feature extraction module is used to extract the local and global features of the input tensor output by the data preprocessing module to obtain a high-level feature tensor. The feature reconstruction module receives the high-level feature tensor and uses a linear interpolation reconstruction strategy to upsample and perform feature skip connections on the high-level feature tensor to obtain the final data tensor. The sequence continuity optimization module performs secondary fine-tuning and temporal smoothing correction on the data tensor output by the feature reconstruction module to form a complete prediction of sleep state per minute of a day and the corresponding confidence score output.

6. The sleep detection system as described in claim 5, characterized in that, The data preprocessing module is connected to a wristband accelerometer, which is worn on the user's arm.

7. The sleep detection system as described in claim 5, characterized in that, The feature extraction module includes a standard feature extraction unit and a multi-scale hole residual enhancement unit; The standard feature extraction unit includes a first one-dimensional convolutional layer, a batch normalization layer, and a ReLU activation function layer connected in sequence. The standard feature extraction unit uses convolutional kernel sizes of 12, 15, and 15, and strides of 12, 9, and 5, respectively. The multi-scale dilated residual enhancement unit includes three feature extraction sub-units. Each feature extraction sub-unit includes a one-dimensional dilated convolutional layer, a second one-dimensional convolutional layer, and a residual connection layer connected in sequence. The dilation rate of the multi-scale dilated residual enhancement unit increases sequentially to 1, 3, and 9, respectively, and the length of the dilated convolutional kernel is 7.

8. The sleep detection system as described in claim 5, characterized in that, The feature reconstruction module includes an upsampling layer, a skip connection layer, and a feature fusion layer connected in sequence. The upsampling layer is used to receive the high-level feature tensor output by the feature extraction module and upsample it. The feature fusion layer outputs the final data tensor to the sequence continuity optimization module.