Electrocardiosignal classification method and electrocardiosignal classification model training method

By using a lightweight model based on Transformer in the ECG signal classification, combining one-dimensional convolutional layer and global feature extraction, combined with RR interperiod features and weight pruning technology, the model complexity and the traditional ECG signal classification method are solved. The problem of resource limitations has achieved efficient classification of ECG signals.

CN119249197APending Publication Date: 2025-01-03XIAN UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411258321.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

The traditional electrocardiogram classification method has a complex model structure and large parameters, which leads to low classification accuracy and low degree of parallelization, making it difficult to efficiently process on resource-constrained edge devices.

Method used

A lightweight electrocardiogram classification model based on Transformer is adopted, and the local spatial features are extracted and the Transformer encoding layer is combined with a one-dimensional convolutional layer to capture global features, and the RR interphase features are fully connected, and the model structure is simplified with weight pruning technology.

Benefits of technology

It improves the accuracy and efficiency of ECG data classification, realizes efficient ECG signal classification in resource-constrained environments, and reduces the storage space and calculation amount of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119249197A_ABST
    Figure CN119249197A_ABST
Patent Text Reader

Abstract

The invention particularly relates to an electrocardiosignal classification method and a model training method. The electrocardiosignal classification method comprises the following steps: acquiring to-be-processed electrocardiosignal data, and preprocessing the to-be-processed electrocardiosignal data to obtain a corresponding cardiac beat signal; inputting the heart beat signal into a trained signal classification model, and performing convolution processing on the heart beat signal by using a one-dimensional convolution layer to obtain first feature information used for representing local spatial features; coding the first feature information by using a Transform coding layer so as to obtain second feature information used for representing global features; performing convolution operation on the second feature by using a convolution layer to obtain third feature information; performing full connection processing on the third feature information and RR interval feature information corresponding to the electrocardiogram data by using a linear layer to obtain fourth feature data; and performing classification processing on the fourth features by using a classification layer to obtain an electrocardiosignal classification result corresponding to the to-be-processed electrocardiosignal data. According to the method, the electrocardio classification precision can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to an electrocardiogram signal classification method and an electrocardiogram signal classification model training method. Background Art

[0002] Among related technologies, electrocardiogram is an important way to diagnose and monitor cardiovascular diseases. By recording the potential waveform generated by human heart activity to reflect the state of the heart, it can provide a lot of valuable information for clinical treatment. Due to the rapid growth in the demand for ECG signal detection and the shortage of professional ECG doctors, the automatic classification and diagnosis of ECG signals has become a prominent research field. However, traditional ECG signal classification methods often involve a large number of parameters, complex model structures, and low classification accuracy.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0004] The present disclosure provides an electrocardiogram signal classification method and device, an electrocardiogram signal classification model training method and device; a storage medium, a computer program product, and an electronic device, which can effectively overcome the defects existing in the prior art.

[0005] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0006] According to a first aspect of the present disclosure, a method for classifying an electrocardiogram signal is provided, the method comprising:

[0007] Acquire the ECG data to be processed, and pre-process the ECG data to be processed to obtain a corresponding heartbeat signal;

[0008] Inputting the heartbeat signal into a trained signal classification model, performing convolution processing on the heartbeat signal using a one-dimensional convolution layer, and obtaining first feature information for characterizing local spatial features;

[0009] Encoding the first feature information using a Transformer encoding layer to obtain second feature information for characterizing global features;

[0010] Using a convolution layer to perform a convolution operation on the second feature to obtain third feature information;

[0011] Using a linear layer, fully connect the third feature information and the RR interval feature information corresponding to the electrocardiogram data to obtain fourth feature data;

[0012] The fourth feature is classified by using a classification layer to obtain an electrocardiogram signal classification result corresponding to the electrocardiogram data to be processed.

[0013] In some exemplary embodiments, preprocessing the to-be-processed electrocardiogram data to obtain corresponding heartbeat data includes:

[0014] Performing denoising on the ECG data to be processed to obtain a denoised ECG signal;

[0015] The denoised electrocardiogram signal is divided into heart beats according to a preset sampling number based on the peak position of the R wave to obtain the heart beat signal.

[0016] In some exemplary embodiments, the one-dimensional convolution layer includes a first convolution layer, a first attention mechanism layer, a second convolution layer, and a second attention mechanism layer arranged in sequence; wherein the first convolution layer includes a plurality of depth-wise separable convolution layers arranged in succession; the second convolution layer includes at least one depth-wise separable convolution layer; the first attention module layer and the second attention module layer include lightweight channel attention mechanism layers.

[0017] In some exemplary embodiments, the extracting features from the first feature information using a Transformer coding layer to obtain second feature information for characterizing global features includes:

[0018] Encode the first feature information and convert it into a corresponding vector representation; and generate a corresponding position vector for each position of the first feature information;

[0019] The vector representation and the position vector are encoded using a plurality of stacked encoders to obtain the second feature information.

[0020] According to a second aspect of the present disclosure, there is provided an electrocardiogram signal classification device, comprising:

[0021] A preprocessing module, used for acquiring the ECG data to be processed, and preprocessing the ECG data to be processed to obtain a corresponding heartbeat signal;

[0022] A one-dimensional convolutional layer processing module, used for inputting the heartbeat signal into a trained signal classification model, performing convolution processing on the heartbeat signal using a one-dimensional convolutional layer, and obtaining first feature information for characterizing local spatial features;

[0023] A coding layer processing module, used for encoding the first feature information by using a Transformer coding layer to obtain second feature information for representing global features;

[0024] A convolution layer processing module, used for performing a convolution operation on the second feature using a convolution layer to obtain third feature information;

[0025] A linear layer processing module, used for performing full connection processing on the third characteristic information and the RR interval characteristic information corresponding to the electrocardiogram data using a linear layer to obtain fourth characteristic data;

[0026] The classification layer processing module is used to classify the fourth feature using the classification layer to obtain the ECG signal classification result corresponding to the ECG data to be processed.

[0027] According to a third aspect of the present disclosure, there is provided a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned electrocardiogram signal classification method is implemented.

[0028] According to a fourth aspect of the present disclosure, there is provided an electronic device, including:

[0029] Processor; and

[0030] A memory, configured to store executable instructions of the processor;

[0031] Wherein, the processor is configured to implement the above-mentioned electrocardiogram signal classification method by executing the executable instructions.

[0032] According to a fifth aspect of the present disclosure, a computer program product is provided, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned electrocardiogram signal classification method is implemented.

[0033] According to a sixth aspect of the present disclosure, a method for training an electrocardiogram signal classification model is provided, the method comprising:

[0034] Construct heart beat sample data using labeled ECG sample data;

[0035] Constructing an initial classification model; the initial classification model includes a one-dimensional convolutional layer, a Transformer encoding layer, a convolutional layer, a linear layer and a classification layer; wherein the one-dimensional convolutional layer is used to perform convolution processing on the heartbeat signal to obtain first feature information for characterizing local spatial features; the Transformer encoding layer is used to perform feature extraction on the first feature information to obtain second feature information for characterizing global features; the convolutional layer is used to perform convolution operation on the second feature to obtain third feature information; the linear layer is used to perform full connection processing on the third feature information and the RR interval feature information corresponding to the electrocardiogram data to obtain fourth feature data; the classification layer is used to perform classification processing on the fourth feature;

[0036] Using the heartbeat sample data to train the initial classification model to obtain a trained model;

[0037] The trained model is weight pruned to obtain a compressed electrocardiogram signal classification model.

