A method and system for real-time compression of ECG data

CN122997705APending Publication Date: 2026-10-30CHENGDU XINJIKANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611192697.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-07
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

然而,长程心电监测在带来便利的同时,也引发了数据传输与存储方面的严峻挑战

Benefits of technology

[0025]对心电数据压缩前,针对其特性将其分段成心拍段和间期段,对心拍段和间期段采用不同的压缩方式和压缩档位,根据相邻心拍的QRS波形相近的特性,采用逐拍残差的方式,每一个心拍段都与前一个心拍段计算形变残差,相邻拍之间的残差值通常能量较低,占用比特也较少,采用Rice编码能大幅降低编码的比特开销,提高了压缩率。而间期段采用量化+Rice编码的方式简化压缩过程,分段的方式契合心电数据的特性,且由于间期段信息量较少,不包含特征点,可采用较高档位的有损压缩,在保证压缩率的同时保证了压缩速率,是一种专门针对于心电数据的压缩方式。其次编码简单,编码时只需保存第一个心拍段作为QRS关键帧以及后续的所有形变残差形成的残差序列和间期段,无需存储历史信号数据作为样本。此外,由于本发明的方法中涉及的rice编码以及R波检测算法都具备轻量级计算的特性,使之可以在简单的设备端边采集边压缩,真正实现实时压缩。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122997705A_ABST
    Figure CN122997705A_ABST
Patent Text Reader

Abstract

The application discloses an ECG data real-time compression method and system, first, R peak detection is performed on an ECG waveform signal, then, according to the detection result, the signal is divided into a heartbeat segment and an interbeat interval segment, for the heartbeat segment, the deformation residual error of each current heartbeat segment and the previous heartbeat segment is calculated, a residual error sequence is generated, then, the residual error sequence, the interbeat interval segment and the first heartbeat segment are encoded and outputted together, and further, rice coding is performed on the residual error sequence and the interbeat interval segment. While guaranteeing the compression rate, the compression rate and the compression ratio are guaranteed, it is a compression method specially for ECG data, and the method and the system can be applied to collecting and compressing at the collecting device end in a streaming window mode, and real-time compression is truly realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data compression, and more particularly to a real-time compression method for ECG data. Background Technology

[0002] Long-term Holter monitoring plays an increasingly important role in arrhythmia screening, postoperative follow-up, and telemedicine. Compared to traditional Holter monitors, long-term ECG monitors are typically lighter and more comfortable to wear, and can continuously collect ECG signals for several days or even weeks. They not only serve clinical patients but are also gradually being integrated into the daily health management of healthy individuals. However, while long-term ECG monitoring brings convenience, it also presents significant challenges in data transmission and storage.

[0003] Electrocardiogram (ECG) signals are continuously acquired, high-sampling-rate time-series signals. Current wearable devices, such as ECG vests and long-term ECG monitors, have long wearing and acquisition cycles, resulting in large data volumes. Wearable devices typically only handle signal acquisition and lack complete local analysis capabilities, requiring data to be transmitted to remote servers for storage and analysis. This prolonged data transmission significantly depletes device battery life, and the large data transfer also incurs considerable communication and storage costs. Therefore, a method is urgently needed to effectively compress ECG signals at the device level to reduce communication power consumption, extend monitoring cycles, and alleviate the server's storage burden. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide a real-time ECG data compression method and system that can collect and compress data in real time at the acquisition device.

[0005] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:

[0006] First, a method for real-time compression of ECG data is disclosed, including the following steps:

[0007] S1. Acquire continuously collected ECG waveform signals, wherein the ECG waveform signals include timing sampling data of at least one lead.

[0008] S2. Detect the R-peak of the acquired ECG waveform signal using a sliding window with a fixed window length;

[0009] S3. Based on the detection results of S2, the ECG waveform signal within the sliding window is divided into the heartbeat segment and the heartbeat interval segment, and the first heartbeat segment of the time-series sampling data is the QRS keyframe;

[0010] S4. For the heartbeat segments within the sliding window, calculate the deformation residual between each current heartbeat segment and its previous heartbeat segment to generate a residual sequence, and encode and output the residual sequence, the heartbeat interval segment and the QRS key frame together;

[0011] S5. Assemble the encoding results output in step S4 into compressed data frames in time sequence to generate a compressed code stream.

[0012] Further, in step S4, when encoding the heartbeat interval segment and the residual sequence, the Rice encoding method is used for encoding and output.

