Arrhythmia real-time detection method, system and device based on shape fidelity consistency constraint

By jointly training and constraining the ECG signal encoder, the problems of instability and high resource consumption in arrhythmia detection under dynamic interference are solved, achieving robust identification of arrhythmias and accurate preservation of key waveforms, which is suitable for real-time monitoring of wearable and Holter devices.

CN121101514BActive Publication Date: 2026-05-26GENERAL HOSPITAL OF SOUTHERN THEATRE COMMAND OF PLA
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GENERAL HOSPITAL OF SOUTHERN THEATRE COMMAND OF PLA
Filing Date
2025-09-25
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing arrhythmia detection methods suffer from drift under dynamic interference, insufficient sensitivity to fine-grained morphological features, and difficulty in balancing latency and energy efficiency requirements for online deployment, resulting in unstable identification and excessive resource consumption.

Method used

A real-time arrhythmia detection method based on morphological fidelity and consistency constraints is adopted. By jointly training the ECG signal encoder and combining the contrast consistency and morphological fidelity constraint losses, the encoder parameters are optimized to achieve robust identification under dynamic interference and accurate preservation of clinical key waveform details, and efficient real-time deployment at the edge.

Benefits of technology

It improves the discrimination stability and sensitivity to key clinical waveforms in arrhythmia detection, reduces the false alarm rate, meets the low power consumption and real-time requirements of wearable devices, and is suitable for various ECG monitoring scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121101514B_ABST
    Figure CN121101514B_ABST
Patent Text Reader

Abstract

This invention discloses a real-time arrhythmia detection method based on morphological fidelity consistency constraints, comprising the following steps: S1, preprocessing continuous electrocardiogram (ECG) signals and dividing them into overlapping sliding time windows; S2, inputting each time window into an ECG signal encoder obtained through joint training to obtain a latent representation vector for that time window; the joint training is specifically defined as: simultaneously optimizing the encoder parameters using supervised classification signals, contrast consistency signals, and morphological fidelity signals during the training phase; S3, inputting the latent representation vector into a classifier and outputting the class probability of the time window belonging to each arrhythmia category; S4, based on the class probability, outputting real-time detection results using an online decision strategy of threshold hysteresis and cross-window consistency. This invention can simultaneously achieve robust identification under dynamic interference, accurate preservation of clinically critical waveform details, and efficient real-time deployment at the edge. This invention also provides a real-time arrhythmia detection system and device based on morphological fidelity consistency constraints.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical technology, specifically to a method, system, and device for real-time detection of arrhythmias based on morphological fidelity and consistency constraints. Background Technology

[0002] Cardiac arrhythmias, as one of the most common and significantly harmful cardiovascular electrophysiological abnormalities, include various types such as atrial fibrillation (AF), ventricular tachycardia / ventricular fibrillation (VT / VF), supraventricular tachycardia (SVT), premature beats (PAC / PVC), and atrioventricular block. They are closely associated with severe clinical outcomes such as sudden death, ischemic stroke, and worsening heart failure. International guidelines emphasize long-term cardiac rhythm monitoring in suspected or high-risk populations to improve the detection rate of occult or intermittent arrhythmias and provide a basis for clinical strategies such as anticoagulation therapy, catheter ablation, and long-term follow-up. This trend has driven ambulatory electrocardiogram monitoring and continuous outpatient monitoring to become a key focus of clinical and industrial attention.

[0003] In terms of monitoring technology, the standard 12-lead electrocardiogram (ECG) can provide multi-view morphological information and is the basis for the diagnosis and classification of arrhythmias at rest. Holter monitoring improves the probability of capturing incidental events through continuous recording for 24 hours or more, and is suitable for assessing symptom relevance and workload levels. Wearable ECG devices (such as chest patches, wristbands, armbands, textile electrodes, and ear-worn devices) extend the monitoring scenario from the hospital to daily life and sports environments, realizing long-term, low-load daily ECG monitoring, and have shown good diagnostic and management value in many clinical studies.

[0004] Over the past five years, the release of large-scale public ECG datasets has significantly promoted the advancement of automated arrhythmia diagnosis algorithms. For example, PTB-XL provides nearly 22,000 cases of large-scale 12-lead clinical data with multi-label diagnosis and recommendation classification, and has become an important benchmark for model comparison and generalization performance evaluation; the Chapman–Shaoxing database is designed for real-world multi-diagnostic label construction, covering 11 common rhythms and dozens of cardiovascular states. These resources have driven research on automated diagnosis centered on deep learning, transitioning from traditional feature engineering combined with classifiers to end-to-end representation learning models, achieving recognition performance comparable to specialist physicians in single-lead or multi-lead scenarios.

[0005] At the algorithmic level, deep neural networks (such as CNN, RNN, and Transformer) have become the mainstream architecture for ECG analysis. Existing studies have achieved high AUC values ​​and clinical-level consistency for various arrhythmias in single-lead dynamic monitoring, validating the effectiveness of end-to-end learning methods in rhythm recognition. Meanwhile, self-supervised and contrastive learning have been introduced into ECG representation learning to reduce reliance on large amounts of labeled data and enhance the model's generalization ability across populations and devices. Taking the CLOCS method as an example, this algorithm, by imposing contrastive constraints in spatial, temporal, and individual dimensions, significantly outperforms generalized representation learning methods such as SimCLR and BYOL, and maintains strong generalization performance even in low-label data environments, demonstrating the significant potential of consistency constraints in ECG dynamic monitoring and cross-domain tasks.

[0006] Although intelligent ECG recognition methods have achieved good results under resting or relatively quiet conditions, they still have a series of common shortcomings in real-world dynamic monitoring and continuous cross-device applications, which urgently need to be systematically addressed. Specifically, existing methods mainly face the following three problems: First, the representation drift problem caused by dynamic disturbances is significant. Motion artifacts, changes in electrode contact, and short-term signal loss can cause changes in the amplitude and phase characteristics of ECG segments, resulting in inconsistent potential representations of the same physiological event in different time windows. Most existing methods rely solely on classification loss for training, lacking a constraint mechanism to ensure consistency of homologous segments in the latent space, leading to unstable model outputs under perturbation conditions and the coexistence of false positives and false negatives. Second, insufficient sensitivity to fine-grained morphological features. Clinical diagnosis highly depends on the discernibility of the P wave start and end points, the continuity of inter-beat timing, subtle differences in QRS waveforms, and key details such as ST segment or T wave morphological changes. However, in dynamic scenarios, these details are easily masked by noise or ignored by the model. Without explicit morphological fidelity constraints, networks often tend to rely on coarse-grained peak features and overall rhythmic patterns, leading to a decline in the ability to identify key clinical clues and a decrease in the reliability of output results. Thirdly, it is difficult to balance the latency and energy efficiency requirements of online deployment. To improve robustness, some methods introduce complex model structures or multi-branch designs, increasing the computational and power consumption burden on edge devices; while lightweight methods lack stability in complex dynamic environments. Continuous off-site monitoring requires low-latency, high-reliability real-time identification under limited computing power and power constraints, which places higher demands on algorithm target design and inference processes. Summary of the Invention

[0007] To overcome the shortcomings of existing technologies, one of the objectives of this invention is to provide a real-time arrhythmia detection method based on morphological fidelity consistency constraints, so as to simultaneously achieve robust identification under dynamic interference, accurate preservation of clinical key waveform details, and efficient real-time deployment at the edge.

[0008] The second objective of this invention is to provide a real-time arrhythmia detection system based on morphological fidelity consistency constraints, so as to simultaneously achieve robust identification under dynamic interference, accurate preservation of clinical key waveform details, and efficient real-time deployment at the edge.

[0009] The third objective of this invention is to provide a real-time arrhythmia detection device based on morphological fidelity consistency constraints, so as to simultaneously achieve robust identification under dynamic interference, accurate preservation of clinical key waveform details, and efficient real-time deployment at the edge.

[0010] One of the objectives of this invention is achieved through the following technical solution:

[0011] A real-time arrhythmia detection method based on morphological fidelity consistency constraints includes the following steps:

[0012] S1. Preprocess the continuous ECG signal and divide it into overlapping sliding time windows;

[0013] S2. Input each time window into the ECG signal encoder obtained through joint training to obtain the potential representation vector of that time window; the joint training is defined as: simultaneously using supervised classification signal, contrast consistency signal and morphological fidelity signal to optimize the parameters of the encoder during the training phase;

[0014] S3. Input the latent representation vector into the classifier and output the class probability of the time window belonging to each arrhythmia category;

[0015] S4. Based on the category probability, output the real-time detection result using an online decision strategy that combines threshold hysteresis and cross-window consistency.