[0038] In some exemplary embodiments, constructing heart beat sample data using labeled ECG sample data includes:

[0039] De-noising the ECG sample signals of the MIT-BIH arrhythmia database to obtain de-noised ECG sample data;

[0040] Based on the R peak position, the denoised ECG sample data is divided into heart beats according to preset sampling points to obtain the first heart beat sample data;

[0041] Use the SMOTE algorithm to synthesize the minority heartbeat data as the second heartbeat sample data;

[0042] The heartbeat sample data is constructed based on the first sample data and the second sample data.

[0043] In some exemplary embodiments, the step of performing weight pruning on the trained model includes:

[0044] Performing importance evaluation on the trainable parameters of the trained model, and using L1 norm to measure the importance of the trainable parameters;

[0045] Sorting the trainable parameters according to importance evaluation results, and pruning the trainable parameters according to the sorting results;

[0046] The pruned model is fine-tuned and retrained to obtain a compressed ECG signal classification model.

[0047] According to a seventh aspect of the present disclosure, there is provided a training device for an electrocardiogram signal classification model, comprising:

[0048] A sample data processing module, used to construct heart beat sample data using the marked ECG sample data;

[0049] An initial model building module, used to build an initial classification model; the initial classification model includes a one-dimensional convolution layer, a Transformer encoding layer, a convolution layer, a linear layer and a classification layer; wherein the one-dimensional convolution layer is used to perform convolution processing on the heartbeat signal to obtain first feature information for characterizing local spatial features; the Transformer encoding layer is used to perform feature extraction on the first feature information to obtain second feature information for characterizing global features; the convolution layer is used to perform convolution operation on the second feature to obtain third feature information; the linear layer is used to perform full connection processing on the third feature information and the RR interval feature information corresponding to the electrocardiogram data to obtain fourth feature data; the classification layer is used to perform classification processing on the fourth feature;

[0050] A model training module, used to train the initial classification model using heartbeat sample data to obtain a trained model;

[0051] The model optimization module is used to perform weight pruning on the trained model to obtain a compressed ECG signal classification model.

[0052] According to an eighth aspect of the present disclosure, there is provided a storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned training method of the electrocardiogram signal classification model when executed by a processor.

[0053] According to a ninth aspect of the present disclosure, there is provided an electronic device, including:

[0054] Processor; and

[0055] A memory, configured to store executable instructions of the processor;

[0056] Wherein, the processor is configured to implement the above-mentioned training method of the electrocardiogram signal classification model by executing the executable instructions.

[0057] According to a tenth aspect of the present disclosure, there is provided a computer program product having a computer program stored thereon, which implements the above-mentioned training method of the electrocardiogram signal classification model when the computer program is executed by a processor.

[0058] The ECG signal classification method provided by the embodiments of the present disclosure uses a lightweight ECG classification model based on Transformer, so that heartbeat data can be efficiently processed on resource-constrained edge devices. By using a one-dimensional convolutional layer in the ECG classification model to extract local spatial features, and combining the Transformer encoding layer to capture global features, the feature vector of the heartbeat data can be accurately obtained. By using a classifier to fully connect the global features and RR interval feature information, the time characteristics of the ECG signal are combined in the process of identifying the heartbeat type, so that normal heart rhythm and abnormal heart rhythm can be better distinguished, which can effectively improve the accuracy of ECG data classification and achieve accurate judgment of the heartbeat type.

[0059] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0061] Figure 1 A schematic diagram schematically illustrating an exemplary system architecture of the technical solution of an exemplary embodiment of the present disclosure;

[0062] Figure 2 A schematic diagram schematically illustrates a training method for an electrocardiogram signal classification model according to an exemplary embodiment of the present disclosure;

[0063] Figure 3 A schematic diagram schematically illustrates an electrocardiogram classification model architecture of an exemplary embodiment of the present disclosure;

[0064] Figure 4 A schematic diagram schematically illustrates a weight pruning process in an exemplary embodiment of the present disclosure;

[0065] Figure 5 A schematic diagram schematically showing a loss function curve under different learning rates in an exemplary embodiment of the present disclosure;

[0066] Figure 6 A schematic diagram schematically showing an accuracy curve under different learning rates in an exemplary embodiment of the present disclosure;

[0067] Figure 7 A schematic diagram schematically showing how a loss curve changes with increasing iteration times in an exemplary embodiment of the present disclosure;

[0068] Figure 8 A schematic diagram schematically showing a change in accuracy with increasing number of iterations in an exemplary embodiment of the present disclosure;

[0069] Fig. 9 A schematic diagram schematically illustrates a confusion matrix of a classification result on a balanced data set in an exemplary embodiment of the present disclosure;

[0070] Fig.10 A schematic diagram schematically illustrates an electrocardiogram signal classification method according to an exemplary embodiment of the present disclosure;

[0071] Fig.11 A schematic diagram schematically illustrates an electrocardiogram signal classification device according to an exemplary embodiment of the present disclosure;

[0072] Fig.12 A schematic diagram schematically illustrates a training device for an electrocardiogram signal classification model according to an exemplary embodiment of the present disclosure;

[0073] Fig.13 The diagram schematically shows the components of an electronic device in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0074] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0075] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0076] In the relevant technology, cardiovascular disease (CVD) refers to a class of diseases that affect the heart and vascular system, and arrhythmia is generally considered to be one of them. Arrhythmia may cause irregular heart rhythm, affect the heart's pumping function, and thus cause other cardiovascular diseases, such as myocardial ischemia and heart failure. According to the 2023 World Heart Report released by the World Heart Federation (WHF), cardiovascular disease remains the leading cause of death worldwide. In 2021, approximately 20.5 million people died from cardiovascular disease, accounting for one-third of the global death toll, a significant increase from the 12.1 million deaths from cardiovascular disease in 1990. Therefore, timely detection of arrhythmias is crucial to protect people from these complications and diseases. Electrocardiogram (ECG) is the gold standard for checking arrhythmias. It captures the electrical signals generated by the heart during contraction and relaxation by sticking electrodes to the chest or limbs of the human body. A typical set of ECG waveforms usually includes P waves, QRS complexes, and T waves, which represent the depolarization of the atria, the potential changes of ventricular depolarization, and the repolarization of the ventricles, respectively. In addition, there are other features in the ECG, such as PR segment, ST segment, PR interval and RR interval, etc. These features are also important for classifying and identifying ECG signals.

[0077] With the rapid growth of demand for ECG signal detection and the shortage of professional ECG physicians, automatic classification and diagnosis of ECG signals has become a hot topic in industry research. At present, the methods used to automatically classify ECG signals are mainly divided into two categories: traditional machine learning methods and deep learning-based methods. Traditional methods refer to methods that use machine learning algorithms for pattern recognition and feature extraction, such as support vector machines (SVM), random forests, and K-Nearest Neighbors (KNN). However, traditional machine learning methods require model construction and training based on specific feature engineering and algorithms. Compared with deep learning methods, traditional machine learning algorithms rely more on feature extraction and feature selection, and feature selection usually requires professionals to conduct a large number of comparative tests, which is prone to errors and omissions. The second is a method based on deep learning, which perfectly solves the above problems and provides an end-to-end solution for the classification of ECG signals. The deep learning method does not require manual denoising and feature extraction. The segmented ECG signal can be directly input into the designed model for classification. Although the deep learning method has good performance, it still has some problems. Most deep learning-based methods usually use complex convolution and recursive structures when dealing with ECG signal classification problems, resulting in a complex model structure. These structures generate a series of hidden states, and the current hidden state often depends on the previous hidden state, which limits the degree of parallelization of these models.