[0013] Further, in step S3, the ECG waveform signal is divided into heartbeat segments and heartbeat interval segments, wherein the heartbeat segment is a segment that extends from the R point to both ends and contains all waveforms of the entire heartbeat.

[0014] Further, before encoding the heartbeat interval segment and the residual sequence, the data sequence is quantized first. The quantization includes three gears Q1, Q2 and Q3, where the compression ratio Q1<Q2<Q3, Q1 is a lossless compression gear, Q2 and Q3 are both lossy compression gears, the residual sequence is compressed and encoded using the Q1 or Q2 gear, and the heartbeat interval segment is compressed and encoded using the Q3 gear.

[0015] Further, in step S3, the heartbeat segment is scaled to align the sampling points of the heartbeat segment with those of the QRS key frame.

[0016] In another aspect, an ECG data real-time compression system is provided, comprising:

[0017] An R peak detection module, configured to perform R peak detection on the collected ECG waveform signal using a sliding window with a fixed window length;

[0018] A signal segmentation module, configured to divide the ECG waveform signal into heartbeat segments and heartbeat interval segments according to the R peak detection result, wherein the first heartbeat segment of the time-series sampled data is a QRS key frame;

[0019] An encoding module, configured to encode and compress the segmented ECG waveform signal, specifically by calculating the deformation residual between each current heartbeat segment and its previous heartbeat segment to generate a residual sequence, encoding and outputting the residual sequence, the heartbeat interval segment and the QRS key frame together, and then assembling the output encoding results into compressed data frames in time sequence to generate a compressed code stream.

[0020] Further, when the encoding module encodes the heartbeat interval segment and the residual sequence, the Rice encoding method is used for encoding and output.

[0021] Further, the signal segmentation module divides the ECG waveform into a heartbeat segment and a heartbeat interval segment, wherein the heartbeat segment is a segment that expands from the R point to both ends and contains all the waveforms of the entire heartbeat.

[0022] Further, the encoding module is further provided with a quantization unit. Before encoding the heartbeat interval and the residual sequence, the integer data sequence is first quantized. The quantization includes three gears Q1, Q2, and Q3, where the compression ratio satisfies Q1<Q2<Q3, Q1 is a lossless compression gear, and both Q2 and Q3 are lossy compression gears. The residual sequence is compressed and encoded using the Q1 or Q2 gear, and the heartbeat interval segment is compressed and encoded using the Q3 gear.

[0023] Further, in step S3, the heartbeat segments are scaled to align the other heartbeat segments with the sampling points of the QRS key frame.

[0024] The beneficial effects of the present invention are as follows:

[0025] Before compressing the ECG data, the ECG data is segmented into heartbeat segments and interval segments according to its characteristics, and different compression methods and compression gears are adopted for the heartbeat segments and the interval segments. Based on the characteristic that the QRS waveforms of adjacent heartbeats are similar, a beat-by-beat residual method is adopted, where each heartbeat segment calculates a deformation residual with the previous heartbeat segment. The residual value between adjacent beats usually has low energy and occupies fewer bits, and Rice coding can greatly reduce the bit overhead of coding and improve the compression rate. For the interval segment, the quantization + Rice coding method is adopted to simplify the compression process. The segmentation method fits the characteristics of ECG data, and since the interval segment has less information and does not contain feature points, a higher-gear lossy compression can be adopted, which ensures the compression rate while guaranteeing the compression speed, making it a compression method specifically for ECG data. Secondly, the coding is simple: during coding, only the first heartbeat segment as the QRS key frame, as well as the subsequent residual sequence formed by all deformation residuals and the interval segments, need to be saved, and there is no need to store historical signal data as samples. In addition, since the Rice coding and R-wave detection algorithm involved in the method of the present invention both have the feature of lightweight computation, the method can perform compression while collecting data on a simple device end, truly realizing real-time compression. Brief Description of the Drawings

[0026] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings described below show only some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without any creative effort.

[0027] Figure 1 is a flowchart of a real-time ECG data compression method of the present application;

[0028] Figure 2 This is a compression ratio-distortion trade-off diagram for different levels in the embodiments of this application;

[0029] Figure 3 The images show waveform comparisons and error comparisons for single-lead compression decoding at different speeds in the embodiments of this application. Detailed Implementation