[0016] Among them, the contrastive consistency signal and morphological fidelity signal are only enabled during the training phase to update the encoder parameters. The contrastive embedding and reconstruction branch are no longer calculated during the inference phase. Only the encoder and classifier participate in the forward computation during the inference phase.

[0017] Furthermore, the joint training is achieved through a single unified objective function, which is a weighted sum of supervised classification loss, contrast consistency constraint loss, and morphological fidelity constraint loss. The three weights are preset constants or are automatically learned and determined during training through an uncertainty weighting strategy, so as to simultaneously enhance class separability, perturbation invariance, and key morphological fidelity.

[0018] Furthermore, the contrast consistency constraint loss term is constructed as follows: for each original ECG signal time window, two views based on real-world perturbations are independently generated as homologous positive pairs; these two views are then compared with views from other original time windows within the same batch. Figure 1The shared ECG signal encoder and projector are used to obtain normalized embedding. A contrastive learning criterion with temperature parameters is adopted to make homologous positive pairs close to each other in the embedding space and keep them separate from other views in the batch, so as to improve the representation stability under occlusion, short missing and amplitude-phase change conditions.

[0019] Furthermore, the real-world perturbation includes one or more combinations of time occlusion, amplitude scaling, phase micro-shift, and band-limited noise superposition. The perturbation is applied on the time axis in alignment with the original time window to ensure the comparability of the two views corresponding to the same physiological event.

[0020] Furthermore, the morphological fidelity constraint loss is constructed as follows: the latent representation output by the encoder is input into the reconstruction decoder to obtain a reconstructed waveform of the same length as the original time window, and the morphological difference between the reconstructed waveform and the original waveform is used as the loss signal. The morphological difference includes at least point-by-point time-domain error or the sum of point-by-point time-domain error and amplitude spectrum difference based on short-time Fourier transform, so as to enhance the sensitivity to slowly changing morphology.

[0021] Furthermore, the reconstruction decoder adopts a one-dimensional U-Net structure with symmetrical skip connections. By upsampling step by step and fusing with the features of the corresponding layer in the encoding stage, it outputs a reconstructed waveform of the same length as the input time window, so as to maintain lightweight computation while taking into account both local details and global trends.

[0022] Furthermore, the ECG signal encoder is a lightweight causal multi-scale network, which includes parallel branches of one-dimensional causal convolution and one-dimensional dilated convolution to cover two types of time scales: rapid change and slow change. It also introduces a channel attention mechanism in the channel dimension to enhance the discriminative feature response. Moreover, the effective receptive field of the encoder does not cross the time window boundary to meet the real-time requirements of online processing.

[0023] Furthermore, the threshold hysteresis and cross-window consistency decision strategy includes setting a lower threshold and an upper threshold greater than the lower threshold. When the target category probability of K consecutive time windows in the current sliding time series is not lower than the upper threshold, the arrhythmia event is determined to begin. During the duration of the event, when the target category probability of K consecutive time windows is lower than the lower threshold, the event is determined to end. Positive results that only appear in a single time window and do not meet the continuity condition are not output as events and are marked as suspicious to reduce the false alarm probability.

[0024] The second objective of this invention is achieved by the following technical solution:

[0025] A real-time arrhythmia detection system based on morphological fidelity consistency constraints includes:

[0026] The preprocessing module is used to resample, filter, and standardize the amplitude of continuous electrocardiogram signals and divide them into overlapping sliding time windows;

[0027] The feature extraction module includes a jointly trained ECG signal encoder, which receives the time window output by the preprocessing module and extracts latent representations; the joint training refers to simultaneously optimizing the encoder using supervised classification signals, contrast consistency signals, and morphological fidelity signals.

[0028] The classification module is used to receive the latent representation output by the feature extraction module and obtain the category probability of the arrhythmia.

[0029] The online decision module receives the category probabilities output by the classification module and, in conjunction with the threshold hysteresis and cross-window consistency decision strategy, outputs real-time detection results.

[0030] The third objective of this invention is achieved by the following technical solution:

[0031] A real-time arrhythmia detection device based on morphological fidelity consistency constraints includes a memory and a processor. The memory stores a computer program, which is a real-time arrhythmia detection program. The processor executes the real-time arrhythmia detection program to implement the steps of a real-time arrhythmia detection method based on morphological fidelity consistency constraints, as one of the objectives of this invention.

[0032] Compared with existing technologies, the advantages of this invention are as follows: 1. High discrimination stability. By comparing consistency constraints, the model is forced to output consistent latent representations for two real-world perturbation views of the same source signal, effectively suppressing representation drift caused by dynamic interference and reducing false alarms and false negatives. 2. Strong morphological fidelity. Through morphological fidelity constraints, the encoder retains key waveform details such as P waves, QRS complexes, ST segments, and T waves in the latent representation, improving sensitivity to subtle clinical clues. 3. High deployment efficiency. Adopting a decoupled training and inference architecture, the encoder is jointly optimized through a unified objective function during training, while only a lightweight encoder and classification head are retained during inference, combined with an online decision strategy, completing calculations within millisecond latency, meeting the low power consumption and real-time requirements of wearable and Holter monitors. 4. Wide applicability. The method and system are not limited to specific acquisition devices and lead configurations, and are applicable to dynamic monitoring scenarios such as single-lead or multi-lead wearable ECG and Holter ECG, possessing good generalization and engineering feasibility. Attached Figure Description

[0033] Figure 1 This is a flowchart of the real-time arrhythmia detection method based on morphological fidelity consistency constraints in this invention;

[0034] Figure 2 This is a flowchart of the threshold hysteresis and cross-window consistency decision strategy in this invention;

[0035] Figure 3 This is a performance graph showing the results of the CPSC2018 Holter 12, Chapman Holter 12, and wearable single-lead datasets under real dynamic scenarios with short-term occlusion, amplitude and phase perturbation, and local missing data in this invention. Detailed Implementation

[0036] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments. It should be noted that, without conflict, the various embodiments or technical features described below can be arbitrarily combined to form new embodiments.

[0037] Example 1

[0038] This invention provides a preferred embodiment of a real-time arrhythmia detection method based on morphological fidelity consistency constraints, such as... Figure 1 As shown, it includes the following steps:

[0039] S1. Preprocess the continuous ECG signal by resampling, filtering, and amplitude standardization, then dividing it into overlapping sliding time windows according to a preset window length and step size. Data acquisition and preprocessing specifically include the following:

[0040] This invention targets dynamic continuous monitoring scenarios. Data sources include wearable ECG devices or Holter monitors, supporting single-lead or multi-lead signal input. The subjects are cardiovascular disease patients or suspected cases, and the recording period covers daily activities and routine examinations, including various states such as resting, walking, and light to moderate physical activity. The sampling rate and quantization accuracy of the signal acquisition follow the device's default configuration, and timestamps and event annotation information are retained to support subsequent real-time monitoring. For multi-lead recordings, channel consistency verification and clock alignment are performed during the data acquisition phase to ensure the stability of the phase relationship between leads. After anonymization and quality checks, the raw data enters the algorithm processing flow.

[0041] The preprocessing stage employs a unified time-domain and frequency-domain shaping method to obtain a normalized sequence suitable for subsequent encoder input. The specific steps are as follows: First, all records are resampled to a unified frequency f. s An anti-aliasing low-pass filter H is used before resampling. AA (z) to suppress out-of-band energy; then baseline drift and high-frequency noise are removed by a bandpass filter, with the preferred passband range being [0.5, 45] Hz: Let the original sequence be x(t), and the output after bandpass filtering be:

[0042] x bp (t)=(h bp *x)(t),

[0043] Where h bpIt exhibits a linear phase finite-length impulse response. Power frequency interference is filtered according to the local power grid frequency, using a second-order notch filter.

[0044]

[0045] f0 is set to 50 or 60 Hz, and the damping coefficient r ∈ [0.90, 0.98] is used to control the bandwidth. To enhance the comparability of numerical scales between different individuals and devices, robust standardization is adopted, and the median and absolute median difference of each window signal are normalized:

[0046]

[0047] Where x clean =H notch (z)·H bp (x), MAD is the absolute median deviation, scaled to a Gaussian equivalent standard deviation by a coefficient of 1.4826. To avoid extreme artifacts dominating the numerical dynamic range, [the following is omitted as it is not explicitly stated in the original text]. Percentile constraints are applied to clip the amplitude to [p]. 0.5 ,p 99.5 The interval is linearly scaled to [-1, 1].