[0078] In view of the shortcomings and deficiencies of the prior art, this example implementation provides an ECG signal classification method and an ECG signal classification model training method to solve the problems of large number of parameters and low degree of parallelization of traditional ECG classification models.

[0079] Figure 1 A schematic diagram showing an exemplary system architecture to which the technical solution of an embodiment of the present invention can be applied.

[0080] like Figure 1 As shown, the system architecture 100 may include an intelligent ECG monitoring device (such as Figure 1 As shown in the figure, one or more of a smart bracelet 101, a smart clothing 102, and a (portable) ECG monitor 103, which may also be other smart ECG monitoring devices), a smart terminal (such as a mobile phone) 104, a base station 105, and an edge server 106. The communication links between them may include various connection types, such as wired communication links, wireless communication links, and the like.

[0081] It should be understood that Figure 1 The number of intelligent ECG monitoring devices, intelligent terminals, base stations and edge servers in the embodiment is only for illustration. According to the implementation requirements, any number of intelligent devices, base stations and edge servers may be provided. For example, the server 106 may be a server cluster composed of multiple servers.

[0082] In one embodiment of the present invention, the intelligent ECG monitoring device 101 collects the user's ECG data and sends it to the intelligent terminal 104 via a low-power communication link such as Bluetooth. The intelligent terminal 104 sends a data processing request for classifying the user's ECG data to the edge server 106. The data processing request may include the patient's ECG data to be processed, or the storage address of the ECG data. After receiving the data processing request, the edge server 106 can extract the ECG data, perform classification operations on it, and return the classification results to the terminal 104.

[0083] Alternatively, the classification model may be deployed locally on the smart ECG detection device, and the collected ECG data may be detected in real time, and the ECG signal detection results may be displayed.

[0084] It should be noted that the method provided in the embodiment of the present invention is generally executed by the server 106. However, in other embodiments of the present invention, the terminal device 104 may also have similar functions to the server 106, and may be able to execute the training method of the ECG signal classification model, train the ECG signal classification model and obtain the trained ECG signal classification model; or, the ECG signal classification method may be arranged and executed in the terminal device, and cooperate with the server to execute the ECG classification method provided in the embodiment of the present invention.

[0085] The following will describe in more detail the various steps of the training method for the electrocardiogram signal classification model in this example implementation in conjunction with the accompanying drawings and embodiments.

[0086] Exemplary, reference Figure 2 As shown, the training method of the ECG signal classification model may specifically include:

[0087] Step S11, constructing heart beat sample data using the marked ECG sample data;

[0088] Step S12, constructing an initial classification model; the initial classification model includes a one-dimensional convolutional layer, a Transformer encoding layer, a linear layer and a classification layer; wherein the one-dimensional convolutional layer is used to perform convolution processing on the heartbeat signal to obtain first feature information for characterizing local spatial features; the Transformer encoding layer is used to perform feature extraction on the first feature information to obtain second feature information for characterizing global features; the linear layer is used to perform full connection processing on the second feature information and third feature information corresponding to the electrocardiogram data to obtain fourth feature data; wherein the third feature information is RR interval feature information corresponding to the electrocardiogram data to be processed; the classification layer is used to perform classification processing on the fourth feature;

[0089] Step S13, training the initial classification model using the heartbeat sample data to obtain a trained model;

[0090] Step S14, performing weight pruning on the trained model to obtain a compressed ECG signal classification model.

[0091] In this example implementation, in step S11, constructing heart beat sample data using the labeled ECG sample data may specifically include:

[0092] Step S111, performing denoising processing on the ECG sample signals of the MIT-BIH arrhythmia database to obtain denoised ECG sample data;

[0093] Step S112, dividing the de-noised ECG sample data into heart beats according to preset sampling points based on the R peak position to obtain first heart beat sample data;

[0094] Step S113, using the SMOTE algorithm to synthesize the minority class heartbeat data as the second heartbeat sample data;

[0095] Step S114: construct the heartbeat sample data based on the first sample data and the second sample data.

[0096] Specifically, the MIT-BIH arrhythmia database can be used as the source of our ECG data as raw ECG data. The MIT-BIH database has a large amount of data and authoritative experts have annotated and labeled each piece of data in detail. It is currently the most widely used ECG database. The MIT-BIH database contains 48 dynamic ECG data from 47 subjects, 22 of whom are female and 25 are male, aged between 23 and 89 years old. Each record is about 30 minutes, with a sampling frequency of 360Hz, a total of 109,500 heartbeats, of which abnormal heartbeats account for only about 30%. In addition, each record is annotated by at least two cardiologists (a total of about 110,000 annotations). Each record contains two lead data, namely lead II and lead V1 (a few are leads V2, V4 or V5).

[0097] There are usually many kinds of noise in ECG signals, and the most common ones are three: power frequency interference, baseline drift, and myoelectric interference. These noises may affect the quality and accuracy of ECG signals, thereby affecting the accuracy of ECG analysis and diagnosis. Therefore, ECG signals need to be denoised before classification. We use discrete wavelet transform to denoise ECG signals, and select Daubechies 6 wavelet as the wavelet basis. First, the ECG signal containing noise is decomposed into 7 scales by discrete wavelet transform; for example, wavelet decomposition can be achieved by calling a function. Specifically, the following steps can be included: 1) Select the filter coefficient of Daubechies 6 wavelet; 2) Perform 1-scale wavelet decomposition on the ECG signal, where the approximate coefficient (low-frequency part) A1 and the detail coefficient (high-frequency part) D1; 3) Perform 2-scale wavelet decomposition on the approximate coefficient A1 to obtain A2 and D2; 4) Repeat the above process until the 7-scale decomposition is completed. The obtained coefficients include A7 (approximate coefficient of scale 7) and D1, D2, D3, D4, D5, D6, D7 (corresponding to detail coefficients of scales 1 to 7), and the wavelet coefficients at each scale are obtained. The wavelet coefficient calculation formula is as follows:

[0098]

[0099] Where f(t) is the noisy ECG signal, Ψ j,k is a discrete wavelet function, j,k∈Z.

[0100] Then, the decomposed wavelet coefficients of each scale are subjected to soft threshold processing. After wavelet decomposition, the coefficient of the useful signal should be greater than the noise coefficient, so an appropriate threshold can be set. When the wavelet coefficient is less than the set threshold, the wavelet coefficient is mainly caused by noise and should be set to zero; when the wavelet coefficient is greater than the set threshold, it is considered that the wavelet coefficient is mainly caused by the signal, and this part of the coefficient needs to be retained. The calculation formula of the soft threshold function is:

[0101]

[0102] Wherein, w represents the wavelet coefficient, and T is a pre-selected threshold value. For example, the threshold value can be set to 0.014.

[0103] After filtering out the noise coefficients, the processed wavelet coefficients are reconstructed by using inverse discrete wavelet transform to obtain the ECG signal after noise removal. The formula is as follows:

[0104]

[0105] Where C is a constant that has nothing to do with the signal.

[0106] After data denoising, a denoised ECG signal can be obtained. The ECG data we use comes from the MIT-BIH arrhythmia database. Since the annotation file in the database already contains the position information of the R peak, this position information can be directly used to segment the entire ECG signal. According to the R peak position in the annotation file, we use the following method to segment the ECG signal: take 99 points forward and 200 points backward, for a total of 300 sampling points. The duration corresponding to this segmentation method is 0.83 seconds, which is consistent with the duration of a normal heartbeat. The divided heartbeat signal can be used as the first heartbeat sample data.