[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. For example, terms such as “length,” “width,” “upper,” “lower,” “left,” “right,” “front,” “rear,” “vertical,” “horizontal,” “top,” “bottom,” “inner,” and “outer” indicate orientations or positions based on the orientations or positions shown in the accompanying drawings and are for ease of description only, and should not be construed as limiting the technical solution.

[0031] The terms "comprising" and "having," and any variations thereof, used in the specification, claims, and accompanying drawings of this invention are intended to cover non-exclusive inclusion; the terms "first," "second," etc., used in the specification, claims, and accompanying drawings are used to distinguish different objects, not to describe a particular order. "A plurality of" means two or more, unless otherwise explicitly specified.

[0032] In the description and claims of this invention and the foregoing drawings, when an element is referred to as "fixed to," "mounted to," "disposed on," or "connected to" another element, it can be located directly or indirectly on that other element. For example, when an element is referred to as "connected to" another element, it can be directly or indirectly connected to that other element.

[0033] Furthermore, the reference to "embodiment" herein means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0034] Example

[0035] Long-term Holter monitoring plays an increasingly important role in arrhythmia screening, postoperative follow-up, and telemedicine. Compared to traditional Holter monitors, long-term ECG monitors are typically lighter and more comfortable to wear, and can continuously collect ECG signals for several days or even weeks. They not only serve clinical patients but are also gradually being integrated into the daily health management of healthy individuals. However, while long-term ECG monitoring brings convenience, it also presents significant challenges in data transmission and storage.

[0036] Electrocardiogram (ECG) signals are continuously acquired, high-sampling-rate time-series signals. Current wearable devices, such as ECG vests and long-term ECG monitors, have long wearing and acquisition cycles, resulting in large data volumes. Wearable devices typically only handle signal acquisition and lack complete local analysis capabilities, requiring data to be transmitted to remote servers for storage and analysis. This prolonged data transmission significantly depletes device battery life, and the large data transfer also incurs considerable communication and storage costs. Therefore, a method is urgently needed to effectively compress ECG signals at the device level to reduce communication power consumption, extend monitoring cycles, and alleviate the server's storage burden.

[0037] As one optional embodiment, a real-time compression method for ECG data is provided, such as... Figure 1 As shown, it includes the following steps:

[0038] S1. Acquire continuously collected ECG waveform signals, wherein the ECG waveform signals include timing sampling data from at least one lead. The ECG waveform signals are typically acquired using wearable devices, such as ECG watches, ECG vests, or heart rate patches. Long-range acquisition devices, such as ECG vests and heart rate patches, can support continuous ECG signal acquisition for 7-14 days, resulting in a massive amount of data. The acquired data is compressed before being transmitted to the server, resulting in higher transmission efficiency, improved battery life of the acquisition device, and reduced storage costs.

[0039] S2. R-peak detection is performed on the acquired ECG waveform signal using a sliding window of fixed window length. The fixed window length can be selected by those skilled in the art based on experience or actual needs. In this embodiment, an 8-second sliding window is selected. When the window slides, the detection only uses the current 8-second historical window. Each detection and subsequent encoding only submits a new closed 8-second window segment. Submitted samples will not be re-encoded due to window sliding. Therefore, the encoding process is continuous streaming, rather than encoding each window independently. As for the detection of R-peaks, it involves detecting the position of the R point in the QRS wave of each heartbeat. There are many mature R-peak detection algorithms in the prior art, and they are not the focus of the solution taught in this embodiment, so they will not be elaborated on here.

[0040] S3. Based on the detection results of S2, the ECG waveform signal within the sliding window is divided into a beat segment and a beat interval segment. The first beat segment of the time-series acquired data is the QRS keyframe. The beat segment is a fragment extending from point R to both ends, encompassing the entire waveform segment of the beat. When dividing the beat segment, those skilled in the art can select a signal segment before and after point R based on experience. In principle, it should include all waveform and feature points of a single beat. There are multiple ways to extract beat segments; a fixed-duration segment can be taken from both ends centered on point R, or a segment can be taken based on the RR interval, according to the percentage of the preceding and following RR interval segments. The beat interval segment is any signal segment other than the beat segment, i.e., the baseline signal segment in the electrocardiogram signal. It is worth noting that the distance between heartbeats is not always fixed and usually varies. When symptoms such as tachycardia or atrial fibrillation occur, the RR interval may be very short. In this case, after dividing the heartbeat segments according to the rules, there may not be a corresponding heartbeat interval segment. In this case, the heartbeat segment can be directly coded. Alternatively, if the heartbeat interval segment is too short, it can be merged into the preceding and following heartbeat segments to form a new heartbeat segment before coding.

