An electrocardiosignal classification method based on lead feature fusion and particle swarm algorithm
By combining lead feature fusion and particle swarm optimization for ECG signal classification, the instability and resource constraints of ECG signal models in clinical settings are addressed, achieving high-precision, low-complexity ECG signal classification suitable for wearable devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- EAST CHINA JIAOTONG UNIVERSITY
- Filing Date
- 2026-02-10
- Publication Date
- 2026-04-24
AI Technical Summary
Existing intelligent diagnostic models for electrocardiogram signals are unstable in real clinical environments, have poor generalization ability, and the large size of deep learning models is incompatible with the resource-constrained wearable devices. Traditional hyperparameter tuning methods are inefficient and it is difficult to find the optimal configuration.
An ECG signal classification method based on lead feature fusion and particle swarm optimization is adopted. Noise is removed by wavelet thresholding and dual median filtering. Multi-lead feature branches are constructed. The hierarchical feature fusion and model parameter optimization are achieved by using fractional-order particle swarm optimization algorithm and weighted cross-entropy loss function. The model configuration is dynamically adjusted by combining computational penalty factor.
It improves the generalization ability and classification accuracy of the ECG signal classification model, reduces computational complexity, adapts to resource-constrained real-world application scenarios, and enhances the model's deployment potential in wearable devices.
Smart Images