[0107] For example, after completing the heartbeat division, the heartbeat sample data set can be balanced. Specifically, consider that the MIT-BIH arrhythmia database contains samples of multiple arrhythmia categories, but the number of normal samples accounts for the majority, and the number of abnormal samples accounts for a small proportion. The imbalance of the number of samples in different categories may affect the model and classification performance.

[0108] Therefore, the SMOTE algorithm can be used to solve the problem of unbalanced data distribution. By applying the SMOTE algorithm, new minority class samples can be synthesized to increase the number of minority class samples, thereby achieving a balanced data set. This helps to improve the model's learning ability for each arrhythmia category and improve the overall classification performance. The basic steps of the SMOTE algorithm are as follows: First, the nearest neighbor algorithm is used for sampling, and the K nearest neighbors of each minority class sample are calculated based on the Euclidean distance. Then, the K nearest neighbor samples Y are selected from the K nearest neighbor samples.j Randomly select N samples from the random linear interpolation. Finally, construct a new minority class sample according to the following formula, which can be expressed as: New =X i +radn(0,1)×(Y j -X i ),j=1,2,...N; where X i For a given raw ECG data sample. rand(0,1) is a random number between 0 and 1 (usually uniformly distributed in the range [0,1]).

[0109] The constructed minority class samples are used as the second heartbeat sample data. The first heartbeat sample data is combined with the second heartbeat sample data to form a complete heartbeat sample data set. For the heartbeat sample data set, it can be divided into a training set, a validation set, and a test set in a ratio of 7:1:2.

[0110] In this example implementation, in step S12, after the construction of the heartbeat sample data set is completed, or when the heartbeat sample data set is being constructed, an initial classification model may be constructed.

[0111] Exemplarily, the model may include a one-dimensional convolution layer, a Transformer encoding layer, a linear layer, and a classification layer arranged in sequence. The one-dimensional convolution layer is used to perform convolution processing on the heartbeat signal to obtain the first feature information for characterizing the local spatial feature; the Transformer encoding layer is used to perform feature extraction on the first feature information to obtain the second feature information for characterizing the global feature; the linear layer is used to perform full connection processing on the second feature information and the third feature information corresponding to the ECG data to obtain the fourth feature data; wherein the third feature information is the RR interval feature information corresponding to the ECG data to be processed; and the classification layer is used to perform classification processing on the fourth feature.

[0112] Exemplarily, the one-dimensional convolution layer can be a 1D-CNN module. The heartbeat data is convoluted using the 1D-CNN module to extract spatial features in local context information. The 1D-CNN module includes a first convolution layer, a first attention mechanism layer, a second convolution layer, and a second attention mechanism layer arranged in succession; the first convolution layer includes a plurality of depth-separable convolution layers arranged in succession; the second convolution layer includes at least one depth-separable convolution layer. For example, its network structure is as follows: Figure 3 As shown, the first convolution layer includes three consecutive depth-wise separable convolution layers; the second convolution layer is a depth-wise separable convolution layer. The first attention module layer and the second attention module layer include a lightweight channel attention mechanism layer, such as a lightweight and efficient channel attention module.

[0113] Among them, the input of the 1D-CNN model is heartbeat data of size 300×1, the number of input channels of conv1 is 12, the number of output channels is 128, and the size of the convolution kernel is 14; the number of input channels of conv2 is 128, the number of output channels is 256, and the size of the convolution kernel is 14; the number of input channels of conv3 is 256, the number of output channels is 64, and the size of the convolution kernel is 10; the number of input and output channels of the ECA (Efficient Channel Attention) module remains unchanged at 64; the number of input channels of conv4 is 64, the number of output channels is 64, and the size of the convolution kernel is 10.

[0114] For example, refer to Figure 3 As shown in the model structure, this scheme proposes a new type of 1D-CNN as the input structure of the Transformer model, which is mainly composed of 4 convolutional layers and 2 attention modules. First, in order to expand the receptive field to capture some features of the electrocardiogram in a longer time range in the ECG signal, such as spanning multiple heartbeat cycles, considering that abnormal rhythms or periodic changes in the electrocardiogram need to be detected and analyzed through a larger receptive field, the 1D-CNN is improved, and the kernel size of the convolution (Conv) layer is adjusted to be larger; for example, the convolution kernels of most models in the prior art are mostly 3 and 5, and the winning convolution kernels in this scheme are configured to be 10 and 14. This approach is more effective than the general method of using small convolution kernels. Secondly, we replace all standard convolution layers in 1D-CNN with depthwise separable convolution layers (DSC) to reduce the number of parameters of the model. By introducing a lightweight ECA module, the expression ability and performance of the model can be effectively improved.

[0115] The raw heartbeat signal is first fed into the 1D-CNN module to extract local spatial features. Next, in order to identify long-range dependencies in the ECG sequence (in the electrocardiogram (ECG) sequence, it refers to the correlation or dependency between two far-separated positions. For example, a feature of the ECG signal (such as a peak, trough or other shape feature) may be correlated or influenced by another feature far away from it. For example, a specific heart disease may cause certain features in multiple heartbeat cycles to change synchronously, and this synchronization is a manifestation of long-range dependencies.), the output of the 1D-CNN module is connected to the Transformer encoder part to extract meaningful global context information. In order to adapt to the ECG classification task, we only use the encoder part. Because the encoder part has integrated the key functions of the Transformer model, it is able to extract effective feature representations for classification tasks.

[0116] Exemplarily, the Transformer encoding layer can be a Transformer encoder module. Specifically, the Transformer encoder module includes input embedding, position encoding and attention module. The embedding dimension of the word embedding layer of the input embedding in the Transformer encoder module is set to 64 to match the number of output channels of the convolutional layer; the position encoding defines the vocabulary size or the total number of positions as 242, and the dimension of each position encoding is 64; the multi-head self-attention input feature dimension of the attention module is 64 (including the dimensions of the key and value in the attention mechanism), and the output feature dimension is 64; the number of input and output channels of the feedforward network is 64.

[0117] For example, the Transformer encoder module achieves encoding and feature extraction of the input sequence through the collaborative work of input embedding, position encoding, and attention modules.

[0118] Among them, the output of the 1D convolution layer is directly used as the input of the Transformer Encoder. Input embedding maps the input ECG signal sequence to a vector representation. Since we first use the 1D convolution layer to extract the spatial features of the ECG signal and use it as the input of the Transformer Encoder model. Therefore, the input size of the defined word embedding layer is consistent with the number of output channels of the convolution layer. This word embedding layer maps the spatial features of each time point to a vector representation. At the same time, since our input sequence is one-dimensional.

[0119] Since the Transformer model lacks sequential information, in order to preserve the sequential relationship of the ECG signal, it is necessary to use a position encoding module to encode the position information of the above input embedding. For example, a method based on sine and cosine functions is usually used. It maps the position information into a continuous space and generates a fixed position vector to represent the relative position relationship of different positions. The specific calculation formula is as follows:

[0120]

[0121] Where pos represents the position of each point in the sequence, i is the dimension index of the positional encoding, and d is the total dimension of the positional encoding (usually equal to the dimension of the input embedding). Scaling factor: used to ensure that sine and cosine functions of different dimensions have different frequencies. By adjusting the scaling factor, position information can be encoded at different scales, so that the model can capture position information of different ranges. After position encoding, an encoded array X with exactly the same dimensions as the input can be obtained. pos , by superimposing the encoded array onto the original word embedding, we can get the new word embedding.