[0041] Considering the characteristics of ECG signals, the morphological differences between the beat segment and the baseline signal segment are significant, and the beat segment is the only signal segment that truly reflects cardiac activity. Therefore, in this embodiment, before compressing the ECG signal, the beat segment and the interbeat segment are separated and encoded and compressed using different methods. Since the interbeat segment contains less information and is not of interest to image interpreters, a lossy compression method with a high compression ratio and simple compression technique can be used for it, while the beat segment is compressed more precisely. Compared to directly compressing the ECG signal without preprocessing, this method improves real-time compression efficiency and compression ratio without affecting image interpretation after decoding.

[0042] S4. For each heartbeat segment within the sliding window, calculate the deformation residual between each current heartbeat segment and its previous heartbeat segment, generate a residual sequence, and encode and output the residual sequence, the heartbeat interval, and the QRS keyframe together. Based on the characteristics of ECG signals, the morphological differences between consecutive heartbeats are small, and the deformation residual value between each heartbeat segment and its previous heartbeat segment is also small. As a result, the space occupied by the generated residual sequence is also low. Based on this, the heartbeat segments can be encoded and compressed to the maximum extent. During encoding, only the sampled value of the first heartbeat segment and the subsequent residual sequence need to be encoded. Compared with encoding each heartbeat segment, the compression efficiency can be greatly improved. If abnormal waveforms (premature beats, beats significantly affected by noise) are present in the acquired heartbeat waveform, although the deformation residual value between the current beat and the previous beat will increase, since it is a streaming encoding, each heartbeat segment is only compared with the previous heartbeat segment. At this time, the deformation residual value affected will only be the two deformation residuals before and after the abnormal heartbeat. After the subsequent waveform returns to normal, the deformation residual value will also decrease, and the impact on the compression ratio is negligible.

[0043] S5. Assemble the encoding results output in step S4 into compressed data frames in time sequence to generate a compressed code stream. When decoding is required, all heartbeat segments can be completely restored according to the first heartbeat segment and the residual sequence, and the entire segment of ECG waveform data can be restored by combining with the time-sequentially decoded heartbeat interval segments.

[0044] Preferably, in step S4, when encoding the heartbeat interval segments and the residual sequence, the Rice encoding method is used for encoding output. Rice encoding is a simple and efficient lossless compression algorithm, which is especially suitable for processing data where small values appear frequently and large values appear occasionally. The residual sequence in the present application is composed of deformation residuals, and the deformation residuals reflect the difference between adjacent heartbeat segments, so the data of the deformation residuals are small. Similarly, the heartbeat interval segments belong to the baseline part of the ECG waveform, and their data are also small, which is just suitable for being compressed by the Rice encoding method.

[0045] Preferably, before encoding the heartbeat intervals and the residual sequence, the integer data sequence is quantized first. The quantization includes three gears Q1, Q2 and Q3, where Q1 is a lossless compression gear, and both Q2 and Q3 are lossy compression gears. The quantization here refers to dividing the deformation residual integer sample by the step size q and then taking the integer, only storing the integer index with coarser granularity; when decoding, multiply back by q to obtain the reconstructed value. Therefore, quantization is neither filtering nor changing the sampling rate, but approximating the original samples with fixed steps on the amplitude axis. The three different compression gears correspond to different step sizes q, and the step size q is , the larger the step size, the higher the compression ratio and the higher the PRD after compression. In this embodiment, the step size q is selected as q∈{1,16,32}.

[0046] The specific compression process is: let the j-th heartbeat segment after scaling and alignment be h_j[ℓ], where j is the serial number of the heartbeat segment, ℓ is the serial number of the sampling point in the heartbeat segment, L is the number of sampling points of the heartbeat segment after alignment, and 0≤ℓ<L. The first heartbeat segment h_0[ℓ] is used as the key frame. The deformation residual of the j-th heartbeat segment relative to the previous heartbeat segment is defined as:

[0047]

[0048] Expand each heartbeat deformation residual into a heartbeat residual integer sequence u_H[n] according to the heartbeat sequence and the sampling point sequence within the segment; connect each heartbeat interval segment in time sequence into a heartbeat interval integer sequence u_I[n]. In this embodiment, u_c[n] is uniformly used to represent the signed integer sequence entering the encoding chain, where c∈{H,I}, H represents the heartbeat residual sequence, I represents the heartbeat interval sequence, and n is the global sample serial number in the corresponding independent sequence. The expansion relationship of the heartbeat residual sequence is:

[0049]