[0048] The continuous sequence is divided into overlapping sliding windows based on the online detection delay and the event duration. Let the window length be L seconds and the step size be Δ seconds. A single-lead input is represented as... Multi-lead is represented as Where C is the number of leads, and the window sequence is denoted as... To ensure consistent labeling during training and evaluation, window labels are assigned based on the temporal intersection-union ratio (IUU) of the event and the window: if the overlap ratio between the window and a certain arrhythmia event reaches a threshold θ... l If an event is specified, the window is labeled as belonging to the corresponding category; otherwise, it is a non-event category.

[0049]

[0050] θ l The values ​​can be determined on the validation set. To improve online stability, the signal quality index of each window is recorded and output to the subsequent decision module as a reference, without changing the input waveform itself. After the above processing, a normalized window sequence with uniform amplitude and sampling rate, stable baseline and consistent time scale is obtained, which can be directly used for single-lead or multi-lead encoders, and can also be used for unified training and real-time inference across sources.

[0051] Consistency constraints between annotation and preprocessing: Labels are assigned using the temporal intersection-union threshold of the window and the event; preprocessing includes uniform resampling, bandpass and notch filtering, and robust amplitude normalization, with percentile pruning and normalization of the amplitudes. This aims to reduce training drift caused by source differences and annotation noise, ensuring consistency between training and deployment input distributions.

[0052] S2. Input each time window into the ECG signal encoder obtained through joint training to obtain the potential representation vector of that time window; the joint training is defined as: simultaneously using supervised classification signal, contrast consistency signal and morphological fidelity signal to optimize the parameters of the encoder during the training phase.

[0053] Causal multi-scale temporal encoder and lead attention: The encoder employs causal padding and dilated convolution to form a non-window-crossing receptive field, and parallel multi-scale branches to cover fast and slow time scales. Channel attention enhances the effective channel response. In multi-lead scenarios, lead attention is introduced to weight the input lead by lead before unified encoding. This allows for the simultaneous capture of time-frequency features of QRS and ST-T under low computational budget, and highlights high-contribution leads in heterogeneous lead combinations.

[0054] By unifying the objective function constraints, the three losses are jointly minimized according to their weights:

[0055] L total =αL cls +βL con +γL rec

[0056] Where L cls For weighted cross-entropy, L con For temperature-induced contrast loss, L rec A morphological fidelity metric is used. Weights are set within a given interval or learned automatically by weighting against uncertainty. It simultaneously achieves separability, perturbation invariance, and morphological fidelity within the same latent space without increasing inference complexity.

[0057] The specific construction of the consistency constraint is as follows: For each original window, two real-world perturbation views are generated. The perturbation sources include any combination of temporal occlusion, amplitude scaling, phase micro-shift, and band-limited noise superposition. The two views are embedded using the unit norm output of a shared encoder and two layers of projectors. The InfoNCE objective is based on normalized dot product similarity and temperature τ, with the temperature undergoing slow annealing during training. This aims to suppress representation drift caused by occlusion, missing data, and amplitude / phase changes, achieving stable discrimination across time windows.

[0058] Curriculum-based scheduling and temperature annealing: In the early stages of training, higher temperatures and milder perturbations are used to establish global consistency. In the mid-to-late stages, the temperature is gradually reduced and the perturbations are increased to refine the inter-class boundaries. This improves convergence stability and final performance while reducing sensitivity to hyperparameters.

[0059] The specific construction of morphological fidelity constraints involves using a one-dimensional U-Net to reconstruct the decoder, upsampling from the bottom up and skipping connections with intermediate encoding layers, resulting in a reconstructed waveform of equal length to the input. Morphological fidelity is primarily measured using time-domain L1 spectral density, incorporating short-time Fourier spectrum differences. If necessary, P, QRS, and ST-T segments are weighted to emphasize key regions. This approach forces the preservation of fine-grained morphological information based on latent characteristics, avoiding reliance solely on coarse-grained peak values ​​and enhancing the sensitivity and reliability of clinically relevant clues.

[0060] Equivalent replacement boundary for morphological fidelity measurement: Morphological fidelity can be constituted by a combination of time-domain L1 and any one or more of the following: short-time Fourier spectrum difference, dynamic time-warped distance, and energy band difference. This ensures that fidelity constraints on key morphologies are effectively applied without altering the technical essence.

[0061] A decoupled deployment path for training and inference: During training, the three loss terms jointly shape the same encoder; during inference, the projection head and reconstruction decoder are shut down, leaving only the encoder and classification head outputting online. This solidifies the benefits of both types of constraints into the backbone, achieving deployment costs and latency equivalent to conventional lightweight models.

[0062] S3. Input the latent representation vector into the classifier and output the class probability of the time window belonging to each arrhythmia category. Overall Model Structure and Feature Representation: This invention, based on supervised classification, simultaneously introduces contrast consistency constraints and morphological fidelity constraints, all three jointly optimized with a unified objective. Let the sliding window input be... encoder output last layer timing feature h (L) The vector υ is obtained by convergence in the time domain, and then the class probability is output by the classifier head. The classification term uses cross-entropy loss:

[0063]

[0064] Where B is the batch size, C y w represents the number of categories. c As class weights, they can be set according to validation set statistics or business needs.

[0065] To suppress representation drift caused by dynamic disturbances, two types of real-world perturbation views are generated for the same original segment. and The two views are mapped to a unit vector z in the contrast space via a shared encoder and two projector heads. k Similarity is calculated using the normalized dot product:

[0066]

[0067] For the i-th sample, define an InfoNCE term with temperature τ for the pair (2i-1, 2i):

[0068]

[0069] Intra-batch averaging yields consistency loss:

[0070]

[0071] Where N is the original number of segments. The temperature τ can be in the range of 0.05 to 0.5, and is slowly decreased as the training progresses to align first and then refine.

[0072] To maintain accurate representation of key clinical details, an optimized U-Net reconstruction branch is introduced for waveform-level reconstruction constrained by morphological metrics. Let the decoder output reconstructed waveform be... Morphological fidelity loss is measured using pointwise L1 metric:

[0073]

[0074] A preferred embodiment can add short-time Fourier spectral differences to the time-domain L1 to enhance sensitivity to the slowly varying details of the ST segment and T wave, forming a time-frequency joint morphological fidelity metric:

[0075]

[0076] weight λ f The value is taken in the range of 0.05 to 0.5 and determined by the validation set. If segmented morphological attention is used, weights ω can be assigned to the P segment, QRS segment, and ST-T segment respectively. P ω QRS ω ST-T To highlight the fidelity of key components:

[0077]

[0078] Ultimately, the three losses are jointly optimized with a unified objective:

[0079]

[0080] The condition α, β, γ > 0 controls the trade-off among the three factors. This serves as a fidelity metric for any of the aforementioned forms. The empirical intervals for the coefficients can be set as α∈[1,2], β∈[0.2,1], and γ∈[0.2,1], and determined through a validation set search. An optional embodiment employs task uncertainty-weighted automatic learning of the three coefficients to reduce the cost of manual parameter tuning.

[0081]

[0082] Optimization employs AdamW or Adam, with an initial learning rate of 1e-3 to 3e-4 and weight decay of 1e-4 to 1e-5. Linear warm-up is performed for several epochs, followed by cosine annealing decay. The gradient norm is pruned to 1.0 for stable training. Batch size is set based on GPU memory and window length, typically ranging from 64 to 256. Negative samples for the comparison branch are automatically provided by other views in the same batch. The length and occlusion intensity of negative pairs are scheduled synchronously with the training phase. Lighter perturbations are used early to establish global consistency, with gradually increased perturbations later to improve robustness. After training, only the encoder and classification head are retained for online inference; the reconstruction branch and projection head are disabled during deployment to meet latency and energy consumption requirements.

[0083] S4. Based on the category probability, output the real-time detection result using an online decision strategy that combines threshold hysteresis and cross-window consistency.

[0084] Among them, the contrastive consistency signal and morphological fidelity signal are only enabled during the training phase to update the encoder parameters. The contrastive embedding and reconstruction branch are no longer calculated during the inference phase. Only the encoder and classifier participate in the forward computation during the inference phase.

[0085] Online decision constraints: The output side implements dual-threshold hysteresis and cross-window consistency; the upper threshold is used to initiate an alarm, and the lower threshold is used to stop an alarm. After several consecutive windows meet the conditions, the event is confirmed, and isolated single-window positive results are suppressed as suspicious. This significantly reduces instantaneous false alarms in dynamic monitoring and improves alarm consistency and practicality.

