Electrocardiosignal classification method based on double-view CNN-Transformer and external attention mechanism
The ECG signal classification method through dual-view CNN-Transformer and external attention mechanism solves the problem of poor performance of traditional models in complex classification tasks and improves the classification accuracy and model efficiency of ECG signal data.
Patent Information
- Application Number
- CN202410866281.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional ECG signal classification models perform poorly on complex classification tasks, with insufficient feature extraction and unfocused feature learning, resulting in low classification accuracy.
Using the ECG signal classification method based on dual-view CNN-Transformer and external attention mechanism, the ECG signal data is segmented and characterized through the dual-view model of heartbeat perspective and recording perspective, and the attention feature map is calculated based on the external attention mechanism. and spatial features for feature fusion and classification.
It improves the accuracy of classification results of ECG signal data, reduces the complexity and computational cost of the classification model, and improves the feature capture capability and classification performance of the traditional ECG classification model.
Smart Images

Figure CN118656702A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to an electrocardiogram signal classification method based on a dual-view CNN-Transformer and an external attention mechanism. Background Art
[0002] ECG signals can effectively reflect cardiac activity and show different characteristics under different cardiac states. In recent years, with the development of deep learning and neural networks, research on ECG signal classification has also developed rapidly. Compared with traditional feature extraction methods, deep learning and neural network methods can automatically extract key features in ECG signals, thereby achieving more accurate classification. However, when dealing with ECG signal classification, traditional network models still have some shortcomings, such as insufficient feature extraction and lack of focus on feature learning. These problems will cause the model to perform poorly on complex classification tasks and reduce the accuracy of classification. Summary of the invention
[0003] The present invention provides an ECG signal classification method based on dual-view CNN-Transformer and external attention mechanism, the main purpose of which is to solve the problem that the model in the related technology performs poorly on complex classification tasks and has low classification accuracy.
[0004] According to a first aspect of the present disclosure, a method for classifying electrocardiogram signals based on a dual-view CNN-Transformer and an external attention mechanism is provided, comprising:
[0005] Acquire ECG signal data, and segment the ECG signal data based on a fuzzy segmentation module of a heartbeat perspective to obtain a preset number of ECG signal segments;
[0006] Inputting the electrocardiogram signal segments into the first external attention mechanism and the first spatial feature extraction module of the heartbeat perspective respectively;
[0007] Calculating a pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, and extracting a first spatial feature of the ECG signal segment based on the first spatial feature extraction module;
[0008] Fusing the pooled first attention feature map and the first spatial feature to obtain a first spatial feature incorporating external attention;
[0009] A first temporal feature extraction module based on the heartbeat perspective extracts features from the first spatial feature integrated with external attention to obtain a temporal and spatial feature of an electrocardiogram signal segment;
[0010] Merging the temporal and spatial features of the ECG signal segments corresponding to the preset number of ECG signal segments to obtain a first temporal and spatial feature corresponding to the ECG signal data;
[0011] After acquiring the electrocardiogram signal data, the electrocardiogram signal data are respectively input into a second spatial feature extraction module and a second external attention mechanism of the recording perspective;
[0012] Extracting the second spatial feature of the electrocardiogram signal data based on the second spatial feature extraction module, and calculating a fourth attention feature map of the change of intervals between consecutive adjacent heartbeat waveforms of the electrocardiogram signal data based on the second external attention mechanism;
[0013] fusing the fourth attention feature map and the second spatial feature to obtain a second spatial feature integrating external attention;
[0014] A second temporal feature extraction module based on the recorded perspective extracts features from the second spatial feature incorporating external attention to obtain a second spatiotemporal feature;
[0015] Fusing the first spatiotemporal feature and the second spatiotemporal feature to obtain fused feature data;
[0016] The fused feature data is classified based on a classifier to obtain a classification result of the electrocardiogram signal data.
[0017] Optionally, the calculating of the pooled first attention feature map of the electrocardiogram signal segment based on the first external attention mechanism includes:
[0018] Calculate the sampling point slope of the electrocardiogram signal segment based on the preset slope algorithm in the first external attention mechanism to obtain the sampling point slope;
[0019] Calculating the slope of the sampling point based on the preset slope difference algorithm in the first external attention mechanism to obtain a second attention feature map;
[0020] Calculating the relative amplitude difference of the sampling points of the electrocardiogram signal segment based on the relative amplitude difference algorithm preset in the first external attention mechanism to obtain a third attention feature map;
[0021] Based on the preset weighted fusion algorithm in the first external attention mechanism, the second attention feature map and the third attention feature map are weightedly fused to obtain a first attention feature map;
[0022] Performing average pooling processing on the first attention feature map to obtain the pooled first attention feature map;
[0023] The formula of the preset slope algorithm is expressed as:
[0024]
[0025] Among them, X ij (t+1) is the sampling point amplitude at time t+1, X ij (t) is the sampling point amplitude at time t, (t+1)-t is the difference in time, and k(t) is the slope of the sampling point;
[0026] The formula of the preset slope difference algorithm is expressed as:
[0027]
[0028] Among them, k(t) is the slope of the sampling point corresponding to time t, k(t+1) is the slope of the sampling point at time t+1, is the second attention feature map;
[0029] The formula of the preset relative amplitude difference algorithm is expressed as:
[0030]
[0031] Among them, X ij (t) is the sampling point amplitude at time t, is the baseline amplitude, is the third attention feature map;
[0032] The formula of the preset weighted fusion algorithm is expressed as:
[0033]
[0034] Among them, ∈1 is the weight corresponding to the second attention feature map, ∈2 is the weight corresponding to the third attention feature map, δ1 is the bias term, Beat_Attention ij This is the first attention feature map.
[0035] Optionally, the fourth attention feature graph for calculating the change in intervals between consecutive adjacent heartbeat waveforms of the electrocardiogram signal data based on the second external attention mechanism includes:
[0036] Determine the target positions corresponding to the adjacent heartbeat waveforms in the electrocardiogram signal data based on a preset algorithm;
[0037] Calculating a target interval between the two adjacent heartbeat waveforms based on the target positions corresponding to the two adjacent heartbeat waveforms;
[0038] Calculating the target interval based on a preset relative ratio algorithm to obtain a relative ratio;
[0039] Performing average pooling processing on the relative ratio to obtain the fourth attention feature map;
[0040] The formula of the preset relative ratio algorithm is expressed as:
[0041]
[0042] Among them, τ(p) is the target interval between two adjacent heartbeat waveforms, τ(p-1) is the target interval between two adjacent heartbeat waveforms before τ(p), τ(p+1) is the target interval between two adjacent heartbeat waveforms after τ(p), and δ2 is the bias term.
[0043] Optionally, the acquiring of electrocardiogram signal data includes:
[0044] Acquire original ECG signal data, and perform noise reduction processing on the original ECG signal data based on a wavelet decomposition method to obtain noise-reduced original ECG signal data;
[0045] After downsampling and linear normalization of the original electrocardiogram signal data after noise reduction, enhancement processing is performed on the original electrocardiogram signal data after noise reduction based on a cutout algorithm to obtain the electrocardiogram signal data;
[0046] Acquire the electrocardiogram signal data.
[0047] Optionally, the method comprises:
[0048] The model algorithm of the heartbeat perspective and the model algorithm of the recording perspective are back-propagated and optimized using the Adam optimizer and the cross-entropy loss function so that the model algorithm of the heartbeat perspective and the model algorithm of the recording perspective are dynamically updated. The model algorithm of the heartbeat perspective includes the model segmentation module, the first external attention mechanism, the first spatial feature extraction module and the first temporal feature extraction module, and the model algorithm of the recording perspective includes the second external attention mechanism, the second spatial feature extraction module and the second temporal feature extraction module.
[0049] Optionally, the first spatial feature extraction module includes a first convolution layer, a first ReLU layer, a second convolution layer, a second ReLU layer, a first Max_Pooling layer, a third convolution layer, a third ReLU layer, a fourth convolution layer, a fourth ReLU layer, and a second Max_Pooling layer, and all convolution layers in the first spatial feature extraction module are one-dimensional, wherein the number of channels of the first convolution layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1, the number of channels of the second convolution layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1, the window of the first Max_Pooling layer is 5, the step size is 5, the number of channels of the third convolution layer is 128, the convolution kernel is 3, the step size is 1, and the padding is 1, the number of channels of the fourth convolution layer is 128, the convolution kernel is 3, the step size is 1, and the padding is 1, and the window of the first Max_Pooling layer is 2, and the step size is 2;
[0050] The second spatial feature extraction module includes a first convolution layer, a first ReLU layer, a second convolution layer, a second ReLU layer, a first Max_Pooling layer, a third convolution layer, a third ReLU layer, a fourth convolution layer, a fourth ReLU layer, a second Max_Pooling layer, a fifth convolution layer, a fifth ReLU layer, a sixth convolution layer, a sixth ReLU layer, and a third Max_Pooling layer. In the second spatial feature extraction module, all convolution layers are one-dimensional, wherein the number of channels of the first convolution layer is 32, the convolution kernel is 3, the stride is 1, and the padding is 1; the number of channels of the second convolution layer is 32, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the first Max_Pooling layer is 5 and the stride is 5. The number of channels of the third convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the fourth convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the second Max_Pooling layer is 2 and the stride is 2. The number of channels of the fifth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the sixth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the third Max_Pooling layer is 5 and the stride is 5.
[0051] According to a second aspect of the present disclosure, there is provided an electrocardiogram signal classification device based on a dual-view CNN-Transformer and an external attention mechanism, comprising:
[0052] An acquisition unit, used for acquiring ECG signal data, and segmenting the ECG signal data based on a fuzzy segmentation module of a heartbeat perspective to obtain a preset number of ECG signal segments;
[0053] A first input unit, configured to input the electrocardiogram signal segment into a first external attention mechanism and a first spatial feature extraction module of the heartbeat perspective respectively;
[0054] a first computing unit, configured to compute a pooled first attention feature map of the electrocardiogram signal segment based on the first external attention mechanism, and extract a first spatial feature of the electrocardiogram signal segment based on the first spatial feature extraction module;
[0055] A first fusion unit is used to fuse the pooled first attention feature map with the first spatial feature to obtain a first spatial feature that incorporates external attention;
[0056] A first extraction unit, configured to extract features of the first spatial features integrated with external attention based on the first temporal feature extraction module of the heartbeat perspective, and obtain temporal and spatial features of the electrocardiogram signal segment;
[0057] a merging unit, configured to merge the temporal and spatial features of the ECG signal segments corresponding to the preset number of ECG signal segments to obtain a first temporal and spatial feature corresponding to the ECG signal data;
[0058] A second input unit is used to input the electrocardiogram signal data into a second spatial feature extraction module and a second external attention mechanism of the recording perspective after acquiring the electrocardiogram signal data;
[0059] a second calculation unit, configured to extract a second spatial feature of the electrocardiogram signal data based on the second spatial feature extraction module, and calculate a fourth attention feature map of changes in intervals between consecutive adjacent heartbeat waveforms of the electrocardiogram signal data based on the second external attention mechanism;
[0060] A second fusion unit is used to fuse the fourth attention feature map and the second spatial feature to obtain a second spatial feature that incorporates external attention;
[0061] A second extraction unit, configured to extract the second spatial feature integrated with external attention based on the second temporal feature extraction module of the recorded perspective, to obtain a second spatiotemporal feature;
[0062] A third fusion unit, configured to fuse the first spatiotemporal feature and the second spatiotemporal feature to obtain fused feature data;
[0063] A classification unit is used to classify the fused feature data based on a classifier to obtain a classification result of the electrocardiogram signal data.
[0064] Optionally, the first computing unit is further used for:
[0065] Calculate the sampling point slope of the electrocardiogram signal segment based on the preset slope algorithm in the first external attention mechanism to obtain the sampling point slope;
[0066] Calculating the slope of the sampling point based on the preset slope difference algorithm in the first external attention mechanism to obtain a second attention feature map;
[0067] Calculating the relative amplitude difference of the sampling points of the electrocardiogram signal segment based on the relative amplitude difference algorithm preset in the first external attention mechanism to obtain a third attention feature map;
[0068] Based on a preset weighted fusion algorithm in the first external attention mechanism, the second attention feature map and the third attention feature map are weightedly fused to obtain the first attention feature map;
[0069] Performing average pooling processing on the first attention feature map to obtain the pooled first attention feature map;
[0070] The formula of the preset slope algorithm is expressed as:
[0071]
[0072] Among them, X ij (t+1) is the sampling point amplitude at time t+1, X ij (t) is the sampling point amplitude at time t, (t+1)-t is the difference in time, and k(t) is the slope of the sampling point;
[0073] The formula of the preset slope difference algorithm is expressed as:
[0074]
[0075] Among them, k(t) is the slope of the sampling point corresponding to time t, k(t+1) is the slope of the sampling point at time t+1, is the second attention feature map;
[0076] The formula of the preset relative amplitude difference algorithm is expressed as:
[0077]
[0078] Among them, X ij (t) is the sampling point amplitude at time t, is the baseline amplitude, is the third attention feature map;
[0079] The formula of the preset weighted fusion algorithm is expressed as:
[0080]
[0081] Among them, ∈1 is the weight corresponding to the second attention feature map, ∈2 is the weight corresponding to the third attention feature map, δ1 is the bias term, Beat_Attentionij This is the first attention feature map.
[0082] Optionally, the second computing unit is further used for:
[0083] Determine the target positions corresponding to the adjacent heartbeat waveforms in the electrocardiogram signal data based on a preset algorithm;
[0084] Calculating a target interval between the two adjacent heartbeat waveforms based on the target positions corresponding to the two adjacent heartbeat waveforms;
[0085] Calculating the target interval based on a preset relative ratio algorithm to obtain a relative ratio;
[0086] Performing average pooling processing on the relative ratio to obtain the fourth attention feature map;
[0087] The formula of the preset relative ratio algorithm is expressed as:
[0088]
[0089] Among them, τ(p) is the target interval between two adjacent heartbeat waveforms, τ(p-1) is the target interval between two adjacent heartbeat waveforms before τ(p), τ(p+1) is the target interval between two adjacent heartbeat waveforms after τ(p), and δ2 is the bias term.
[0090] Optionally, the acquisition unit is further used for:
[0091] Acquire original ECG signal data, and perform noise reduction processing on the original ECG signal data based on a wavelet decomposition method to obtain noise-reduced original ECG signal data;
[0092] After downsampling and linear normalization of the original electrocardiogram signal data after noise reduction, enhancement processing is performed on the original electrocardiogram signal data after noise reduction based on a cutout algorithm to obtain the electrocardiogram signal data;
[0093] Acquire the electrocardiogram signal data.
[0094] Optionally, the device is also used for:
[0095] The model algorithm of the heartbeat perspective and the model algorithm of the recording perspective are back-propagated and optimized using the Adam optimizer and the cross-entropy loss function so that the model algorithm of the heartbeat perspective and the model algorithm of the recording perspective are dynamically updated. The model algorithm of the heartbeat perspective includes the model segmentation module, the first external attention mechanism, the first spatial feature extraction module and the first temporal feature extraction module, and the model algorithm of the recording perspective includes the second external attention mechanism, the second spatial feature extraction module and the second temporal feature extraction module.
[0096] Optionally, the device includes: the first spatial feature extraction module includes a first convolution layer, a first ReLU layer, a second convolution layer, a second ReLU layer, a first Max_Pooling layer, a third convolution layer, a third ReLU layer, a fourth convolution layer, a fourth ReLU layer, and a second Max_Pooling layer, and all convolution layers in the first spatial feature extraction module are one-dimensional, wherein the number of channels of the first convolution layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1, the number of channels of the second convolution layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1, the window of the first Max_Pooling layer is 5, the step size is 5, the number of channels of the third convolution layer is 128, the convolution kernel is 3, the step size is 1, and the padding is 1, the number of channels of the fourth convolution layer is 128, the convolution kernel is 3, the step size is 1, and the padding is 1, and the window of the first Max_Pooling layer is 2, and the step size is 2;
[0097] The second spatial feature extraction module includes a first convolution layer, a first ReLU layer, a second convolution layer, a second ReLU layer, a first Max_Pooling layer, a third convolution layer, a third ReLU layer, a fourth convolution layer, a fourth ReLU layer, a second Max_Pooling layer, a fifth convolution layer, a fifth ReLU layer, a sixth convolution layer, a sixth ReLU layer, and a third Max_Pooling layer. In the second spatial feature extraction module, all convolution layers are one-dimensional, wherein the number of channels of the first convolution layer is 32, the convolution kernel is 3, the stride is 1, and the padding is 1; the number of channels of the second convolution layer is 32, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the first Max_Pooling layer is 5 and the stride is 5. The number of channels of the third convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the fourth convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the second Max_Pooling layer is 2 and the stride is 2. The number of channels of the fifth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the sixth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the third Max_Pooling layer is 5 and the stride is 5.
[0098] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0099] at least one processor; and
[0100] a memory communicatively connected to the at least one processor; wherein,
[0101] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.
[0102] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the first aspect.
[0103] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method as described in the first aspect above.
[0104] The present invention provides an ECG signal classification method based on a dual-view CNN-Transformer and an external attention mechanism, which obtains ECG signal data, segments the ECG signal data based on a fuzzy segmentation module from a heartbeat perspective, and obtains a preset number of ECG signal segments; respectively inputs the ECG signal segments into a first external attention mechanism and a first spatial feature extraction module from a heartbeat perspective; calculates a pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, and extracts a first spatial feature of the ECG signal segment based on the first spatial feature extraction module; fuses the pooled first attention feature map and the first spatial feature to obtain a first spatial feature integrated with external attention; extracts features from the first spatial feature integrated with external attention based on a first temporal feature extraction module from the heartbeat perspective to obtain spatiotemporal features of the ECG signal segment; and extracts the ECG signal corresponding to each of the preset number of ECG signal segments. The first spatial-temporal feature of the electrocardiogram data is merged to obtain the first spatial-temporal feature corresponding to the electrocardiogram data; after obtaining the electrocardiogram data, the electrocardiogram data is input into the second spatial feature extraction module and the second external attention mechanism of the recording perspective respectively; the second spatial feature of the electrocardiogram data is extracted based on the second spatial feature extraction module, and the fourth attention feature map of the continuous adjacent heartbeat waveform interval change of the electrocardiogram data is calculated based on the second external attention mechanism; the fourth attention feature map and the second spatial feature are fused to obtain the second spatial feature integrated with external attention; the second temporal feature extraction module of the recording perspective extracts the second spatial feature integrated with external attention to obtain the second spatial-temporal feature; the first spatial-temporal feature and the second spatial-temporal feature are fused to obtain fused feature data; the fused feature data is classified based on the classifier to obtain the classification result of the electrocardiogram data. Compared with the related art, by setting the classification model algorithm with the heartbeat perspective and the recording perspective, the above dual-perspective classification model algorithm is used to classify the electrocardiogram data, which improves the accuracy of the classification result of the electrocardiogram data, improves the classification efficiency, and reduces the complexity of the classification model algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0105] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0106] Figure 1 A schematic diagram of a flow chart of an electrocardiogram signal classification method based on a dual-view CNN-Transformer and an external attention mechanism provided in an embodiment of the present disclosure;
[0107] Figure 2 A flowchart of another electrocardiogram signal classification method based on dual-view CNN-Transformer and external attention mechanism provided by an embodiment of the present disclosure;
[0108] Figure 3 A schematic diagram of a sampling point slope provided by an embodiment of the present disclosure;
[0109] Figure 4 A schematic diagram of a sampling point amplitude provided by an embodiment of the present disclosure;
[0110] Figure 5 A schematic diagram of a process for weighted fusion of an attention feature map provided in an embodiment of the present disclosure;
[0111] Figure 6 A schematic diagram of sampling points with adjacent R-wave annotations provided in an embodiment of the present disclosure;
[0112] Figure 7 A schematic diagram of the structure of an electrocardiogram signal classification device based on a dual-view CNN-Transformer and an external attention mechanism provided in an embodiment of the present disclosure;
[0113] Figure 8 A schematic block diagram of an exemplary electronic device 300 provided for an embodiment of the present disclosure. DETAILED DESCRIPTION
[0114] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other without conflict.
[0115] The following detailed description is an exemplary description, which is intended to provide further detailed description of the present invention. Unless otherwise specified, all technical terms used in the present invention have the same meaning as those generally understood by those skilled in the art to which the present invention belongs. The terms used in the present invention are only for describing specific embodiments, and are not intended to limit the exemplary embodiments according to the present invention.
[0116] In addition, the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in sequences other than those illustrated or described herein.
[0117] The following describes an electrocardiogram signal classification method based on a dual-view CNN-Transformer and an external attention mechanism in an embodiment of the present disclosure with reference to the accompanying drawings.
[0118] In order to at least solve the problem that the model in the related art performs poorly on complex classification tasks and has low classification accuracy, this embodiment provides an ECG signal classification method based on a dual-view CNN-Transformer and an external attention mechanism.
[0119] Figure 1 A flowchart of an electrocardiogram signal classification method based on a dual-view CNN-Transformer and an external attention mechanism is provided in an embodiment of the present disclosure.
[0120] Figure 2 This is a flowchart of another ECG signal classification method based on dual-view CNN-Transformer and external attention mechanism provided by the embodiment of the present disclosure. Figure 2 right Figure 1 to understand the steps involved. Figure 1 As shown, the method comprises the following steps:
[0121] Step 101, acquiring ECG signal data, and segmenting the ECG signal data based on a fuzzy segmentation module of a heartbeat perspective to obtain a preset number of ECG signal segments;
[0122] As a refinement of the above step 101, in order to facilitate understanding of the process involved in step 101, an exemplary description is provided here, including: assuming that there are N electrocardiogram signals in a batch, for an electrocardiogram signal in the batch is X i (i∈1,2,…N), the X i That is the ECG signal data, for which X i It can also be described as a piece of ECG signal data in a batch. i The input is sent to the classification model algorithm composed of the model algorithm of the heartbeat perspective and the model algorithm of the recording perspective. In the classification model algorithm, all convolutions are one-dimensional. The classification model algorithm includes a fuzzy segmentation module, a first spatial feature extraction module, a first temporal feature extraction module, a first external attention mechanism, a second spatial feature extraction module, a second temporal feature extraction module, a second external attention mechanism, a feature fusion module and a classifier. The structure involved in the aforementioned classification model algorithm can be referred to Figure 2 , Figure 2 The fully connected layer shown in the figure constitutes the classifier, the output result of the first time series feature extraction module and the output result of the second time series feature extraction module need to be pooled by MaxPooling for feature fusion, and the fused features are re-represented based on the ReLU layer. Figure 2It can be seen that the heartbeat perspective is the observation perspective for extracting the first spatiotemporal features of the ECG signal segment, which includes the functional modules and processes for extracting the first spatiotemporal features of the ECG signal segment; the recording perspective is the observation perspective for extracting the second spatiotemporal features of the ECG signal data, which includes the functional modules and processes for extracting the second spatiotemporal features of the ECG signal data.
[0123] X i For example, the other samples in the same batch perform the same operation. First, X i Enter the fuzzy segmentation module and use the sliding window method to transform X i Divide into non-overlapping 1.5s equal length signal segments, and obtain M ECG signal segments X ij (j∈1,2,…M). X ij That is the electrocardiogram signal segment.
[0124] Step 102, inputting the ECG signal segments into the first external attention mechanism and the first spatial feature extraction module of the heartbeat perspective respectively;
[0125] As a refinement of the above step 102, the X ij Input the first spatial feature extraction module and convert the X ij A first external attention mechanism is input, wherein the first spatial feature extraction module is used to extract spatial features from the ECG signal segment, and the first external attention mechanism is used to describe the importance of each feature value in the ECG signal segment.
[0126] Step 103, calculating a pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, and extracting a first spatial feature of the ECG signal segment based on the first spatial feature extraction module;
[0127] As a refinement of the above step 103, the output of the first spatial feature extraction module is BF ij , the BF ij That is, the first spatial feature, and the output of the first external attention mechanism is Beat_Attention′ ij , the Beat_Attention′ ij It is the first attention feature map after pooling aligned with the first spatial feature dimension.
[0128] Step 104, fusing the pooled first attention feature map and the first spatial feature to obtain a first spatial feature that incorporates external attention;
[0129] As a refinement of the above step 104, in order to highlight the key feature information in the first spatial feature and suppress irrelevant information in the first spatial feature, the first attention feature map after pooling is fused with the first spatial feature. The specific fusion process includes: ij and Beat_Attention′ ij Multiply the elements together to get the feature BF that incorporates external attention ij ', the BF ij 'This is the first spatial feature that incorporates external attention.
[0130] Step 105, extracting features from the first spatial features integrated with external attention based on the first temporal feature extraction module of the heartbeat perspective to obtain temporal and spatial features of the ECG signal segment;
[0131] As a refinement of the above step 105, the BF ij 'Enter the first temporal feature extraction module. Use the triangular position encoding method to extract BF ij 'Perform position encoding and encode the BF ij 'Input the first Encoder layer of the first time series feature extraction module, and use the output of the first Encoder layer as the input of the second Encoder layer of the first time series feature extraction module to extract the BF ij ', the timing feature is the output BF of the first timing feature extraction module ij ", the BF ij " is the spatiotemporal feature of the ECG signal segment. Each Encoder layer includes a multi-head attention mechanism unit, a first residual connection and a normalization layer, a feedforward neural network, and a second residual connection and a normalization layer.
[0132] Step 106: Merge the temporal and spatial features of the ECG signal segments corresponding to the preset number of ECG signal segments to obtain a first temporal and spatial feature corresponding to the ECG signal data.
[0133] As a refinement of the above step 106, the M ECG signal segments X ij Output of BF ij Merge along the channel to generate BF i ", perform global maximum pooling, and get X i Spatiotemporal characteristics from the perspective of heartbeat Said This is the first spatiotemporal feature.
[0134] Step 107, after acquiring the ECG signal data, input the ECG signal data into a second spatial feature extraction module and a second external attention mechanism of the recording perspective respectively.
[0135] As a refinement of the above step 107, after the ECG signal data is obtained in step 101, the ECG signal data is respectively input into a second spatial feature extraction module and a second external attention mechanism of the recording perspective. The second spatial feature extraction module is used to extract spatial features from the ECG signal data, and the second external attention mechanism is used to describe the importance of each feature value in the ECG signal data.
[0136] Step 108: extract the second spatial feature of the ECG signal data based on the second spatial feature extraction module, and calculate the fourth attention feature map of the change in the interval between consecutive adjacent heartbeat waveforms of the ECG signal data based on the second external attention mechanism.
[0137] As a refinement of the above step 108, the output of the second spatial feature extraction module is RF i , the RF i That is, the second spatial feature, and the output of the second external attention mechanism is Record-Attention i ', the Record-Attention i 'This is the fourth attention feature map.
[0138] Step 109, fusing the fourth attention feature map and the second spatial feature to obtain a second spatial feature that incorporates external attention.
[0139] As a refinement of the above step 109, in order to highlight the key feature information in the second spatial feature and suppress the irrelevant information in the first spatial feature, the fourth attention feature map is fused with the second spatial feature. The specific fusion process includes: RF i Record-Attention i 'Element multiplication to obtain the feature RF that incorporates external attention i '. The RF i 'This is the second spatial feature that incorporates external attention.
[0140] Step 1010: A second temporal feature extraction module based on the recorded perspective extracts the second spatial feature integrated with external attention to obtain a second spatiotemporal feature.
[0141] As a refinement of the above step 1010, the RF i 'Enter the second time series feature extraction module. Use the triangular position encoding method to extract RF i 'Perform position encoding and encode the RF i'Input the first Encoder layer of the second time series feature extraction module, and use the output of the first Encoder layer as the input of the second Encoder layer of the second time series feature extraction module to extract the RF i ', the timing feature is the output RF of the second timing feature extraction module i ". For the RF i Perform global maximum pooling along the channel to obtain the spatiotemporal features of Xi at the recorded viewing angle Said That is the second spatiotemporal feature. Each Encoder layer includes a multi-head attention mechanism unit, a first residual connection and a normalization layer, a feedforward neural network, and a second residual connection and a normalization layer.
[0142] Step 1011: fuse the first spatiotemporal feature and the second spatiotemporal feature to obtain fused feature data.
[0143] As a refinement of the above step 1011, and Input into the fusion feature module, perform concat operation, and get F i The F i is the fused feature data.
[0144] Step 1012: classify the fused feature data based on a classifier to obtain a classification result of the electrocardiogram signal data.
[0145] As a refinement of the above step 1012, the Fi is input into the classifier to obtain the classification result of the ECG signal data. The classifier includes a fully connected layer with 9 neurons. The output of the fully connected layer is subjected to a sigmoid activation function to obtain the probability distribution Zi of Xi. The classification result of the ECG signal data is determined based on the probability distribution Zi.
[0146] In some embodiments, the first spatial feature extraction module, the first temporal feature extraction module, the second spatial feature extraction module, and the second temporal feature extraction module respectively include but are not limited to using a CNN-Transformer network model.
[0147] The present invention provides an ECG signal classification method based on a dual-view CNN-Transformer and an external attention mechanism, which obtains ECG signal data, segments the ECG signal data based on a fuzzy segmentation module from a heartbeat perspective, and obtains a preset number of ECG signal segments; respectively inputs the ECG signal segments into a first external attention mechanism and a first spatial feature extraction module from a heartbeat perspective; calculates a pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, and extracts a first spatial feature of the ECG signal segment based on the first spatial feature extraction module; fuses the pooled first attention feature map and the first spatial feature to obtain a first spatial feature integrated with external attention; extracts features from the first spatial feature integrated with external attention based on a first temporal feature extraction module from the heartbeat perspective to obtain spatiotemporal features of the ECG signal segment; and extracts the ECG signal corresponding to each of the preset number of ECG signal segments. The first spatial-temporal feature corresponding to the ECG signal data is merged; after obtaining the ECG signal data, the ECG signal data is input into the second spatial feature extraction module and the second external attention mechanism of the recording perspective respectively; the second spatial feature of the ECG signal data is extracted based on the second spatial feature extraction module, and the fourth attention feature map of the interval change of the continuous adjacent heartbeat waveform of the ECG signal data is calculated based on the second external attention mechanism; the fourth attention feature map and the second spatial feature are fused to obtain the second spatial feature integrated with external attention; the second temporal feature extraction module of the recording perspective is used to extract the second spatial feature integrated with external attention to obtain the second spatial-temporal feature; the first spatial-temporal feature and the second spatial-temporal feature are fused to obtain fused feature data; the fused feature data is classified based on the classifier to obtain the classification result of the ECG signal data. Compared with the related art, by setting the classification model algorithm with the heartbeat perspective and the recording perspective, the above dual-perspective classification model algorithm is used to classify the ECG signal data, thereby improving the accuracy of the classification result of the ECG signal data.
[0148] As a refinement of the embodiment of the present disclosure, when executing step 103 to calculate the pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, the following implementation methods may also be adopted but are not limited to, for example: calculating the sampling point slope of the ECG signal segment based on the preset slope algorithm in the first external attention mechanism to obtain the sampling point slope; calculating the sampling point slope based on the preset slope difference algorithm in the first external attention mechanism to obtain the second attention feature map; calculating the sampling point relative amplitude difference of the ECG signal segment based on the preset relative amplitude difference algorithm in the first external attention mechanism to obtain the third attention feature map; performing weighted fusion of the second attention feature map and the third attention feature map based on the preset weighted fusion algorithm in the first external attention mechanism to obtain the first attention feature map; performing average pooling processing on the first attention feature map to obtain the first attention feature map after pooling.
[0149] In order to facilitate understanding of the processes involved in the above embodiments, Figure 3 A schematic diagram of a sampling point slope provided in an embodiment of the present disclosure, Figure 4 A schematic diagram of a sampling point amplitude provided by an embodiment of the present disclosure, Figure 5 A schematic diagram of a process for weighted fusion of an attention feature map provided in an embodiment of the present disclosure, Figure 3 and Figure 4 The P wave, Q wave, R wave, S wave and T wave of the electrocardiogram are shown in Figure 5 The ECG signal segment shown is the electrocardiogram signal segment. Figure 2 The signal segments are described as signal segments, including signal segments 1 to signal segments N, where "N" is the last electrocardiogram signal segment in the preset number of electrocardiogram signal segments. Figure 5 The slope module calculates the slope difference of the sampling points, and the amplitude module calculates the relative amplitude of the sampling points. Figure 2 , Figure 3 , Figure 4 as well as Figure 5 , the specific calculation process of the first attention feature map after pooling includes:
[0150] The first external attention mechanism consists of two branches: the slope difference of the sampling point and the relative amplitude of the sampling point. The calculation process in the first branch slope module includes: first, the sampling point amplitude X is calculated according to formula (1) ij The slope k(t) of (t)(t∈1,2,…150) is then calculated according to formula (2) to calculate the sampling point amplitude X ij The slope k(t) and the amplitude X of the sampling point ijThe absolute value difference of the slope k(t+1) of (t+1) is used to obtain the attention map Beat_Attention output by the first branch ij 1 The Beat_Attention ij 1 is the second attention feature map.
[0151]
[0152] Formula (1) is the preset slope algorithm, where X ij (t+1) is the sampling point amplitude at time t+1, X ij (t) is the sampling point amplitude at time t, (t+1)-t is the time difference, k(t) is the sampling point slope, X ij (t) is X ij The sampling point amplitude of the ECG signal segment at time t;
[0153]
[0154] Formula (2) is the preset slope difference algorithm, where k(t) is the slope of the sampling point corresponding to time t, k(t+1) is the slope of the sampling point at time t+1, is the second attention feature map;
[0155] The calculation process in the second branch amplitude module includes calculating the sampling point X according to formula (3): ij (t) and baseline amplitude The relative amplitude difference of the second branch outputs the attention feature map Beat_Attention ij 2 . Beat_Attention ij 1 and Beat_Attention ij 2 The sizes are the same, and they are weighted fused according to formula (4) to obtain the heartbeat external attention feature map representation Beat_Attention ij The number of channels is 1 and the attention mechanism dimension is 150. In order to align the spatial feature dimension of the heartbeat perspective with the dimension of the attention feature map, Beat_Attention ij Perform average pooling and output Beat_Attention′ ij . Beat_Attention ij is the first attention feature map, and the pooling size when the first attention feature map is averaged pooled is 10, and the step size is 10. ij2 is the third attention feature map. The first attention feature map after pooling is the Beat_Attention′ ij .
[0156]
[0157] Formula (3) is the preset relative amplitude difference algorithm, where X ij (t) is the sampling point amplitude at time t, is the baseline amplitude, It is the third attention feature map.
[0158]
[0159] Formula (4) is the preset weighted fusion algorithm, where ∈1 is the weight corresponding to the second attention feature map, ∈2 is the weight corresponding to the third attention feature map, δ1 is the bias term, and Beat_Attention ij This is the first attention feature map.
[0160] In some embodiments, the baseline amplitude The baseline value is obtained by normalizing the baseline value, and the baseline value is 0. The specific normalization process of the baseline amplitude includes but is not limited to: obtaining all sampling point amplitudes of the heartbeat signal, subtracting the baseline value from the largest sampling point amplitude among all sampling point amplitudes to obtain a first target difference, subtracting the largest sampling point amplitude from the smallest sampling point amplitude among all sampling point amplitudes to obtain a second target difference, and the result of dividing the first target difference by the second target difference is the baseline amplitude. It can be seen from the above calculation process that the baseline amplitude is determined by the sampling point amplitude obtained by sampling the heartbeat signal, and it is not a fixed value.
[0161] As a refinement of the above embodiment, when executing step 108 of calculating the fourth attention feature map of the changes in the intervals between consecutive adjacent heartbeat waveforms of the electrocardiogram signal data based on the second external attention mechanism, the following implementation methods may also be used but are not limited to, for example: determining the target positions corresponding to each adjacent heartbeat waveform in the electrocardiogram signal data based on a preset algorithm; calculating the target interval between the two adjacent heartbeat waveforms based on the target positions corresponding to each of the two adjacent heartbeat waveforms; calculating the target interval based on a preset relative ratio algorithm to obtain a relative ratio; and performing average pooling processing on the relative ratio to obtain the fourth attention feature map.
[0162] To facilitate understanding of the above steps, Figure 6A schematic diagram of a sampling point with adjacent R wave annotations provided in an embodiment of the present disclosure, combined with Figure 6 The calculation process of the fourth attention feature map is described. It includes:
[0163] Assume X i There are Q R waves in the system, and the Hamilton method, i.e., the preset algorithm, is used to detect X i The location of the R wave is the target location, and the R wave index t is obtained. p (p∈1,2,…Q), calculate the adjacent RR interval τ(p)=t p+1 ―t p , the relative ratio of the continuous RR interval changes is calculated according to formula (5) to obtain Record-Attention i , and then average pooling is performed according to the total pooling size of the record view space feature extraction module, and the output is Record-Attention i '. The Record-Attention i ' is the fourth attention feature map, the Record-Attention i is the relative ratio, the pooling size when performing average pooling on the relative ratio is 50, the step size is 50, and the relative ratio is average pooled to obtain the fourth attention feature map.
[0164]
[0165] Formula (5) is the preset relative ratio algorithm, wherein τ(p) is the target interval of two adjacent heartbeat waveforms, τ(p-1) is the target interval of two adjacent heartbeat waveforms prior to τ(p), τ(p+1) is the target interval of two adjacent heartbeat waveforms after τ(p), and δ2 is the bias term. The total pooling size is the product of the window values of all Max_Pooling layers in the second spatial feature extraction module. It should be understood that the same heartbeat waveform in this embodiment is an R wave. This embodiment is described with an R wave for exemplary purposes only and does not constitute a limitation on the present disclosure. Therefore, P waves, Q waves, etc. can all be replacement elements of this embodiment.
[0166] As a refinement of the above embodiment, when executing step 101 to obtain the ECG signal data, the method may adopt but is not limited to the following implementation methods, for example: obtaining original ECG signal data, performing noise reduction processing on the original ECG signal data based on the wavelet decomposition method to obtain the noise-reduced original ECG signal data; after downsampling and linear normalization of the noise-reduced original ECG signal data, performing enhancement processing on the noise-reduced original ECG signal data based on the cutout algorithm to obtain the ECG signal data; obtaining the ECG signal data.
[0167] In some embodiments, the original ECG signal data includes but is not limited to being obtained from the CPSC 2018 data set, and the sampling frequency during the acquisition process is 500 Hz and the duration is 6-60 seconds. In order to improve the signal quality and classification performance, the original ECG signal data is denoised using the wavelet decomposition method, and then downsampled and linearly normalized. The cutout method is used to enhance the data of the denoised original ECG signal data. The ECG signal data includes but is not limited to LBBB and STE ECG data.
[0168] As a refinement of the above embodiment, the method can also adopt but is not limited to the following implementation methods, for example: using the Adam optimizer and the cross entropy loss function to perform back propagation optimization on the model algorithm of the heartbeat perspective and the model algorithm of the recording perspective, so that the model algorithm of the heartbeat perspective and the model algorithm of the recording perspective are dynamically updated, the model algorithm of the heartbeat perspective includes the model segmentation module, the first external attention mechanism, the first spatial feature extraction module and the first temporal feature extraction module, and the model algorithm of the recording perspective includes the second external attention mechanism, the second spatial feature extraction module and the second temporal feature extraction module.
[0169] As a refinement of the above embodiment, the first spatial feature extraction module includes a first convolution layer, a first ReLU layer, a second convolution layer, a second ReLU layer, a first Max_Pooling layer, a third convolution layer, a third ReLU layer, a fourth convolution layer, a fourth ReLU layer, and a second Max_Pooling layer. All convolution layers in the first spatial feature extraction module are one-dimensional, wherein the number of channels of the first convolution layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1. The number of channels of the second convolution layer is 64, The convolution kernel is 3, the step size is 1, the padding is 1, the window of the first Max_Pooling layer is 5, the step size is 5, the number of channels of the third convolution layer is 128, the convolution kernel is 3, the step size is 1, the padding is 1, the number of channels of the fourth convolution layer is 128, the convolution kernel is 3, the step size is 1, the padding is 1, the window of the first Max_Pooling layer is 2, and the step size is 2; the second spatial feature extraction module includes a first convolution layer, a first ReLU layer, a second convolution layer, a second ReLU layer, a first Max_Pooling layer, The third convolution layer, the third ReLU layer, the fourth convolution layer, the fourth ReLU layer, the second Max_Pooling layer, the fifth convolution layer, the fifth ReLU layer, the sixth convolution layer, the sixth ReLU layer, the third Max_Pooling layer, in the second spatial feature extraction module, all convolution layers are one-dimensional, among which the number of channels of the first convolution layer is 32, the convolution kernel is 3, the step size is 1, and the padding is 1; the number of channels of the second convolution layer is 32, the convolution kernel is 3, the step size is 1, and the padding is 1; the first Max_Pooling layer ling layer has a window of 5 and a stride of 5, the number of channels of the third convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1, the number of channels of the fourth convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1, the window of the second Max_Pooling layer is 2 and the stride is 2, the number of channels of the fifth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1, the number of channels of the sixth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1, and the window of the third Max_Pooling layer is 5 and the stride is 5.
[0170] In order to more clearly demonstrate the beneficial effects of the ECG signal classification method based on the dual-view CNN-Transformer and the external attention mechanism provided by the present disclosure, the performance parameters of the classification model algorithm with the heartbeat view and the recording view provided by the method of the present disclosure are compared with the performance parameters of the relevant classification task model. The comparison process is as follows:
[0171] Method Accuracy(%) F1 Score RestNet50 77.4±0.67 0.757±0.01 InceptionTime 78.9±0.62 0.766±0.01 Wang et al. 84.4±1.5 0.833±0.02 Zhang et al. 80.2±1.1 0.792±0.01 Ours 86.3±1.21 0.854±0.01
[0172] Based on the CPSC 2018 dataset, the classification model algorithm proposed in this disclosure is compared with the mainstream classification task models (RestNet50, InceptionTime) proposed in References 1 and 2, and the ECG classification models (Yao et al., Zhang et al.) proposed in References 3 and 4. All models to be compared are carried out under uniform experimental conditions, and the hyperparameters of all network architectures are manually adjusted to the optimal level. Accuracy and F1-Score are selected as evaluation indicators. The k-fold cross-validation method is used to calculate the mean and variance of the obtained evaluation results, and k is taken as 5.
[0173] According to the evaluation indicators and statistical data in Table 1, the following conclusions can be drawn: Compared with the two mainstream classification models of RestNet50 and InceptionTime and the two ECG classification models of Yao et al. and Zhang et al., the classification model algorithm Ours proposed in the present disclosure shows better classification performance. In the comparison of accuracy and F1 score, Ours showed a higher level. This shows that Ours is more outstanding in overall performance, can reduce the risk of missed diagnosis in the evaluation process, and provide more reliable signals for subsequent tasks. Among them, the source and related information of citation document 1: K.He, X.Zhang, S.Ren, J.Sun, Deep residual learning for image recognition, in: Proceedings of the IEEE conference on computer vision and patternrecognition, 2016, pp.770-778. Citation document 1 proposes the RestNet50 classification task model in Table 1. Reference 2: H.Ismail Fawaz, B.Lucas, G.Forestier, C.Pelletier, DF Schmidt, J.Weber, GI Webb, L Idoumghar, P.-A.Muller, F.Petitjean, Inception time: Finding alexnet for time series classification, Data Mining and Knowledge Discovery 34(6)(2020)1936-1962. Reference 2 proposes the Inception Time classification task model in Table 1. Reference 3: R.Wang, J.Fan, Y.Li, Deep multi-scale fusion neural network for multiclass arrhythmia detection, IEEE journal of biomedical and healthinformatics 24(9)(2020)2461-2472. Reference 3 proposes the Wang et al. ECG classification model in Table 1.Reference 4 source and related information: A token selection-basednmulti-scaledual-branch cnn-transformer network for 12-lead ecgsignalnclassification, Knowledge-Based Systems (2023) 111006. Reference 4 proposes the Zhang et al. ECG classification model in Table 1.
[0174] Table 2 is a comparison table of different model complexity
[0175] Method Parameter(M) Flops(M) RestNet50 15.978 2439.168 InceptionTime 0.303 938.564 Wang et al. 7.079 831.488 Zhang et al. 31.168 3469.184 Ours 2.806 762.776
[0176] Table 2 selects the number of model parameters and floating point operations (FLOPs) to compare the complexity of each model in Table 1. As shown in Table 2, compared with the other four reference models, Ours has a lower number of parameters and much lower floating point operations than other models, showing a lower model complexity.
[0177] In summary, from the perspective of model performance, Ours can achieve better classification results with lower model complexity, showing that it has a good ability to distinguish ECG signals in practical application environments, especially in wearable product environments.
[0178] In summary, the embodiments of the present disclosure can achieve the following effects:
[0179] 1. By setting the heartbeat perspective and the recording perspective, the above dual-perspective classification model algorithm classifies the ECG signal data, thereby improving the accuracy of the ECG signal data classification results, improving the classification efficiency, and reducing the complexity of the classification model algorithm.
[0180] 2. The classification model algorithm fully learns the dual-view information of ECG signals through the combination and optimization of multiple modules, captures key features, and improves the feature capture ability and classification performance of traditional ECG classification models
[0181] Corresponding to the above-mentioned ECG signal classification method based on dual-view CNN-Transformer and external attention mechanism, the present invention also proposes an ECG signal classification device based on dual-view CNN-Transformer and external attention mechanism. Since the device embodiment of the present invention corresponds to the above-mentioned method embodiment, the details not disclosed in the device embodiment can be referred to the above-mentioned method embodiment, and will not be repeated in the present invention.
[0182] Figure 7A schematic diagram of the structure of an electrocardiogram signal classification device based on a dual-view CNN-Transformer and an external attention mechanism provided by an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, including:
[0183] An acquisition unit 21 is used to acquire ECG signal data, and segment the ECG signal data based on a fuzzy segmentation module of a heartbeat perspective to obtain a preset number of ECG signal segments;
[0184] A first input unit 22, used to input the electrocardiogram signal segment into a first external attention mechanism and a first spatial feature extraction module of the heartbeat perspective respectively;
[0185] a first calculation unit 23, configured to calculate a pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, and extract a first spatial feature of the ECG signal segment based on the first spatial feature extraction module;
[0186] A first fusion unit 24 is used to fuse the pooled first attention feature map with the first spatial feature to obtain a first spatial feature that incorporates external attention;
[0187] A first extraction unit 25, configured to extract features of the first spatial features integrated with external attention based on the first temporal feature extraction module of the heartbeat perspective, and obtain temporal and spatial features of the ECG signal segment;
[0188] A merging unit 26, configured to merge the temporal and spatial features of the ECG signal segments corresponding to the preset number of ECG signal segments to obtain a first temporal and spatial feature corresponding to the ECG signal data;
[0189] A second input unit 27 is used to input the ECG signal data into a second spatial feature extraction module and a second external attention mechanism of the recording perspective after acquiring the ECG signal data;
[0190] A second calculation unit 28 is used to extract the second spatial feature of the electrocardiogram signal data based on the second spatial feature extraction module, and calculate a fourth attention feature map of the change of the interval between consecutive adjacent heartbeat waveforms of the electrocardiogram signal data based on the second external attention mechanism;
[0191] A second fusion unit 29 is used to fuse the fourth attention feature map and the second spatial feature to obtain a second spatial feature that incorporates external attention;
[0192] A second extraction unit 210 is used to extract the second spatial feature integrated with external attention based on the second temporal feature extraction module of the recorded perspective to obtain a second spatiotemporal feature;
[0193] A third fusion unit 211 is used to fuse the first spatiotemporal feature and the second spatiotemporal feature to obtain fused feature data;
[0194] The classification unit 212 is used to classify the fused feature data based on a classifier to obtain a classification result of the electrocardiogram signal data.
[0195] The present invention provides an ECG signal classification method based on a dual-view CNN-Transformer and an external attention mechanism, which obtains ECG signal data, segments the ECG signal data based on a fuzzy segmentation module from a heartbeat perspective, and obtains a preset number of ECG signal segments; respectively inputs the ECG signal segments into a first external attention mechanism and a first spatial feature extraction module from a heartbeat perspective; calculates a pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, and extracts a first spatial feature of the ECG signal segment based on the first spatial feature extraction module; fuses the pooled first attention feature map and the first spatial feature to obtain a first spatial feature integrated with external attention; extracts features from the first spatial feature integrated with external attention based on a first temporal feature extraction module from the heartbeat perspective to obtain spatiotemporal features of the ECG signal segment; and extracts the ECG signal corresponding to each of the preset number of ECG signal segments. The first spatial-temporal feature corresponding to the ECG signal data is merged; after obtaining the ECG signal data, the ECG signal data is respectively input into the second spatial feature extraction module and the second external attention mechanism of the recording perspective; the second spatial feature of the ECG signal data is extracted based on the second spatial feature extraction module, and the fourth attention feature map of the interval change of the continuous adjacent heartbeat waveform of the ECG signal data is calculated based on the second external attention mechanism; the fourth attention feature map and the second spatial feature are fused to obtain the second spatial feature integrated with external attention; the second temporal feature extraction module of the recording perspective extracts the second spatial feature integrated with external attention to obtain the second spatial-temporal feature; the first spatial-temporal feature and the second spatial-temporal feature are fused to obtain fused feature data; the fused feature data is classified based on the classifier to obtain the classification result of the ECG signal data. Compared with the related art, by setting the classification model algorithm with the heartbeat perspective and the recording perspective, the above dual-perspective classification model algorithm classifies the ECG signal data, which improves the accuracy of the classification result of the ECG signal data, improves the classification efficiency, and reduces the complexity of the classification model algorithm.
[0196] Furthermore, in a possible implementation of the embodiment of the present disclosure, as Figure 7 As shown, the first calculation unit 23 is also used for:
[0197] Calculate the sampling point slope of the electrocardiogram signal segment based on the preset slope algorithm in the first external attention mechanism to obtain the sampling point slope;
[0198] Calculating the slope of the sampling point based on the preset slope difference algorithm in the first external attention mechanism to obtain a second attention feature map;
[0199] Calculating the relative amplitude difference of the sampling points of the electrocardiogram signal segment based on the relative amplitude difference algorithm preset in the first external attention mechanism to obtain a third attention feature map;
[0200] Based on the preset weighted fusion algorithm in the first external attention mechanism, the second attention feature map and the third attention feature map are weightedly fused to obtain a first attention feature map;
[0201] Performing average pooling processing on the first attention feature map to obtain the pooled first attention feature map;
[0202] The formula of the preset slope algorithm is expressed as:
[0203]
[0204] Among them, X ij (t+1) is the sampling point amplitude at time t+1, X ij (t) is the sampling point amplitude at time t, (t+1)-t is the difference in time, and k(t) is the slope of the sampling point;
[0205] The formula of the preset slope difference algorithm is expressed as:
[0206]
[0207] Among them, k(t) is the slope of the sampling point corresponding to time t, k(t+1) is the slope of the sampling point at time t+1, is the second attention feature map;
[0208] The formula of the preset relative amplitude difference algorithm is expressed as:
[0209]
[0210] Among them, X ij (t) is the sampling point amplitude at time t, is the baseline amplitude, is the third attention feature map;
[0211] The formula of the preset weighted fusion algorithm is expressed as:
[0212]
[0213] Among them, ∈1 is the weight corresponding to the second attention feature map, ∈2 is the weight corresponding to the third attention feature map, δ1 is the bias term, Beat_Attention ij This is the first attention feature map.
[0214] Optionally, the second calculating unit 28 is further used for:
[0215] Determine the target positions corresponding to the adjacent heartbeat waveforms in the electrocardiogram signal data based on a preset algorithm;
[0216] Calculating a target interval between the two adjacent heartbeat waveforms based on the target positions corresponding to the two adjacent heartbeat waveforms;
[0217] Calculating the target interval based on a preset relative ratio algorithm to obtain a relative ratio;
[0218] Performing average pooling processing on the relative ratio to obtain the fourth attention feature map;
[0219] The formula of the preset relative ratio algorithm is expressed as:
[0220]
[0221] Among them, τ(p) is the target interval between two adjacent heartbeat waveforms, τ(p-1) is the target interval between two adjacent heartbeat waveforms before τ(p), τ(p+1) is the target interval between two adjacent heartbeat waveforms after τ(p), and δ2 is the bias term.
[0222] Optionally, the acquiring unit 21 is further used for:
[0223] Acquire original ECG signal data, and perform noise reduction processing on the original ECG signal data based on a wavelet decomposition method to obtain noise-reduced original ECG signal data;
[0224] After downsampling and linear normalization of the original electrocardiogram signal data after noise reduction, enhancement processing is performed on the original electrocardiogram signal data after noise reduction based on a cutout algorithm to obtain the electrocardiogram signal data;
[0225] Acquire the electrocardiogram signal data.
[0226] Optionally, the device is also used for:
[0227] The model algorithm of the heartbeat perspective and the model algorithm of the recording perspective are back-propagated and optimized using the Adam optimizer and the cross-entropy loss function so that the model algorithm of the heartbeat perspective and the model algorithm of the recording perspective are dynamically updated. The model algorithm of the heartbeat perspective includes the model segmentation module, the first external attention mechanism, the first spatial feature extraction module and the first temporal feature extraction module, and the model algorithm of the recording perspective includes the second external attention mechanism, the second spatial feature extraction module and the second temporal feature extraction module.
[0228] Optionally, the device includes: the first spatial feature extraction module includes a first convolution layer, a first ReLU layer, a second convolution layer, a second ReLU layer, a first Max_Pooling layer, a third convolution layer, a third ReLU layer, a fourth convolution layer, a fourth ReLU layer, and a second Max_Pooling layer, and all convolution layers in the first spatial feature extraction module are one-dimensional, wherein the number of channels of the first convolution layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1, the number of channels of the second convolution layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1, the window of the first Max_Pooling layer is 5, the step size is 5, the number of channels of the third convolution layer is 128, the convolution kernel is 3, the step size is 1, and the padding is 1, the number of channels of the fourth convolution layer is 128, the convolution kernel is 3, the step size is 1, and the padding is 1, and the window of the first Max_Pooling layer is 2, and the step size is 2;
[0229] The second spatial feature extraction module includes a first convolution layer, a first ReLU layer, a second convolution layer, a second ReLU layer, a first Max_Pooling layer, a third convolution layer, a third ReLU layer, a fourth convolution layer, a fourth ReLU layer, a second Max_Pooling layer, a fifth convolution layer, a fifth ReLU layer, a sixth convolution layer, a sixth ReLU layer, and a third Max_Pooling layer. In the second spatial feature extraction module, all convolution layers are one-dimensional, wherein the number of channels of the first convolution layer is 32, the convolution kernel is 3, the stride is 1, and the padding is 1; the number of channels of the second convolution layer is 32, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the first Max_Pooling layer is 5 and the stride is 5. The number of channels of the third convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the fourth convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the second Max_Pooling layer is 2 and the stride is 2. The number of channels of the fifth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the sixth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the third Max_Pooling layer is 5 and the stride is 5.
[0230] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and the principle is the same, which is no longer limited in this embodiment.
[0231] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0232] Figure 8 A schematic block diagram of an example electronic device 300 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0233] like Figure 8 As shown, the device 300 includes a computing unit 301, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 302 or a computer program loaded from a storage unit 308 to a RAM (Random Access Memory) 303. In the RAM 303, various programs and data required for the operation of the device 300 can also be stored. The computing unit 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An I / O (Input / Output) interface 305 is also connected to the bus 304.
[0234] A number of components in the device 300 are connected to the I / O interface 305, including: an input unit 306, such as a keyboard, a mouse, etc.; an output unit 307, such as various types of displays, speakers, etc.; a storage unit 308, such as a disk, an optical disk, etc.; and a communication unit 309, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 309 allows the device 300 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0235] The computing unit 301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Units), various dedicated AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, a DSP (Digital Signal Processor), and any appropriate processor, controller, microcontroller, etc. The computing unit 301 performs the various methods and processes described above, such as an ECG signal classification method based on a dual-view CNN-Transformer and an external attention mechanism. For example, in some embodiments, an ECG signal classification method based on a dual-view CNN-Transformer and an external attention mechanism may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 300 via the ROM 302 and / or the communication unit 309. When the computer program is loaded into RAM 303 and executed by the computing unit 301, one or more steps of the method described above may be performed. Alternatively, in other embodiments, the computing unit 301 may be configured to perform the aforementioned ECG signal classification method based on dual-view CNN-Transformer and external attention mechanism in any other appropriate manner (e.g., by means of firmware).
[0236] Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application Specific Standard Products), SOCs (System On Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor that may be a dedicated or general-purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0237] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0238] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include electrical connections based on one or more lines, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0239] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0240] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network), WAN (Wide Area Network), the Internet, and blockchain networks.
[0241] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0242] It should be noted that artificial intelligence is a discipline that studies how computers can simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.), and includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.
[0243] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
Claims
1. A method for classifying electrocardiogram signals based on a dual-view CNN-Transformer and an external attention mechanism, characterized in that: include: Acquire electrocardiogram signal data, and segment the electrocardiogram signal data based on a fuzzy segmentation module of a heartbeat perspective to obtain a preset number of electrocardiogram signal segments; Inputting the electrocardiogram signal segments into the first external attention mechanism and the first spatial feature extraction module of the heartbeat perspective respectively; Calculating a pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, and extracting a first spatial feature of the ECG signal segment based on the first spatial feature extraction module; Fusing the pooled first attention feature map and the first spatial feature to obtain a first spatial feature incorporating external attention; A first temporal feature extraction module based on the heartbeat perspective extracts features from the first spatial feature integrated with external attention to obtain a spatiotemporal feature of an electrocardiogram signal segment; Merging the temporal and spatial features of the ECG signal segments corresponding to the preset number of ECG signal segments to obtain a first temporal and spatial feature corresponding to the ECG signal data; After acquiring the electrocardiogram signal data, the electrocardiogram signal data is input into a second spatial feature extraction module and a second external attention mechanism of the recording perspective respectively; extracting a second spatial feature of the electrocardiogram signal data based on the second spatial feature extraction module, and calculating a fourth attention feature map of changes in intervals between consecutive adjacent heartbeat waveforms of the electrocardiogram signal data based on the second external attention mechanism; fusing the fourth attention feature map and the second spatial feature to obtain a second spatial feature incorporating external attention; A second temporal feature extraction module based on the recorded perspective extracts features from the second spatial feature incorporating external attention to obtain a second spatiotemporal feature; fusing the first spatiotemporal feature and the second spatiotemporal feature to obtain fused feature data; The fused feature data is classified based on a classifier to obtain a classification result of the electrocardiogram signal data.
2. The method according to claim 1, characterized in that The calculating of the pooled first attention feature map of the electrocardiogram signal segment based on the first external attention mechanism includes: Calculating the sampling point slope of the electrocardiogram signal segment based on a preset slope algorithm in the first external attention mechanism to obtain a sampling point slope; Calculating the slope of the sampling point based on a preset slope difference algorithm in the first external attention mechanism to obtain a second attention feature map; Calculating the relative amplitude difference of the sampling points of the electrocardiogram signal segment based on the relative amplitude difference algorithm preset in the first external attention mechanism to obtain a third attention feature map; Performing weighted fusion on the second attention feature map and the third attention feature map based on a preset weighted fusion algorithm in the first external attention mechanism to obtain a first attention feature map; Performing average pooling processing on the first attention feature map to obtain the pooled first attention feature map; The formula of the preset slope algorithm is expressed as: Among them, X i is the ECG signal data with sequence number i, X ij The electrocardiogram signal data is divided into the electrocardiogram signal segment with sequence number j among the preset number of electrocardiogram signal segments, X ij (t+1) is the amplitude of the sampling point at time t+1 in the ECG signal segment with sequence number j, X ij (t) is the amplitude of the sampling point at time t in the ECG signal segment with sequence number j, (t+1)-t is the difference in time, and k(t) is the slope of the sampling point; The formula of the preset slope difference algorithm is expressed as: Wherein, k(t) is the slope of the sampling point corresponding to time t in the ECG signal segment with sequence number j, and k(t+1) is the slope of the sampling point at time t+1 in the ECG signal segment with sequence number j. is the second attention feature map, The subscript ij in represents that the second attention feature map is obtained based on the electrocardiogram signal segment with sequence number j; The formula of the preset relative amplitude difference algorithm is expressed as: Among them, X ij (t) is the amplitude of the sampling point at time t in the electrocardiogram signal segment with sequence number j, is the baseline amplitude, is the third attention feature map, The subscript ij in represents that the third attention feature map is obtained based on the electrocardiogram signal segment with sequence number j; The formula of the preset weighted fusion algorithm is expressed as: Among them, ∈1 is the weight corresponding to the second attention feature map, ∈2 is the weight corresponding to the third attention feature map, δ1 is the bias term, Beat_Attention ij For the first attention feature map, Beat_Attention ij The subscript ij in indicates that the first attention feature map is obtained based on the electrocardiogram signal segment with serial number j.
3. The method according to claim 1, characterized in that The fourth attention feature graph for calculating the change in intervals between consecutive adjacent heartbeat waveforms of the electrocardiogram signal data based on the second external attention mechanism includes: Determine target positions corresponding to adjacent heartbeat waveforms in the electrocardiogram signal data based on a preset algorithm; Calculating a target interval between the two adjacent heartbeat waveforms based on target positions corresponding to the two adjacent heartbeat waveforms; Calculating the target interval based on a preset relative ratio algorithm to obtain a relative ratio; Performing average pooling processing on the relative ratio to obtain the fourth attention feature map; The formula of the preset relative ratio algorithm is expressed as: Where τ(p) is the target interval between two adjacent heartbeat waveforms, τ(p-1) is the target interval between two adjacent heartbeat waveforms before τ(p), τ(p+1) is the target interval between two adjacent heartbeat waveforms after τ(p), δ2 is the bias term, and Record-Attention i is the relative ratio, Record-Attention i The subscript i in indicates that the relative ratio is obtained based on the electrocardiogram signal data with sequence number i.
4. The method according to claim 1, wherein Acquiring electrocardiogram signal data includes: Acquire original ECG signal data, and perform noise reduction processing on the original ECG signal data based on a wavelet decomposition method to obtain noise-reduced original ECG signal data; After downsampling and linear normalization of the noise-reduced original ECG signal data, enhancement processing is performed on the noise-reduced original ECG signal data based on a cutout algorithm to obtain the ECG signal data; Acquire the electrocardiogram signal data.
5. The method according to claim 1, characterized in that The method comprises: The Adam optimizer and the cross-entropy loss function are used to perform back-propagation optimization on the model algorithm of the heartbeat perspective and the model algorithm of the recording perspective so that the model algorithm of the heartbeat perspective and the model algorithm of the recording perspective are dynamically updated. The model algorithm of the heartbeat perspective includes a model segmentation module, the first external attention mechanism, the first spatial feature extraction module and the first temporal feature extraction module, and the model algorithm of the recording perspective includes the second external attention mechanism, the second spatial feature extraction module and the second temporal feature extraction module.
6. The method according to claim 1, wherein The first spatial feature extraction module includes a first convolutional layer, a first ReLU layer, a second convolutional layer, a second ReLU layer, a first Max_Pooling layer, a third convolutional layer, a third ReLU layer, a fourth convolutional layer, a fourth ReLU layer, and a second Max_Pooling layer. All convolutional layers in the first spatial feature extraction module are one-dimensional, wherein the number of channels of the first convolutional layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1; the number of channels of the second convolutional layer is 64, the convolution kernel is 3, the step size is 1, and the padding is 1; the window of the first Max_Pooling layer is 5, the step size is 5; the number of channels of the third convolutional layer is 128, the convolution kernel is 3, the step size is 1, and the padding is 1; the number of channels of the fourth convolutional layer is 128, the convolution kernel is 3, the step size is 1, and the padding is 1; the window of the first Max_Pooling layer is 2, and the step size is 2; The second spatial feature extraction module includes a first convolutional layer, a first ReLU layer, a second convolutional layer, a second ReLU layer, a first Max_Pooling layer, a third convolutional layer, a third ReLU layer, a fourth convolutional layer, a fourth ReLU layer, a second Max_Pooling layer, a fifth convolutional layer, a fifth ReLU layer, a sixth convolutional layer, a sixth ReLU layer, and a third Max_Pooling layer. In the second spatial feature extraction module, all convolutional layers are one-dimensional, wherein the number of channels of the first convolutional layer is 32, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the second convolutional layer is 32, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the first Max_Pooling layer is 5, the stride is 5, the number of channels of the third convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the fourth convolution layer is 64, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the second Max_Pooling layer is 2, the stride is 2, the number of channels of the fifth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1. The number of channels of the sixth convolution layer is 128, the convolution kernel is 3, the stride is 1, and the padding is 1. The window of the third Max_Pooling layer is 5, the stride is 5.
7. An electrocardiogram signal classification device based on a dual-view CNN-Transformer and an external attention mechanism, characterized in that: include: an acquisition unit, configured to acquire electrocardiogram signal data, and segment the electrocardiogram signal data based on a fuzzy segmentation module of a heartbeat perspective to obtain a preset number of electrocardiogram signal segments; a first input unit, configured to input the electrocardiogram signal segments into a first external attention mechanism and a first spatial feature extraction module of the heartbeat perspective respectively; a first computing unit, configured to compute a pooled first attention feature map of the ECG signal segment based on the first external attention mechanism, and extract a first spatial feature of the ECG signal segment based on the first spatial feature extraction module; a first fusion unit, configured to fuse the pooled first attention feature map and the first spatial feature to obtain a first spatial feature incorporating external attention; a first extraction unit, configured to extract features from the first spatial features integrated with external attention based on the first temporal feature extraction module of the heartbeat perspective, to obtain spatiotemporal features of the electrocardiogram signal segment; a merging unit, configured to merge the temporal and spatial features of the ECG signal segments corresponding to the preset number of ECG signal segments to obtain a first temporal and spatial feature corresponding to the ECG signal data; a second input unit, configured to input the electrocardiogram signal data into a second spatial feature extraction module and a second external attention mechanism of a recording perspective after acquiring the electrocardiogram signal data; a second computing unit, configured to extract a second spatial feature of the electrocardiogram signal data based on the second spatial feature extraction module, and calculate a fourth attention feature map of changes in intervals between consecutive adjacent heartbeat waveforms of the electrocardiogram signal data based on the second external attention mechanism; a second fusion unit, configured to fuse the fourth attention feature map and the second spatial feature to obtain a second spatial feature incorporating external attention; a second extraction unit, configured to extract the second spatial feature integrated with external attention based on the second temporal feature extraction module of the recorded perspective, to obtain a second spatiotemporal feature; a third fusion unit, configured to fuse the first spatiotemporal feature and the second spatiotemporal feature to obtain fused feature data; A classification unit is used to classify the fused feature data based on a classifier to obtain a classification result of the electrocardiogram signal data.
8. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the method according to any one of claims 1-6.
10. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Multi-lead electrocardiogram classification and identification method based on convolution and self-attention mechanism
CN115470828A
Multimodal neural biological signal processing method and apparatus, and server and storage medium
WO2024108483A1
Cited By
PICC (Peripherally Inserted Central Catheter) tip precise navigation fixing method and system based on electrocardiogram real-time positioning
CN120919492A
A PICC catheter tip precise navigation and fixation method and system based on real-time electrocardiogram positioning
CN120919492B
