Disclosure of Invention
The invention aims to provide an ECG display filtering method, an ECG display filtering device and a storage medium, which are used for carrying out wavelet decomposition on an ECG original signal, reconstructing a processed multiscale stable wavelet coefficient into a new ECG signal, greatly enhancing the quality of an ECG display waveform on the premise of not losing useful signals, better highlighting the P wave, improving the R wave and the T wave and inhibiting motion artifacts.
The invention is realized by the following technical scheme:
in one aspect, the invention discloses an ECG display filtering method, comprising the following steps:
performing multi-scale stable wavelet decomposition on an original ECG signal with a sampling rate of Fs to obtain wavelet coefficients on each scale, wherein the wavelet coefficients on each scale comprise wavelet coefficients decomposed by frequency band signals below 1Hz, and the sampling rate of Fs is more than or equal to 128Hz; and (3) carrying out the following treatment on each scale wavelet coefficient decomposed in the steps: and (3) carrying out the following treatment on each scale wavelet coefficient decomposed in the steps: filtering baseline interference and MA motion artifact interference from low-frequency signals below 1Hz by adopting a first threshold filtering mode; performing second threshold filtering processing on wavelet coefficients of each layer generated by decomposing an intermediate frequency signal with a valid signal; setting all wavelet coefficients of each layer generated by decomposing high-frequency signals with high-frequency noise and myoelectricity interference to zero; reconstructing the processed multiscale stationary wavelet coefficient into a new ECG signal for output and display.
Preferably, the method for filtering the low-frequency signals below 1Hz by adopting the first threshold value is as follows: and determining a threshold Th=mean (x) +/-mse (x) for the wavelet coefficients generated by decomposing the low-frequency signals below 1Hz, wherein the wavelet coefficients with absolute values larger than the threshold Th are set to be zero, mean (x) is the mean value of the x-Th layer wavelet, and mse is the mean square error of x.
Preferably, a multi-scale stationary wavelet decomposition is performed on the raw ECG signal.
Preferably, the raw ECG signal undergoes a multi-scale stationary wavelet decomposition using a wavelet filter function that is a sym4 wavelet function.
Further preferably, the second threshold filtering processing method is performed on each layer of wavelet coefficients generated by decomposing the intermediate frequency signal with the effective signal: the filtering is carried out by using an improved threshold method with the threshold value f1, wherein the improved threshold method is to set the wavelet coefficient with the absolute value smaller than or equal to the threshold value to zero, the wavelet coefficient with the absolute value larger than the threshold value is not processed, and then a smooth transition zone is added at the cut-off position of the waveform.
In another preferred embodiment, the second threshold filtering method for each layer of wavelet coefficients generated by decomposing an intermediate frequency signal with a valid signal includes the following steps: detecting all R-wave positions within the ECG signal; setting a maximum PR interval, and filtering by adopting an improved threshold method with a threshold value of f2 in the PR interval; and filtering in other time intervals by adopting an improved threshold method with a threshold value of f1, wherein f2 is less than f1, the improved threshold method is that the wavelet coefficient smaller than or equal to the threshold value is set to zero, the wavelet coefficient larger than the threshold value is not processed, and then a smooth transition zone is added at the cut-off position of the waveform.
In a second aspect, the invention discloses an ECG display filter device comprising
Wavelet decomposition module: the method comprises the steps of performing multi-scale stable wavelet decomposition on an original ECG signal with a sampling rate of Fs to obtain wavelet coefficients on each scale, wherein the wavelet coefficients on each scale comprise wavelet coefficients decomposed by frequency band signals below 1Hz, and the sampling rate of Fs is more than or equal to 128Hz; wavelet layering processing module: the wavelet coefficients of each scale, which are decomposed by the wavelet decomposition module, are processed as follows: filtering baseline interference and MA motion artifact interference from low-frequency signals below 1Hz by adopting a first threshold filtering mode; performing second threshold filtering processing on wavelet coefficients of each layer generated by decomposing an intermediate frequency signal with a valid signal; setting all wavelet coefficients of each layer generated by decomposing high-frequency signals with high-frequency noise and myoelectricity interference to zero; and an output display module: for reconstructing the processed multiscale stationary wavelet coefficients into a new ECG signal output and display.
Corresponding to the second aspect, the method for adopting the first threshold filtering to the low-frequency signals below 1Hz is as follows: the method for filtering the low-frequency signal with myoelectricity interference below 1Hz by adopting the first threshold value comprises the following steps: and determining a threshold Th=mean (x) +/-mse (x) for the wavelet coefficients generated by decomposing the low-frequency signals below 1Hz, wherein the wavelet coefficients with absolute values larger than the threshold Th are set to be zero, mean (x) is the mean value of the x-Th layer wavelet, and mse is the mean square error of x.
Corresponding to the second aspect, the second threshold filtering processing method for each layer of wavelet coefficients generated by decomposing the intermediate frequency signal with the effective signal comprises the following steps: detecting all R-wave positions within the ECG signal; setting a maximum PR interval, and filtering by adopting an improved threshold method with a threshold value of f2 in the PR interval; filtering other time periods by adopting an improved threshold method with a threshold value of f 1; wherein f2 is less than f1, the improved threshold method is to set the wavelet coefficient with the absolute value smaller than or equal to the threshold value to zero, the wavelet coefficient with the absolute value larger than the threshold value is not processed, and then a smooth transition zone is added at the cut-off position of the waveform.
In a third aspect, the present invention discloses a computer storage medium for storing computer program instructions for any of the ECG display filtering devices described above, the computer program instructions being executed by a processor to implement the module functions of the ECG display filtering device.
Compared with the prior art, the invention has the following advantages and beneficial effects:
1. the invention carries out multiscale stable wavelet decomposition on the ECG original signal, then reconstructs the processed multiscale stable wavelet coefficient into a new ECG signal, greatly enhances the quality of the ECG display waveform on the premise of not losing useful signals, better highlights P waves, improves R waves and T waves and inhibits motion artifacts.
2. In the method for carrying out the first threshold filtering on the wavelet coefficient generated by decomposing the low-frequency signal with myoelectricity interference below 1Hz, the baseline interference and MA motion artifact interference in the low-frequency signal are filtered; in the method for carrying out the second threshold filtering on the wavelet coefficient generated by the intermediate frequency signal decomposition with the effective signal, only the power frequency interference and the myoelectric interference are filtered, but the high-frequency MA motion artifact with extremely high similarity with the PVC waveform is not processed, the quality of the ECG display waveform is greatly enhanced, the P wave is better highlighted, the R wave and the T wave are improved, and the motion artifact is restrained on the premise of not losing the effective signal.
Sym4 may better graft the pseudo-Gibbs effect.
Detailed Description
For the purpose of making apparent the objects, technical solutions and advantages of the present invention, the present invention will be further described in detail with reference to the following examples and the accompanying drawings, wherein the exemplary embodiments of the present invention and the descriptions thereof are for illustrating the present invention only and are not to be construed as limiting the present invention.
In the description of the present invention, the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In the description of the present invention, the term SWT (Stationary Wavelet Transformation) is either a stationary wavelet transform, or a static wavelet transform; the term DWT (Discrete Wavelet Transformation) is a discrete wavelet transform. Both SWT and DWT are methods for wavelet decomposing the original waveform. The term Motion Artifacts (Motion Artifacts) in the description of the invention is a common broadband noise interference in an ECG signal, and the low-frequency interference in the invention has larger interference on a filtering result, so the scheme focuses on the processing of the low-frequency Motion Artifacts MA, and generally, during signal acquisition, the Motion Artifacts MA are generated due to the non-forced Motion of a tested person. P-R interval in the present invention: refers to the time in the electrocardiogram from the beginning of atrial depolarization to the beginning of ventricular depolarization.
Electrocardiography (ECG) is a powerful non-invasive tool that allows diagnosis of various heart diseases. There are a variety of portable electrocardiographic recording devices today that are capable of acquiring ECG signals and are equipped with transmitters that provide remote health related information monitoring by wireless communication and triggering alarms in the event of life threatening events. However, for acquiring recorded ECG signals, the simple movements of the patient can generate obvious artifacts, and these portable electrocardiograph recording devices are susceptible to motion-induced artifacts, and although a great deal of research has been done to eliminate time-invariant noise, motion-induced artifacts, namely "motion artifacts MA (Motion Artifacts)", remain, which result in poor quality of ECG waveforms acquired and transmitted by the electrocardiograph recording device, and remote monitoring makes decisions based on poor quality ECG waveforms, and is prone to errors, thereby resulting in triggering alarm errors. Additionally, a skewed baseline on the ECG waveform may also have an impact on the P-wave display.
In order to solve the problem that the P-wave display is not obvious due to poor quality of an ECG waveform caused by motion artifact MA and an inclined baseline, as shown in figures 1-5, the invention discloses an ECG display filtering method, which comprises the following steps:
step S1: performing multi-scale stable wavelet decomposition on an original ECG signal with a sampling rate of Fs to obtain wavelet coefficients on each scale, wherein the wavelet coefficients on each scale comprise wavelet coefficients decomposed by frequency band signals below 1Hz, and Fs is more than or equal to 128Hz;
for example, when the sampling rate Fs is 511Hz, the original ECG signal may be subjected to multi-scale smooth wavelet decomposition by using SWT, DWT or other methods to decompose 9 layers of wavelet coefficients, that is, wavelet coefficients decomposed by a frequency band signal below 1Hz, that is, a 0-1Hz frequency band signal and wavelet coefficients of each layer of wavelet, and all the approximate wavelet coefficients a9 (0-0.5 Hz) and part of the detailed wavelet coefficients d9 (0.5-1 Hz) of the 9 th layer of wavelet coefficients are used as low-frequency base lines and motion artifact interference; when the sampling rate Fs is 256Hz, the original ECG signal may be subjected to multi-scale smooth wavelet decomposition by using SWT, DWT or other methods, and the wavelet coefficients including the wavelet coefficients decomposed by the frequency band signal below 1Hz, that is, the wavelet coefficients of the 0-1Hz frequency band signal and each layer of wavelet, are obtained by decomposing 8 layers of wavelet coefficients, and the 8 th layer of wavelet coefficients are divided into all approximate wavelet coefficients a8 (0-0.5 Hz) and part of detail wavelet coefficients d8 (0.5-1 Hz) as low-frequency baseline and motion artifact interference, and then the part of interference is removed in a targeted manner in the following steps. The sampling rate Fs may also take any other value, and when the values are different, the number of the decomposed wavelet layers and the obtained frequency band range containing the wavelet coefficients decomposed by the frequency band signal below 1Hz are different, and corresponding processing is required according to the concept of the invention according to the actually obtained frequency band.
Step S2: and (3) carrying out the following treatment on each scale wavelet coefficient decomposed in the steps: filtering baseline interference and MA motion artifact interference from low-frequency signals below 1Hz by adopting a first threshold filtering mode; performing second threshold filtering processing on wavelet coefficients of each layer generated by decomposing an intermediate frequency signal with a valid signal; setting all wavelet coefficients of each layer generated by decomposing high-frequency signals with high-frequency noise and myoelectricity interference to zero;
for example, when the sampling rate Fs is 512Hz, the wavelet coefficients of the original ECG signal on each scale include the wavelet coefficients decomposed by the frequency band signal below 1Hz, and the original ECG signal needs to be decomposed into 9 layers, wherein the wavelet coefficients decomposed by the frequency band signal below 1Hz of the low-frequency signal, that is, the wavelet coefficients decomposed by the frequency band signal below 0-1Hz are filtered in a first threshold filtering manner, so as to filter baseline interference and MA motion artifact interference in the frequency band signal below 0-1 Hz; performing second threshold filtering processing on wavelet coefficients of each layer generated by decomposing an intermediate frequency signal with the effective signal at 1-64 Hz; setting all wavelet coefficients of each layer generated by decomposing high-frequency signals above 64Hz to zero; the sampling rate Fs may take other values, and if the values are different, the intervals of the low-frequency signal, the intermediate-frequency signal and the high-frequency signal are different, but the interval of the low-frequency signal is the wavelet coefficient decomposed by the frequency band signal below 1Hz, the interval of the intermediate-frequency signal with the effective signal is determined by the skilled person by reserving the acquired data according to the need, and the remaining interval is the high-frequency signal interval.
The method for filtering the low-frequency signals below 1Hz by adopting the first threshold value comprises the following steps: and determining a threshold Th=mean (x) +/-mse (x) for the wavelet coefficients generated by decomposing the low-frequency signals below 1Hz, wherein the wavelet coefficients with absolute values larger than the threshold Th are set to be zero, mean (x) is the mean value of the x-Th layer wavelet, and mse is the mean square error of x.
By the method, myoelectricity interference and MA motion artifact interference of low-frequency signals can be filtered on the premise of no loss of useful signals.
The method for performing the second threshold filtering processing on the wavelet coefficients of each layer generated by decomposing the intermediate frequency signal with the effective signal can be the same as or different from the first threshold filtering method, and the method for performing the second threshold filtering processing on the wavelet coefficients of each layer generated by decomposing the intermediate frequency signal with the effective signal comprises the following steps: the filtering is carried out by using an improved threshold method with the threshold value f1, wherein the improved threshold method is to set the wavelet coefficient smaller than or equal to the threshold value to zero, the wavelet coefficient larger than the threshold value is not processed, and then a smooth transition zone is added at the cut-off position of the waveform.
Taking Fs as 512Hz as an example to illustrate, removing MA motion artifact interference and baseline interference with larger amplitude for a low-frequency signal with myoelectricity interference in a 0-1Hz frequency band by adopting a first threshold filtering idea, determining a threshold Th, considering that the wavelet coefficient with the absolute value larger than the threshold is generated by MA and low-frequency baseline decomposition, carrying out zero setting operation on the part of wavelet coefficient to achieve the effect of completely removing broadband motion artifact, leveling the inclined baseline, removing baseline interference, obtaining a filtered signal which is more stable than the original signal, greatly reducing the influence of interference of low-frequency noise, improving the quality of a display waveform of an ECG after filtering, greatly enhancing the quality of the display waveform of the ECG on the premise of not losing useful signals, better highlighting P waves, improving R waves and T waves and inhibiting the motion artifact.
For the 1-64Hz medium-frequency ECG signal with effective signals, effective PVC waveforms, high-frequency MA motion artifacts and power frequency interference are mixed, the PVC waveforms and the high-frequency MA motion artifacts in the ECG signal are hardly distinguished, and in order to avoid mistakenly killing normal waveforms of diseases, the scheme selects to process only the power frequency interference and the myoelectric interference of the frequency band, but not the high-frequency MA motion artifacts with extremely high similarity with the PVC waveforms.
The power frequency interference is generated because the electrocardiosignals acquired by the sensors on the portable electrocardio recording equipment are superimposed with the power frequency interference, the power frequency interference is human myoelectric interference, respiratory interference, thermal noise and the like, if the power frequency interference is not removed, the final waveform quality is affected, and when the myoelectric interference is strong, the wavelet coefficient amplitude of the P wave is close to or smaller than the wavelet coefficient of the myoelectric interference, the single threshold cannot be effectively distinguished, and in order to avoid false killing of normal waveforms of diseases and enhance the quality of ECG display waveforms, a second threshold filtering processing mode is adopted for 1-64Hz frequency band intermediate frequency signals. The reference value to diseases for signals in the frequency band above 64Hz is not high, so that the signals can be directly filtered out.
Step S3: reconstructing the processed multiscale stationary wavelet coefficient into a new ECG signal for output and display.
According to the scheme, wavelet decomposition is carried out on an ECG original signal to obtain wavelet coefficients of each layer of wavelet, then the processed multi-scale stable wavelet coefficients are reconstructed into new ECG signals, the quality of an ECG display waveform is greatly enhanced on the premise that useful signals are not lost, P waves are better highlighted, R waves and T waves are improved, and motion artifacts are restrained.
As shown in fig. 4, in the figure, K1 is an original ECG waveform, K2 is a waveform obtained by processing an ECG signal by adopting the scheme, K3 is a waveform obtained by processing an ECG signal by adopting a conventional method, a circled part in the figure is a waveform for protecting diseases such as R wave, P wave, T wave and PVC, and comparing the waveforms of K2 and K3, it is known that the waveform of K2 can better highlight the R wave, P wave and T wave, and can also protect special waveforms related to diseases such as PVC. As shown in fig. 5, in the figure, K1 is a typical original ECG signal waveform with motion artifact, K2 is a waveform obtained by processing an ECG signal by adopting the scheme, and K3 is a waveform obtained by processing an ECG signal by adopting the conventional method, and it is known from the figure that the processed K2 waveform is more stable than a K3 waveform baseline, and when K2 processes low-frequency interference such as motion artifact, compared with the conventional algorithm, the effect is obvious, the interference caused by the baseline is smaller, and the waveform quality is higher.
In another embodiment, as shown in fig. 2, the second threshold filtering processing method for each layer of wavelet coefficients generated by decomposing an intermediate frequency signal with a valid signal includes the following steps:
step S101: detecting all R-wave positions within the ECG signal; because the P wave only appears in the P-R interval, and the probability of the occurrence of the P wave is greatly higher than the probability of the occurrence of the low frequency of the electromyographic signals in a period of time of the R wave front surface, a smaller threshold f1 is adopted to reserve the P wave to the maximum extent in a certain period of time of the R wave front surface, and a larger threshold f2 is adopted in other places to remove the electromyographic noise to the maximum extent. Namely, in the P-R interval, the threshold value can be reduced in a targeted manner to reserve the P wave signal to the maximum extent, so that the false killing of useful waveforms is avoided, then in the non-P-R interval, the threshold value is increased in a targeted manner to maximally filter electromechanical interference, and on the premise of not false killing of useful waveforms, the quality of the ECG display waveforms is further enhanced, the P wave is better highlighted, and meanwhile, the problem of highlighting of R waves and T waves is also improved.
Step S102: setting a maximum PR interval, and filtering by adopting an improved threshold method with a threshold value of f1 in the PR interval; filtering is carried out in other periods by adopting an improved threshold method with a threshold value of f2, the calculation methods of the thresholds f1 and f2 are the same as the threshold calculation method in the first threshold filtering treatment, the threshold value f1=f2=sqrt (2×log (length)) sigma of noise is estimated according to median variance, the sigma represents noise variance, sqrt represents open root number, and length represents wavelet coefficient length; sigma=media (abs (b))/k, abs represents taking absolute value, b represents the coefficient of the first layer, media represents taking median value, adjusting coefficient k is set for threshold value to adjust filtering range, k takes value between 0.5-1, f1 < f2, the improved threshold method is to set wavelet coefficient smaller than or equal to threshold value to zero, wavelet coefficient larger than threshold value is not processed, and then smooth transition zone is added at cut-off position of waveform.
In another embodiment, the raw ECG signal is preferably subjected to SWT multiscale stationary wavelet decomposition. Other ways of wavelet decomposition may be chosen, except that this method is not as good. First, since SWT is a shift invariant to the time domain signal, which is critical for detecting specified signal components (motion-induced artifacts MA, outliers, and QRS complexes), it is well suited for ECG signal de-agitation. Secondly, in the wavelet decomposition process of the SWT, the extraction conversion algorithm is omitted from each level coefficient, so that more sample coefficient sequences are available, and abnormal value detection can be better executed. These advantages allow the same number of layers of wavelet decomposition to be performed on the same signal, and SWT calculation is more efficient than other algorithms.
In another embodiment, the raw ECG signal is subjected to a multi-scale stationary wavelet decomposition (SWT) using a wavelet filter function that is a sym4 wavelet function. The wavelet coefficient obtained by the function has a good inhibition effect on the Gibbs effect, and improves the quality of the displayed ECG waveform.
In another embodiment, as shown in fig. 3, the invention also discloses an ECG display filtering device, which comprises a controller, a memory, a wavelet decomposition module, a wavelet layering processing module and an output display module, wherein the memory is simultaneously connected with the controller;
the wavelet decomposition module: the method comprises the steps of performing multi-scale stable wavelet decomposition on an original ECG signal with a sampling rate of Fs to obtain wavelet coefficients on each scale, wherein the wavelet coefficients on each scale comprise wavelet coefficients decomposed by frequency band signals below 1Hz, and the sampling rate of Fs is more than or equal to 128Hz;
wavelet layering processing module: the wavelet coefficients of each scale, which are decomposed by the wavelet decomposition module, are processed as follows: filtering baseline interference and MA motion artifact interference from low-frequency signals below 1Hz by adopting a first threshold filtering mode; performing second threshold filtering processing on wavelet coefficients of each layer generated by decomposing an intermediate frequency signal with a valid signal; setting all wavelet coefficients of each layer generated by decomposing high-frequency signals with high-frequency noise and myoelectricity interference to zero;
and an output display module: for reconstructing the processed multiscale stationary wavelet coefficients into a new ECG signal output and display
The method for filtering the low-frequency signals below 1Hz by adopting the first threshold value comprises the following steps: the method for filtering the low-frequency signal with myoelectricity interference below 1Hz by adopting the first threshold value comprises the following steps: and determining a threshold Th=mean (x) +/-mse (x) for the wavelet coefficients generated by decomposing the low-frequency signals below 1Hz, wherein the wavelet coefficients with absolute values larger than the threshold Th are set to be zero, mean (x) is the mean value of the x-Th layer wavelet, and mse is the mean square error of x.
The second threshold filtering processing method for each layer of wavelet coefficient generated by decomposing the intermediate frequency signal with the effective signal comprises the following steps:
detecting all R-wave positions within the ECG signal;
setting a maximum PR interval, and filtering by adopting an improved threshold method with a threshold value of f2 in the PR interval; filtering other time periods by adopting an improved threshold method with a threshold value of f 1;
wherein f2 is less than f1, the improved threshold method is to set the wavelet coefficient with the absolute value smaller than or equal to the threshold value to zero, the wavelet coefficient with the absolute value larger than the threshold value is not processed, and then a smooth transition zone is added at the cut-off position of the waveform.
In another embodiment, the invention also discloses a computer storage medium for storing computer program instructions for any of the ECG display filtering devices described above, the computer program instructions being executed by a processor to implement the module functions of the ECG display filtering device.
In summary, the invention discloses a method, a device and a storage medium for ECG display filtering, which are used for carrying out multi-scale stable wavelet decomposition on an ECG original signal, then carrying out different processing on each layer of wavelet coefficient and then inversely transforming the waveform back, thereby greatly enhancing the quality of the ECG display waveform on the premise of not losing useful signals, better highlighting P waves, improving R waves and T waves and inhibiting motion artifacts. According to the prior device, the scheme, the device, the storage medium or the method, the front-back comparison diagram of the ECG signal shown in the figures 4-5 is obtained, and the quality of the ECG display waveform is greatly enhanced, the P wave is better highlighted, the R wave and the T wave are improved, and the motion artifact is restrained on the premise of not losing useful signals according to the diagram.
It will be understood by those skilled in the art that all or part of the steps in implementing the methods of the above embodiments may be implemented by hardware, or may be implemented by a program to instruct related hardware, where the program may be stored in a computer readable storage medium, and the program may include the flow of the embodiments of the methods as described above when executed. The storage medium may be a read-only memory, a random access memory, a magnetic disk or an optical disk.
The foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the scope of the invention, but to limit the invention to the particular embodiments, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the invention are intended to be included within the scope of the invention.