[0086] Furthermore, the joint training is achieved through a single unified objective function, which is a weighted sum of supervised classification loss, contrast consistency constraint loss, and morphological fidelity constraint loss. The three weights are preset constants or automatically learned and determined during training through an uncertainty weighting strategy, thereby simultaneously enhancing class separability, perturbation invariance, and key morphological fidelity. Further, the contrast consistency constraint loss term is constructed as follows: for each original ECG signal time window, two views based on real-world perturbations are independently generated as homologous positive pairs. These two views are then compared with views from other original time windows within the same batch. Figure 1 The shared ECG signal encoder and projector are used to obtain normalized embedding. A contrastive learning criterion with temperature parameters is adopted to make homologous positive pairs close to each other in the embedding space and keep them separate from other views in the batch, so as to improve the representation stability under occlusion, short missing and amplitude-phase change conditions.

[0087] Furthermore, the real-world perturbation includes one or more combinations of time occlusion, amplitude scaling, phase micro-shift, and band-limited noise superposition. The perturbation is applied on the time axis to keep it aligned with the original time window to ensure that the two views correspond to the same physiological event.

[0088] Furthermore, the morphological fidelity constraint loss term is constructed in the following manner: the latent representation extracted by the ECG signal encoder is input into a reconstructed ECG signal decoder to reconstruct a normalized waveform of the same length as the original time window, and the morphological difference between the reconstructed waveform and the original ECG waveform is used as the loss term. The morphological difference includes at least point-by-point time-domain error and can be further combined with amplitude spectrum difference based on short-time Fourier transform.

[0089] Furthermore, the reconstructed ECG signal decoder adopts a one-dimensional U-Net structure with symmetrical skip connections, and outputs a reconstructed waveform of the same length as the input time window by upsampling step by step and fusing it with the features of the corresponding layer in the encoding stage.

[0090] Furthermore, the ECG signal encoder is a lightweight causal multi-scale network, which includes parallel branches of one-dimensional causal convolution and one-dimensional dilated convolution to cover two types of time scales: rapid change and slow change. It also introduces a channel attention mechanism in the channel dimension to enhance the discriminative feature response. Moreover, the effective receptive field of the encoder does not cross the time window boundary to meet the real-time requirements of online processing.

[0091] Furthermore, when processing multi-lead ECG signals, a lead attention mechanism is introduced before encoding to adaptively weight different lead signals before uniformly sending them to the encoder, so as to highlight the lead information sources that contribute more.

[0092] like Figure 2 As shown, the threshold hysteresis and cross-window consistency decision strategy further includes setting an upper threshold that is strictly greater than the lower threshold. When the target class probability of K consecutive time windows in the current sliding time series is not lower than the upper threshold, the arrhythmia event is determined to begin. During the duration of the event, when the target class probability of subsequent time windows is lower than the lower threshold and K consecutive time windows are satisfied, the event is determined to end. Positive results that only appear in a single time window and do not meet the continuity condition are not output as events and are marked as suspicious, such as false alarms caused by momentary jitter, electrode detachment, etc.

[0093] This invention first performs standardized preprocessing and sliding window slicing on continuous ECG data from wearable ECG devices and Holter monitors, generating two types of realistic perturbation views for each original segment to simulate dynamic disturbances such as motion artifacts, local occlusion, and slight changes in amplitude and phase. Subsequently, a lightweight multi-scale temporal encoder extracts latent representations, introducing two key constraints on top of supervised classification: first, a contrast consistency constraint, which suppresses representation drift caused by perturbations through latent alignment of homologous perturbation views, stabilizing cross-time-window discrimination; second, a morphological fidelity constraint, which performs waveform-level reconstruction through a U-Net reconstruction module and constrains the fit between the reconstructed waveform and the original ECG using time-domain or frequency-domain metrics, thereby maintaining the accurate representation of clinically critical details, including the P wave initiation and termination, QRS morphology, and subtle changes in the ST segment and T wave. The aforementioned classification supervision, contrast consistency supervision, and morphological fidelity supervision are synergistically optimized using a unified weighted loss, enabling the model to maintain stable and interpretable discrimination under realistic disturbances such as signal occlusion, segment loss, and amplitude and phase perturbations, without increasing the structural complexity of the inference stage.

[0094] In terms of implementation, this invention adopts a decoupled training-inference architecture: during the training phase, discriminativity, robustness, and morphological fidelity are jointly learned through a unified objective, forming a latent representation with intrinsic robustness to dynamic disturbances; during the inference phase, only the encoder and lightweight classification head are retained, with single-window low-latency output, and online decision-making is implemented by combining threshold hysteresis and cross-window consistency strategies, balancing real-time performance and reliability. This solution is not limited to specific electrode layouts or device forms, and is suitable for dynamic continuous monitoring of wearable ECG and Holter ECG, meeting the engineering requirements of low power consumption and practical deployment for long-term outpatient applications, thereby achieving stable, sensitive, and efficient detection of arrhythmias under real-world conditions.

[0095] This invention improves robustness, stability, sensitivity to key morphologies, and online deployment efficiency in real-world dynamic monitoring through a unified training objective and a streamlined inference chain. The core of this invention includes the following three points: 1. Introducing contrast consistency constraints during the training phase: aligning potential representations for different real-world perturbation views of the same original segment, suppressing representation drift caused by signal occlusion, segment loss, and amplitude / phase perturbations, making the model's discrimination across segments and time windows more stable; 2. Introducing morphological fidelity constraints: mapping potential representations back to normalized waveform representations through morphological projection or lightweight decoding, and constraining their fit with the original ECG signal using time-domain or frequency-domain metrics, thereby maintaining the accurate preservation and interpretability of fine-grained morphologies such as P waves, QRS complexes, ST segments, or T waves; 3. Collaboratively optimizing classification performance, contrast consistency, and morphological fidelity constraints under a unified, integrated training objective. During the inference phase, only the backbone network and classification head are retained, and combined with online decision strategies such as threshold hysteresis and cross-window consistency, real-time arrhythmia detection under low latency and low power consumption conditions is achieved. This technical solution is not limited to the specific form of the acquisition device and can be used in dynamic scenarios with wearable ECG devices and Holter monitors. In summary, this invention addresses the dynamic monitoring of arrhythmias, maintaining stable identification under dynamic interference conditions without limiting the specific acquisition device, and achieving morphologically accurate representation of key clinical waveform details; it also considers the requirements for low latency and low power consumption in online deployment. This invention is applicable to different acquisition forms such as wearable ECG and Holter ECG, possessing good scenario applicability and engineering feasibility, and can provide a reliable algorithmic foundation for arrhythmia identification in long-term real-world monitoring and clinical decision support.

[0096] The concept and principle of the real-time arrhythmia detection method based on morphological fidelity consistency constraints in this invention:

[0097] 1. Formal description of the target:

[0098] Let X be the time window of the preprocessed ECG signal, Y be the arrhythmia category label, and N be perturbation factors irrelevant to diagnosis, such as motion artifacts, amplitude and phase variations, and short-term signal loss. The encoder maps X to a latent representation Z = E. θ (X). The representation needs to meet the following two conditions: first, it must have sufficient representational ability for the diagnostic task; second, it must be insensitive to perturbations. This can be formalized as:

[0099] and

[0100] Where I(·;·) represents mutual information. Directly optimizing the above objectives is difficult, therefore this invention approximates them with three achievable surrogate objectives: supervised classification loss to improve I(Z;Y), contrast consistency constraint to reduce I(Z;N), and morphological fidelity constraint to ensure that sufficient information required to reconstruct key waveforms is retained in Z, avoiding the model from learning only significant peak features while ignoring detailed information.

[0101] 2. The principle of contrast consistency constraints:

[0102] Contrast consistency is approximated by maximizing the similarity of two source views, where S represents the latent variables of the same ECG event after perturbation removal. The two views originate from real-world perturbations of the same original signal X, containing the same ECG event semantics but different noise components. A temperature-modified InfoNCE objective is used to bring positive pairs closer together and separate latent negatives within a batch; its optimization effect is equivalent to establishing perturbation-invariant clusters of the same event in the projection space. Even with window occlusion, amplitude scaling, or local missing values, the encoder can still output a consistent Z, thus suppressing representation drift. This constraint is not simple data augmentation but incorporates the constraint of source alignment into a differentiable optimization objective, directly shaping the encoder parameters through gradients.

[0103] The principle of 3-morphological fidelity constraints:

[0104] Morphological fidelity constraints optimize the U-Net reconstruction architecture to project Z back to the normalized waveform. Constrained by time-domain L1 or time-frequency joint metric The fit with x. Because U-Net aggregates coding features from different levels using skip connections, both high-frequency and low-frequency morphological information can flow back to the decoder. Backpropagation pushes the requirement to reconstruct the start and end of the P wave, the rapid changes in QRS complexes, and the gradual changes in ST / T complexes back to the encoder, forcing it to retain sufficient fine-grained information in Z rather than relying solely on coarse-grained peak values ​​for classification. Unlike simple denoising, morphological fidelity does not aim to restore all noise, but rather uses a metric function to limit the authenticity of key morphologies, thereby improving clinical interpretability.