Figure CN121705847B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence, and in particular to a method for classifying electrocardiogram signals based on lead feature fusion and particle swarm optimization. Background Technology
[0002] With the development of artificial intelligence theory and the improvement of hardware performance, significant progress has been made in the field of intelligent analysis of electrocardiogram signals. However, these methodological achievements still face serious challenges in the process of translating them into widespread and universally applicable clinical practice:
[0003] The models used exhibit unstable performance and poor generalization ability in real clinical settings, which is one of the core bottlenecks currently facing the market. Deep learning models are typically trained on specific datasets, and the learned features may be biased by the dataset itself rather than reflecting the essential characteristics of heart disease. When encountering electrocardiogram data from different hospitals, different devices, and different populations, the data distribution may differ from the training set, leading to a significant performance degradation.
[0004] While many existing deep learning-based ECG intelligent diagnostic models have achieved remarkable high accuracy in ideal laboratory environments, their large model size and computational requirements create a sharp contradiction with the strict resource constraints of edge terminals such as wearable devices and body area network nodes in the real world, directly hindering their practical application. Achieving a balance between the model's classification performance and the number of parameters is a crucial problem that urgently needs to be solved.
[0005] At the algorithm level, most methods still rely on researchers' experience for manual debugging or the use of grid search, random search, and other methods. Due to the limited search space, it is easy to miss key hyperparameter combinations, causing the model to fail to achieve its best performance. Traditional methods rely on subjective experience and it is difficult to systematically find the optimal configuration. Summary of the Invention
[0006] In view of the above situation, the main objective of this invention is to propose an electrocardiogram signal classification method based on lead feature fusion and particle swarm optimization algorithm to solve the above-mentioned technical problems.
[0007] This invention proposes an electrocardiogram (ECG) signal classification method based on lead feature fusion and particle swarm optimization algorithm. The method includes the following steps:
[0008] Step 1: Remove high-frequency noise from the original ECG signal in the original dataset using wavelet thresholding, and then remove low-frequency noise using dual median filtering to obtain the denoised multi-lead ECG signal.
[0009] Step 2: Perform multi-lead separation feature branch construction processing on the denoised multi-lead ECG signal to obtain lead feature vectors;
[0010] Step 3: Perform multi-lead feature hierarchical fusion processing on the lead feature vectors to obtain global hierarchical feature vectors and location hierarchical feature vectors;
[0011] Step 4: Perform multi-lead feature hierarchical classification using global hierarchical feature vectors, location hierarchical feature vectors, and lead feature vectors to obtain the classification results output by the global classifier, the location classifier, and the lead classifier, respectively.
[0012] Step 5: Using the training dataset, class labels, and pre-defined baseline model computational cost obtained from the original dataset, construct the weighted cross-entropy loss function and the classification system fitness function;
[0013] Step 6: Iterate the network structure parameters of the classification model using the classification results output by the global classifier, the classification results output by the part classifier, the classification results output by the lead classifier, the weighted cross-entropy loss function, and the fitness function of the classification system to obtain the optimal model configuration parameters;
[0014] Step 7: Configure the classification model using the optimal model configuration parameters to obtain the configured classification model; input the original ECG signal into the configured classification model to obtain the ECG signal classification result.
[0015] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0016] 1. This invention achieves feature fusion at three levels—global, regional, and lead—by constructing a "lead-separated feature branch," thereby enhancing the fine-grainedness and richness of feature expression. It explicitly separates and fuses features at different levels, preserving the approximate correspondence between various cardiac regions and leads to the greatest extent possible. It accurately retains information on the septum corresponding to V1 and V2, the anterior wall corresponding to V3 and V4, the inferior wall corresponding to II, III, and aVF, the lateral wall corresponding to I, aVL, V5, and V6, and the endocardium corresponding to aVR. This provides a stronger physiological interpretation and discrimination ability at the feature level than existing models, fundamentally improving the generalization ability of classification models and advancing the process of applying electrocardiogram signals from the laboratory to the clinic.
[0017] 2. This invention integrates fractional calculus theory into the velocity update process of particle swarm optimization, constructing a fractional particle swarm optimization algorithm. Fractional operators have memory characteristics, which can make full use of the historical motion trajectory information of particles to participate in the current velocity calculation. By adjusting the iteration of the memory length, a dynamic balance between global exploration and local development capabilities can be achieved, effectively overcoming the defect of traditional algorithms that are prone to getting trapped in local optima, and significantly improving the convergence accuracy and solution quality of ECG signal classification model parameter optimization.
[0018] 3. This invention uses a hierarchical population management mechanism based on fitness values to dynamically divide the particle swarm into three levels: elite particles, medium particles, and poor particles. Differentiated evolutionary strategies are implemented for different levels. Elite learning is adopted for medium particles, and the reasons for the low fitness of poor particles are analyzed and then a pruning strategy is adopted. This enables the algorithm to maintain fast convergence while having the ability to escape local optima. This effectively improves the optimization efficiency and global optimization performance while further reducing the size of the classification network.
[0019] 4. By constructing a fitness function with a computational penalty factor and coordinating it with an improved particle swarm optimization algorithm, this invention can effectively control computational complexity while maintaining high classification accuracy. This consideration of the balance between performance and efficiency makes the model more practical and have greater deployment potential when facing resource-constrained real-world application scenarios compared to some large-scale models that only pursue high accuracy. Attached Figure Description
[0020] Figure 1 This is a flowchart of the ECG signal classification method based on lead feature fusion and particle swarm optimization proposed in this invention;
[0021] Figure 2 This is a flowchart of the wavelet thresholding method for removing high-frequency noise in the ECG signal classification method based on lead feature fusion and particle swarm optimization proposed in this invention.
[0022] Figure 3 This is a flowchart of the dual median filtering method for removing low-frequency noise in the ECG signal classification method based on lead feature fusion and particle swarm optimization proposed in this invention.
[0023] Figure 4 This is a schematic diagram illustrating the hierarchical fusion of multi-lead features in the ECG signal classification method based on lead feature fusion and particle swarm optimization proposed in this invention.
[0024] Figure 5 This is a schematic diagram of the multi-branch feature fusion coding classification method for ECG signal classification based on lead feature fusion and particle swarm optimization proposed in this invention.
[0025] Figure 6This diagram illustrates a comparison between the fractional-order particle swarm optimization algorithm and the basic particle swarm optimization algorithm in the ECG signal classification method based on lead feature fusion and particle swarm optimization proposed in this invention.
[0026] Figure 7 This is a schematic diagram of the effective memory length variation curve of the ECG signal classification method based on lead feature fusion and particle swarm optimization proposed in this invention.
[0027] Figure 8 This is a schematic diagram of the intermediate particle elite learning method for ECG signal classification based on lead feature fusion and particle swarm optimization proposed in this invention.
[0028] Figure 9 This is a flowchart of the differential particle pruning structure for the ECG signal classification method based on lead feature fusion and particle swarm optimization proposed in this invention. Detailed Implementation
[0029] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0030] These and other aspects of the embodiments of the present invention will become clear from the following description and accompanying drawings. In these descriptions and drawings, some specific embodiments of the present invention are specifically disclosed to illustrate some ways of implementing the principles of the embodiments of the present invention; however, it should be understood that the scope of the embodiments of the present invention is not limited thereto.
[0031] Please see Figure 1 This invention proposes a method for classifying electrocardiogram (ECG) signals based on lead feature fusion and particle swarm optimization. The method includes the following steps:
[0032] Step 1: Remove high-frequency noise from the original ECG signal in the original dataset using wavelet thresholding, and then remove low-frequency noise using dual median filtering to obtain the denoised multi-lead ECG signal.
[0033] In step 1, the original ECG signals in the original dataset are processed to remove high-frequency noise using wavelet thresholding, and then low-frequency noise is removed using dual median filtering to obtain the denoised multi-lead ECG signals. The specific steps are as follows:
[0034] The original electrocardiogram signal was decomposed using the db6 wavelet basis to obtain approximation coefficients and detail coefficients;
[0035] Soft-thresholding is applied to the detail coefficients to obtain the soft-thresholded detail coefficients. The corresponding process has the following relationship:
[0036] ;
[0037] in, This represents the detail coefficients after soft thresholding. Indicates detail coefficients. This indicates the threshold value set by the threshold method;
[0038] Wavelet reconstruction was performed using the detail coefficients and approximation coefficients after soft thresholding to obtain a high-frequency denoised ECG signal;
[0039] A first and a second window are preset. The first filtering window is used to perform a first median filtering process on the ECG signal after high-frequency denoising to obtain a preliminary baseline estimate. The set expression for median filtering is defined as follows:
[0040] ;
[0041] in, Indicates time The filtered value, Indicates the length of the filtering window;
[0042] The preliminary baseline estimate is subjected to a second median filter using a second filtering window to obtain the final baseline estimate;
[0043] Based on the final baseline estimation and high-frequency denoised ECG signal, the multi-lead ECG signal after removing low-frequency noise is obtained by baseline subtraction.
[0044] For further details, please refer to Figure 2 The wavelet thresholding method used in this invention includes the following three basic operations:
[0045] Wavelet decomposition is used in this invention because the waveform of the db6 wavelet basis is similar to the QRS complex shape in the ECG signal. This allows for a more complete extraction of the feature information from the original ECG signal. The output of wavelet decomposition consists of two parts: approximation coefficients and detail coefficients. The approximation coefficients represent the low-frequency part of the original ECG signal and include the approximate shape and outline of the P wave, T wave, and QRS complex. The main energy of the original ECG signal is also present in the approximation coefficients. The detail coefficients represent the high-frequency part of the original ECG signal and include the steep curves in the QRS complex. High-frequency noise such as power line interference and electromyography interference is present in these coefficients.
[0046] Thresholding: Taking the detail coefficients generated by the wavelet decomposition in the previous step as input, a threshold is first set. , the coefficient absolute value and Compare, if the coefficients The absolute value is less than If the coefficient with a very small amplitude is considered to be introduced by noise, it is directly set to zero to suppress high-frequency noise; if the coefficient The absolute value is greater than or equal to If so, then soft threshold processing will be performed;
[0047] Wavelet reconstruction maps frequency domain data back to the time domain through discrete wavelet inverse transform. The wavelet reconstruction process receives two sets of inputs: one set of approximate coefficients that preserve the original state, and the other set of detail coefficients after soft thresholding. By processing these two sets of coefficients with upsampling interpolation and inverse filtering based on the db6 wavelet basis, the reconstructed low-frequency complete information is superimposed and synthesized with the high-frequency denoised details. The final output is a high-frequency ECG signal that removes high-frequency noise interference and completely preserves the morphological characteristics of each P-QRS-T wave group.
[0048] Please see Figure 3 This invention proposes a dual median filtering strategy, which first uses a small window to accurately remove spikes from the QRS complex, and then uses a large window to smooth the wider P and T waves. The advantage of this is that it can accurately estimate the baseline while preserving the diagnostic information of ECG to the maximum extent.
[0049] The details of low-frequency noise reduction methods include the following:
[0050] The window parameters were set, and two filter windows with different widths were defined. and ,in Set to 0.2 times the ECG sampling rate, i.e. fs is the ECG sampling rate. It is a small window used to eliminate QRS groups; Set to 0.6 times the ECG sampling rate, i.e. , It is a large window used for smoothing wave groups;
[0051] First median filtering, using a window The ECG signal, which has already undergone high-frequency denoising, is then filtered. Because the QRS complex duration is short, only 90ms to 130ms, and... The setting is around 200ms. The first median filter effectively suppresses these spikes and obtains a preliminary baseline estimate. ;
[0052] The second median filter uses a wider window. right After further filtering and smoothing, the duration of the P wave is between 60ms and 100ms, and the duration of the T wave is between 150ms and 200ms. The window is set to about 600ms, which is longer than the duration of the P wave and T wave. The residual components of the P wave, T wave and other waves are also smoothed out, so as to obtain the final baseline estimate B(n).
[0053] Baseline subtraction involves subtracting the estimated baseline B(n) from the original signal x(n) to output the ECG signal after removing low-frequency noise and baseline drift.
[0054] Step 2: Perform multi-lead separation feature branch construction processing on the denoised multi-lead ECG signal to obtain lead feature vectors;
[0055] In step 2, the denoised multi-lead ECG signal is processed to construct multi-lead feature branches to obtain lead feature vectors. The specific steps are as follows:
[0056] The denoised multi-lead ECG signal was separated to obtain twelve separate lead ECG signals;
[0057] An independent feature encoder is constructed for each separate lead ECG signal. This independent feature encoder is then used to process the corresponding separate lead ECG signal to obtain the lead feature vector. The relationship in this process is as follows:
[0058] ;
[0059] in, Both represent lead eigenvectors. Both indicate that the processing is done through a feature encoder. All of these represent separate lead ECG signals.
[0060] It should be noted that the focus of this invention is on the hierarchical fusion of leads and the subsequent fitness function and algorithm, and it does not impose any restrictions on the encoder structure. The internal structure is the same; as long as the input and output formats are satisfied, classic structures such as CNN, ResNET, and VGG can be used.
[0061] Step 3: Perform multi-lead feature hierarchical fusion processing on the lead feature vectors to obtain global hierarchical feature vectors and location hierarchical feature vectors;
[0062] In step 3, the lead feature vectors are subjected to multi-lead feature hierarchical fusion processing to obtain global hierarchical feature vectors and location hierarchical feature vectors. The specific steps are as follows:
[0063] By directly concatenating all lead feature vectors along their feature dimensions, a global hierarchical feature vector is obtained. The corresponding relationship in this process is as follows:
[0064] ;
[0065] in, Represents the global hierarchical feature vector;
[0066] Based on the correspondence between heart location and leads, the lead feature vectors are grouped and concatenated to obtain location-level feature vectors. The relationship in this correspondence process is as follows:
[0067] ;
[0068] in, This represents the feature vector of the corresponding anterior wall region. This represents the feature vector of the corresponding partition. This represents the feature vector of the corresponding lower wall region. This represents the feature vector of the corresponding sidewall at the hierarchical level.
[0069] It should be noted that the previous step or The global and regional features are fused to form three levels of features: "global-region-lead" for subsequent classification. This fully considers the overall (global) and differential (regional and lead) characteristics of ECG leads. First, all lead-level features are directly concatenated to obtain the global features. .
[0070] Furthermore, the correspondence between the cardiac location and the leads is shown in Table 1:
[0071] Table 1. Correspondence between heart location and leads
[0072]
[0073] For further details, please refer to Figure 4 The features of each lead can be fused together to form three levels of features. Multiple levels of features can provide more sufficient basis for subsequent classification and diagnosis, and reduce the probability of misjudgment.
[0074] Step 4: Perform multi-lead feature hierarchical classification using global hierarchical feature vectors, location hierarchical feature vectors, and lead feature vectors to obtain the classification results output by the global classifier, the location classifier, and the lead classifier, respectively.
[0075] Please see Figure 5In step 4, multi-lead hierarchical classification is performed using global hierarchical feature vectors, location hierarchical feature vectors, and lead feature vectors to obtain the classification results output by the global classifier, the location classifier, and the lead classifier, respectively. The specific steps are as follows:
[0076] The global hierarchical feature vector is input into the global classifier for classification calculation, and the classification result output by the global classifier is obtained. The corresponding relationship in the process is as follows:
[0077] ;
[0078] in, This represents the classification result output by the global classifier. This indicates that the data is processed using a global classifier.
[0079] The feature vectors at the part level are input into the corresponding part classifier for calculation, and the classification result output by the part classifier is obtained. The relationship in the corresponding process is as follows:
[0080] ;
[0081] in, This represents the classification result output by the classifier for the corresponding anterior wall region. This represents the classification result output by the classifier for the corresponding partition. This represents the classification result output by the classifier for the corresponding lower wall region. This represents the classification result output by the classifier for the corresponding sidewall location. Both represent part classifiers;
[0082] The lead feature vector is input into the corresponding feature classifier for calculation, and the classification result output by the lead classifier is obtained.
[0083] In the process of inputting the lead feature vectors into the corresponding feature classifier for calculation and obtaining the classification result output by the lead classifier, the following relationship exists:
[0084] ;
[0085] in, All of these represent the classification results output by the lead classifier. Both represent feature classifiers.
[0086] It should be noted that the classifiers used in this step can be divided into the following three types:
[0087] Global classifier, This is a global classifier, which is used to classify the global feature vector after fusing 12 feature vectors. Its input vector length is the sum of the lengths of the 12 feature branches, and its output is the global predicted probability.
[0088] Part classifier, where, yes The corresponding classifier has an input vector length that is twice the length of the feature branch vector; yes The corresponding classifier has an input vector length that is twice the length of the feature branch vector; yes The corresponding classifier has an input vector length that is three times the length of the feature branch vector; yes The corresponding classifiers have an input vector length that is 4 times the feature branch vector length; the outputs of the four classifiers are the predicted probabilities of the anterior wall, septum, inferior wall, and lateral wall.
[0089] Feature classifier, Both represent feature classifiers, whose input is... The output is the predicted probability for each of the 12 leads.
[0090] Furthermore, the key innovation of this invention lies in the hierarchical fusion of leads and the subsequent fitness function and algorithm. Similar to the encoder, it does not restrict the structure of the classifier, only requiring that the input and output format requirements be met. Various combinations of fully connected layers and pooling layers can be used.
[0091] Step 5: Using the training dataset, class labels, and pre-defined baseline model computational cost obtained from the original dataset, construct the weighted cross-entropy loss function and the classification system fitness function;
[0092] In step 5, using the training dataset obtained from the original dataset, the class labels, and the pre-defined baseline model computational cost, a weighted cross-entropy loss function and a classification system fitness function are constructed. The specific steps are as follows:
[0093] Using the total number of samples and the total number of classes obtained from the training dataset, the weight coefficients are manually calculated based on inverse class frequency. The corresponding relationship in this process is as follows:
[0094] ;
[0095] in, Indicates the weighting coefficient. Represents the total number of samples. Indicates the total number of categories. Indicates the first Number of samples resembling arrhythmias;
[0096] It should be noted that the weights are set manually. Its core advantage lies in directly mapping the prior knowledge of clinical experts and the severity of pathology into the optimization objective of the model, making up for the shortcomings of pure data-driven methods that only focus on statistical distribution and ignore medical risks.
[0097] In clinical ECG datasets, simple mathematical statistics cannot accurately quantify the serious consequences of misdiagnosing malignant heart rates. Therefore, this invention constructs a medical safety-based guide for the particle swarm optimization algorithm by artificially setting the weight of scarce and high-risk categories to a very large maximum value. This strategy artificially creates a huge loss penalty in the optimization space, forcing the particle swarm algorithm to prioritize overcoming the feature extraction problem of scarce samples in the early stages of the search, otherwise it will face an unbearable fitness penalty.
[0098] Furthermore, a weighted cross-entropy loss function is constructed using the weight coefficients and the true labels obtained from the training dataset. The corresponding relationship in this process is as follows:
[0099] ;
[0100] in, This represents the weighted cross-entropy loss, which is the objective of model optimization, and the training process aims to minimize this value. This represents the total number of all ECG signal categories. Indicates category index, Indicates the predicted probability. Indicates the true label, This represents the difference between the predicted probability and certainty (100%).
[0101] It should be noted that existing ECG signal classification methods generally use the standard cross-entropy loss function during training. This operation ignores the long-tailed distribution of ECG signals and the imbalance in the distribution among different arrhythmia categories. In clinical scenarios, normal heart rhythm and sinus heart rate samples account for the vast majority of the data. In contrast, second- / third-degree atrioventricular block and atrial flutter are malignant arrhythmias with high mortality rates. Due to their low incidence and small sample size, traditional optimization objectives tend to make the model cater to the majority class of samples to obtain a higher overall statistical accuracy. This results in the model having extremely low sensitivity to scarce but high-mortality pathological features, making it difficult to meet the needs of medical diagnosis for accurate and timely diagnosis of high-risk malignant arrhythmias.
[0102] The fitness function of the classification system is constructed by using dynamic penalty coefficients and the computational cost of a preset baseline model;
[0103] In the process of constructing the fitness function of the classification system using the dynamic penalty coefficient and the computational cost of the preset benchmark model, the following relationship exists:
[0104] ;
[0105] in, Represents the fitness value of the classification system. Indicates the model's classification accuracy. Indicates the dynamic penalty coefficient. This represents the computational cost of the baseline model. This represents the computational cost of the existing benchmark model. Indicates the initial penalty coefficient. This represents the final penalty coefficient. Indicates the current iteration round. This indicates the maximum number of iterations.
[0106] In previous inventions in the field of ECG signal classification, although the method of continuously stacking deep learning network structures has significantly improved the accuracy of diagnosis, this performance improvement is accompanied by a huge number of parameters and computational overhead, resulting in a very large computational cost (FLOPs) of the deployed network structure. ECG signal diagnosis and monitoring are widely used in portable medical devices and some wearable devices. These scenarios have almost stringent limitations on the real-time performance and power consumption of the algorithm. Therefore, simply pursuing high accuracy while ignoring computational cost is putting the cart before the horse and will inevitably make it difficult to deploy the model efficiently in actual hardware.
[0107] To address this issue, this invention constructs a joint optimization objective that can simultaneously consider classification accuracy and computational efficiency. By introducing the computational complexity of the model as a penalty term into the evaluation system and using dynamic coefficients to adjust the weights between the two, this invention designs a comprehensive evaluation function aimed at finding the optimal balance between accuracy and resource consumption.
[0108] It should be noted that this invention introduces the concept of... The loss function mechanism for the penalty term is implemented, and dynamic coefficients are utilized. During training, the model's sensitivity to computational consumption is adaptively adjusted. This mechanism forces the model to actively suppress high-energy-consuming neuronal connections that contribute little to classification while learning effective pathological features, thus simplifying and optimizing the architecture at the source of training.
[0109] Step 6: Iterate the network structure parameters of the classification model using the classification results output by the global classifier, the classification results output by the part classifier, the classification results output by the lead classifier, the weighted cross-entropy loss function, and the fitness function of the classification system to obtain the optimal model configuration parameters;
[0110] In step 6, the network structure parameters of the classification model are iterated using the classification results output by the global classifier, the location classifier, the lead classifier, the weighted cross-entropy loss function, and the classification system fitness function to obtain the optimal model configuration parameters. The specific steps are as follows:
[0111] Step 601: Randomly initialize the particle swarm to obtain an initialized particle swarm;
[0112] Step 602: Based on the classification results output by the global classifier, the classification results output by the part classifier, the classification results output by the lead classifier, and the true labels, the weighted cross-entropy loss function is used as the optimization objective to train the parameters of the grid structure corresponding to the initial particle swarm until convergence, and the trained network is obtained.
[0113] Step 603: On the validation set obtained from the original dataset, perform forward propagation using the trained network to obtain the classification result and the model classification accuracy; obtain the inherent computational cost through the parameters of the trained network;
[0114] Step 604: Substitute the model classification accuracy and inherent computational cost into the classification system fitness function to obtain the classification system fitness value of the particle.
[0115] Step 605: Update the velocities of the particles in the initial particle swarm using fractional calculus to obtain the updated particle velocities. Based on the updated particle velocities, obtain the updated particle swarm. The corresponding relationship in this process is as follows:
[0116] ;
[0117] in, Indicates that the particle is in The velocity vector at time t, Represents the memory weight coefficient. Indicates the particle's distance at time [time]. past The velocity vector at time t, All represent learning factors. All represent random numbers. Indicates the first In the nth iteration The particle in the first The optimal position found in 3D space. Indicates the first In the nth iteration The particle in the first The current coordinates in 3D space Indicates the first In the nth iteration The globally optimal position in the entire population within the dimensional space. Indicates the order of a fraction. Represents the generalized binomial coefficient. This indicates that the process is handled using a gamma function.
[0118] It should be noted that this step utilizes a fractional particle swarm optimization algorithm, introducing fractional calculus theory to overcome the "short-range memory" characteristic of particles and enhance global optimization capabilities. By introducing the fractional derivative defined by Grünwald-Letnikov (GL), the algorithm is endowed with a "long-range memory" mechanism, enabling particles to retain and utilize velocity information from all historical moments in a weighted decreasing manner, thereby achieving a more robust and accurate search in the complex ECG feature space.
[0119] For further details, please refer to Figure 6 The fundamental difference between the basic particle swarm optimization algorithm and the fractional-order particle swarm optimization algorithm of this invention lies in their velocity update mechanisms. For example... Figure 6 The upper structure, at time The historical velocity information of the previous 1, 2, and 3 time points is completely discarded, only the time point is used. The speed is utilized, and the memory weight distribution presents a single pulse pattern, which means that the particle cannot effectively utilize the historical information of its motion trajectory during the search process;
[0120] Fractional particle swarm optimization (PSO) employs a long memory mechanism, based on the fractional derivative design defined by Grünwald-Retnikov, such as... Figure 6 The lower half of the structure, from time... The particle's historical velocity at all forward moments is included in the calculation. In the diagram, the color of the squares changes from light to dark, indicating a gradual increase in weight, achieved through a decaying weight coefficient. By weighting and summing historical speeds, the distribution of memory weights shows an increasing step-like pattern, with recent speeds having a larger weight and long-term speeds having a gradually decreasing weight, but still contributing, thus achieving full utilization of historical search information.
[0121] Please see Figure 7 The fundamental difference between the basic particle swarm optimization (PSO) algorithm and the fractional-order PSO algorithm lies in the effective memory length L. The effective memory length L is defined as the minimum number of historical steps required for the weight accumulation to reach 75% of the total weight during the particle swarm iteration process; its unit is the number of steps.
[0122] The effective memory length represented by the gray dashed line in the basic particle swarm optimization algorithm always remains L=1, indicating that regardless of the iteration stage, particles can only utilize the velocity information at the current moment, and historical search trajectories are completely discarded. In contrast, the effective memory length represented by the black solid line in the fractional-order particle swarm optimization algorithm exhibits a dynamic growth characteristic with the iteration progress.
[0123] Due to weighting coefficients Follow While the contribution of early historical velocity is small, it allows the fractional-order particle swarm optimization algorithm to preserve a "long-term memory" of the search history throughout the entire search optimization process. In the ECG signal classification task based on hierarchical fusion, the algorithm can fully draw on valuable search directions discovered in the early exploration stage when optimizing feature fusion weights and classifier network structure, avoiding repeated searches or local optimum traps caused by information loss. In the middle stage, it accumulates past search memories, balancing exploration and development. In the later stage, it reviews the global historical participation and converges more finely. This operation enables particles to achieve more stable global optimization in the complex high-dimensional network structure parameter space.
[0124] Step 606: Using the updated particle swarm as the initial particle swarm, execute steps 602 to 604 to obtain the fitness values of the updated particle classification system; Based on the preset stratification threshold and the fitness values of the updated particle classification system, sort and stratify all particles according to the fitness values of the updated particle classification system to obtain elite particles, medium particles and poor particles.
[0125] It should be noted that this invention arranges all particles according to They are divided into three main categories: inferior particles, intermediate particles, and elite particles;
[0126] Elite particles: After each specified number of iterations, according to All particles are sorted, and the top 10% are considered elite particles. These particles represent the best network structure found so far, which has high accuracy while ensuring a low computational cost. These particles directly enter the next generation without requiring position updates. They are the leaders in the entire particle swarm and serve as the benchmark for learning by intermediate particles.
[0127] Medium-sized particles: After each specified number of iterations, according to All particles are sorted, and those with fitness function values between 10% and 85% are considered medium-sized particles. These particles perform moderately well, and medium-sized particles are the main force in the search, requiring a balance between "exploration" and "exploitation." The velocity change is obtained using the velocity update formula of the particle swarm optimization algorithm. Medium-sized particles do not directly change their position, but rather adjust their velocity according to an approximation formula. The ratio is 7 medium particles to 1 elite particle, which learns through the elite learning formula;
[0128] Difference particles: After each specified number of iterations, according to All particles are sorted, and particles with fitness function values between 85% and 100% are considered poor particles. These particles cannot find a good solution for a long time, possibly because they are trapped in a local optimum, or their accuracy is too low, or more likely, their FLOPs are too large, making particle updates meaningless.
[0129] Step 607: While keeping the positions of elite particles unchanged, perform elite learning and pruning operator processing on intermediate and poor particles respectively to obtain the corrected particle swarm.
[0130] Figure 8 This visually demonstrates the geometric significance of the position update of intermediate particles based on an elite guidance strategy. Figure 8 The center dot represents the particle's current position in the search space. The positive direction point represents the position of the elite particle it is trying to follow. It has a superior structure with higher classification accuracy or lower FLOPs, and the particles are "pulled" to the new position indicated by the triangle. This geometrically directional movement mechanism ensures that the medium-sized particles, which make up 70% of the population, can quickly move towards the high-quality areas where the elite group is located, thus significantly accelerating the convergence process of the model while ensuring exploratory nature.
[0131] Elite learning and pruning operators are applied to medium-sized and poor-sized particles respectively to obtain a corrected particle swarm. The elite learning process corresponds to the following relationship:
[0132] ;
[0133] in, This indicates the location that needs to be updated. This represents the change in velocity obtained from the velocity update formula. Represents the chaotic value. Indicates the position of elite particles;
[0134] The handling of difference particles is the essence of this invention; it is crucial in the later stages of model evolution as the fitness function... As the accuracy increases, many particles become poor particles not because their accuracy is too low, but because their FLOPs are too high. For poor particles at the bottom of the population, this invention does not use a blind random reset strategy, but rather a pruning strategy based on a penalty mechanism;
[0135] Considering that the fitness function includes a dynamic penalty term The formation of poor particles often stems from overly redundant network structures, leading to excessively high computational complexity (FLOPs). Therefore, this strategy aims to forcibly reduce the number of network channels and layers corresponding to these high-load particles nonlinearly, specifically the number of feature branches in the ECG signal and the number of fusion layers in the above steps. By making large leaps in the search space along the direction of "complexity reduction," this mechanism can quickly transfer particles from the local disadvantage region of "high precision - high computational cost" to the "lightweight" region. This not only effectively reduces the negative impact of FLOPs penalties, giving particles a chance to compete again, but also meets the actual need for low power consumption when deploying ECG signal classification models on mobile devices.
[0136] The pruning operator process corresponds to the following relationship:
[0137] ;
[0138] in, Indicates the updated number The particle in the first Position in dimensional space, This indicates that the data is processed using a rounding function. Indicates the pruning coefficient. Indicates the first The particle in the first Position in dimensional space, Indicates the first Lower bound constraints on the parameters of the dimension.
[0139] Please see Figure 9 ,exist Figure 9 The paper focuses on the three-step execution logic of the core pruning operator to ensure the legality and validity of the newly generated structure;
[0140] First, the algorithm uses randomly generated pruning coefficients. The current structural parameters are reduced to achieve nonlinear compression of the model size; secondly, a rounding operation is performed. This ensures that the number of channels and layers meets the discrete integer requirements of the neural network architecture; finally, a rigorous boundary discrimination mechanism is introduced to compare the calculation results with a preset minimum structure threshold. The system compares the parameters and, if excessive pruning causes the parameters to fall below the lower bound, it will forcibly correct them to the lower bound value. This significantly reduces model complexity while effectively preventing network crashes caused by parameters returning to zero or being invalid.
[0141] Step 608: Use the corrected particle swarm as the initial particle swarm again, and repeat steps 602 to 608. After reaching the iteration limit, the corrected final particle swarm is obtained.
[0142] Step 609: The mesh structure parameters corresponding to the particle with the highest fitness value in the classification system of the particles in the final particle swarm after correction are taken as the optimal model configuration parameters.
[0143] It should be noted that the actual physical meaning of the particle position in this invention is to perform two processing on the output probabilities of the 12 feature network branches and 17 classifiers in the multi-branch feature fusion coding classification diagram: discarding (pruning) and selecting.
[0144] Discard: The output of the classifier is deemed completely unreliable, and the feature branches and fusion levels of the lead to which the classifier belongs are pruned. The results are then recalculated. and ;
[0145] Selected: Fully accept the probability output by the classifier, and calculate the computational cost of the selected lead feature branch and fusion level for this particle. and Substitute into the fitness function to calculate its .
[0146] Step 7: Configure the classification model using the optimal model configuration parameters to obtain the configured classification model; input the original ECG signal into the configured classification model to obtain the ECG signal classification result.
[0147] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0148] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0149] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
Claims
1. A method for classifying electrocardiogram (ECG) signals based on lead feature fusion and particle swarm optimization, characterized in that, The method includes the following steps: Step 1: Remove high-frequency noise from the original ECG signal in the original dataset using wavelet thresholding, and then remove low-frequency noise using dual median filtering to obtain the denoised multi-lead ECG signal. Step 2: Perform multi-lead separation feature branch construction processing on the denoised multi-lead ECG signal to obtain lead feature vectors; Step 3: Perform multi-lead feature hierarchical fusion processing on the lead feature vectors to obtain global hierarchical feature vectors and location hierarchical feature vectors; Step 4: Perform multi-lead feature hierarchical classification using global hierarchical feature vectors, location hierarchical feature vectors, and lead feature vectors to obtain the classification results output by the global classifier, the location classifier, and the lead classifier, respectively. Step 5: Using the training dataset, class labels, and pre-defined baseline model computational cost obtained from the original dataset, construct the weighted cross-entropy loss function and the classification system fitness function; Step 6: Using the classification results output by the global classifier, the location classifier, the lead classifier, the weighted cross-entropy loss function, and the classification system fitness function, iterate the network structure parameters of the classification model to obtain the optimal model configuration parameters. Step 7: Configure the classification model using the optimal model configuration parameters to obtain the configured classification model; input the original ECG signal into the configured classification model to obtain the ECG signal classification result.
2. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 1, characterized in that, In step 1, the original ECG signals in the original dataset are processed to remove high-frequency noise using wavelet thresholding, and then low-frequency noise is removed using dual median filtering to obtain denoised multi-lead ECG signals. The specific steps are as follows: The original electrocardiogram signal was decomposed using the db6 wavelet basis to obtain approximation coefficients and detail coefficients; Soft-thresholding is applied to the detail coefficients to obtain the soft-thresholded detail coefficients. The corresponding process has the following relationship: ; in, This represents the detail coefficients after soft thresholding. Indicates detail coefficients. This indicates the threshold value set by the threshold method; Wavelet reconstruction was performed using the detail coefficients and approximation coefficients after soft thresholding to obtain a high-frequency denoised ECG signal; A first and a second window are preset. The first filtering window is used to perform a first median filtering process on the ECG signal after high-frequency denoising to obtain a preliminary baseline estimate. The set expression for median filtering is defined as follows: ; in, Indicates time The filtered value, Indicates the length of the filtering window; The preliminary baseline estimate is subjected to a second median filter using a second filtering window to obtain the final baseline estimate; Based on the final baseline estimation and high-frequency denoised ECG signal, the multi-lead ECG signal after removing low-frequency noise is obtained by baseline subtraction.
3. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 2, characterized in that, In step 2, the denoised multi-lead ECG signal is processed to construct multi-lead feature branches to obtain lead feature vectors. The specific steps are as follows: The denoised multi-lead ECG signal is separated to obtain the separated lead ECG signal; An independent feature encoder is constructed for each separate lead ECG signal. This independent feature encoder is then used to process the corresponding separate lead ECG signal to obtain the lead feature vector. The relationship in this process is as follows: ; in, Both represent lead eigenvectors. Both indicate that the processing is done through a feature encoder. All of these represent separate lead ECG signals.
4. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 3, characterized in that, In step 3, the lead feature vectors are subjected to multi-lead feature hierarchical fusion processing to obtain global hierarchical feature vectors and location hierarchical feature vectors. The specific steps are as follows: By directly concatenating all lead feature vectors along their feature dimensions, a global hierarchical feature vector is obtained. The corresponding relationship in this process is as follows: ; in, Represents the global hierarchical feature vector; Based on the correspondence between heart location and leads, the lead feature vectors are grouped and concatenated to obtain location-level feature vectors. The relationship in this correspondence process is as follows: ; in, This represents the feature vector of the corresponding anterior wall region. This represents the feature vector of the corresponding partition. This represents the feature vector of the corresponding lower wall region. This represents the feature vector of the corresponding sidewall at the hierarchical level.
5. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 4, characterized in that, In step 4, multi-lead hierarchical classification is performed using global hierarchical feature vectors, location hierarchical feature vectors, and lead feature vectors to obtain the classification results output by the global classifier, the location classifier, and the lead classifier, respectively. The specific steps are as follows: The global hierarchical feature vector is input into the global classifier for classification calculation, and the classification result output by the global classifier is obtained. The corresponding relationship in the process is as follows: ; in, This represents the classification result output by the global classifier. This indicates that the data is processed using a global classifier. The feature vectors at the part level are input into the corresponding part classifier for calculation, and the classification result output by the part classifier is obtained. The relationship in the corresponding process is as follows: ; in, This represents the classification result output by the classifier for the corresponding anterior wall region. This represents the classification result output by the classifier for the corresponding partition. This represents the classification result output by the classifier for the corresponding lower wall region. This represents the classification result output by the classifier for the corresponding sidewall location. Both represent part classifiers; The lead feature vector is input into the corresponding feature classifier for calculation, and the classification result output by the lead classifier is obtained.
6. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 5, characterized in that, In the process of inputting the lead feature vectors into the corresponding feature classifier for calculation and obtaining the classification result output by the lead classifier, the following relationship exists: ; in, All of these represent the classification results output by the lead classifier. Both represent feature classifiers.
7. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 6, characterized in that, In step 5, the weighted cross-entropy loss function and the classification system fitness function are constructed using the training dataset, class labels, and pre-defined baseline model computational cost obtained from the original dataset. The specific steps are as follows: Using the total number of samples and the total number of classes obtained from the training dataset, the weight coefficients are calculated based on inverse class frequency. The corresponding relationship in this process is as follows: ; in, Indicates the weighting coefficient. Represents the total number of samples. Indicates the total number of categories. Indicates the first Number of samples resembling arrhythmias; The weighted cross-entropy loss function is constructed using the weight coefficients and the true labels obtained from the training dataset. The corresponding relationship in this process is as follows: ; in, This represents the weighted cross-entropy loss. This represents the total number of all ECG signal categories. Indicates category index, Indicates the predicted probability. Indicates the true label; The fitness function of the classification system is constructed by using a preset dynamic penalty coefficient and a preset baseline model computational cost.
8. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 7, characterized in that, In the process of constructing the fitness function of the classification system using a preset dynamic penalty coefficient and a preset baseline model computational cost, the following relationship exists: ; in, Represents the fitness value of the classification system. Indicates the model's classification accuracy. Indicates the dynamic penalty coefficient. This represents the computational cost of the baseline model. This represents the computational cost of the existing benchmark model. Indicates the initial penalty coefficient. This represents the final penalty coefficient. Indicates the current iteration round. This indicates the maximum number of iterations.
9. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 8, characterized in that, In step 6, the network structure parameters of the classification model are iterated using the classification results output by the global classifier, the location classifier, the lead classifier, the weighted cross-entropy loss function, and the classification system fitness function to obtain the optimal model configuration parameters. The specific steps are as follows: Step 601: Randomly initialize the particle swarm to obtain an initialized particle swarm; Step 602: Based on the classification results output by the global classifier, the classification results output by the part classifier, the classification results output by the lead classifier, and the true labels, the weighted cross-entropy loss function is used as the optimization objective to train the parameters of the grid structure corresponding to the initial particle swarm until convergence, and the trained network is obtained. Step 603: On the validation set obtained from the original dataset, perform forward propagation using the trained network to obtain the classification result and the model classification accuracy; obtain the inherent computational cost through the parameters of the trained network; Step 604: Substitute the model classification accuracy and inherent computational cost into the classification system fitness function to obtain the classification system fitness value of the particle. Step 605: Update the velocities of the particles in the initial particle swarm using fractional calculus to obtain the updated particle velocities. Based on the updated particle velocities, obtain the updated particle swarm. The corresponding relationship in this process is as follows: ; in, Indicates that the particle is in The velocity vector at time t, Represents the memory weight coefficient. Indicates the particle's distance at time [time]. past The velocity vector at time t, All represent learning factors. All represent random numbers. Indicates the first In the nth iteration The particle in the first The optimal position found in 3D space. Indicates the first In the nth iteration The particle in the first The current coordinates in 3D space Indicates the first In the nth iteration The globally optimal position in the entire population within the dimensional space. Indicates the order of a fraction. Represents the generalized binomial coefficient. This indicates processing via a gamma function; Step 606: Using the updated particle swarm as the initial particle swarm, execute steps 602 to 604 to obtain the fitness values of the updated particle classification system; Based on the preset stratification threshold and the fitness values of the updated particle classification system, sort and stratify all particles according to the fitness values of the updated particle classification system to obtain elite particles, medium particles and poor particles. Step 607: While keeping the positions of elite particles unchanged, perform elite learning and pruning operator processing on intermediate and poor particles respectively to obtain the corrected particle swarm. Step 608: Use the corrected particle swarm as the initial particle swarm again, and repeat steps 602 to 608. After reaching the iteration limit, the corrected final particle swarm is obtained. Step 609: The mesh structure parameters corresponding to the particle with the highest fitness value in the classification system of the final particle swarm after correction are taken as the optimal model configuration parameters.
10. The ECG signal classification method based on lead feature fusion and particle swarm optimization algorithm according to claim 9, characterized in that, Elite learning and pruning operators are applied to medium-sized and poor-sized particles respectively to obtain a corrected particle swarm. The elite learning process corresponds to the following relationship: ; in, This indicates the location that needs to be updated. This represents the change in velocity obtained from the velocity update formula. Represents the chaotic value. Indicates the position of elite particles; The pruning operator process corresponds to the following relationship: ; in, Indicates the updated number The particle in the first Position in dimensional space, This indicates that the data is processed using a rounding function. Indicates the pruning coefficient. Indicates the first The particle in the first Position in dimensional space, Indicates the first Lower bound constraints on the parameters of the dimension.
Citation Information
Patent Citations
Multi-lead electrocardiosignal classification method based on convolutional neural network
CN113080994A
Myocardial infarction global lead reconstruction method applied to real-time electrocardiogram monitoring equipment
CN116807491A