[0050] Before performing differential and Rice coding, symmetric uniform scalar quantization is first employed. Let the quantization levels p∈{1,2,3} correspond to Q1, Q2, and Q3 respectively, with quantization step sizes as follows:

[0051]

[0052] The quantization index y_c[n] is defined as:

[0053]

[0054] Where sgn(·) is the sign function, taking 1 for positive numbers, 0 for zero, and -1 for negative numbers; this definition explicitly stipulates that when the value is exactly at half the quantization step size, it is rounded in the direction away from zero. The reconstructed integer value after dequantization is:

[0055]

[0056] Quantization error satisfies:

[0057]

[0058] Therefore, the quantization step size for Q1 is 1, achieving lossless reconstruction of integer inputs; the maximum quantization errors in the integer field for Q2 and Q3 are no more than 8 AD and 16 AD, respectively. After quantization, the quantized index sequence is subjected to first-order differencing:

[0059]

[0060]

[0061] Where n=0 represents the starting point of an independent sequence of integers to be encoded. The first-order difference state is not reset when subsequently dividing Rice data blocks. To map signed differences to non-negative integers, a Zigzag mapping is used:

[0062]

[0063]

[0064] The above mapping maps 0, -1, 1, -2, 2 to 0, 1, 2, 3, 4 respectively. z_c[n] is divided into Rice data blocks with a maximum of 128 symbols. Let the starting index of the g-th data block be n_g, and the actual number of symbols be M_g, 1 ≤ M_g ≤ 128; the i-th symbol within the block is defined as:

[0065]

[0066] For each candidate Rice parameter k∈{0,1,…,15}, calculate the total code length within the block. When encoding a non-negative integer z_(g,i) using parameter k, the unary code of the quotient requires ⌊z_(g,i) / 2^k⌋+1 bits, and the remainder requires k bits; adding the 4-bit parameter block header, the estimated total code length is:

[0067]

[0068] The Rice parameter used for the g-th data block is defined as follows:

[0069]

[0070] When multiple k values ​​yield the same minimum code length, the smallest k is selected. When using k_g^⋆, the Rice quotient and remainder of the i-th symbol are defined as follows:

[0071]

[0072]

[0073] Where 0 ≤ r_(g,i) < 2^(k_g^⋆). Let bin_k(r) be the k-bit fixed-length binary representation of the integer r, and let || be the bit string concatenation operation. Then the Rice codeword is:

[0074]

[0075] For example, when z_(g,i)=13 and k_g^⋆=2, q_(g,i)=3 and r_(g,i)=1, the unary code of the quotient is 0001, the remainder is 01, and the final codeword is 000101. The decoder obtains q_(g,i) by counting the number of consecutive 0s before the terminating 1, then reads the k_g^⋆ bits to obtain r_(g,i), and recovers the result.

[0076]

[0077] The inverse Zigzag mapping is defined as:

[0078]

[0079]

[0080] Then perform the inverse first-order difference:

[0081]

[0082]

[0083] Then perform inverse quantization according to û_c[n]=Δ_py_c[n]. For the heartbeat residual sequence, restore û_H[n] to d̂_j[ℓ] in the same order, and reconstruct it frame by frame according to the keyframes:

[0084]

[0085]

[0086] This completes the reconstruction of the heartbeat segments, which are then combined with the time-recovered interbeat segments to obtain a continuous ECG waveform.

[0087] The focus of ECG waveform analysis is whether the waveform morphology of the heartbeat is normal or abnormal, and if abnormal, what type of abnormality it is. It doesn't require a 100% restoration of the original acquired data. Therefore, when compressing ECG data, lossy compression that doesn't destroy the original waveform morphology is perfectly acceptable under the visual observation of a doctor or professional image interpreter. This embodiment provides different quantization levels with varying compression ratios to further improve the compression rate while ensuring the waveform remains usable. Preferably, different compression levels can be used for the inter-beat segment and the residual sequence. For example, the data restored after decoding the residual sequence is the heartbeat segment data, so a lower quantization step size compression level can be used. The inter-beat segment reflects ECG baseline information, which is less information and not a primary focus, so a higher quantization step size compression level can be used to improve compression efficiency.