[0105] 4. Synergy and complementarity among the three objectives:

[0106] If only contrast consistency is considered, the model may learn a stable but overly coarse representation of perturbations, losing important details; if only reconstruction is considered, the model may retain noisy details, weakening the discrimination boundary. This invention expresses classification, contrast consistency, and morphological fidelity as a unified loss:

[0107] L total =αL cls +βL con +γL rec ,

[0108] This allows the encoder to simultaneously acquire three geometric properties within the same space: separability, invariance, and interpretability. From an information theory perspective, this is equivalent to maximizing I(Z;Y) while simultaneously suppressing the mutual information term related to perturbations with consistency constraints and ensuring the sufficiency of Z for key patterns with reconstruction constraints. From a geometric perspective, the contrast term compresses multiple views of the same event into compact clusters, the reconstruction term stretches the detail radius within the clusters to a level sufficient to reconstruct the key waveforms, and the classification term widens the gaps between different clusters.

[0109] 5. Design motivation for multi-scale and causal convolution:

[0110] ECG morphology exhibits a temporal scale separation characteristic of coexisting rapid and slow changes. The combination of causal convolution and dilated convolution expands the receptive field without introducing forward vision, ensuring linearity while simultaneously sensing rapid changes in the QRS complex and slow trends in the ST / T curve within the same window. Parallel multi-scale branching and channel attention allow the encoder to automatically select the most discriminative time-frequency pattern for the current window, and lead attention in multi-lead scenarios further strengthens the weight of high-contribution leads. These structural designs are not for the sake of complexity, but rather to ensure coverage of key morphologies and context with a low computational budget.

[0111] 6. The principle of training-inference decoupling and online decision-making:

[0112] During training, a three-dimensional objective is applied to the same encoder to form a stable representation with detailed information. During inference, only the encoder and classifier head are retained, minimizing the path length and latency. The output side employs threshold hysteresis and cross-window consistency aggregation, essentially introducing a simple temporal prior: real arrhythmic events are persistent over a short period, while isolated single-window fluctuations are more likely to be false positives. Double thresholding plus consistency is equivalent to imposing a one-dimensional morphological-temporal constraint on the output sequence, reducing jitter and false alarms.

[0113] 7. Reasons for choosing this path over alternatives:

[0114] Compared to cascaded schemes that denoise first and then classify, this invention directly incorporates the requirements for stability and morphological fidelity into the end-to-end target, avoiding the propagation of non-differentiable errors from the preceding denoising stage to the subsequent discrimination stage. Compared to simply expanding a large model, this invention improves robustness and sensitivity without increasing inference complexity by constraining shaping rather than stacking parameters, making it more suitable for the deployment boundaries of continuous off-site monitoring.

[0115] 8. Mapping between clinical and engineering goals:

[0116] Contrast consistency addresses the clinical need for stable identification under dynamic interference; morphological fidelity addresses the diagnostic need to preserve key clinical waveform details; and a unified loss function and decoupled inference design address the engineering goal of low-latency, low-power real-time detection. These three elements work together to form a closed-loop mapping from clinical needs to engineering implementation, enabling this invention to provide a feasible algorithmic solution for the dynamic monitoring and real-time detection of arrhythmias without limiting specific acquisition devices.

[0117] The key innovation of this invention:

[0118] A unified constraint learning paradigm is adopted. Contrast consistency constraints and morphological fidelity constraints are simultaneously applied to the same temporal encoder, and these are incorporated into the unified objective function constraint along with the supervised classification. The three constraints converge synchronously during training, and only the encoder and classification head are retained at the inference end, resulting in zero additional branches and zero additional latency. Stability and morphological fidelity are directly shaped into the latent representation by differentiable constraint signals, avoiding error propagation and deployment overhead caused by cascaded denoising.

[0119] An executable implementation of morphological fidelity constraints. Waveform-level reconstruction is performed through a one-dimensional U-Net reconstruction module. Combined with time-domain L1 and optional time-frequency difference or morphological segmentation weighting, the potential representation must retain key information such as the start and end of the P wave, rapid QRS transitions, and gradual ST and T transitions, thus eliminating distortion discrimination that relies solely on peak values.

[0120] The engineering implementation of consistency constraints is demonstrated. Using real-world perturbation view pairs as a carrier, temperature-based contrast loss is employed to achieve homogeneous alignment and heterogeneous separation. Combined with temperature annealing and hard-to-bear sample emphasis, the representation invariance is maintained under conditions of occlusion, slight amplitude and phase changes, and short-term missing data, resulting in more stable output across time windows.

[0121] Training and inference are decoupled, and online decision-making with time constraints is implemented. Two types of constraints are introduced during training to shape the backbone, and during inference, the backbone is pruned to the shortest path. On the output side, time constraints are applied with double-threshold hysteresis and cross-window consistency, which significantly reduces dynamic monitoring jitter and instantaneous false alarms, while meeting the millisecond-level latency target.

[0122] Experimental Results and Evaluation:

[0123] To verify the effectiveness and deployability of this invention in dynamic monitoring and real-time detection, a unified evaluation process was constructed. The evaluation objects included wearable ECG and Holter ECG records acquired under dynamic out-of-hospital conditions, supplemented by publicly available multi-class clinical ECG data for generalization validation. All records were uniformly resampled to 256Hz, using a ten-second sliding window and fixed-step slicing, and baseline removal, bandpass filtering and shaping, and robust amplitude normalization were performed. Labels were assigned categories after the temporal intersection-union ratio (IUU) of the window and the event reached a threshold. Training and testing were stratified at the subject level to ensure no overlap between samples from different individuals. Evaluation metrics used accuracy and AUC to measure recognition performance, and parameter count, FLOPs, and single-window inference latency to measure engineering deployment capability. A comparative method was used, selecting representative models in recent years for ECG recognition tasks covering convolutional, recurrent, and lightweight networks, including InceptionTime, ResNet1d, FCN, BiLSTM, MobileNetV3, and ATI-CNN, etc., all compared using a uniform ten-second window input and the same preprocessing.

[0124] In evaluations using publicly available clinical data from CPSC2018 and Chapman's 12-lead Holter dataset, the accuracy and AUC of the method presented in this invention reached 0.8452 and 0.9656, respectively, and 0.9574 and 0.9957, respectively. Compared to the best-performing control method, the accuracy improvement ranged from 0.71 to 0.94 percentage points, and the AUC improvement ranged from 0.73 to 0.88 percentage points. These results demonstrate that, within standardized clinical records, this invention achieves a stable overall advantage without increasing reasoning complexity.

[0125] In the evaluation of single-lead recordings from dynamic wearable devices, this invention underwent unified training and testing under both real-world motion and daily activity conditions, achieving an accuracy of 0.9550 and an AUC of 0.9925. Compared to the best-performing lightweight control method, the accuracy improved by 2.18 percentage points, and the AUC improved by 0.79 percentage points. These results demonstrate that in real-world dynamic scenarios with short-term occlusion, amplitude and phase perturbations, and local deficiencies, this invention maintains key morphological details while achieving higher discrimination stability and lower false positives and false negatives.

[0126] In terms of deployment capabilities, the method of this invention has approximately 1.72 million parameters, approximately 1.2496 × 10^8 FLOPs, and a single forward inference time of approximately 8.29 milliseconds within a ten-second window. In contrast, the inference time of multi-branch or recurrent structures in comparative methods is generally longer, while lightweight convolutional networks have shorter inference times but exhibit a significant drop in recognition performance in dynamic scenes. This invention simultaneously achieves high accuracy and high AUC within a ten-millisecond inference latency, adapting to the low-power and real-time alarm requirements of edge computing.

[0127] To ensure the stability of online output, this invention employs threshold hysteresis and cross-window consistency aggregation at the inference end. A dual-threshold strategy (first top, then bottom) suppresses boundary jitter; an event is triggered after several consecutive windows are consistent, while an isolated positive window is suppressed as suspicious. This strategy further reduces instantaneous false alarms in dynamic monitoring without increasing model computation, ensuring reliability in continuous off-site monitoring scenarios.

[0128] In summary, for dynamic monitoring and real-time detection tasks of cardiac arrhythmias, this invention achieves higher accuracy and AUC simultaneously on standardized clinical data and real dynamic records, and meets the requirements for edge deployment in terms of key engineering indicators such as parameter quantity, FLOPs, and inference latency. These results are consistent with the unified training objective, demonstrating that morphological fidelity constraints and contrast consistency constraints have a clear effect on improving stability and sensitivity to key morphologies under dynamic conditions.