[0122] Among them, the attention module includes N layers of attention modules that are repeatedly superimposed; for example, the value of configuration N is set to 3. Each layer of the module consists of two parts. The first part is the multi-head attention mechanism, which includes multiple parallel attention functions. Since a single attention function may not be sufficient to fully capture all dependencies, a multi-head self-attention mechanism is introduced. This mechanism is implemented by running multiple attention functions at the same time, each of which captures the dependencies between input data from a different perspective. The multi-head self-attention mechanism uses multiple independent attention "heads", each of which is equipped with its own query, key, value matrix and corresponding weight distribution and output, thereby enhancing the model's comprehensive processing capabilities for information. The specific calculation formula is as follows:

[0123] MultiHead(Q,K,V)=concat(ead 1 , ead 2 …,ead)W 0

[0124]

[0125] First, calculate the attention output of each head i , and then concatenate the outputs of each head together, and then obtain the final multi-head attention output through linear transformation. Where h is the number of attention heads, W 0 is the weight matrix of the linear transformation.

[0126] The second component of the attention module is a simple feed-forward network. This network performs nonlinear transformation and dimensionality reduction on the features at each position through two layers of fully connected networks. By stacking multiple such encoder layers, the Transformer is able to deeply encode and model the input sequence.

[0127] Exemplarily, after the Transformer encoding layer, a convolution layer may be further provided, and the number of input channels of the convolution layer may be configured to be 64, the number of output channels to be 1, and the size of the convolution kernel to be 1.

[0128] For example, the Linear layer can be used to concatenate the RR interval feature with the output of the previous convolutional layer, with an input feature of 66 and an output feature dimension of 4; the output of the linear layer is converted into a probability distribution through a softmax activation function to obtain the final prediction result. The linear layer can be a fully connected layer with 4 neurons, using a softmax activation function to predict the probability that the heartbeat data belongs to each of the 4 heartbeat types.

[0129] Specifically, the morphological appearance of the ECG signal refers to the shape and changes of the waveform and peaks displayed on the electrocardiogram, usually including features such as P wave, QRS complex and T wave. However, most current studies only focus on the morphological features of the ECG signal and ignore the temporal features. Therefore, this scheme adds the RR interval feature after the encoder, which represents the time interval between two adjacent R waves and can be regarded as the temporal feature of the ECG signal. In addition, the variability of the RR interval is closely related to the health of the heart. Certain arrhythmias can cause irregular or abnormal RR intervals. By extracting the RR interval features, the deep learning network can learn the pattern of arrhythmias and can better distinguish between normal and abnormal heart rhythms.

[0130] Exemplarily, in step S13, the initial model may be trained using the training set and the validation set to obtain the best model.

[0131] Specifically, the above step S13 may include:

[0132] Step S131, inputting the training set into the initial model, and obtaining feature data through the 1D-CNN module and the Transformer encoder module;

[0133] Step S132, using a linear layer to fully connect the feature data and map it to the score space of each category, and then convert these scores into probability distributions through a softmax function to obtain the classification results corresponding to the training set;

[0134] Step S133, calculating the classification loss according to the classification result, and training and optimizing the model parameters through the back propagation algorithm and Adam optimizer;

[0135] Step S134, after each training cycle, use the data of the validation set to evaluate the performance of the model; wherein the evaluation indicators are the loss value, accuracy, precision, F1 score, etc. on the validation set; by continuously observing the performance of the model on the validation set, timely adjust the model or stop training to obtain the best model.

[0136] For example, the dataset can be divided into training set, validation set and test set with a ratio of 7:1:2. In order to reduce the impact of randomness on the experimental results, a 10-fold cross-validation strategy can be adopted. Specifically, 10 rounds of training and evaluation were carried out, and then the results were averaged to obtain the final performance evaluation results. In addition, in order to prevent overfitting, batch normalization (Batch Normalization, BN) technology was used. BN normalizes the input in each training mini-batch data, making the neural network more stable during training and helping to accelerate convergence. Finally, a learning rate scheduler based on the Adam optimizer is created for training and optimizing model parameters. It can update the learning rate according to the given parameters and the current number of training steps, and use the internal optimizer for parameter updates.

[0137] Exemplarily, the above step S14 includes:

[0138] Step S141, evaluating the importance of the trainable parameters of the trained model, and using the L1 norm to measure the importance of the trainable parameters;

[0139] Step S142, sorting the trainable parameters according to the importance evaluation result, and pruning the trainable parameters according to the sorting result;

[0140] Step S143, fine-tuning and retraining the pruned model to obtain a compressed ECG signal classification model.

[0141] Specifically, for trained models, the importance of each weight can be calculated to evaluate their contribution to model performance. Among them, weights are trainable parameters in the model, which are continuously updated by optimization algorithms during the training process to minimize the loss function and thus improve the performance of the model, such as using a gradient descent algorithm. Different types of layers have different weights, such as the convolution kernel of a convolutional layer, the weight matrix of a fully connected layer, and so on. Afterwards, the L1 norm can be used to measure the importance of weights, that is, to determine the proportion to be pruned based on the absolute value of the parameter, and set smaller weights to zero to achieve parameter sparsification. Then sort the weights according to their importance, and cut off 40% of the weights with the smallest absolute value, that is, sort the weights using the L1 norm (i.e., absolute value).