[0088] Preferably, in step S3, the cardiac beat segment is scaled to align the sampling points of the cardiac beat segment with those of the QRS keyframe. Step S3 segments the ECG signal into cardiac beat segments and intercardiac beat segments. A cardiac beat segment typically includes all waves and features of a complete cardiac beat, but the duration of each cardiac beat is not entirely the same; sometimes there are wide QRS waves or longer T waves, resulting in varying numbers of sampling points. This can lead to the inability to calculate deformation residuals. Therefore, it is necessary to scale each cardiac beat segment to ensure that the number of sampling points matches that of the QRS keyframe. Scaling can be achieved by adding or deleting values ​​or by proportional scaling, which will not be elaborated upon in this embodiment.

[0089] On the other hand, as one optional embodiment, an ECG data real-time compression system is provided, comprising:

[0090] The R-peak detection module is used to detect the R-peak of the acquired ECG waveform using a sliding window with a fixed window length.

[0091] The signal segmentation module is used to divide the ECG waveform into a heartbeat segment and a heartbeat interval segment based on the R-peak detection result. The first heartbeat segment of the time-series sampling data is the QRS keyframe.

[0092] an encoding module, configured to encode and compress the segmented ECG waveform, specifically by calculating the deformation residual between each current heartbeat segment and its previous heartbeat segment to generate a residual sequence, encoding and outputting the residual sequence, the heartbeat interval segment, and the QRS key frame together, then assembling the output encoding results into compressed data frames in time sequence to generate a compressed code stream.

[0093] Preferably, when encoding the heartbeat interval and the residual sequence, the encoding module uses the Rice encoding method for encoding and output.

[0094] Preferably, the signal segmentation module divides the ECG waveform into heartbeat segments and heartbeat interval segments, wherein the heartbeat segment is a segment that extends from the R point to both ends and contains all waveforms of the entire heartbeat.

[0095] Preferably, the encoding module is further provided with a quantization unit. Before encoding the heartbeat interval and the residual sequence, the integer data sequence is quantized first, and the quantization includes three gears Q1, Q2 and Q3, where the compression ratio satisfies Q1<Q2<Q3, Q1 is a lossless compression gear, and both Q2 and Q3 are lossy compression gears. The residual sequence is compressed and encoded using the Q1 or Q2 gear, and the heartbeat interval segment is compressed and encoded using the Q3 gear.

[0096] Preferably, the signal segmentation module further scales the heartbeat segments to align the sampling points of the remaining heartbeat segments with the sampling points of the QRS key frame.

[0097] The above modules are usually configured in a wearable device capable of collecting ECG signals, such as an electrocardiograph watch, a heart rate patch, and the like. Specifically, these modules are composed of hardware components in the wearable device and embedded software capable of realizing their corresponding functions. The file encoded by the cooperation of each module is stored in the corresponding storage medium in the wearable device, and the file in the storage medium can be transmitted to the far end for decoding through various transmission modes such as wireless / wired transmission for viewing by users or professional interpreters.

[0098] To further demonstrate the feasibility and beneficial effects of the technical solution taught by the present invention, an experimental design specifically for the embodiment scheme is disclosed below.

[0099] The experimental subjects included 17 ECG input windows from real-world wearable devices, of which 8 were single-lead recordings and 9 were multi-lead recordings; the total recording duration was 56,538.72 seconds, or 15.705 hours, equivalent to a lead-hour of 33.705. Document identification indicates that these 17 windows originated from two sets of device recording sequences, obtained by segmenting their respective consecutive recordings; therefore, they cannot be considered as 17 independent subject samples. The current experiment primarily verifies flow cytometry loop closure, compression characteristics, and distortion boundaries on homologous real-world wearable recordings.

[0100] The main experiment employed a fixed 8-second history window and a fixed 1-second push step, performing a total of 56,421 stateful streaming computations. Each computation preserved the encoder state and only output the new closed sample. The experiment also included two all-zero special samples to simulate boundary inputs when the encoder was not worn or had no effective contact. The main statistics only weighted the summaries of 17 real inputs; the all-zero samples were listed separately and not included in the main conclusions. Compression ratio was weighted according to the original byte count of each file; that is, the original byte count and the compressed byte count were summed first, and then the overall compression ratio was calculated. All compressed files were real single-file decodeable bitstreams; therefore, the experiment evaluated both compression ratio and distortion, and verified the closed-loop correctness of the file format and decoding path.

[0101] The table below shows the operating parameters for different compression levels.

[0102] Q1 1 128 Lossless compression Q2 16 128 Medium distortion, balanced compression Q3 32 128 Higher compression ratio allows for larger quantization errors.

[0103] The experimental results are as follows:

[0104] Q1 1.890 0 0 0 0 Q2 3.528 0.447 3.936 4.598 8 Q3 4.437 0.891 7.872 9.170 16