[0129] Deployment Boundaries and Real-Time Performance: The inference end retains only the encoder and classification head, with a single forward latency controlled in the millisecond range at the ten-second window level. The parameter scale is in the millions, and the computational load is approximately 10. 8 The order of magnitude of floating-point operations is required to meet the real-time deployment requirements of wearable devices and Holter at the edge.

[0130] Advantages of the real-time arrhythmia detection method based on morphological fidelity consistency constraints of this invention:

[0131] 1) Higher discrimination stability under dynamic disturbance conditions. This invention directly incorporates contrast consistency into the training objective, forcing alignment of latent representations between two types of real-world perturbation views of the same segment, significantly suppressing representation drift caused by occlusion, short missing values, and amplitude / phase shift. Compared to schemes that rely solely on classification loss or general data augmentation, false positives and false negatives are significantly reduced in dynamic scenes, and the output across time windows is more consistent. In dynamic recording evaluations using wearable devices and Holter monitoring, both accuracy and AUC outperform the representative control model, without increasing inference complexity.

[0132] 2) Greater sensitivity to key clinical morphological details. This invention superimposes a U-Net reconstruction branch onto the encoder, creating a morphological fidelity constraint that requires the underlying representation to reconstruct a standardized ECG that closely matches the original waveform. This forces the model to simultaneously preserve the P wave initiation and termination, the rapid QRS morphology, and the gradual ST and T details, avoiding reliance solely on coarse-grained peak values ​​or rhythm templates. Experimental results show that this constraint provides a stable gain in overall AUC and accuracy, with particularly significant advantages in segments with mild to moderate artifacts and amplitude fluctuations.

[0133] 3) Unified training with a streamlined inference chain under a unified objective. Classification, contrast consistency, and morphological fidelity are jointly optimized on the same encoder, forming a unified representation that is separable, invariant to perturbations, and morphologically faithful. Multi-objective collaborative convergence occurs during training, while only the encoder and classification head are retained during inference, avoiding the latency and energy consumption caused by multi-branch cascading, and also avoiding the problem of irreversible propagation of front-end denoising errors to subsequent stages.

[0134] 4) Enhanced real-time deployment capabilities. The number of model parameters and computational load are kept within a lightweight range, and the single forward latency at the ten-second window level is in the millisecond range, enabling stable operation on edge devices. Combined with an online decision strategy that integrates threshold hysteresis and cross-window consistency aggregation, output jitter is effectively suppressed, and instantaneous false alarms in continuous monitoring are significantly reduced, meeting the real-time and reliability requirements for long-term use outside the hospital.

[0135] 5) Adaptable to different acquisition methods and lead configurations. The method is not limited to specific devices or electrode layouts and is applicable to wearable ECG and Holter ECG. Both single-lead and multi-lead systems can be directly connected. In multi-lead scenarios, the method highlights the lead information source that contributes more by emphasizing lead attention and early fusion, enabling stable performance even with heterogeneous lead combinations.

[0136] 6) Labeling and parameter tuning costs are more controllable. Contrast consistency is achieved by constructing self-supervised signals using shared source views, reducing marginal dependence on additional label expansion while maintaining the main supervised learning approach. Weights for unified objectives can be automatically learned using uncertainty-weighted methods, reducing manual parameter tuning pressure and resulting in a more stable training process.

[0137] 7) The quantitative advantages of this invention compared to representative control methods have been verified. In both standardized clinical records and real-world dynamic records, this invention consistently leads in accuracy and AUC, while maintaining deployment metrics of low parameter count, low FLOPs, and low latency, demonstrating a comprehensive advantage in performance, efficiency, and robustness.

[0138] In summary, this invention achieves stability, sensitivity to key morphologies, and deployability simultaneously within the same potential space with a unified training objective, demonstrating a clear and reproducible comprehensive improvement over existing best-in-class technologies in the core application of dynamic arrhythmia detection.

[0139] Experimental example:

[0140] The experimental examples are not limited to specific device forms and are applicable to dynamic monitoring scenarios of wearable ECG and Holter ECG. They can be single-lead or multi-lead.

[0141] Implementation Environment and Deployment Constraints: The computing platform consists of a general-purpose GPU workstation for training and a CPU or embedded SoC for inference. The training phase utilizes PyTorch or an equivalent deep learning framework; the deployment phase exports the inference graph in ONNX or an equivalent format, with the target platform supporting FP16 or INT8 inference optimization. The system design goal is to achieve a single forward pass within a ten-second window of less than ten milliseconds, while ensuring sufficient memory usage and power consumption for long-term online operation of portable terminals.

[0142] Data Acquisition and Preprocessing: Data comes from continuous ECG recordings acquired by wearable devices or Holter monitors in dynamic scenarios, including resting, walking, and daily activity states; the recordings are desensitized before entering the algorithm flow. Data is uniformly resampled to frequency fs, with an anti-aliasing low-pass filter applied before resampling. Baseline drift and high-frequency noise are shaped using bandpass FIR filtering, with a passband of [0.5, 45] Hz. Power frequency interference is filtered out using a second-order notch filter, with a center frequency of 50 or 60 Hz. Robust normalization is used to normalize each window signal by median and absolute median difference, followed by percentile pruning and linear scaling to [-1, 1]. Continuous sequences are divided into overlapping sliding windows based on window length L and step size Δ; single-lead inputs have a 1×T shape, and multi-lead inputs have a C×T shape. Window labels are assigned based on the time-domain intersection-union threshold of the window and the event. This step outputs a window sequence with uniform amplitude and sampling rate, stable baseline, and consistent time scale.

[0143] Model Implementation Details: The encoder employs a lightweight multi-scale residual structure, with causal padding ensuring linearity. Convolutional kernel scale and dilation rate are grouped in parallel to cover both fast and slow time scales. Channel attention is used to improve the response of effective channels. In multi-lead applications, lead attention vectors are introduced to weight the input derivative-wise before unified encoding. The classification head performs global temporal aggregation on the final layer features and outputs the class probability. The contrast consistency projection head is a two-layer perceptron with concurrency control at the end. Normalization is used only for training. The U-Net reconstruction decoder upsamples step by step and fuses with multi-scale features from the encoding side, outputting a one-dimensional reconstructed waveform of equal length to the input; the reconstruction branch is enabled only during training and disabled during deployment to reduce latency and power consumption.

[0144] Training Process and Unified Loss: A sliding window of batch size B is used as input. Two real-world perturbation views are constructed from the same original window and embedded as unit vectors via a shared encoder and projector. An InfoNCE target with temperature τ is used to constrain the source views to be close together in the projection space. The classification term uses weighted cross-entropy, with class weights set according to class proportion or business priority. The morphological fidelity term consists of a time-domain L1 or time-frequency joint metric, requiring the reconstructed waveform to closely match the original waveform in key morphological aspects. The three losses are jointly optimized with unified weights α, β, and γ. The learning rate uses preheating followed by cosine annealing, gradient norm pruning, and AdamW or the Adam optimizer. After training, only the encoder and classification head are retained for online inference.

[0145] Online inference and decision-making process: During the inference phase, the input is a real-time sliding window, and the model outputs class probabilities and confidence levels. The online decision-making process employs a threshold hysteresis and cross-window consistency aggregation strategy: candidate events are marked when the confidence level exceeds the upper threshold and removed when it falls below the lower threshold; an alarm is confirmed when consecutive K windows meet the conditions, and isolated single-window positives are suppressed as suspicious. This strategy reduces false alarms caused by short-term jitter without increasing computation.

[0146] Experimental Example 1

[0147] Evaluation of the recognition performance of standardized clinical records

[0148] Experimental objective: To verify the overall recognition performance of the present invention on standardized clinical-style electrocardiogram recordings, and to examine whether it outperforms representative control methods without increasing reasoning complexity.

[0149] Experimental setup: Training and testing were stratified by subjects, with a 10-second sliding window, a 1-second step size, and a uniform sampling rate of 256Hz. Preprocessing and annotation were performed as described in section 5.2. Control methods included three types: typical one-dimensional convolutional networks, lightweight convolutional networks, and recurrent networks, all using the same preprocessing and input window settings. Evaluation metrics were accuracy and AUC.

[0150] Performance advantages of the method of this invention compared with similar methods:

[0151]

[0152]