[0142] For example, you can first calculate the absolute value of each weight, sort the weights according to these absolute values, and cut off the weight with the smallest absolute value. For example, the original weights: weights = [0.1, -0.5, 0.3, -0.2, 0.05]. First calculate the absolute value of each weight: abs_weights = [0.1, 0.5, 0.3, 0.2, 0.05]. Then sort the weights according to these absolute values. The absolute values ​​after sorting are from large to small: [0.5, 0.3, 0.2, 0.1, 0.05], and the corresponding original weight order is: [-0.5, 0.3, -0.2, 0.1, 0.05]. Calculate the number of weights to be pruned: 0.40*5=2 (after pruning the two weights with the smallest absolute values ​​(0.05 and 0.1), the remaining weights are [-0.5, 0.3, -0.2, 0, 0]. Among them, the 40% of the weights with the smallest absolute values ​​are pruned (i.e. set to 0), thereby reducing the complexity of the model. The pruning operation does not change the structure of the weight matrix, but only sets the selected weight values ​​to zero.

[0143] The pruned model is fine-tuned and retrained through multiple iterations of pruning and fine-tuning to further reduce system memory space and improve performance. The model is tested using the data from the test set to obtain the final ECG classification model.

[0144] Existing ECG classification models have shown good classification performance. However, these models often have large-scale training parameters, which puts higher requirements on hardware devices: stronger computing power and larger storage space are required. Weight pruning is a post-training model compression technology that prunes the trained model to remove redundant and unnecessary weights in the network, thereby streamlining the model. Pruning algorithms usually include three steps: training, pruning, and fine-tuning. First, the target model is trained and optimized to obtain an initial high-precision model. Then, the importance of each weight is calculated to evaluate their contribution to the model performance. We use the L1 norm to measure the importance of weights, that is, the proportion to be pruned is determined based on the absolute value of the parameter, and smaller weights are set to zero to achieve parameter sparsification. Secondly, the weights are sorted according to their importance, and thresholds are set for pruning. Finally, the pruned model is fine-tuned and retrained. The specific process is as follows Figure 4 As shown in the figure, we pruned 40% of the model weights with the lowest L1 norm. While maintaining the model classification performance, we successfully reduced the model's memory space by a quarter, significantly improving the model's application performance in resource-constrained environments.

[0145] In one embodiment of the present invention, in order to better evaluate the performance of the method, we use five evaluation indicators commonly used in ECG classification related work, namely accuracy (Acc), precision (Pre), sensitivity (Sen), specificity (Spe) and F1 score (F1). The calculation formula of the evaluation index is:

[0146] Sensitivity: Sen=TP / (TP+FN)

[0147] Specificity: Spe = TN / (TN + FP)

[0148] Accuracy: Pre = TP / (TP+FP)

[0149] Accuracy: Acc = (TP + TN) / (TP + FP + TN + FN)

[0150] F1 score: F1 = 2(Sen*Pre) / (Sen+Pre)

[0151] Among them, TP, FP, TN and FN represent the number of true positive, false positive, true negative and false negative samples.

[0152] The MIT-BIH database has a total of 15 common heart beat types, but most studies divide all heart beats into five types according to the ANSI / AAMIEC57:1998 standard, namely N, S, V, F, and Q, as shown in Table 1. At the same time, according to AAMI's recommendations, this scheme deleted four records 102, 104, 107, and 217, and used the remaining records as experimental data. In addition, since the number of unknown beats Q is too small compared to other categories, this scheme abandons category Q.

[0153] Table 1

[0154]

[0155] Table 2

[0156]

[0157] According to the original heartbeats after segmentation in Table 2, the SMOTE algorithm is used to synthesize new minority class samples. Since the number of heartbeats in category N is the largest, we execute the SMOTE algorithm to make the number of other categories roughly equal to the number of categories N. The final new dataset is shown in Table 3.

[0158] Table 3

[0159]

[0160] In the training phase, the network parameters shown in Table 4 are mainly used. First, we studied the impact of different initial learning rates on the classification performance of the system model. The initial learning rate is the learning rate value used by the model at the beginning of training, which determines the step size of each weight update. When the initial learning rate is set too small, the model may take a long time to converge to the optimal solution. On the contrary, if the initial learning rate is set too large, the model may oscillate or diverge. Therefore, this method determines the optimal learning rate by trying five different learning rate values ​​and observing the training performance of the model. Figure 5 and Figure 6 As shown in the figure, the loss function and classification accuracy curves obtained under different learning rates are shown. It can be seen that when the learning rate is 0.01, the model not only converges fastest, but also has the best classification performance. At the same time, as the number of iterations increases, the accuracy curve is almost close to 1, and the loss function curve is also basically close to 0. Therefore, according to the above simulation results, this scheme selects 0.01 as the initial learning rate of the model.

[0161] The Transformer-based lightweight network model proposed in this method was initially trained using the data from the training set and the validation set. After 60 rounds of iterations, the loss function and accuracy change graphs were obtained, as shown in the figure below. Figure 7 and Figure 8 As shown in the figure, it can be seen that the model becomes gradually stable after 60 iterations, so the training cycle is set to 60.

[0162] from Figure 7 It can be observed that the loss function gradually flattens out after 30 iterations. The loss function of the validation set is basically maintained between 0 and 0.015, and the loss function of the training set is roughly close to 0. The results show that during the training phase, except for slight oscillations in the loss function of the validation set, the model exhibits good convergence performance and does not have overfitting problems. Figure 8 It can be seen that with the increase in the number of iterations and the continuous optimization of the loss function, the accuracy of the training set and the validation set is gradually improving. After 60 iterations, the accuracy of the training set is almost 100%, and the accuracy of the validation set is roughly maintained at around 99.72%. The results show that the proposed model also shows good performance in terms of accuracy.

[0163] After the model is trained, the best model is saved and tested using the test set data. In order to solve the problem of data imbalance in the MIT-BIH arrhythmia database, the SMOTE algorithm is used to upsample the original dataset. The confusion matrix of the classification results of the proposed model on the balanced dataset is shown in Figure 2. Fig. 9 shown.

[0164] The confusion matrix is ​​a table used to evaluate the performance of a classification model. It shows the relationship between the model's predicted results and the actual results on different categories. A heat map is used to display the confusion matrix, with darker colors representing higher values ​​and lighter colors representing lower values. In addition, the rows of the confusion matrix represent the true heartbeat categories, and the columns represent the categories predicted by the model. According to the above equations, the specific values ​​of the five evaluation indicators of the proposed model can be calculated, as shown in Table 5.

[0165] Table 5

[0166] Class Acc(%) Pre(%) Sen(%) Spe(%) F1(%) N 99.74 99.56 99.38 99.85 99.47 S 99.86 99.65 99.79 99.88 99.72 V 99.84 99.76 99.60 99.92 99.68 F 99.90 99.69 99.90 99.90 99.80 Average 99.84 99.66 99.67 99.89 99.67

[0167] According to the results in Table 5, more than 99.84% of ECG heartbeats are correctly classified, which shows that the proposed model has a high classification performance. It can be observed that the accuracy of the four categories remains above 99.7%, the F category has the highest accuracy, and the N category has the lowest accuracy. This may be because the N category contains many types of normal heart rhythms, and there may be large differences between its samples, while the F category has more obvious and specific features, making it easier for the model to distinguish. From the perspective of sensitivity, the values ​​of the sensitivity predicted by the model for the four types are all higher than 99.3%, and the sensitivity of the predictions for the S and F categories are 99.79% and 99.90%, respectively. This shows that the model is very sensitive to the S and F categories, and can effectively capture the true positive examples and misclassify them as negative examples as little as possible. In particular, all rating indicators of the four categories are higher than 99.3%, which shows that the model provided by this scheme is unbiased for each category.

[0168] The performance of the model provided by the method is compared with other related sequence model algorithms for ECG classification, as shown in Table 6. In Table 6, the "Params" column represents the number of parameters of the model, "FLOPs" is the total number of floating-point numbers of the model, indicating the amount of calculation (computation) of the model, and "Size" represents the size of the model, that is, the storage space occupied by the model. It can be seen from the table that compared with previous studies, the performance of the method proposed in the present invention on the MIT-BIH dataset is better than that of other methods. At the same time, the model of this method uses the lowest number of parameters, with a total floating-point number of 3.75B, which is much less than other methods, which means that our model has higher efficiency in storage and calculation. In addition, when the weight pruning technology is applied, the model size of the present invention is reduced by about 25%, but the F1 score of the model is only slightly reduced. This shows that by effectively using weight pruning, it is possible to reduce the system space occupation while having little impact on system performance, thereby providing a better solution in a resource-constrained environment.

[0169] Table 6

[0170]

[0171] In addition, Table 7 compares the lightweight Transformer model proposed in the present invention with other popular ECG classification models. The results show that the one-dimensional lightweight ECG signal classification network based on CNN and Transformer proposed in the present invention has the best performance in terms of accuracy and is much higher than other methods in terms of F1 score. It can be seen from Table 7 that most methods based on the Transformer model perform better than other methods based on CNN or RNN. At the same time, the other methods do not use any technology to balance the data set, and their classification accuracy is lower than that of the network provided by the present invention ([5]-97.4%,

[11] -98.29% and

[28] -98.95%). This is because the present scheme uses the SMOTE algorithm to synthesize new minority class samples to reduce the impact of data set imbalance on the model classification performance. In addition, compared with other methods for balancing data sets, the present invention introduces RR interval features and an efficient attention mechanism to achieve higher accuracy.

[0172] Table 7

[0173]

[0174]

[0175] In this example implementation, a method for classifying an electrocardiogram signal is provided, which uses a signal classification model trained by the training method for the electrocardiogram signal classification model described above. Fig.10 As shown, the ECG signal classification method may include:

[0176] Step S21, obtaining the ECG data to be processed, and preprocessing the ECG data to be processed to obtain a corresponding heartbeat signal;

[0177] Step S22, inputting the heartbeat signal into a trained signal classification model, performing convolution processing on the heartbeat signal using a one-dimensional convolution layer, and obtaining first feature information for characterizing local spatial features;

[0178] Step S23, encoding the first feature information by using a Transformer encoding layer to obtain second feature information for characterizing global features;

[0179] Step S24, performing a convolution operation on the second feature using a convolution layer to obtain third feature information;

[0180] Step S25, using a linear layer to perform full connection processing on the third feature information and the RR interval feature information corresponding to the electrocardiogram data to obtain fourth feature data;

[0181] Step S26, using the classification layer to classify the fourth feature to obtain an ECG signal classification result corresponding to the ECG data to be processed.

[0182] In this example implementation, in the above step S21, the preprocessing of the to-be-processed ECG data to obtain corresponding heartbeat data includes:

[0183] Step S211, performing denoising processing on the ECG data to be processed to obtain a denoised ECG signal;

[0184] Step S212: dividing the denoised electrocardiogram signal into heart beats according to a preset sampling number based on the peak position of the R wave to obtain the heart beat signal.

[0185] Specifically, the ECG data to be processed may be ECG data collected in real time for the current patient. The ECG data may be first denoised. For example, there are usually a variety of noises in the ECG signal, and the three most common ones are power frequency interference, baseline drift, and myoelectric interference. These noises may affect the quality and accuracy of the ECG signal, thereby affecting the accuracy of ECG analysis and diagnosis. Therefore, the ECG signal needs to be denoised before classification. The discrete wavelet transform method can be used to denoise the ECG signal, and the Daubechies 6 wavelet is selected as the wavelet basis. First, the discrete wavelet transform is used to perform a 7-scale wavelet decomposition on the noisy ECG signal. After the denoising process is completed, the denoised ECG signal is divided into beats according to a preset number of samples based on the peak position of the R wave to obtain a beat signal. When obtaining the beat signal, the corresponding RR interval feature is calculated according to the peak position of the R wave.

[0186] In this example implementation, the one-dimensional convolution layer includes a first convolution layer, a first attention mechanism layer, a second convolution layer, and a second attention mechanism layer arranged in sequence; wherein the first convolution layer includes a number of depth-separable convolution layers arranged in succession; the second convolution layer includes at least one depth-separable convolution layer; the first attention module layer and the second attention module layer include lightweight channel attention mechanism layers.

[0187] Exemplarily, in the above step S22, the heartbeat signal is first fed into the 1D-CNN layer to extract local spatial features.

[0188] In this example implementation, in the above step S23, the use of the Transformer coding layer to extract features from the first feature information to obtain second feature information for characterizing global features includes:

[0189] Step S231, encoding the first feature information and converting it into a corresponding vector representation; and generating a corresponding position vector for each position of the first feature information;

[0190] Step S232: Encode the vector representation and the position vector using a plurality of stacked encoders to obtain the second feature information.

[0191] For example, in order to implement the Transformer model for ECG signal classification in edge applications, the encoder part is used exclusively, focusing only on the encoding representation of the input sequence (ECG signal) without generating the output sequence. This choice is made because the encoder part has encapsulated the core functions of the Transformer model, which is sufficient to extract effective feature representations for classification tasks.

[0192] Exemplarily, the output of the Transformer encoding layer is convolved with a convolution layer to obtain the third feature information. The number of input channels of the convolution layer conv5 is 64, the number of output channels is 1, and the size of the convolution kernel is 1. The final linear layer Linear concatenates the RR interval feature with the output of the previous convolution layer, and the input feature is 66, and the output feature dimension is 4; the output of the linear layer is converted into a probability distribution through the softmax activation function to obtain the final prediction result.

[0193] The classification method provided in the embodiment of the present disclosure, the processing process of each level is as described in the embodiment corresponding to the model training method in the above embodiment. The classification method and model classification method provided in the embodiment of the present disclosure, by applying the weight pruning technology to the arrhythmia classification, develop a lightweight ECG classification network based on Transformer, the purpose is to efficiently and accurately process the heartbeat data on the resource-constrained edge device. Specifically, this method designs a new 1D-CNN as the input structure of the Transformer model, replaces the original convolution layer with DSC, and introduces the ECA module to enhance the feature extraction ability of the model. When processing the heartbeat signal, the local spatial features are extracted by the 1D-CNN module, and the global features are captured in combination with the Transformer encoder module, so that the feature vector of the heartbeat data can be accurately obtained. In order to capture richer features, we introduced the RR interval feature after the Transformer model. Subsequently, these feature vectors are fully connected through the classifier, and the probability that the heartbeat data belongs to the preset heartbeat type is preset, which can effectively improve the accuracy of the ECG data classification and realize the accurate judgment of the heartbeat type. Finally, we focus on the lightweight problem and use depthwise separable convolution, lightweight and efficient channel attention, and weight pruning techniques to simplify the model structure to reduce the number of model parameters and the amount of computation while maintaining high classification accuracy. Experimental results show that compared with traditional deep learning models, our method outperforms most existing methods in terms of accuracy, F1 score, computational cost, and storage space, and is more suitable for deployment on portable devices in edge computing scenarios.

[0194] It should be noted that the above figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0195] For further reference, Fig.11 As shown, in the embodiment of this example, an electrocardiogram signal classification device 11 is also provided, comprising:

[0196] A preprocessing module 111 is used to obtain the ECG data to be processed, and preprocess the ECG data to be processed to obtain a corresponding heartbeat signal;

[0197] A one-dimensional convolutional layer processing module 112, used for inputting the heartbeat signal into a trained signal classification model, performing convolution processing on the heartbeat signal using a one-dimensional convolutional layer, and obtaining first feature information for characterizing local spatial features;

[0198] A coding layer processing module 113, configured to encode the first feature information using a Transformer coding layer to obtain second feature information for representing global features;

[0199] A convolution layer processing module 114, configured to perform a convolution operation on the second feature using a convolution layer to obtain third feature information;

[0200] A linear layer processing module 115 is used to perform full connection processing on the third characteristic information and the RR interval characteristic information corresponding to the electrocardiogram data using a linear layer to obtain fourth characteristic data;

[0201] The classification layer processing module 116 is used to classify the fourth feature using the classification layer to obtain an ECG signal classification result corresponding to the ECG data to be processed.

[0202] In some exemplary embodiments, the preprocessing module 111 is used to perform denoising on the ECG data to be processed to obtain a denoised ECG signal; and divide the denoised ECG signal into beats according to a preset sampling number based on the peak position of the R wave to obtain the beat signal.

[0203] In some exemplary embodiments, the one-dimensional convolution layer includes a first convolution layer, a first attention mechanism layer, a second convolution layer, and a second attention mechanism layer arranged in sequence; wherein the first convolution layer includes a plurality of depth-wise separable convolution layers arranged in succession; the second convolution layer includes at least one depth-wise separable convolution layer; the first attention module layer and the second attention module layer include lightweight channel attention mechanism layers.

[0204] In some exemplary embodiments, the encoding layer processing module 113 is used to encode the first feature information and convert it into a corresponding vector representation; and generate a corresponding position vector for each position of the first feature information; and use a stacked plurality of encoders to encode the vector representation and the position vector to obtain the second feature information.

[0205] For further reference, Fig.12 As shown, in the embodiment of this example, a training device 12 for an electrocardiogram signal classification model is also provided, comprising:

[0206] The sample data processing module 121 is used to construct heart beat sample data using the marked ECG sample data;

[0207] The initial model construction module 122 is used to construct an initial classification model; the initial classification model includes a one-dimensional convolution layer, a Transformer encoding layer, a convolution layer, a linear layer and a classification layer; wherein the one-dimensional convolution layer is used to perform convolution processing on the heartbeat signal to obtain first feature information for characterizing local spatial features; the Transformer encoding layer is used to perform feature extraction on the first feature information to obtain second feature information for characterizing global features; the convolution layer is used to perform convolution operation on the second feature to obtain third feature information; the linear layer is used to perform full connection processing on the third feature information and the RR interval feature information corresponding to the electrocardiogram data to obtain fourth feature data; the classification layer is used to perform classification processing on the fourth feature;

[0208] A model training module 123 is used to train the initial classification model using the heartbeat sample data to obtain a trained model;

[0209] The model optimization module 124 is used to perform weight pruning on the trained model to obtain a compressed ECG signal classification model.

[0210] In some exemplary embodiments, the sample data processing module 121 is used to denoise the ECG sample signals of the MIT-BIH arrhythmia database to obtain denoised ECG sample data; divide the denoised ECG sample data into beats according to preset sampling points based on the R peak position to obtain first heart beat sample data; use the SMOTE algorithm to synthesize minority class heart beat data as second heart beat sample data; and construct the heart beat sample data based on the first sample data and the second sample data.

[0211] In some exemplary embodiments, the model optimization module 124 is used to evaluate the importance of the trainable parameters of the trained model, and use the L1 norm to measure the importance of the trainable parameters; sort the trainable parameters according to the importance evaluation results, and prune the trainable parameters according to the sorting results; fine-tune and retrain the pruned model to obtain a compressed ECG signal classification model.

[0212] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0213] Fig.13 A schematic diagram of an electronic device suitable for implementing an embodiment of the present invention is shown.

[0214] It should be noted that Fig.13 The electronic device 1000 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0215] like Fig.13 As shown, the electronic device 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1002 or the program loaded from the storage part 1008 to the random access memory (RAM) 1003. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, ROM 1002 and RAM 1003 are connected to each other through a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0216] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.

[0217] In particular, according to an embodiment of the present invention, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 1009, and / or installed from a removable medium 1011. When the computer program is executed by a central processing unit (CPU) 1001, various functions defined in the system of the present application are executed.

[0218] Specifically, the electronic device may be a smart mobile electronic device such as a mobile phone, a tablet computer or a laptop computer, or may be a smart electronic device such as a desktop computer, or a smart wearable device.

[0219] It should be noted that the storage medium shown in the embodiment of the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any storage medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0220] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0221] The units involved in the embodiments of the present invention may be implemented by software or hardware, and the units described may also be arranged in a processor. The names of these units do not, in some cases, limit the units themselves.

[0222] It should be noted that, as another aspect, the present application also provides a storage medium, which can be included in an electronic device; or it can exist independently without being installed in the electronic device. The above storage medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the following embodiments. For example, the electronic device can implement the following Figure 2 and / or Fig.10 The individual steps of the method are shown.

[0223] In one embodiment, the present application provides a computer program product, including a computer program, which implements the steps in the above-mentioned method embodiments when executed by a processor.

[0224] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0225] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

[0226] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for classifying electrocardiogram signals, characterized in that: The method comprises: Acquire the ECG data to be processed, and pre-process the ECG data to be processed to obtain a corresponding heartbeat signal; Inputting the heartbeat signal into a trained signal classification model, performing convolution processing on the heartbeat signal using a one-dimensional convolution layer, and obtaining first feature information for characterizing local spatial features; Encoding the first feature information using a Transformer encoding layer to obtain second feature information for characterizing global features; Using a convolution layer to perform a convolution operation on the second feature to obtain third feature information; Using a linear layer, fully connect the third feature information and the RR interval feature information corresponding to the electrocardiogram data to obtain fourth feature data; The fourth feature is classified by using a classification layer to obtain an electrocardiogram signal classification result corresponding to the electrocardiogram data to be processed.

2. The method according to claim 1, characterized in that The preprocessing of the to-be-processed electrocardiogram data to obtain corresponding heartbeat data includes: Performing denoising on the ECG data to be processed to obtain a denoised ECG signal; The denoised electrocardiogram signal is divided into heart beats according to a preset sampling number based on the peak position of the R wave to obtain the heart beat signal.

3. The method according to claim 1, characterized in that The one-dimensional convolution layer includes a first convolution layer, a first attention mechanism layer, a second convolution layer and a second attention mechanism layer arranged in sequence; wherein the first convolution layer includes a plurality of depth-separable convolution layers arranged in succession; the second convolution layer includes at least one depth-separable convolution layer; the first attention module layer and the second attention module layer include lightweight channel attention mechanism layers.

4. The method according to claim 1, characterized in that The using the Transformer coding layer to extract features from the first feature information to obtain second feature information for characterizing global features includes: Encode the first feature information and convert it into a corresponding vector representation; and generate a corresponding position vector for each position of the first feature information; The vector representation and the position vector are encoded using a plurality of stacked encoders to obtain the second feature information.

5. A training method for an electrocardiogram signal classification model, characterized in that: The method comprises: Construct heart beat sample data using labeled ECG sample data; Constructing an initial classification model; the initial classification model includes a one-dimensional convolutional layer, a Transformer encoding layer, a convolutional layer, a linear layer and a classification layer; wherein the one-dimensional convolutional layer is used to perform convolution processing on the heartbeat signal to obtain first feature information for characterizing local spatial features; the Transformer encoding layer is used to perform feature extraction on the first feature information to obtain second feature information for characterizing global features; the convolutional layer is used to perform convolution operation on the second feature to obtain third feature information; the linear layer is used to perform full connection processing on the third feature information and the RR interval feature information corresponding to the electrocardiogram data to obtain fourth feature data; the classification layer is used to perform classification processing on the fourth feature; Using the heartbeat sample data to train the initial classification model to obtain a trained model; The trained model is weight pruned to obtain a compressed electrocardiogram signal classification model.

6. The method according to claim 5, characterized in that The method of constructing heart beat sample data using the labeled electrocardiogram sample data includes: De-noising the ECG sample signals of the MIT-BIH arrhythmia database to obtain de-noised ECG sample data; Based on the R peak position, the denoised ECG sample data is divided into heart beats according to preset sampling points to obtain the first heart beat sample data; Use the SMOTE algorithm to synthesize the minority heartbeat data as the second heartbeat sample data; The heartbeat sample data is constructed based on the first sample data and the second sample data.

7. The method according to claim 5, characterized in that The step of performing weight pruning on the trained model comprises: Performing importance evaluation on the trainable parameters of the trained model, and using L1 norm to measure the importance of the trainable parameters; Sorting the trainable parameters according to importance evaluation results, and pruning the trainable parameters according to the sorting results; The pruned model is fine-tuned and retrained to obtain a compressed ECG signal classification model.

8. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for classifying an electrocardiogram signal according to any one of claims 1 to 4 or the method for training an electrocardiogram signal classification model according to any one of claims 5 to 7 is implemented.

9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for classifying an electrocardiogram signal according to any one of claims 1 to 4 or the method for training an electrocardiogram signal classification model according to any one of claims 5 to 7 is implemented.

10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the electrocardiogram signal classification method according to any one of claims 1 to 4, or the electrocardiogram signal classification model training method according to any one of claims 5 to 7 by executing the executable instructions.