 Research article
 Open Access
 Published:
An effective frequencydomain feature of atrial fibrillation based on time–frequency analysis
BMC Medical Informatics and Decision Making volume 20, Article number: 308 (2020)
Abstract
Background
Atrial fibrillation is a type of persistent arrhythmia that can lead to serious complications. Therefore, accurate and quick detection of atrial fibrillation by surface electrocardiogram has great importance on further treatment. The practical electrocardiogram signals contain various interferences in different frequencies, such as myoelectricity interference, power interference and so on. Detection speed and accuracy largely depend on the atrial fibrillation signal features extracted by the algorithm. But some of the discovered atrial fibrillation features are not well distinguishable, resulting in poor classification effect.
Methods
This paper proposed a high distinguishable frequency feature—the frequency corresponding to the maximum amplitude in the frequency spectrum. We used the R–R interval detection method optimized with the mathematical morphology method and combined with the wavelet transform method for analysis. According to the two features—the maximum amplitude in the frequency spectrum and R–R interval irregular, we could recognize atrial fibrillation signals in electrocardiogram signals by decision tree classification algorithm.
Results
The data used in the experiment come from the MITBIH database, which is publicly accessible via the web and with ethical approval and consent. Based on the input of timedomain and frequencydomain features, we classified sinus rhythm signals and AF signals using the decision tree generated by classification and regression tree (CART) algorithm. From the confusion matrix, we got the accuracy was 98.9%, sensitivity was 97.93% and specificity was 99.63%.
Conclusions
The experimental results can prove the validity of the maximum amplitude in the frequency spectrum and the practicability and accuracy of the detection method, which applied this frequencydomain feature. Through the detection method, we obtained good accuracy of classifying sinus rhythm signals and atrial fibrillation signals. And the sensitivity and specificity of our method were pretty good by comparison with other studies.
Background
Atrial fibrillation (AF) is the most common arrhythmia, with a prevalence rate of 1.5% to 2% in developed countries [1]. When AF occurs, the regular order of atrial electrical activity disappears, replaced by the fast and disorderly tremor waves, and the atrial electrical activity is seriously disordered. Patients with AF are often accompanied by symptoms such as palpitations, arrhythmia, shortness of breath, and chest pain. The incidence of AF increases with age, and the most serious complication is stroke. Early diagnosis can effectively reduce the incidence of complications caused by AF.
An electrocardiogram (ECG) is a technique that uses a medical device to collect and record a pattern of changes in activity produced by the heart. Compared with other bioelectrical signals, ECG signals are easier to monitor and have morphological regularity. Typical ECG signals mainly include P wave, Q wave, R wave, S wave, and T wave, as shown in Fig. 1. When AF occurs, the original normal Pwaves disappear and are replaced by a series of irregular highfrequency oscillations called Fwaves; the distance between R waves varies irregularly. The above two features have become the basis of the current automatic detection AF technology [2].
The current diagnosis of AF relies primarily on the presence of some typical symptoms of the patient and the characteristics of the ECG recording. However, early and accurate detection of AF remains a challenge. The detection of asymptomatic paroxysmal AF needs about 72h ECG signals [3]. Therefore, it is valuable to develop an automatic detection algorithm that can diagnose AF quickly, accurately and reliably [2]. It is also of great significance to explore effective and high distinguishable features of atrial fibrillation to realize the automatic detection of atrial fibrillation.
Moody et al. proposed an automatic method for detecting AF based on the difference between the AF signal and the sinus rhythm signal in the RR interval [4]. Tateno et al. proposed a method based on the coefficient of variation and density histograms of RR and ΔRR intervals [5]. They identify the difference between sinus rhythm signal and AF signal by using the Kolmogorov–Smirnov test. These studies based on the RR interval achieved 97% accuracy of automatic detection. Using empirical mode decomposition, Uday Maji et al. found significant differences in the fourth layer intrinsic mode function (IMF4), with an accuracy of 96% [6].
Recently, some scholars have regarded AF as an abnormal phenomenon and analyzed it as a signal abnormality. Paolo Massimo Buscema et al. [7] proposed to apply an improved Back Propagation neural network for the diagnosis of AF. This method used a Supervised Contractive Map neural network structure and achieved the diagnosis of AF with an accuracy rate of 95%. He Runnan et al. [8] proposed a way of detecting AF based on Continuous Wavelet Transform(CWT) and twodimensional convolutional neural network by analyzing ECG’s overall time–frequency features. Asgari et al. [9] applied wavelet transform to extract peaktoaverage power ratio and logarithmic energy entropy as feature vectors for AF detection.
Common methods to extract F wave include the QRST cancellation method, ICA analysis method based on principal component analysis, etc. The QRST cancellation method is very sensitive to the change of waveform and greatly depends on the quality of Fwave extraction. The method in this paper focused on the ECG signals’ frequencydomain feature. By analyzing the decomposition results of each layer of the wavelet transform, we got an effective frequencydomain feature and used the feature as one of the bases for detecting AF. This method did not depend on the extraction of F waves. Simultaneously, our detection results had good accuracy, sensitivity, and specificity.
Methods
Outline of ECG processing methods
First of all, we removed the highfrequency noise and baseline drift of the ECG signal by filtering. Then the ECG signal was segmented by 5 s to detect the R wave peaks of each period. In this way, we could extract the mean and variance of the R–R interval, which could identify the degree of regularity of the R–R interval and obtain the time domain characteristics of the ECG signals. Next, the filtered signal was segmented according to R peak to obtain a singleperiod signal waveform. Then we decomposed the singleperiod signal waveform by wavelet transform. And we reconstructed the characteristic waveform by the approximate decomposition coefficients of the fourth layer. Furthermore, we obtained the frequency corresponding to the maximum amplitude in the frequency spectrum (MAiFS) by fast Fourier transform of the characteristic waveform. Thus we gained the frequency domain feature of the ECG signals. The above two types of features were used as the finally extracted AF signal features. And using the decision tree classification algorithm to detect AF. Finally, we proved the validity of the extracted frequencydomain features and obtained the accuracy, sensitivity, and specificity of the detection method of AF through the MITBIH AF dataset. The processes of the method are shown in Fig. 2.
Timedomain features extraction method
Mathematical morphology filtering
Mathematical morphology [10] is an image analysis discipline based on lattice theory and topology. The basic operations include corrosion and expansion.
Let \({\text{f}}\left( {\text{n}} \right),\left( {{\text{n}} = 0,1,...,{\text{N}}  1} \right)\) and \({\text{g}}\left( {\text{m}} \right),{ }\left( {{\text{m}} = 0,1, \ldots ,{\text{M}}  1} \right)\), among them \({\text{N}} \gg {\text{M}}\). \({\text{g}}\left( {\text{m}} \right)\) is the structural element of the morphological filter. The selection of \({\text{g}}\left( {\text{m}} \right)\) should be similar to the shape of the preserved waveform and different from the shape of the filtered waveform. To preserve the Rwave and filter out other waveforms, we chose the structural element \({\text{g}}\left( {\text{m}} \right) = \left\{ {1,1,1} \right\}\).
Corrosion operation is defined as
Expansion operation is defined as
Because of corrosion operation and expansion operation have time sequence, mathematical morphology gives two different morphological operations. Corrosion first followed by expansion is defined as an open operation and expansion first followed by corrosion as a closed operation. Defining \({\text{f}}({\text{n}})\) on \({\text{g}}({\text{n}})\) open operation
\({\text{f}}({\text{n}})\) on \({\text{g}}({\text{n}})\) closed operation is defined as
Through mathematical analysis, it can be proved that the morphological opening operation can flatten the peak and the closed operation can fill the trough. For ECG signals, the waveforms except the R wave can be flattened by the mathematical morphology operation.
Shannon energy envelope
Considering that the ECG signal fluctuates greatly near the R wave and according to the Shannon energy function [11], the response to the low amplitude is weak in the range of (0,1), and the response to the high amplitude is strong. We performed derivative and normalization on the filtered signal. Then the resulting function values were smoothly enveloped by a moving average method. The range of (0,1) means the normalized amplitude and is unitless.
\({\text{d}}\left( {\text{n}} \right)\) is the derivative of the ECG signal. The Shannon energy operation is defined as
To prevent signal signature delays during smoothing, we used a sliding mean filter without phase shift
If window overflow occurs in the head or tail segment of the signal, making \(\min (1,{\text{n}}  \frac{{{\text{N}}  1}}{2})\) and \(\max ({\text{L}}\left( {{\text{signal}}} \right),{\text{n}} + \frac{{{\text{N}}  1}}{2})\) do some appropriate changes. The N in the denominator of the formula should be appropriately adjusted. L is the length of the signal.
Through the Shannon energy envelope, we obtained the specific position of R peak. Simultaneously, the refractory period is set after each R peak detection. In the refractory period, even if there is a peak in the signal, it is not considered to be an R peak. In this test model, the refractory period was set to 200 ms.
Frequency domain feature extraction method
Wavelet transform (WT) [12] is a powerful technology for representing a signal in different translations and scales. In practical applications, since the ECG signal is a shortterm nonstationary random process, the Fourier transform based on the stationary stochastic process cannot reflect the essential characteristics of AF. The wavelet transform analysis method provides the possibility of extracting nonstationary random signal features.
Wavelet transform theory
For any signal \(f(t) \in L^{2} (T)\), the wavelet transform is
where \(\psi ({\text{t}})\) is a mother wavelet, \({\text{a}}\) is the dilation factor and b is the translation factor. Different frequency and time localizations can be achieved by adjusting a and b.
Since the ECG signal is stored in the form of discrete finitelength signals, continuous wavelet changes must be discretized for ease of calculation. Usually, the discrete formula of the dilation factor and the translation factor in the continuous wavelet transform is taken as: \({\text{a}} = {\text{a}}_{0}^{{\text{m}}}\), \({\text{b}} = {\text{na}}_{0}^{{\text{m}}} {\text{b}}_{0}\), where \({\text{m}},{\text{n}} \in {\text{Z}}\), \({\text{a}}_{0} \ne 1\). The corresponding discrete wavelet function can be expressed as
At this point, the discrete wavelet transform of f(t) is
Its reconstruction formula is
Mallat algorithm
Multiresolution analysis constructs a series of orthogonal function spaces to decompose the sequence into a lowfrequency signal and a series of highfrequency signals (the number of highfrequency signals depends on the number of decomposition layers). As for discretetime signals, the dyadic discrete wavelet transform (DWT) can be implemented by lowpass, h(n), and highpass, g(n), filters [13]. The Mallat algorithm is a fast algorithm for constructing orthogonal wavelets. The recursive formula of the decomposition can be expressed as
where \({\text{CA}}_{{\text{j}}}\) and \({\text{CD}}_{{\text{j}}}\) are respectively column vector forms of wavelet coefficients, and H and G are respectively a matrix composed of lowpass filtering and highpass filter coefficients of the corresponding filter. j is the number of decomposition layers of the wavelet transform.
The signal reconstruction process can be expressed as
It can be seen that the essence of the wavelet transform is a filtering process. The obtained approximate coefficients represent the lowfrequency characteristics of the signal, and the detail coefficients represent the highfrequency characteristics of the signal. Through the wavelet transform, we can focus on the frequency characteristics of a certain frequency band of the ECG signal. We decomposed the ECG signal by wavelet, and reconstruct signals by using the data of each frequency band after decomposition. Then we analyzed the frequency domain characteristics of ECG signals by reconstructed signals. Therefore, the wavelet transform can be used to analyze the ECG signal and extract the frequency domain features of AF.
Results
Data source and preprocessing
The data used in the experiment comes from the MITBIH database [4], which is publicly accessible via the web and with ethical approval and consent. The dataset contains 23 annotated ECG records, each of which is approximately 10 h with a sampling rate of 250 Hz and a 12bit resolution with a range of 10mv. Each record contains two signals, ECG1 and ECG2. In this study, we used ECG1 to do these experiments. The preprocessing was divided into two steps: splitting the signal and filtering. The splitting signal was to divide the input ECG signal into segments of 5 s for subsequent processing. Filtering was to design an FIR digital filter by using a window function method and filtering the ECG signal. Its cutoff frequency was set to 0.5 Hz and 30 Hz. The purpose of setting a cutoff frequency to 30 Hz was to eliminate electromyography interference and 50 Hz frequency interference. The purpose of setting a cutoff frequency of 0.5 Hz was to eliminate human respiration, movement of the electrode and other lowfrequency interference. The results were shown in Fig. 3.
Timedomain feature extraction
As the mean and variance of R–R interval can represent the regularity of ECG signal in different conditions, the mean and variance of R–R interval in sinus rhythm and AF were taken as timedomain features in this paper. The processes can be divided into three steps: mathematical morphological filtering, determining the Rwave position by using the fragrance energy envelope, extracting Rwave waveform and analyzing timedomain features.
Firstly, the preprocessed ECG signal is filtered by mathematical morphology. The result is shown in Fig. 4.
Then we used Shannon energy calculation for further activation and zero phase shift envelope to extract the envelope curve peak and get R wave position, as shown in Fig. 5.
After the detection of R waves from sinus rhythm and AF signal segments, we carried on a statistical analysis of mean value, variance and number of R waves of R–R interval. The results were shown in Fig. 6.
Frequency domain feature extraction
The processes of extracting frequencydomain feature can be divided into three steps: performing fourlayer wavelet decomposition, reconstructing based on the fourth layer, performing Fast Fourier Transform and marking the maximum amplitude in the frequency spectrum (MAiFS).
The fourth layer discrete wavelet transform is performed on a single waveform. And we obtained the subband signal bandwidth (as shown in Table 1) after decomposition. The sampling frequency is 250 Hz.
After using the Fast Fourier transform, the subband signals of this waveform were shown in Fig. 7 and it could be seen that the frequency distribution of each subband signal was consistent with that shown in Table 1.
Then we decomposed the AF signal and sinus rhythm signal according to the frequency range of each subband. The results were shown in Figs. 8 and 9.
Next, we used approximate decomposition coefficients of the fourth layer to reconstruct the sinus rhythm signal and the AF signal. As shown in Fig. 10.
Finally, we performed Fast Fourier transform to analyze the two kinds of the reconstructed signals. As shown in Figs. 11 and 12.
Thus we obtained the frequency corresponding to the maximum amplitude in the spectrum(MAiFS), which can be used as the frequency domain characteristic of the ECG signals. The statistical results of the frequencydomain feature of sinus rhythm signals and AF signals were shown in Fig. 13 (partial data).
Classification using decision tree algorithm
The classifier used a decision tree algorithm [14]. Based on the principle of minimizing the Gini index, a decision tree was generated using the CART (classification and regression tree) algorithm. The data obtained from the above experiments were classified using the generated CART decision tree. And the confusion matrix of the classification results was obtained. As shown in Fig. 14. From the confusion matrix, we knew that the accuracy of classification reaches 98.9%. Sensitivity(SE) and specificity(SP) are calculated as
where true positive (TP): AF is classified as AF; true negative (TN): sinus rhythm is classified as sinus rhythm; false negative (FN): AF is classified as sinus rhythm; false positive (FP): sinus rhythm is classified as AF. According to the confusion matrix, the sensitivity and specificity of our method were 97.93% and 99.63% respectively. The comparison results were shown in Table 2.
Discussion
Through the extraction of the timedomain feature, we found that sinus rhythm signal and AF signal's R–R interval, the mean of R–R interval, the variance of R–R interval and the number of R waves had significant differences. Therefore, these features could be considered as timedomain features in the ECG signal.
Through the extraction of the frequencydomain feature, we found that the frequency corresponding to the maximum amplitude was intensively located in 1 Hz in the spectrum of the reconstructed sinus rhythm signal. However, in the spectrum of the reconstructed AF signal, the frequency corresponding to the maximum amplitude was discretely located from 2 to 8 Hz, which could be regarded as the dominant frequency in ECG signals with AF. Therefore, the frequency corresponding to the maximum amplitude of the spectrum can be used as the frequencydomain feature to detect AF.
Through the decision tree classification algorithm, we classified the sinus rhythm signals and AF signals with high accuracy. Besides, we also got great sensitivity and specificity compared with other studies.
Conclusion
The frequency corresponding to the maximum amplitude of the frequency spectrum in the sinus rhythm signal was concentrated and the fluctuation was weak. But the frequency corresponding to the MAiFS in the atrial fibrillation signal is divergent and irregular. Therefore, the experimental results can prove the validity of the frequency corresponding to MAiFS and the practicability and accuracy of the detection method, which applied this frequencydomain feature. Through the detection method, we obtained good accuracy of classifying sinus rhythm signals and AF signals. And the sensitivity and specificity of our method were pretty good by comparison with other studies.
Availability of data and material
The MITBIH Atrial Fibrillation databases can be found here: https://www.physionet.org/content/afdb/1.0.0/. Accessed 4th Nov 2000.
Abbreviations
 MAiFS:

The maximum amplitude in the frequency spectrum
 AF:

Atrial fibrillation
 ECG:

Electrocardiogram
References
Fuster V, Rydén LE, Cannom DS, Crijns HJ, Curtis AB, Ellenbogen KA,Halperin JL, Kay GN, Le Huezey JY, Lowe JE, Olsson SB, Prystowsky EN, Tamargo JL, Wann LS. 2011 ACCF/AHA/HRS focused updates incorporated into the ACC/AHA/ESC 2006 guidelines for the management of patients with atrial fibrillation. J Am Coll Cardiol. 2011, 57(11).
Xia Y, Wulan N, Wang K, Zhang H. Detecting atrial fibrillation by deep convolutional neural networks. Comput Biol Med. 2018, 93.
Kirchhof P, Benussi S, Kotecha D, et al. 2016 ESC Guidelines for the management of atrial fibrillation developed in collaboration with EACTS. Eur J Cardiothoracic Surg., 2016,50(5).
Moody GB, Mark RG. A new method for detecting atrial fibrillation using R–R intervals. Comput Cardiol. 1983;10:227–30.
Tateno K, Glass L. Automatic detection of atrial fibrillation using the coefficient of variation and density histograms of RR and ΔRR intervals. Med Biol Eng Comput. 2001;39:664–671.
Maji U, Mitra M, Pal S, et al. Automatic detection of atrial fibrillation using empirical mode decomposition and statistical approach. Procedia Technol. 2013: 45–52.
Buscema PM, Grossi E, Massini G, Breda M, Della Torre F. Computer aided diagnosis for atrial fibrillation based on new artificial adaptive systems. Comput Methods Programs Biomed. 2020.
He R, Wang K, Zhao N, Liu Y, Yuan Y, Li Q, Zhang H. Automatic detection of atrial fibrillation based on continuous wavelet transform and 2D convolutional neural networks. Front Physiol. 2018, 9: Article 1206.
Asgari S, Mehrnia A, Moussavi M. Automatic detection of atrial fibrillation using stationary wavelet transform and support vector machine. Comput. Biol. Med. (2015) 132–142.
Chen J, Chen H, Cai X, Weng P, Nie H. Application of signal processing based on mathematical morphology. In: Proceedings of SPIE 10255, Selected Papers of the Chinese Society for Optical Engineering Conferences held October and November 2016, 102553K (8 March 2017).
Park JS, Lee SW, Park U. R peak detection method using wavelet transform and modified Shannon energy envelope. J Healthcare Eng. 2017:1–14.
Daubechies I. Ten lectures on wavelets. J Acoust Soc Am. 1992, 93(3): 1671.
Resnikoff HL, Wells Jr RO. Wavelet analysis. Springer, New York 1998.
Vallée A, Safar ME, Blacher J. Application of a decision tree to establish factors associated with a nomogram of aortic stiffness. J Clin Hypertens. 2019(7).
Helfenbein E, Gregg R, Lindauer J, Zhou S. An automated algorithm for the detection of atrial fibrillation in the presence of paced rhythm. Comput Cardiol. 2010;37:113–116.
Dash S, Raeder E, Merchant S, Chon K. A statistical approach for accurate detection of atrial fibrillation and flutter. Comput Cardiol. 2009; 36, 137−140.
Thong T, McNames J, Aboy M, Goldstein B. Prediction of paroxysmal atrial fibrillation by analysis of atrial premature complexes. IEEE Trans Biomed Eng. 2004;51(4):561–569.
Rincón F, Grassi PR, Khaled N, Atienza D, Sciuto D. Automated realtime atrial fibrillation detection on a wearable wireless sensor platform. In: 34th Annual international conference of the IEEE EMBS2012, pp. 2472–2475.
Acknowledgements
Not applicable.
Funding
This work was partly supported by the Fundamental Research Funds for the Central Universities (N182410001) and supported by the National Training Program of Innovation and Entrepreneurship for Undergraduates (201910145154). The funding bodies don’t take part in the design of the study and collection, analysis, and interpretation of data and writing the manuscript.
Author information
Authors and Affiliations
Contributions
For this paper, YH, YZ and JL have equal contributions. Therefore, they are cofirst author. JL is the corresponding author. YH analyzed the data in datasets and wrote part of the paper. YZ analyzed the experimental results. JL supervised the whole project, presented the whole idea and revised the paper. JP interpreted the data in datasets, CZ wrote the introduction, and PL designed the program. All authors read and approved the final manuscript.
Corresponding author
Ethics declarations
Ethics approval and consent to participate
Not applicable.
Consent for Publication.
Not applicable.
Competing interests
The authors declare that they have no competing interests.
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/. The Creative Commons Public Domain Dedication waiver (http://creativecommons.org/publicdomain/zero/1.0/) applies to the data made available in this article, unless otherwise stated in a credit line to the data.
About this article
Cite this article
Hu, Y., Zhao, Y., Liu, J. et al. An effective frequencydomain feature of atrial fibrillation based on time–frequency analysis. BMC Med Inform Decis Mak 20, 308 (2020). https://doi.org/10.1186/s12911020013371
Received:
Accepted:
Published:
DOI: https://doi.org/10.1186/s12911020013371
Keywords
 Atrial fibrillation
 Frequencydomain feature
 Time–frequency analysis
 ECG
 Decision tree algorithm