[0153] This invention achieves a stable lead in both accuracy and AUC, with an accuracy lead of approximately 0.7 to 0.9 percentage points and an AUC lead of approximately 0.7 to 0.8 percentage points, as shown in Table 1. Considering that all methods are compared under the same input and complexity conditions, this improvement stems from the joint shaping of the encoder by two types of constraints: contrast consistency and morphological fidelity. This allows for better preservation of key forms in standardized records and improves the robustness of the decision boundary.

[0154] Experiment Example 2

[0155] Robustness assessment of dynamic wearable device recording

[0156] Experimental objective: To verify the recognition stability and overall performance of the present invention in real dynamic scenarios with short-term occlusion, amplitude and phase perturbation and local missing data.

[0157] Experimental setup: Data consisted of continuous recordings from wearable devices and Holter monitors in dynamic scenarios, with a sampling rate uniformly set to 256Hz. Preprocessing and online decision-making were performed according to sections 5.2 and 5.5. The control method consisted of the optimal three classes from Experiment Example 1. The metrics were accuracy and AUC.

[0158] like Figure 3 As shown, on records with significant dynamic interference, the present invention improves accuracy by approximately 2.2 percentage points and AUC by approximately 0.8 percentage points compared to the best control. Combined with the online decision strategy, the jitter of the output sequence is significantly reduced, and short-term false alarms decrease, demonstrating stronger adaptability to dynamic scenes. This result is consistent with the design goals of the present invention: suppressing representational drift through contrast consistency and maintaining fine-grained cues through morphological fidelity.

[0159] Experimental Example 3

[0160] Project deployment index evaluation

[0161] Experimental objective: To evaluate the efficiency and resource consumption of the inference at the edge of the present invention, and to verify whether it meets the real-time and energy efficiency requirements of continuous off-site monitoring.

[0162] Experimental setup: Parameter count, FLOPs, and single-window forward latency were statistically analyzed on a unified inference platform; the control method was the representative implementation in Experiment Example 1. The window length was 10 seconds, the batch size was 1, and latency was recorded in both CPU single-threaded and GPU FP16 modes.

[0163] Evaluation of engineering deployment indicators using the method of this invention compared to similar methods:

[0164]

[0165] This invention maintains a low number of parameters and computational load, achieving a forward latency of approximately 8.3 milliseconds in GPU mode with a ten-second window, meeting millisecond-level real-time output requirements; it also maintains a usable latency level in CPU mode. Combined with the online decision mechanism of version 5.5, this invention achieves stable, low-jitter dynamic detection output without increasing structural complexity.

[0166] Implementation Guidelines and Parameter Range Recommendations: To facilitate engineering and clinical implementation, the following key parameter range recommendations are provided. The sampling rate fs should be uniformly set to 200–500 Hz; the window length L should be 5–12 seconds, and the step size Δ should be 0.25–1 second; the bandpass bandwidth should be [0.5, 45] Hz; and the notch damping coefficient r should be 0.90–0.98. The weights of the uniform loss α ∈ [1, 2], β ∈ [0.2, 1], and γ ∈ [0.2, 1] can be learned automatically using uncertainty weighting. The contrast temperature τ ∈ [0.05, 0.5] should be slowly annealed during training. The upper and lower thresholds for online decision-making and the number of consistency windows K can be set on the validation set according to the target false alarm level.

[0167] In summary, the above experimental examples demonstrate the advantages of this invention in terms of recognition performance, dynamic robustness, and engineering deployment. Without increasing the complexity of the inference end, by jointly shaping the same encoder using both consistency and morphological fidelity constraints, higher accuracy and AUC, more stable dynamic output, and millisecond-level inference latency are achieved. These results indicate that this invention can provide a feasible algorithmic solution for the dynamic monitoring and real-time detection of cardiac arrhythmias without limiting specific acquisition devices.

[0168] Example 2

[0169] This invention also provides a real-time arrhythmia detection system based on morphological fidelity consistency constraints, comprising:

[0170] The preprocessing module is used to standardize and slice continuous ECG signals. Specifically, it includes: resampling the input single-lead or multi-lead ECG data, bandpass filtering and power frequency notch filtering, robust amplitude standardization and percentile pruning, and completing time synchronization and channel consistency checks; dividing the standardized signal into overlapping sliding time windows according to the preset window length and step size, generating a time window sequence with timestamps, optionally outputting a signal quality index for subsequent decision reference, and providing a unified sampling rate, amplitude range and time scale for downstream modules;

[0171] The feature extraction module includes a jointly trained ECG signal encoder, which receives time windows output by the preprocessing module and extracts latent representations. The joint training is specifically defined as simultaneously optimizing the encoder using supervised classification signals, contrast consistency signals, and morphological fidelity signals during the training phase. The encoder is preferably a lightweight temporal network with causal multi-scale architecture, incorporating parallel convolution and dilated convolution branches and a channel attention mechanism. When processing multi-lead input, different leads are adaptively weighted before encoding using lead attention, followed by unified encoding. During the training phase, the feature extraction module incorporates a view construction and projection unit for generating contrast consistency signals and a reconstruction and decoding unit for generating morphological fidelity signals, forming a unified objective function with three types of losses and inversely updating the encoder parameters. During the deployment phase, the view construction, projection, and reconstruction units are no longer used; the module only outputs latent representation vectors corresponding one-to-one with each time window and inherits the timestamp.

[0172] The classification module maps the latent representations output by the feature extraction module to the class probabilities and confidence levels of arrhythmias. Specifically, it includes: performing global temporal aggregation on the latent representations and outputting the probability distribution of each target class through the classification head; supporting the loading of class imbalance-based weight settings and threshold configurations; the module maintains the same timestamp and window number as the input time window and provides continuous probability streams and confidence streams to the online decision module.

[0173] The online decision module generates real-time detection results based on the category probabilities output by the classification module. Specifically, it makes decisions according to the double-threshold hysteresis rule (top-down) and the cross-window consistency rule. An event is confirmed to begin when the upper threshold is reached and the condition is met for K consecutive time windows. During the event's duration, an event is confirmed to end when the probability falls below the lower threshold and the condition is met for K consecutive time windows. Positive results that appear only in a single time window and do not meet the continuity condition are not output as events and are marked as suspicious. The module outputs a timestamped list of events, including event category, start and end times, duration, and peak confidence, and provides interfaces for communication with device alarms or upper-layer systems. This module is enabled during both training and deployment phases to evaluate the implementation of consistent strategies during online operation.

[0174] Example 3

[0175] This invention also provides a real-time arrhythmia detection device based on morphological fidelity consistency constraints, including a memory and a processor. The memory stores a computer program, which is a real-time arrhythmia detection program. When the processor executes the real-time arrhythmia detection program, it implements the steps of the real-time arrhythmia detection method based on morphological fidelity consistency constraints as described in Embodiment 1. In training mode, it simultaneously optimizes the encoder parameters using supervised classification signals, contrastive consistency signals, and morphological fidelity signals. In inference mode, it does not perform contrastive embedding and reconstruction-related calculations, but only performs forward inference between the encoder and classifier and the online decision to output real-time detection results. Figure 1 As shown, when the processor executes the real-time arrhythmia detection program, it performs the following steps:

[0176] S1. Preprocess the continuous electrocardiogram signal, resample, filter and standardize the amplitude, and divide it into overlapping sliding time windows according to the preset window length and step size;

[0177] S2. Input each time window into the ECG signal encoder obtained through joint training to obtain the potential representation vector of that time window; the joint training is defined as: simultaneously using supervised classification signal, contrast consistency signal and morphological fidelity signal to optimize the parameters of the encoder during the training phase;

[0178] S3. Input the latent representation vector into the classifier and output the class probability of the time window belonging to each arrhythmia category;

[0179] S4. Based on the category probability, output the real-time detection result using an online decision strategy that combines threshold hysteresis and cross-window consistency.

[0180] Among them, the contrastive consistency signal and morphological fidelity signal are only enabled during the training phase to update the encoder parameters. The contrastive embedding and reconstruction branch are no longer calculated during the inference phase. Only the encoder and classifier participate in the forward computation during the inference phase.

[0181] Furthermore, the joint training is achieved through a single unified objective function, which is a weighted sum of supervised classification loss, contrast consistency constraint loss, and morphological fidelity constraint loss. The three weights are preset constants or are automatically learned and determined during training through an uncertainty weighting strategy, so as to simultaneously enhance class separability, perturbation invariance, and key morphological fidelity.

[0182] Furthermore, the contrast consistency constraint loss term is constructed as follows: for each original ECG signal time window, two views based on real-world perturbations are independently generated as homologous positive pairs; these two views are then compared with views from other original time windows within the same batch. Figure 1The shared ECG signal encoder and projector are used to obtain normalized embedding. A contrastive learning criterion with temperature parameters is adopted to make homologous positive pairs close to each other in the embedding space and keep them separate from other views in the batch, so as to improve the representation stability under occlusion, short missing and amplitude-phase change conditions.

