A sleep apnea monitoring visualization method and storage medium
By converting the electrocardiogram signal into characteristic images and using convolutional neural network for detection, the problem of insufficient complexity and accuracy of traditional sleep apnea detection methods is solved, and high-accuracy sleep apnea monitoring is achieved.
Patent Information
- Application Number
- CN202411322803.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-23
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-09-23
AI Technical Summary
The traditional sleep apnea detection method requires multiple electrodes and wires, which are complex in operation and low in time, and have high requirements for electrocardiogram signal processing, making it difficult to achieve fast and accurate diagnosis.
Convert the ECG signal into characteristic images, use the convolutional neural network to perform sleep apnea detection, extract the R wave signal, RR interval signal and R wave peak signal, filter and interpolate, build a radar diagram and matrix, and generate ECG Signal feature map for classification identification.
Fast and accurate sleep apnea detection is achieved, with an identification accuracy of 84.18%, reducing the complexity and operation difficulty of electrocardiogram signal processing.
Smart Images

Figure CN118845036B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sleep apnea detection, and in particular to a sleep apnea monitoring visualization method and a storage medium. Background Art
[0002] Sleep apnea syndrome (SAS) is the most common respiratory sleep disorder. It is a disease caused by partial or complete obstruction of the upper airway, which can easily induce some neurological and cardiovascular diseases, seriously affecting people's sleep quality and physical and mental health. Traditional sleep apnea detection and judgment are mainly manually interpreted through polysomnography (PSG), and this method requires a lot of electrodes and wires. The use of traditional methods is prone to errors and has low timeliness. Therefore, some researchers have proposed the use of single-channel signals for SAS diagnosis. These methods are mostly based on physiological records, such as electrocardiograph (ECG), blood oxygen saturation, snoring, respiratory signals, etc. Among these signals, ECG signals are one of the most physiologically relevant signals to SAS, and they can be easily used in wearable devices.
[0003] Based on the ECG signal, the time domain features, frequency domain features, and nonlinear features are extracted, and then the extracted features are screened and SAS is classified based on machine learning. This analysis method has shown good performance in SAS detection, but it requires researchers to have rich experience in ECG signal processing and the processing process is very complicated. Deep learning methods can automatically extract features from input signals and have strong autonomous learning capabilities. Since two-dimensional feature construction technology can more comprehensively express signal features than one-dimensional, it is necessary to convert one-dimensional ECG signals into feature images in order to utilize the excellent image processing capabilities of deep neural networks, thereby quickly and accurately realizing sleep apnea detection. Summary of the invention
[0004] The sleep apnea monitoring visualization method, device and storage medium proposed in the present invention can solve at least one of the technical problems in the background technology.
[0005] To achieve the above object, the present invention adopts the following technical solutions:
[0006] A sleep apnea monitoring visualization method mainly includes the following steps:
[0007] Step 1: Using the ECG signals in the PhysioNet Apnea-ECG sleep apnea database as data samples, divide the ECG signals into 1-minute segments according to their corresponding labels, and extract the R wave signal of each ECG signal segment;
[0008] Step 2: Obtain the RR interval signal (RRI) and the R wave peak signal (RA) according to the R wave signal and perform screening;
[0009] Step 3: Filter the RRI signal and interpolate the RA signal and the filtered RRI signal to 128 data points;
[0010] Step 4: Copy the interpolated RA signal and RRI signal 32 times respectively and then splice them to obtain a value of Matrix of
[0011] Step 5: Calculate the maximum, minimum, average, standard deviation, and root mean square of the interpolated RRI signal and the corresponding RA signal, and construct a radar chart;
[0012] Step 6: Combine the radar chart with the matrix formed in step 4 to construct the ECG signal feature map.
[0013] Step 7: Use convolutional neural network to classify ECG signal feature maps to achieve sleep apnea detection.
[0014] Furthermore, the step 1: using the ECG signal in the PhysioNet Apnea-ECG sleep apnea database as a data sample, dividing the ECG signal into 1-minute segments according to its corresponding label, and extracting the R wave signal of each ECG signal segment, specifically includes the following steps:
[0015] S101: The PhysioNet Apnea-ECG database is provided by Phillips University and contains 70 single-lead ECG signal records with a sampling rate of 100 Hz. The length of each record is between 401 and 587 minutes. For each 1-minute ECG signal recording segment, the dataset provides an expert annotation. If an apnea event occurs within that minute, it is marked as SA, otherwise it is recorded as normal N. According to the annotation, each record is divided and cut into 1-minute ECG signal segments.
[0016] S102: Use the Pan-Tompkins peak detection algorithm to identify the R wave for each ECG signal. First, pass the signal through a bandpass filter with a cutoff frequency of 5-15 Hz, then calculate the first-order derivative of the filtered signal, then perform a square operation on the derived signal, integrate the signal through a sliding window, and use the threshold method to identify the location of the R wave.
[0017] Furthermore, the step 2: obtaining the RR interval signal (RRI) and the R wave peak signal (RA) according to the R wave signal and screening them specifically includes the following steps:
[0018] S103: According to the located R wave position, the R wave peak generation time and the corresponding amplitude are recorded, the generation times of adjacent R wave peaks are subtracted to obtain the RRI signal, and the R wave peak amplitudes form the RA signal.
[0019] S104: Check the number of data points in each RRI signal segment, delete abnormal segments with a number of data points less than 30 and greater than 150, and the RA signal corresponding to the RRI signal segment.
[0020] Furthermore, the step 3: filtering the RRI signal and interpolating the RA signal and the filtered RRI signal to 128 data points specifically includes the following steps:
[0021] S105: Use the improved median filter algorithm to filter the RRI signal. The RRI signal is in the form of a one-dimensional sequence. First, set the upper bound UB and the lower bound LB, UB=2, LB=0.4, and find the minimum value in the RRI sequence, recorded as .
[0022] if , then the window center is set at the minimum value of the RRI sequence At, the window length is 2w+1, and the median in the window is calculated , and calculate and , the data in the window and , The calculation formulas are shown as follows:
[0023] (1)
[0024] (2)
[0025] (3)
[0026] In the formula, Indicates the data contained in the window, take , and Respectively represent the RRI sequence and The values before and after, and Respectively The 5th value counting forward and backward, when or When the RRI sequence index range is exceeded, the RRI sequence is border-filled. yes The median of the data, It means taking the minimum value among several given values. Indicates taking the maximum value among several given values.
[0027] get and Then, the RRI sequence The value is updated, and the update formula is:
[0028] (4)
[0029] In the formula It means the original After the update, continue to search for the minimum value in the RRI sequence and compare it with LB until it meets So far, start looking for the maximum value in the RRI sequence, denoted as .
[0030] if , select the window center as The window length is , calculate the median within the window , and calculate and , its calculation formula and window data are expressed as follows:
[0031] (5)
[0032] (6)
[0033] (7)
[0034] (8)
[0035] In the formula, It represents the data contained in the window. and Respectively represent the RRI sequence and The values before and after, and Respectively The fifth value taken forward and backward, when or When the RRI sequence index range is exceeded, the RRI sequence is border-filled. yes The median of the data, It means taking the minimum value among several given values. Indicates taking the maximum value among several given values.
[0036] Then The value is updated, and the update formula is:
[0037] (9)
[0038] In the formula It means the original The value after the value is updated, and after the update, continue to search for the maximum value in the RRI sequence until it satisfies until.
[0039] If both meet , , stop processing the current RRI signal.
[0040] S106: If the number of data points in the RA signal and the filtered RRI signal is greater than 128, the first 128 data are intercepted. If the number of data points is less than 128, cubic spline interpolation is used to obtain the RRI signal and RA signal with 128 data points. The cubic spline interpolation is a mathematical interpolation method that can expand the data.
[0041] Furthermore, in step 4: the interpolated RA sequence and RRI sequence are copied 32 times respectively and then spliced to obtain a size of The matrix specifically includes the following steps:
[0042] S107: Both RRI signal and RA signal are The RRI signal and RA signal are copied 32 times respectively and then concatenated to obtain the matrix I. The matrix I can be expressed as:
[0043] (10)
[0044] RRI and RA are repeated 32 times respectively, and the size of matrix I is , and can be displayed as a grayscale image.
[0045] Furthermore, the step 5: calculating the maximum value, minimum value, average value, standard deviation and root mean square of the interpolated RRI signal and the corresponding RA signal, and constructing a radar chart, specifically includes the following steps:
[0046] S108: Find the maximum and minimum values of the interpolated RRI signal and the corresponding RA signal, and calculate their average value, standard deviation, and root mean square. The calculation formula is as follows:
[0047] (11)
[0048] (12)
[0049] (13)
[0050] Where n represents the signal length, that is, the number of data points of the RRI signal and the RA signal. , represents the value of the i-th point in the RRI signal or RA signal, represents the average value, represents the standard deviation, represents root mean square.
[0051] S109: With the maximum value, minimum value, average value, standard deviation and root mean square as indicators, create coordinate axes corresponding to the above indicators in the radar chart. Specifically, a semicircle is made with a radius of unit 1, and a coordinate axis corresponding to each indicator is created in the semicircle, and the maximum value of all input indicator data is used as the maximum value of each coordinate axis, and other indicator data are normalized relative to the maximum value of the input data, and then the corresponding point is found in the coordinate axis of the corresponding indicator, and all the corresponding points are connected to form a polygon. After the above operation, the RRI and the corresponding RA signal can be simultaneously drawn on a radar chart.
[0052] Furthermore, the step 6: splicing the constructed radar chart with the matrix formed in step 4 to construct an ECG signal characteristic chart specifically includes the following steps:
[0053] S110: Since the radar chart is an RGB three-channel chart, including R, G, and B channel data, the radar chart generated in step 4 must be merged before stitching. A single-channel grayscale image is converted into a three-channel image. By assigning matrix I to the three channels R, G, and B respectively, a single-channel grayscale image can be converted into a three-channel image. , and then compare the radar chart with The images are stitched together to obtain the characteristic image of the ECG signal.
[0054] Furthermore, the step 7: using a convolutional neural network to classify the ECG signal feature graph specifically includes:
[0055] S111: Design the input layer size of the convolutional neural network to be In order to meet the size of the network input layer, the ECG feature map must be cropped before inputting it into the network. The image data is then passed through 5 convolutional layers, 5 pooling layers, and 4 fully connected layers to obtain the sleep apnea detection results. The 0 and 1 labels of the recognition results correspond to the normal and apnea conditions respectively.
[0056] The network combination method and parameter settings are: the convolution kernel size of all convolution layers is , the step size is 2, and the convolution kernel size of all pooling layers is , the step size is 1, as follows:
[0057] The input data size of the first convolutional layer is , the number of convolution kernels is 4, and the output data size of BN operation and ReLu operation is , denoted as .
[0058] The input data of the first pooling layer is , the output data size is , denoted as .
[0059] The input data of the second convolutional layer is , the number of convolution kernels is 8, and the output data size of BN and ReLu operations is , denoted as .
[0060] The input data of the second pooling layer is , the output data size is , denoted as .
[0061] The input data of the third convolutional layer is , the number of convolution kernels is 16, and the output data size of BN and ReLu operations is , denoted as .
[0062] The input data of the third pooling layer is , the output data size is , denoted as .
[0063] The input data of the 4th convolutional layer is , the number of convolution kernels is 32, and the output data size of BN and ReLu operations is , denoted as .
[0064] The input data of the 4th pooling layer is , the output data size is , denoted as .
[0065] The input data of the 5th convolutional layer is , the number of convolution kernels is 64, and the output data size of BN and ReLu operations is , denoted as .
[0066] The input data of the 5th pooling layer is , the output data size is , denoted as .
[0067] Then It is flattened into a one-dimensional vector and input into the first fully connected layer. The number of neurons in the first fully connected layer is 128, the number of neurons in the second fully connected layer is 64, the number of neurons in the third fully connected layer is 32, and the number of neurons in the fourth fully connected layer is 2. Finally, the detection result is obtained through the classification layer.
[0068] S112: Divide the ECG characteristic graph into a training set and a test set, input the training set into the convolutional neural network for training, and then input the test set into the trained convolutional neural network to obtain the sleep apnea detection result and the model test accuracy.
[0069] The training of the convolutional neural network is a self-learning and parameter optimization process of the convolutional neural network. After the training is completed, an optimal learnable network parameter can be obtained. Then the test set used to detect the training effect is input into the trained convolutional neural network to obtain the detection results and accuracy of sleep apnea.
[0070] On the other hand, the present invention further discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the above method.
[0071] On the other hand, the present invention further discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above method.
[0072] It can be seen from the above technical scheme that the present invention discloses a sleep apnea monitoring visualization method, which includes the following steps: step 1, taking the electrocardiogram signal in the PhysioNet Apnea-ECG sleep apnea database as a data set sample, dividing the electrocardiogram signal into 1-minute segments according to its given label, and extracting the R wave signal of each electrocardiogram signal segment; step 2, obtaining the RR interval signal (RR interval, RRI) and the R wave peak signal (R-amplitude, RA) according to the R wave signal and screening them; step 3, filtering the RRI signal, and interpolating the RA signal and the filtered RRI signal to 128 data points; step 4, copying the interpolated RA signal and the RRI signal 32 times respectively and then splicing them to obtain a size of matrix; Step 5, calculate the maximum value, minimum value, average value, standard deviation, root mean square of the interpolated RRI signal and RA signal, and construct a radar chart; Step 6, splice the radar chart and the matrix formed in step 4 to construct an ECG signal feature map. Step 7, use a convolutional neural network to classify the ECG signal feature map to achieve sleep apnea detection. The present invention represents the one-dimensional ECG signal related to sleep apnea as a two-dimensional feature image, realizes the visualization of the ECG signal, and displays the characteristics of the signal from multiple dimensions, so that the signal contains richer features. Based on the generated ECG signal feature map, a convolutional neural network can be used to detect sleep apnea, and the recognition accuracy rate reaches 84.18%. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 A flowchart of a sleep apnea monitoring visualization method according to an embodiment of the present invention;
[0074] Figure 2 A radar chart formed by the RRI signal and the corresponding RA signal;
[0075] Figure 3 To combine the radar map with the three-channel feature map The characteristic graph of the ECG signal is formed after splicing. DETAILED DESCRIPTION
[0076] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0077] A sleep apnea monitoring visualization method in this example has a flowchart as shown below: Figure 1 As shown, the specific steps include:
[0078] Step 1: Using the ECG signals in the PhysioNet Apnea-ECG sleep apnea database as data samples, divide the ECG signals into 1-minute segments according to their corresponding labels, and extract the R wave signal of each ECG signal segment, including the following specific steps:
[0079] S101: The PhysioNet Apnea-ECG database is provided by Phillips University and contains 70 single-lead ECG signal records with a sampling rate of 100 Hz. The length of each record is between 401 and 587 minutes. For each 1-minute ECG signal recording segment, the dataset provides an expert annotation. If an apnea event occurs within that minute, it is marked as SA, otherwise it is recorded as normal N. According to the annotation, each record is divided and cut into 1-minute ECG signal segments.
[0080] S102: Use the Pan-Tompkins peak detection algorithm to identify the R wave for each ECG signal. First, pass the signal through a bandpass filter with a cutoff frequency of 5-15 Hz, then calculate the first-order derivative of the filtered signal, then perform a square operation on the derived signal, integrate the signal through a sliding window, and use the threshold method to identify the location of the R wave.
[0081] Step 2: Obtain the RR interval signal (RRI) and the R wave peak signal (RA) according to the R wave signal and screen them, which specifically includes the following steps:
[0082] S103: According to the located R wave position, the R wave peak generation time and the corresponding amplitude are recorded, the generation times of adjacent R wave peaks are subtracted to obtain the RRI signal, and the R wave peak amplitudes form the RA signal.
[0083] S104: Check the number of data points in each RRI signal segment, delete abnormal segments with a number of data points less than 30 and greater than 150, and the RA signal corresponding to the RRI signal segment.
[0084] Step 3: Filter the RRI signal and interpolate the RA signal and the filtered RRI signal to 128 data points, which specifically includes the following steps:
[0085] S105: Use the improved median filter algorithm to filter the RRI signal. The RRI signal is in the form of a one-dimensional sequence. First, set the upper bound UB and the lower bound LB, UB=2, LB=0.4, and find the minimum value in the RRI sequence, recorded as .
[0086] if , then the window center is set at the minimum value of the RRI sequence At, the window length is 2w+1, and the median in the window is calculated , and calculate and , the data in the window and , The calculation formulas are as shown below:
[0087] (1)
[0088] (2)
[0089] (3)
[0090] In the formula, Indicates the data contained in the window, take , and Respectively represent the RRI sequence and The values before and after, and Respectively The 5th value counting forward and backward, when or When the RRI sequence index range is exceeded, the RRI sequence is border-filled. yes The median of the data, It means taking the minimum value among several given values. Indicates taking the maximum value among several given values.
[0091] get and Then, the RRI sequence The value is updated, and the update formula is:
[0092] (4)
[0093] In the formula It means the original After the update, continue to search for the minimum value in the RRI sequence and compare it with LB until it meets So far, start looking for the maximum value in the RRI sequence, denoted as .
[0094] if , select the window center as The window length is , calculate the median within the window , and calculate and , its calculation formula and window data are expressed as follows:
[0095] (5)
[0096] (6)
[0097] (7)
[0098] (8)
[0099] In the formula, It represents the data contained in the window. and Respectively represent the RRI sequence and The values before and after, and Respectively The fifth value taken forward and backward, when or When the RRI sequence index range is exceeded, the RRI sequence is border-filled. yes The median of the data, It means taking the minimum value among several given values. Indicates taking the maximum value among several given values.
[0100] Then The value is updated, and the update formula is:
[0101] (9)
[0102] In the formula It means the original The value after the value is updated, and after the update, continue to search for the maximum value in the RRI sequence until it satisfies until.
[0103] If both meet , , stop processing the current RRI signal.
[0104] S106: If the number of data points in the RA signal and the filtered RRI signal is greater than 128, the first 128 data are intercepted. If the number of data points is less than 128, cubic spline interpolation is used to obtain the RRI signal and RA signal with 128 data points. The cubic spline interpolation is a mathematical interpolation method that can expand the data.
[0105] Step 4: Copy the interpolated RA sequence and RRI sequence 32 times respectively and then splice them to obtain a size of The matrix specifically includes the following steps:
[0106] S107: Both RRI signal and RA signal are The RRI signal and RA signal are copied 32 times respectively and then concatenated to obtain the matrix I. The matrix I can be expressed as:
[0107] (10)
[0108] RRI and RA are repeated 32 times respectively, and the size of matrix I is , and can be displayed as a grayscale image.
[0109] Step 5: Calculate the maximum, minimum, average, standard deviation, and root mean square of the interpolated RRI signal and the corresponding RA signal, and construct a radar chart, which specifically includes the following steps:
[0110] S108: Find the maximum and minimum values of the interpolated RRI signal and the corresponding RA signal, and calculate their average value, standard deviation, and root mean square. The calculation formula is as follows:
[0111] (11)
[0112] (12)
[0113] (13)
[0114] Where n represents the signal length, that is, the number of data points of the RRI signal and the RA signal. , represents the value of the i-th point in the RRI signal or RA signal, represents the average value, represents the standard deviation, represents root mean square.
[0115] S109: Using the maximum value, minimum value, average value, standard deviation and root mean square as indicators, create coordinate axes corresponding to the above indicators in the radar chart. Specifically, a semicircle is made with a radius of unit 1, and a coordinate axis corresponding to each indicator is created in the semicircle, and the maximum value of all input indicator data is used as the maximum value of each coordinate axis, and other indicator data are normalized relative to the maximum value of the input data, and then the corresponding point is found in the coordinate axis of the corresponding indicator, and all the corresponding points are connected to form a polygon, such as Figure 2 As shown, after the above operation, the RRI and the corresponding RA signal can be simultaneously plotted on a radar chart.
[0116] Step 6: Concatenate the constructed radar chart with the matrix formed in step 4 to construct an ECG signal feature chart, which specifically includes the following steps:
[0117] S110: Since the radar image is a RGB three-channel image, the image generated in step 4 must be stitched together before it is stitched. A single-channel grayscale image is converted into a three-channel image. By assigning matrix I to the three channels R, G, and B respectively, a single-channel grayscale image can be converted into a three-channel image. , and then compare the radar chart with After splicing, we can get the ECG signal characteristic image. The ECG signal characteristic image is as follows: Figure 3 shown.
[0118] Step 7: Use convolutional neural network to classify ECG signal feature graphs, including:
[0119] S111: Design the input layer size of the convolutional neural network to be In order to meet the size of the network input layer, the ECG feature map must be cropped before inputting it into the network. The image data is then passed through 5 convolutional layers, 5 pooling layers, and 4 fully connected layers to obtain the sleep apnea detection results. The 0 and 1 labels of the recognition results correspond to the normal and apnea conditions respectively.
[0120] The network combination method and parameter settings are: the convolution kernel size of all convolution layers is , the step size is 2, and the convolution kernel size of all pooling layers is , the step size is 1, as follows:
[0121] The input data size of the first convolutional layer is , the number of convolution kernels is 4, and the output data size of BN operation and ReLu operation is , denoted as .
[0122] The input data of the first pooling layer is , the output data size is , denoted as .
[0123] The input data of the second convolutional layer is , the number of convolution kernels is 8, and the output data size of BN and ReLu operations is , denoted as .
[0124] The input data of the second pooling layer is , the output data size is , denoted as .
[0125] The input data of the third convolutional layer is , the number of convolution kernels is 16, and the output data size of BN and ReLu operations is , denoted as .
[0126] The input data of the third pooling layer is , the output data size is , denoted as .
[0127] The input data of the 4th convolutional layer is , the number of convolution kernels is 32, and the output data size of BN and ReLu operations is , denoted as .
[0128] The input data of the 4th pooling layer is , the output data size is , denoted as .
[0129] The input data of the 5th convolutional layer is , the number of convolution kernels is 64, and the output data size of BN and ReLu operations is , denoted as .
[0130] The input data of the 5th pooling layer is , the output data size is , denoted as .
[0131] Then It is flattened into a one-dimensional vector and input into the first fully connected layer. The number of neurons in the first fully connected layer is 128, the number of neurons in the second fully connected layer is 64, the number of neurons in the third fully connected layer is 32, and the number of neurons in the fourth fully connected layer is 2. Finally, the detection result is obtained through the classification layer.
[0132] S112: Divide the ECG characteristic graph into a training set and a test set, input the training set into the convolutional neural network for training, and then input the test set into the trained convolutional neural network to obtain the sleep apnea detection result and the model test accuracy.
[0133] The training of the convolutional neural network is a self-learning and parameter optimization process of the convolutional neural network. After the training is completed, an optimal learnable network parameter can be obtained. Then the test set used to detect the training effect is input into the trained convolutional neural network to obtain the detection results and accuracy of sleep apnea.
[0134] Specifically, the total number of ECG characteristic graph samples finally obtained from the PhysioNet Apnea-ECG sleep apnea database is 33485, which are divided into a training set and a test set, of which the number of training set samples is 16669 and the number of test set samples is 16768. The training set is input into the convolutional neural network for parameter training, and then the test set is input into the trained convolutional neural network to obtain the test set detection accuracy.
[0135] The parameter training of the convolutional neural network is the self-learning and parameter optimization process of the convolutional neural network. Through repeated parameter iterations, the optimal learnable network parameters can be obtained. Finally, the test set used to detect the training effect is input into the trained convolutional neural network to obtain the sleep apnea detection results. The convolutional neural network parameter training iterations are set to 30 times, the learning rate is 0.05, and the average detection accuracy of the test set is finally 84.18%.
[0136] In summary, the embodiment of the present invention discloses a sleep apnea monitoring visualization method, comprising the following steps: (1) using the electrocardiogram signal in the PhysioNet Apnea-ECG sleep apnea database as a data sample, dividing the electrocardiogram signal into 1-minute segments according to its corresponding label, and extracting the R wave signal of each electrocardiogram signal segment; (2) obtaining the RR interval signal (RRI) and the R wave peak signal (RA) according to the R wave signal and screening them; (3) filtering the RRI signal, and interpolating the RA signal and the filtered RRI signal to 128 data points; (4) copying the interpolated RA signal and the RRI signal 32 times respectively and then splicing them to obtain a size of matrix; (5) Calculate the maximum, minimum, average, standard deviation and root mean square of the interpolated RRI signal and the corresponding RA signal, and construct a radar chart; (6) Concatenate the radar chart with the matrix formed in step 4 to construct an ECG signal feature map. (7) Use a convolutional neural network to classify the ECG signal feature map to achieve sleep apnea detection. The present invention represents the one-dimensional ECG signal related to apnea as a two-dimensional feature image, realizes the visualization of the ECG signal, and displays the signal characteristics from multiple dimensions, making the signal characteristics richer. Based on the generated ECG signal feature map, a convolutional neural network can be used to detect sleep apnea, and the recognition accuracy rate reaches 84.18%.
[0137] On the other hand, the present invention further discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the above method.
[0138] On the other hand, the present invention further discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above method.
[0139] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any of the sleep apnea monitoring visualization methods in the above embodiments.
[0140] It is understandable that the system, device and storage medium provided in the embodiments of the present invention correspond to the method provided in the embodiments of the present invention, and the explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the above methods.
[0141] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0142] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0143] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0144] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A sleep apnea monitoring visualization method, characterized in that: The following steps are included: Step 1: Using the ECG signals in the PhysioNet Apnea-ECG sleep apnea database as data samples, divide the ECG signals into 1-minute segments according to their corresponding labels, and extract the R wave signal of each ECG signal segment; Step 2: Obtain the RR interval signal RRI and the R wave peak signal RA according to the R wave signal and screen them; Step 3: Filter the RRI signal and interpolate the RA signal and the filtered RRI signal to 128 data points; Step 4: Copy the interpolated RA signal and RRI signal 32 times respectively and then splice them to obtain a value of Matrix of Step 5: Calculate the maximum, minimum, average, standard deviation, and root mean square of the interpolated RRI signal and the corresponding RA signal, and construct a radar chart; Step 6: Combine the radar chart with the matrix formed in step 4 to construct an ECG signal feature map; Step 7: Use convolutional neural network to classify ECG signal feature maps to achieve sleep apnea detection.
2. The sleep apnea monitoring visualization method according to claim 1, characterized in that: The step 1: using the ECG signal in the PhysioNet Apnea-ECG sleep apnea database as a data sample, dividing the ECG signal into 1-minute segments according to its corresponding label, and extracting the R wave signal of each ECG signal segment, specifically includes the following steps: S101: The PhysioNet Apnea-ECG database contains 70 single-lead ECG signal records with a sampling rate of 100 Hz. The length of each record is between 401 and 587 minutes. For each 1-minute ECG signal recording segment, the dataset provides an expert annotation. If an apnea event occurs within this 1-minute period, it is marked as SA, otherwise it is recorded as normal N. Based on the annotation, each record is divided and cut into 1-minute ECG signal segments. S102: Use the Pan-Tompkins peak detection algorithm to identify the R wave for each ECG signal segment; first, pass the signal through a bandpass filter with a cutoff frequency of 5-15 Hz, then calculate the first-order derivative of the filtered signal, then square the derived signal, integrate the signal through a sliding window, and use the threshold method to identify the location of the R wave.
3. The sleep apnea monitoring visualization method according to claim 1, characterized in that: The step 2: obtaining the RR interval signal RRI and the R wave peak signal RA according to the R wave signal and screening them, specifically includes the following steps: S103: recording the R wave peak generation time and the corresponding amplitude according to the located R wave position, subtracting the generation times of adjacent R wave peaks to obtain an RRI signal, and forming an RA signal from the R wave peak amplitudes; S104: Check the number of data points in each RRI signal segment, delete abnormal segments with a number of data points less than 30 and greater than 150, and the RA signal corresponding to the RRI signal segment.
4. The sleep apnea monitoring visualization method according to claim 3, characterized in that: The step 3: filtering the RRI signal and interpolating the RA signal and the filtered RRI signal to 128 data points specifically includes the following steps: S105: Use the improved median filter algorithm to filter the RRI signal. The RRI signal is in the form of a one-dimensional sequence. First, set the upper bound UB and the lower bound LB, UB=2, LB=0.4, and find the minimum value in the RRI sequence, recorded as , if , then the window center is set at the minimum value of the RRI sequence At, the window length is 2w+1, and the median in the window is calculated , and calculate and , the data in the window and , The calculation formulas are as shown below: (1) (2) (3) In the formula, Indicates the data contained in the window, take , and Respectively represent the RRI sequence and The values before and after, and Respectively The 5th value counting forward and backward, when or When the RRI sequence index range is exceeded, the RRI sequence is border-filled; yes The median of the data, It means taking the minimum value among several given values. It means taking the maximum value among several given values; get and Then, the RRI sequence The value is updated, and the update formula is: (4) In the formula It means the original After the update, continue to search for the minimum value in the RRI sequence and compare it with LB until it meets So far, start looking for the maximum value in the RRI sequence, denoted as ; if , select the window center as The window length is , calculate the median within the window , and calculate and , its calculation formula and window data are expressed as follows: (5) (6) (7) (8) In the formula, It represents the data contained in the window. and Respectively represent the RRI sequence and The values before and after, and Respectively The fifth value taken forward and backward, when or When the RRI sequence index range is exceeded, the RRI sequence is border-filled; yes The median of the data, It means taking the minimum value among several given values. It means taking the maximum value among several given values; Then The value is updated, and the update formula is: (9) In the formula It means the original The value after the value is updated, and after the update, continue to search for the maximum value in the RRI sequence until it satisfies until; If both meet , , stop processing the current RRI signal; S106: If the number of data points in the RA signal and the filtered RRI signal is greater than 128, the first 128 data are intercepted; if the number of data points is less than 128, cubic spline interpolation is used to obtain the RRI signal and RA signal with 128 data points respectively.
5. The sleep apnea monitoring visualization method according to claim 4, characterized in that: Step 4: Copy the interpolated RA sequence and RRI sequence 32 times respectively and then splice them to obtain a size of The matrix specifically includes the following steps: S107: Both RRI signal and RA signal are The RRI signal and RA signal are copied 32 times respectively and then concatenated to obtain the matrix I. The matrix I is expressed as: (10) RRI and RA are repeated 32 times respectively, and the size of matrix I is , and can be displayed as a grayscale image.
6. The sleep apnea monitoring visualization method according to claim 5, characterized in that: The step 5: calculating the maximum value, minimum value, average value, standard deviation and root mean square of the interpolated RRI signal and the corresponding RA signal, and constructing a radar chart, specifically includes the following steps: S108: Find the maximum and minimum values of the interpolated RRI signal and the corresponding RA signal, and calculate their average value, standard deviation, and root mean square. The calculation formula is as follows: (11) (12) (13) Where n represents the signal length, that is, the number of data points of the RRI signal and the RA signal. , represents the value of the i-th point in the RRI signal or RA signal, represents the average value, represents the standard deviation, represents root mean square; S109: Using the maximum value, minimum value, average value, standard deviation and root mean square as indicators, create coordinate axes corresponding to the above indicators in the radar chart; specifically, make a semicircle with unit 1 as the radius, create coordinate axes corresponding to each of the indicators in the semicircle, and use the maximum value in the corresponding data of all input indicators as the maximum value of each coordinate axis, and normalize the data of other indicators relative to the maximum value of the input data, then find the corresponding point in the coordinate axis of the corresponding indicator, connect all the corresponding points to form a polygon, and finally draw the RRI and the corresponding RA signal on a radar chart at the same time.
7. The sleep apnea monitoring visualization method according to claim 1, characterized in that: The step 6: splicing the constructed radar chart with the matrix formed in step 4 to construct an ECG signal characteristic chart, specifically includes the following steps: S110: Since the radar chart formed is an RGB three-channel chart, which contains three channels of R, G, and B, the generated in step 4 must be merged before stitching. A single-channel grayscale image is converted into a three-channel image. By assigning matrix I to the three channels R, G, and B respectively, a single-channel grayscale image can be converted into a three-channel image. , and then compare the radar chart with The images are stitched together to obtain the characteristic image of the ECG signal.
8. The sleep apnea monitoring visualization method according to claim 1, characterized in that: The step 7: using a convolutional neural network to classify the ECG signal feature graph specifically includes: S111: Design the input layer size of the convolutional neural network to be In order to meet the size of the network input layer, the ECG feature map must be cropped before inputting it into the network. The image data is then passed through 5 convolutional layers, 5 pooling layers, and 4 fully connected layers to obtain the sleep apnea detection results. The 0 and 1 labels of the recognition results correspond to the normal and sleep apnea conditions respectively. S112: Divide the ECG characteristic graph into a training set and a test set, input the training set into the convolutional neural network for training, and then input the test set into the trained convolutional neural network to obtain the sleep apnea detection result and the test accuracy.
9. The sleep apnea monitoring visualization method according to claim 8, characterized in that: In step S111, the network combination mode and parameter settings are: the convolution kernel sizes of all convolution layers are , the step size is 2, and the convolution kernel size of all pooling layers is , the step size is 1, as follows: The input data size of the first convolutional layer is , the number of convolution kernels is 4, and the output data size of BN operation and ReLu operation is , denoted as ; The input data of the first pooling layer is , the output data size is , denoted as ; The input data of the second convolutional layer is , the number of convolution kernels is 8, and the output data size of BN and ReLu operations is , denoted as ; The input data of the second pooling layer is , the output data size is , denoted as ; The input data of the third convolutional layer is , the number of convolution kernels is 16, and the output data size of BN and ReLu operations is , denoted as ; The input data of the third pooling layer is , the output data size is , denoted as ; The input data of the 4th convolutional layer is , the number of convolution kernels is 32, and the output data size of BN and ReLu operations is , denoted as ; The input data of the 4th pooling layer is , the output data size is , denoted as ; The input data of the 5th convolutional layer is , the number of convolution kernels is 64, and the output data size of BN and ReLu operations is , denoted as ; The input data of the 5th pooling layer is , the output data size is , denoted as ; Then It is flattened into a one-dimensional vector and input into the first fully connected layer. The number of neurons in the first fully connected layer is 128, the number of neurons in the second fully connected layer is 64, the number of neurons in the third fully connected layer is 32, and the number of neurons in the fourth fully connected layer is 2. Finally, the detection result is obtained through the classification layer.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 9.