[0105] The weighted summation reflects the overall byte overhead, but it cannot replace the single-file distribution. The range of single-file results on the 17 real inputs is as follows:

[0106] Q1 1.603--2.175 0 Q2 2.629--3.985 0.115--0.708 Q3 3.119--5.179 0.230--1.410

[0107] Therefore, the compression performance mentioned in this embodiment is a weighted result on the current sample set, and does not mean that each input file achieves the same compression ratio or PRD.

[0108] All-zero special samples are used to represent extreme inputs when the device is not worn or when there is no effective contact with the leads. This type of data is not included in the main statistics of actual wear, but its compression ratio can reflect the frame overhead and Rice coding boundary of the method in this embodiment under low-entropy input. Both all-zero inputs are 250 Hz and 900,000 points, that is, each input is 1 h; since the samples are all zero, the sequences before and after quantization are the same for all three levels, so the compression ratio is consistent.

[0109] All-zero single-lead 250 Hz 900000 1 h 15.509 15.509 15.509

[0110] To standardize compression performance metrics, let the original ECG AD integer sequence be A[n], the decoded and reconstructed AD integer sequence be Â[n], and the number of evaluation samples be N. The mean absolute error is defined as:

[0111]

[0112] The root mean square error is defined as:

[0113]

[0114] The maximum absolute error is defined as:

[0115]

[0116] The percentage root mean square difference is defined as:

[0117]

[0118] In this embodiment, the PRD refers to the definition without removing the mean as described above. Let the total number of bits of the original data be B_original, and the total number of bits of the compressed bitstream, including the frame header, block header, Rice parameters, and payload, be B_compressed. Then the compression ratio is defined as:

[0119]

[0120] According to this definition, the quantization step sizes of Q1, Q2, and Q3 increase sequentially, and their experimental compression ratio relationship is CR_Q1. <CR_Q2<CR_Q3。

[0121] like Figure 2 The graph shows the compression ratio-distortion tradeoff at different gears, with the right vertical axis representing the PRD and MAE indicators. The left vertical axis represents the compression ratio indicator. The bar chart in the graph shows the compression ratio at different gears. As can be seen from the graph, even at the Q3 gear, with a compression ratio of 4.437, the PRD is only 0.891%, which satisfies the requirement of a high compression ratio while ensuring a low distortion rate.

[0122] like Figure 3 The image shows the ECG waveforms and errors after compression and decoding at Q2 and Q3 levels. It can be seen that even at Q3, the difference from lossless compression at Q1 is negligible, almost imperceptible, and does not affect the interpretation of the waveforms. That is, in this embodiment, Q3 compression quantization step size can be selected for the same cardiac beat segment. Those skilled in the art can set higher quantization levels if a higher compression ratio is required.

[0123] Furthermore, this embodiment also analyzes the distortion effect under the ECG signal mv error tolerance.

[0124] This embodiment limits the distortion impact analysis to the range of engineering signal fidelity and does not extrapolate to clinical diagnostic conclusions. The evaluation metric uses acceptable error tolerance in the voltage domain, but the conversion from AD count to voltage depends on the range, gain, and calibration coefficients of the specific acquisition hardware. Since the current experimental input file does not carry traceable hardware calibration metadata, this embodiment first provides conditional criteria related to the hardware coefficients, then provides example conversions, without presenting the example values ​​as universal conclusions across all acquisition systems.

[0125] Let α be the voltage coefficient of the calibrated AD converter in the target acquisition hardware, with units of mV / AD, and β be the voltage bias. The original ECG voltage value and the reconstructed ECG voltage value are defined as follows:

[0126]

[0127]

[0128] Since the original and reconstructed values ​​use the same voltage bias, β cancels out in the error calculation, therefore:

[0129]

[0130] The maximum absolute voltage error is:

[0131]

[0132] When using the engineering tolerance error ε_acc for judgment, the following should be satisfied:

[0133]

[0134] This embodiment uses ε_acc = 0.01 mV as the engineering amplitude error threshold. This threshold is only used to evaluate the amplitude disturbance introduced by compression and does not independently prove that the peak position, polarity, or width of morphological characteristics such as R-peaks and T-waves remain unchanged. According to the upper bound of uniform quantization error, the maximum absolute voltage errors corresponding to Q2 and Q3 are respectively:

[0135]

[0136]