[0183] Furthermore, the real-world perturbation includes one or more combinations of time occlusion, amplitude scaling, phase micro-shift, and band-limited noise superposition. The perturbation is applied on the time axis to keep it aligned with the original time window to ensure that the two views correspond to the same physiological event.

[0184] Furthermore, the morphological fidelity constraint loss term is constructed in the following manner: the latent representation extracted by the ECG signal encoder is input into a reconstructed ECG signal decoder to reconstruct a normalized waveform of the same length as the original time window, and the morphological difference between the reconstructed waveform and the original ECG waveform is used as the loss term. The morphological difference includes at least point-by-point time-domain error and can be further combined with amplitude spectrum difference based on short-time Fourier transform.

[0185] Furthermore, the reconstructed ECG signal decoder adopts a one-dimensional U-Net structure with symmetrical skip connections, and outputs a reconstructed waveform of the same length as the input time window by upsampling step by step and fusing it with the features of the corresponding layer in the encoding stage.

[0186] Furthermore, the ECG signal encoder is a lightweight causal multi-scale network, which includes parallel branches of one-dimensional causal convolution and one-dimensional dilated convolution to cover two types of time scales: rapid change and slow change. It also introduces a channel attention mechanism in the channel dimension to enhance the discriminative feature response. Moreover, the effective receptive field of the encoder does not cross the time window boundary to meet the real-time requirements of online processing.

[0187] Furthermore, when processing multi-lead ECG signals, a lead attention mechanism is introduced before encoding to adaptively weight different lead signals before uniformly sending them to the encoder, so as to highlight the lead information sources that contribute more.

[0188] like Figure 2 As shown, the threshold hysteresis and cross-window consistency decision strategy further includes setting an upper threshold that is strictly greater than the lower threshold. When the target class probability of K consecutive time windows in the current sliding time series is not lower than the upper threshold, the arrhythmia event is determined to begin. During the duration of the event, when the target class probability of subsequent time windows is lower than the lower threshold and K consecutive time windows are satisfied, the event is determined to end. Positive results that only appear in a single time window and do not meet the continuity condition are not output as events and are marked as suspicious.

[0189] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.

Claims

1. A real-time arrhythmia detection method based on morphological fidelity consistency constraints, characterized in that, Includes the following steps: S1. Preprocess the continuous ECG signal and divide it into overlapping sliding time windows; S2. Input each time window into the ECG signal encoder obtained through joint training to obtain the potential representation vector of that time window; the joint training is defined as: simultaneously using supervised classification signal, contrast consistency signal and morphological fidelity signal to optimize the parameters of the encoder during the training phase; the joint training is achieved through a single unified objective function, which is formed by weighted summation of supervised classification loss, contrast consistency constraint loss and morphological fidelity constraint loss, with the three weights being preset constants or automatically learned and determined during training through an uncertainty weighting strategy, so as to simultaneously enhance class separability, perturbation invariance and key morphological fidelity; The contrast consistency constraint loss term is constructed as follows: For each original ECG signal time window, two views based on real-world perturbations are independently generated as homologous positive pairs. These two views, along with views from other original time windows in the same batch, are input into a shared ECG signal encoder and projector to obtain normalized embedding. A contrast learning criterion with temperature parameters is used to make homologous positive pairs close to each other in the embedding space and keep them separate from other views in the batch, so as to improve the representation stability under occlusion, short missing and amplitude-phase change conditions. The morphological fidelity constraint loss is constructed as follows: the latent representation output by the encoder is input to the reconstruction decoder to obtain a reconstructed waveform of the same length as the original time window, and the morphological difference between the reconstructed waveform and the original waveform is used as the loss signal. The morphological difference includes at least point-by-point time-domain error or the sum of point-by-point time-domain error and amplitude spectrum difference based on short-time Fourier transform, so as to enhance the sensitivity to slowly changing morphology. S3. Input the latent representation vector into the classifier and output the class probability of the time window belonging to each arrhythmia category; S4. Based on the category probability, output the real-time detection result using an online decision strategy that combines threshold hysteresis and cross-window consistency. Among them, the contrastive consistency signal and morphological fidelity signal are only enabled during the training phase to update the encoder parameters. The contrastive embedding and reconstruction branch are no longer calculated during the inference phase. Only the encoder and classifier participate in the forward computation during the inference phase.

2. The real-time arrhythmia detection method based on morphological fidelity consistency constraints according to claim 1, characterized in that, The real-world perturbation includes one or more combinations of time occlusion, amplitude scaling, phase micro-shift, and band-limited noise superposition. The perturbation is applied to the time axis in alignment with the original time window to ensure the comparability of the two views corresponding to the same physiological event.

3. The real-time arrhythmia detection method based on morphological fidelity consistency constraints according to claim 1, characterized in that, The reconstruction decoder adopts a one-dimensional U-Net structure with symmetrical skip connections. By upsampling step by step and fusing with the features of the corresponding layer in the encoding stage, it outputs a reconstructed waveform of the same length as the input time window, so as to maintain lightweight computation while taking into account local details and global trends.

4. The real-time arrhythmia detection method based on morphological fidelity consistency constraints according to claim 1, characterized in that, The ECG signal encoder is a lightweight causal multi-scale network that includes parallel branches of one-dimensional causal convolution and one-dimensional dilated convolution to cover two types of time scales: rapid and slow changes. It also introduces a channel attention mechanism in the channel dimension to enhance the discriminative feature response. Furthermore, the effective receptive field of the encoder does not cross the time window boundary to meet the real-time requirements of online processing.

5. The real-time arrhythmia detection method based on morphological fidelity consistency constraints according to claim 1, characterized in that, The threshold hysteresis and cross-window consistency decision strategy includes setting a lower threshold and an upper threshold that is greater than the lower threshold. When the target class probability of K consecutive time windows in the current sliding time series is not lower than the upper threshold, the arrhythmia event is determined to begin. During the duration of the event, when the target class probability of K consecutive time windows is lower than the lower threshold, the event is determined to end. Positive results that only appear in a single time window and do not meet the continuity condition are not output as events and are marked as suspicious to reduce the probability of false alarms.

6. A real-time arrhythmia detection system based on morphological fidelity consistency constraints, characterized in that, include: The preprocessing module is used to resample, filter, and standardize the amplitude of continuous electrocardiogram signals and divide them into overlapping sliding time windows; The feature extraction module includes a jointly trained ECG signal encoder, which receives the time window output by the preprocessing module and extracts latent representations. The joint training refers to simultaneously optimizing the encoder using supervised classification signals, contrast consistency signals, and morphological fidelity signals. The joint training is achieved through a single unified objective function, which is a weighted sum of supervised classification loss, contrast consistency constraint loss, and morphological fidelity constraint loss. The three weights are preset constants or are automatically learned and determined during training through an uncertainty weighting strategy, so as to simultaneously enhance class separability, perturbation invariance, and key morphological fidelity. The contrast consistency constraint loss term is constructed as follows: For each original ECG signal time window, two views based on real-world perturbations are independently generated as homologous positive pairs. These two views, along with views from other original time windows in the same batch, are input into a shared ECG signal encoder and projector to obtain normalized embedding. A contrast learning criterion with temperature parameters is used to make homologous positive pairs close to each other in the embedding space and keep them separate from other views in the batch, so as to improve the representation stability under occlusion, short missing and amplitude-phase change conditions. The morphological fidelity constraint loss is constructed as follows: the latent representation output by the encoder is input to the reconstruction decoder to obtain a reconstructed waveform of the same length as the original time window, and the morphological difference between the reconstructed waveform and the original waveform is used as the loss signal. The morphological difference includes at least point-by-point time-domain error or the sum of point-by-point time-domain error and amplitude spectrum difference based on short-time Fourier transform, so as to enhance the sensitivity to slowly changing morphology. The classification module is used to receive the latent representation output by the feature extraction module and obtain the category probability of the arrhythmia. The online decision module receives the category probabilities output by the classification module and, in conjunction with the threshold hysteresis and cross-window consistency decision strategy, outputs real-time detection results.

7. A real-time arrhythmia detection device based on morphological fidelity consistency constraints, comprising a memory and a processor, wherein the memory stores a computer program, the computer program being a real-time arrhythmia detection program, characterized in that, When the processor executes the real-time arrhythmia detection program, it implements the steps of the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Multi-label arrhythmia discrimination method based on multi-scale neural network model

    CN118319325A

  • Electrocardiosignal artifact elimination method and system based on dynamic channel weighting

    CN120616564A