[0137] For example, when α ≈ 0.000333 mV / AD, the maximum absolute voltage errors for Q2 and Q3 are approximately 0.0027 mV and 0.0053 mV, respectively, both less than 0.01 mV. This result applies only to the calibration coefficients used; when deploying to other hardware, the actual α of the corresponding device should be recalculated.

[0138] Combination Figure 3 As can be seen, no obvious R peak, T wave polarity, peak position or main width misalignment was observed in Q2 and Q3 within the segment shown. The error is mainly manifested as amplitude disturbance caused by the finite quantization step size.

[0139] The above embodiments are preferred implementations of the present invention. In addition, the present invention can be implemented in other ways. Any obvious substitutions without departing from the concept of the present technical solution are within the protection scope of the present invention.

Claims

1. A method for real-time compression of ECG data, characterized in that: comprising the following steps: S1. Acquire continuously collected ECG waveform signals, where the ECG waveform signals at least include time-series sampling data of one lead; S2. Perform R-peak detection on the collected ECG waveform signals using a sliding window with a fixed window length; S3. According to the detection result of S2, divide the ECG waveform signals in the sliding window into heartbeat segments and heartbeat interval segments, where the first heartbeat segment of the time-series sampling data is a QRS key frame; S4. For the heartbeat segments in the sliding window, calculate the deformation residual between each current heartbeat segment and its previous heartbeat segment to generate a residual sequence, and encode and output the residual sequence, the heartbeat interval segments and the QRS key frame together; S5. Assemble the encoding results output in step S4 into compressed data frames in time sequence to generate a compressed code stream.

2. The real-time compression method for ECG data according to claim 1, characterized in that: In step S4, when encoding the heartbeat interval segments and the residual sequence, a Rice encoding method is used for encoding and output.

3. The real-time compression method for ECG data according to claim 1, characterized in that: In step S3, the ECG waveform signals are divided into heartbeat segments and heartbeat interval segments, where the heartbeat segment is a segment that expands from the R point to both ends and contains the entire full waveform of the heartbeat.

4. The real-time compression method for ECG data according to claim 2, characterized in that: Before encoding the heartbeat interval segments and the residual sequence, the data sequence is first quantized, and the quantization includes three gears Q1, Q2 and Q3, where the compression ratio Q1<Q2<Q3, Q1 is a lossless compression gear, Q2 and Q3 are both lossy compression gears, the residual sequence is compressed and encoded using the Q1 or Q2 gear, and the heartbeat interval segments are compressed and encoded using the Q3 gear.

5. The real-time compression method for ECG data according to claim 1, characterized in that: In step S3, the heartbeat segment is scaled to align the sampling points of the heartbeat segment with those of the QRS key frame.

6. A real-time ECG data compression system, characterized in that: comprising: an R-peak detection module, configured to perform R-peak detection on the collected ECG waveform signals using a sliding window with a fixed window length; a signal segmentation module, configured to divide the ECG waveform signals into heartbeat segments and heartbeat interval segments according to the R-peak detection result, where the first heartbeat segment of the time-series sampling data is a QRS key frame; an encoding module, configured to encode and compress the segmented ECG waveform signals, specifically by calculating the deformation residual between each current heartbeat segment and its previous heartbeat segment to generate a residual sequence, encoding and outputting the residual sequence, the heartbeat interval segments and the QRS key frame together, and then assembling the output encoding results into compressed data frames in time sequence to generate a compressed code stream.

7. The ECG data real-time compression system according to claim 6, characterized in that: When the encoding module encodes the heartbeat interval segments and the residual sequence, a Rice encoding method is used for encoding and output.

8. The ECG data real-time compression system according to claim 6, characterized in that: The signal segmentation module divides the ECG waveform signals into heartbeat segments and heartbeat interval segments, where the heartbeat segment is a segment that expands from the R point to both ends and contains the entire full waveform of the heartbeat.

9. The ECG data real-time compression system according to claim 7, characterized in that: The encoding module is further provided with a quantization unit, which quantizes the integer data sequence before encoding the heartbeat intervals and the residual sequence, the quantization includes three gears Q1, Q2 and Q3, where the compression ratio Q1<Q2<Q3, Q1 is a lossless compression gear, Q2 and Q3 are both lossy compression gears, the residual sequence is compressed and encoded using the Q1 or Q2 gear, and the heartbeat interval segments are compressed and encoded using the Q3 gear.

10. The ECG data real-time compression system according to claim 6, characterized in that: The signal segmentation module further scales the heartbeat segments to align the remaining heartbeat segments with the sampling points of the QRS keyframes.