Next Article in Journal / Special Issue
Multimodal Hybrid CNN-Transformer with Attention Mechanism for Sleep Stages and Disorders Classification Using Bio-Signal Images
Previous Article in Journal
Combined Infinity Laplacian and Non-Local Means Models Applied to Depth Map Restoration
Previous Article in Special Issue
Explainable AI-Based Clinical Signal Analysis for Myocardial Infarction Classification and Risk Factor Interpretation
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Novel Deterministic Algorithm for Atrial Fibrillation Detection

Elettronica SpA, Via Tiburtina V. Km 13.7, 00131 Rome, Italy
*
Author to whom correspondence should be addressed.
Submission received: 10 November 2025 / Revised: 25 December 2025 / Accepted: 29 December 2025 / Published: 8 January 2026
(This article belongs to the Special Issue Advanced Methods of Biomedical Signal Processing II)

Abstract

The absence of a recognizable P wave in an electrocardiogram (ECG) is a critical indicator for the diagnosis of atrial fibrillation (AF). An algorithm capable of distinguishing between physiological and pathological states in a short period of time could serve as a valuable tool for timely and effective diagnosis, even in a home setting. To achieve this goal, a deterministic algorithm is proposed. The Fantasia Database and the AF Termination Challenge Database were used for training the model. Subsequently, for the test session, a one-minute recording was extracted from the Autonomic Aging Dataset and the Long-Term AF Database. After band-pass filtering, characteristic points such as R-peaks and P waves were extracted. The R-peak detection algorithm was compared with the gold standard Pan-Tompkins, obtaining a p-value > 0.05 on the Fantasia Database, which means that there is no statistical difference between them. Subsequently derived features such as duration, amplitude, subtended area, and P wave slope have been used to discriminate healthy subjects from AF patients. The P-wave slope emerged as the most effective feature, achieving a classification accuracy of 100% and 96% for the training and test sets, respectively. This algorithm thus represents a significant advancement as it achieves a performance comparable to other deterministic methods based on P wave analysis using only one-minute recordings, thereby enabling accurate diagnosis in a shorter time frame.

1. Introduction

1.1. Risk and Epidemiology of Atrial Fibrillation

Atrial fibrillation (AF) is the most common cardiac arrhythmia. In the Western world (Australia, Europe, and the US), the estimated prevalence of the condition in adults ranges from 1 to 4% [1], with an increase up to 13% in 80 years old individuals [2]. Notably, atrial fibrillation is associated with an elevated risk of stroke [3], myocardial infarction [4], and heart failure [3,5], as well as increased mortality [2,3,6]. Other established risk factors for the development of AF include hypertension, valvular heart disease, ischemic cardiomyopathy, diabetes mellitus, and thyroid dysfunction [7]. It is important to note that the incidence of the condition has been steadily rising, with a global prevalence of 35.574 million cases (0.51% of the world population), representing an increase of 33% over the past 20 years [8], which has now reached an estimated 60 million cases worldwide [9]. It is estimated that between 6 and 12 million people in the United States will suffer from this disease by 2050, and 17.9 million people in Europe will suffer from this disease by 2060 [8]. Early recognition and monitoring of this disease are crucial to preventing potential complications.
The electrocardiogram (ECG) is the primary tool for diagnosing AF, as one of the main features of AF is the absence of P waves, which are replaced by smaller-amplitude waves exhibiting a “sawtooth” pattern [10]. This characteristic can be utilized to distinguish a healthy trace from a pathological one.

1.2. Related Work

The application of AI algorithms represents a highly promising and powerful tool, particularly in the biomedical domain, enabling the resolution of complex problems and providing valuable support to clinicians in the diagnostic process.
Notably, numerous algorithms based on machine learning (ML) or deep learning (DL) have been documented in the literature, demonstrating the ability to distinguish a healthy trace from one affected by AF. A convolutional neural network (CNN) tested on a 12-lead ECG of 10 s duration was implemented and achieved an overall accuracy of 83.3%, a sensitivity of 82.3%, a specificity of 83.4%, and an F1 score of 45.4%. A total of 180,922 patients—with 649,931 having normal sinus rhythm ECG recordings—were enrolled for analysis, comprising 454,789 ECGs from 126,526 patients in the training set, 64,340 ECGs from 18,116 patients in the internal validation set, and 130,802 ECGs from 36,280 patients in the testing set [11]. A hybrid approach using feature selection followed by ensemble classification for the diagnosis of arrhythmia was also proposed, achieving an accuracy of 77.27% and a precision of 76%. This research utilized the UCI arrhythmia dataset, which comprises 452 records categorized into 16 distinct arrhythmia types, including one representing healthy individuals. Among these, 245 instances correspond to healthy subjects, while the remaining 207 are from patients diagnosed with arrhythmia. [12]. Another study proposes the combination of modified frequency slice wavelet transform (MFSWT) and convolutional neural networks (CNNs), reaching an accuracy of 84.85%, with a corresponding sensitivity and specificity of 79.05% and 89.99%, respectively. These performance parameters were calculated on the test dataset, excluding ECG recordings with low signal quality. The database utilized was from the MIT-BIH AFDB [13]. The dataset includes 25 individual recordings, each derived from ambulatory ECG monitoring of a different subject. Every recording spans 10 h and 15 min and contains two ECG signal channels. The recordings were separated into five groups and, in order to employ a balanced dataset to train the model, an equal number of AF and non-AF samples were selected for training, while all remaining samples in the held-out fold were used for testing [14]. A novel algorithm called Ensemble Learning and Multi-Feature Discrimination (ELMD) was proposed for the identification and detection of AF signals. The proposed method was evaluated on the MIT-BIH AF database [13], reaching a specificity and accuracy that exceed 99% in AF detection in long-term ECG and reaching a sensitivity and accuracy that exceed 96% by testing the algorithm on cardiac segments [15]. Another study employed a methodology based on the extraction of features derived from the RR interval. In this case as well, the MIT-BIH Atrial Fibrillation Database was utilized [13]. Specifically, the extracted features include the robust coefficient of variation (RCV), the skewness parameter (SKP), and the Lempel–Ziv complexity (LZC), which, respectively, characterize the discrete degree of the RR interval, the distribution of shape of the RR interval, and the complexity of the RR interval. These features were subsequently used as input into a support vector machine (SVM) classifier, achieving a sensitivity of 95.81% and an accuracy of 96.09% [16]. Another study presented a deep neural network strategy (DNN) followed by a genetic algorithm (GA) process to obtain the best feature’s combination, extraction, and classification [17]. The algorithm is implemented on the MIT-BIH AF database [13]. Finally, another study proposed a deep learning model named HBBI-AI, designed to predict atrial fibrillation episodes during sinus rhythm [18]. For the testing phase, multiple datasets were employed, including the Long-Term Atrial Fibrillation Database [19] and the Autonomic Aging Dataset [20], which were also used in the evaluation of our proposed algorithm. The HBBI-AI model achieved a sensitivity of 73.8% and a specificity of 76.5%, which are comparable to the performance of our method. In fact, our algorithm obtained a sensitivity of 96% and a specificity of 96%. The approach of identifying pathology using deep learning is promising as these algorithms can detect heart diseases with an accuracy level comparable to that of medical experts [21]. However, several challenges must be addressed for the direct application of these algorithms in clinical settings, including issues related to accuracy, reliability, consistency, and interpretability [21]. This limitation is primarily due to the available datasets being limited and failing to reflect the quality of signals obtained in a real-world context [21]. Furthermore, machine learning methods often require many features (over 150) to achieve high classification accuracy, which can compromise the interpretability and physiological relevance of those features. Additionally, while ML techniques can automatically extract features and classify data, they are prone to overfitting, bias, and limitations due to insufficient training data, which affects their accuracy and reliability. Moreover, most current ML algorithms need long ECG recordings (more than 100 heartbeats), reducing their practicality in clinical settings [22]. Therefore, a deterministic automatic discrimination algorithm is proposed, as it does not require training on large datasets and the extraction of many features, unlike AI approaches, and could thus be a viable alternative for application in contexts characterized by limited data availability or in clinical settings. For this reason, only the P wave was considered, as the primary characteristic of the pathology lies in malformations of this specific wave. Although variations in RR intervals can also indicate the presence of atrial fibrillation, such changes are not exclusive to AF and are commonly observed in other types of arrhythmias [23]. In previous studies, several deterministic algorithms based on the analysis of the P wave have been proposed. While these approaches have demonstrated promising results, their performance metrics remain inferior to those achieved by the algorithm presented in our work. For example, a study conducted using the MIT-BIH Normal Sinus Rhythm [24] and AF Termination Challenge databases [25,26] examined the standard deviation between consecutive RR intervals and analyzed data points within four windows preceding the detected R-peaks [27]. However, this study only highlights the observation that patients with atrial fibrillation exhibit a higher RR interval standard deviation and a lower P power value—a parameter used to quantify the presence of the P wave—compared to healthy individuals. Notably, the algorithm does not perform beat-level detection, nor does it distinguish between healthy subjects and those affected by AF, unlike our proposed method. Another study utilized signal-averaged ECG recordings of the P wave in 73 patients following successful cardioversion. It calculated the duration of the filtered P wave and the root mean square (RMS) voltage of the final 20 ms of the P wave. The reported sensitivity and specificity for detecting AF recurrence post-cardioversion were 70% and 76%, respectively [28], which are inferior to the performance metrics achieved by our algorithm. Finally, a further study based on the CSE and MIT-BIH databases proposed a set of features extracted from the P wave, including duration, morphological descriptors, spectral characteristics, and wavelet entropy parameters. The reported sensitivity and specificity ranged between 65% and 70% [29], again demonstrating a lower performance compared to our approach.

2. Materials and Methods

2.1. Data Description

This study introduces a deterministic algorithm designed for the diagnosis of atrial fibrillation (AF) through the analysis of the P waves in electrocardiographic (ECG) signals. This research utilized four datasets, the first two as training sets and the remaining as test sets. The data used during both the training and testing phases were sourced from the publicly available PhysioNet Database [24]. As training sets, the Fantasia Database [24,29] and the AF Termination Challenge Database [2,26] were chosen, while as test sets, the Autonomic Aging Dataset [20,24] and Long-Term AF Database [19,24] were chosen.
The Fantasia Database was utilized for training on healthy subjects. This dataset includes 20 strictly healthy individuals aged 21–34 years and 20 older individuals aged 68–85 years. Each subgroup of subjects includes equal numbers of men and women. The ECG signals were recorded, while the subjects were in a supine position and digitized with a sampling rate of 250 Hz. To optimize the algorithm for early detection, a one-minute segment of signal was extracted from each recording. The AF Termination Challenge Database was employed for training on patients with AF. This dataset comprises two lead ECG recordings for each patient, with each trace having a duration of 1 min, sampled at a frequency of 128 Hz. For both datasets, only leads exhibiting positive R-peaks were considered for each subject. This selection process resulted in the examination of 31 traces from healthy subjects and 69 traces from AF patients. To ensure traces of comparable duration, only the first minute of recording was considered for the ECG recordings of healthy subjects. Finally, the traces from the AF patient dataset were oversampled, increasing the sampling rate from 128 Hz to 250 Hz.
The Long-Term AF Database was used for testing on AF patients. This database includes 84 long-term ECG recordings of subjects with paroxysmal or sustained atrial fibrillation. Each record contains two simultaneously recorded ECG signals digitized at 128 Hz. Record durations are typically 24 to 25 h. Only one trace from each subject was chosen in accordance with the previously mentioned selection criterion. The subjects who did not meet this guideline were discarded. Additionally, in order to make a comparison with training dataset, one minute of recording was extracted from traces that presented episodes of AF. This selection process led to a the dataset being reduced to 46 subjects. Finally, traces were oversampled to 250 Hz. The Autonomic Aging Dataset was utilized for testing on healthy subjects. This database contains resting recordings of ECGs of 1121 healthy volunteers. The dataset has been collected over the last decade in Jena University Hospital. This dataset includes volunteers whose age range is between 18 and 92 years. An ECG (lead II) was recorded at 1000 Hz, either by an MP150 (ECG100C, BIOPAC systems Inc., Golata, CA, USA) or s Task Force Monitor system (CNSystems Medizintechnik GmbH, Graz, Austria). Pre-gelled Ag/AgCl electrodes (BlueSensor VL, Ambu BmbH, Bad Nauheim, Germany) were attached according to an Einthoven triangle. The length of the recording was, on average, 19 min. To maintain the same sampling rate as the training set, the traces were down-sampled to 250 Hz. Also, to obtain a balanced test set between healthy subjects and AF patients, from a total of 1121 traces, 57 recordings were randomly selected, and from these traces, one-minute recordings were extracted. The analysis of the periodograms of the recorded traces revealed an absence of frequency components beyond 250 Hz. Therefore, we consider no alterations in the morphology of the P wave to have occurred. Consequently, down-sampling the trace does not introduce alterations to the morphology of the P wave. Regarding the up-sampling of the trace from 128 Hz to 250 Hz, we determine that it did not introduce morphological alterations to the P wave. This is because the process does not reduce the signal bandwidth, limiting its informational content; rather, it simply provides a denser representation by interpolating additional points between the original samples acquired at 128 Hz.

2.2. Algorithm’s Logical Structure

As reported in Figure 1, the proposed algorithm is composed of several logical blocks, starting from ECG signal preprocessing and R-peaks extraction, and progressing to P waves detection, derivate feature extraction, derivate feature optimization, derivate features performance computation on a training set, best feature selection, test set subject classification, and performance computation on a test set.
The following paragraphs provide a detailed account of the logical steps involved. In addition, a dedicated section presents the validation of R-peak detection performed using the proposed algorithm.

2.3. Preprocessing and R-Peaks Extraction

To de-noise the signal, each trace was processed using a second-order Butterworth bandpass filter with a frequency range from 0.5 to 15 Hz because beyond 15 Hz, there are no significant spectral components for our purpose. The R-peaks were then detected by applying a moving window of 1.5 s with an overlap of 70%. From these R-peaks, P waves were subsequently identified. Each element of the window was multiplied by the following nonlinear function:
f x = 10 15 × v k
where v k is the k -th amplitude value in the window.
This process emphasized the higher amplitude values associated with the R-peaks, simplifying the detection process. From these R-peaks, P waves were subsequently identified. For each window, a threshold value ( T H R _ L I V ) was computed using the same criterion as the Pan-Tompkins algorithm [30], but with different threshold levels:
T H R L I V w i = max w i × 1 1.75
where
o
T H R _ L I V i is the threshold computed for the i-th window w i , with i = 1 ,   2 ,   ,   n ;
o
max w i is the maximum value computed in the i-th window w i , with i = 1 ,   2 ,   ,   n .
Then, only the amplitude values within the window that exceed the threshold level are taken into account, and among these, only the values that are greater than both the preceding and following magnitudes are classified as R-peaks. A check on the correct detection is then carried out. Let R j be the j-th peak in the samples identified in the i-th window w i , and let T j be the j-th T-wave peak in the i-th window w i :
if   R j + 1   R j 250   ms   then   R j + 1 =   T j  
R j + 1 is identified as the T-wave peak and is therefore excluded from further analysis. The threshold value was set at 250 ms because the average duration of the RT interval in healthy subjects is 257 ms, with a standard error (SE) of 5.7 ms [31].
Subsequently, to recover any missed R-peaks, the heart rate ( H R ) for the obtained RR intervals is calculated. If the H R within the interval considered is less than 50 bpm [32], the process of detecting the R-peak in the window between the two beats considered is reinitiated.

2.4. R-Peaks Detection Algorithm Validation

To ensure that the R-peak extraction procedure adheres to the Pan-Tompkins gold standard, the proposed algorithm was validated by comparing the output results of both methods. Ten traces were randomly selected from the Fantasia Database and ten were randomly selected from the AF Termination Challenge Database. The selected sample size provides enough data points for statistical analysis. As reported in [33], under resting conditions, the context in which our data were collected, healthy individuals exhibit an average heart rate of approximately 75 beats per minute. Conversely, patients with AF typically present heart rates ranging from 60 to 100 bpm [34]. Therefore, considering a 60 s recording for a cohort comprising 10 healthy subjects and 10 AF patients, the total number of heartbeats amounts to approximately 1350. This quantity of observations is deemed adequate to support the statistical analyses conducted in this study. The temporal instances of the R-peaks were annotated through visual inspection of these traces. Subsequently, both algorithms were applied, and the absolute error between the visual inspection and the temporal indices returned by the algorithms was evaluated. For each individual trace, the average absolute error (AAE) was calculated. Assuming that the AAEs for healthy subjects and AF patients follow a Gaussian distribution, a paired sample t-test was conducted to determine if there is a statistically significant difference between the two R-peak detection algorithms and their deviation from the ground truth data obtained through visual inspection. The null hypothesis posited the absence of a statistically significant difference between the two algorithms, while the alternative hypothesis posited the presence of statistical independence between the two algorithms. The alternative hypothesis was accepted for p-values less than 0.05. Table 1 reports the results from the t-test applied to healthy subjects, indicating that the p-value is greater than 0.05; thus, the two algorithms are not statistically different.
Figure 2 presents the distributions of the average absolute error obtained from the comparisons between the ground truth and the Pan-Tompkins algorithm and between the ground truth and the proposed algorithm on healthy subjects. From the figure, it can be observed that the mean value and the standard error of the distribution derived from the comparison with the proposed algorithm is higher than that obtained from the Pan-Tompkins algorithm. This indicates that the proposed algorithm demonstrates inferior performance compared to the gold standard on healthy subjects. However, no statistically significant difference is detectable.
It is important to note the classification performance of the two algorithms. As demonstrated in Table 2, the Pan-Tompkins algorithm exhibits superior performance, with a mean value of 0.006 and a standard deviation (SD) of 0.005 compared to the mean value of 0.134 and a standard deviation of 0.209 obtained by the proposed algorithm.
Regarding patients with AF, as reported in Table 3, the t-test yielded a p-value < 0.001, indicating that the alternative hypothesis can be accepted.
The difference between the two distributions is clearly illustrated in Figure 3, as it can be observed that there is no overlap between them. Additionally, it is evident that in this case, the proposed algorithm demonstrates superior performance compared to the Pan-Tompkins algorithm, with a lower mean value and standard deviation than the gold standard.
Regarding the performance of the algorithms, as reported in Table 4, it is evident from the mean and standard deviation values that the proposed algorithm produced better results compared to the Pan-Tompkins algorithm. The proposed algorithm achieved a mean value of 0.076, with a standard deviation of 0.069, whereas the Pan-Tompkins algorithm attained a mean value of 0.470, with a standard deviation of 0.142.
In conclusion, although the Pan-Tompkins algorithm demonstrates superior performance in healthy subjects, when considering the entire cohort of individuals analyzed, the proposed algorithm exhibits better overall performance due to its enhanced generalization capability.

2.5. P-Waves and Derivate Features Extraction

After the identification of R-peaks, the P wave was delineated. From this delineation, several parameters were quantified: the duration of the P wave ( P d i f f ), the area under the curve ( P a r e a ), the amplitude ( P a m p ), and the slope, defined as the derivated of the descending segment of the P-wave ( P s l o p e ) [26]. To identify the P waves, a window with length l was implemented from the R-peaks’ location:
l = R R m e a n 5 r
where
o
R R m e a n is the average distance between two consecutive R-peaks;
o
r is a scale factor.
The search window was constructed by considering the average distance between R-peaks in the subject under consideration, dividing by 5, and then multiplying by the corrective factor r . In this manner, for a subject with a sinus rhythm, the average distance between two R-peaks is 1 s, corresponding to 60 bpm [32]. Dividing by 5 yields approximately 200 ms, which constitutes the distance from the R-peak, where the presence of the P wave is expected before the R-peak in healthy subjects. PR intervals greater than 200 ms may be associated with episodes of AF [35]. For this reason, the corrective factor has been introduced to adjust the length of the window for the j-th beat under review. Based on the previous considerations, the factor r is calculated as follows:
r = 60 [ b p m ] H R j
where H R j is the j-th bpm.
Finally, the maximum value within the window is classified as the i-th peak P i . To calculate the derived features of the P wave, it is essential to identify its onset ( P o n ) and offset ( P o f f ) points. These points mark the beginning and the end of the P wave, respectively. For this purpose, a time window with length L was implemented as follows:
L = R R m e a n 16 r
The search window was constructed in the same manner as the previous window and is centered at the previously identified P-peak to include all preceding and subsequent points within the window. Dividing by 16 and multiplying through the corrective factor r , the window is adjusted accordingly. Consequently, the results are a window of approximately 0.063 s. Considering that the duration of a P wave in a healthy subject is approximately 100–105 ms [36], this results in a search window with an adequate duration to encompass the P o n and P o f f points. The minimum values identified within these windows correspond to P o n and P o f f , respectively. Figure 4 and Figure 5 illustrate a segment of a healthy ECG and a pathological one, showcasing the extracted features, such as R-peaks, P waves, P o n , and P o f f . The ECG trace was first denoised, and R-peaks extraction was conducted through a personal algorithm.
Once the characteristic points of the P wave were identified, the following parameters were extrapolated:
o
P d i f f : defined as the difference between the times corresponding to P o f f and P o n ;
o
P a r e a : defined as the area under the P wave curve;
o
P a m p : defined as the difference between the amplitude of the P-wave’s peak and P o n ;
o
P s l o p e : defined as the derivative of the curve segment from the peak of the P wave to P o f f .
The extracted features are subsequently compared against specific threshold values for each parameter. The j-th heartbeat H B j is classified as pathological based on the following criteria for each feature:
H B j - p a t h = P s l o p e j   t h r P s l o p e P d i f f j <   t h r P d i f f P a r e a j < t h r P a r e a P a m p j <   t h r P a m p
where t h r is the threshold corresponding to the feature considered, and H B j - p a t h is the j-th pathological heartbeat.

3. Results

3.1. Optimization and Performance Computation

Since atrial fibrillation (AF) episodes do not occur deterministically [37,38] with each heartbeat, the parameter M, defined as the divisor for the number of beats, was introduced. Let E represent the number of pathological events, defined as
E = H B t o t M
where H B t o t represents the total number of heartbeats in the trace. If there are at least E pathological events within a trace, the subject is considered to have atrial fibrillation. The performance of each parameter was optimized using an iterative method designed to minimize the percentage error (PE). The objective of the optimization is to determine the optimal threshold and M values for each derived feature that minimizes the following cost function:
C F = P E H e l t h y + P E A F 2
where
o
C F is the cost function to be minimized;
o
P E H e l t h y is the percentage error committed for healthy subjects;
o
P E A F is the percentage error committed for AF patients.
Figure 6 illustrates the evolution of the cost function for the parameter P s l o p e .
As can be seen in Figure 6, the minimum of the cost function was reached for M = 7 and t h r P s l o p e = 0 .

3.2. Training Set Performance Analysis

Performance analysis is performed by comparing the Eps resulting from each optimized parameter obtained from the application of the algorithm on the training set.
It can clearly be seen from Table 5 that P s l o p e is the feature that exhibited the best performance in terms of PE, correctly classifying both healthy subjects and those with atrial fibrillation. Subsequently, its performance was analyzed in terms of accuracy (ACC), true positive rate (TPR), false positive rate (FPR), and positive predictive value (PPV), defined as follows:
A C C   =   T P   +   T N T P   +   T N   +   F P   +   F N T P R   =   T P T P   +   F N F P R   =   F P F P   +   T N S p e c i f i c i t y =   T N F P   +   T N P P V   =   T P T P   +   F P
Specifically, on the training set, the algorithm achieved ACC, PPV, and TPR, all equal to 100%. It is therefore crucial to evaluate the algorithm’s performance on the test set.

3.3. Test Set Performance Analysis

The algorithm was tested on the test set using only the P s l o p e feature as it demonstrated superior performance during the training phase compared to other features. The performance evaluation was conducted similarly to the training set: the classification PE relative to the ground truth was assessed, and the confusion matrix was subsequently constructed with the calculation of the classification metrics. Specifically, TP (true positive), TN (true negative), FP (false positive), and FN (false negative) denote the respective outcomes of the classification process. The symbols P and N represent the ground truth, while P’ and N’ denote the predicted positive and negative classes, respectively. In this case, a classification PE of 3.70% was observed on the Aging Dataset, which includes healthy subjects, while a PE of 4.35% was observed on the Long-Term AF Database, which includes patients with atrial fibrillation. The confusion matrix obtained from the application of the algorithm on the test set is presented in Table 6.
From the confusion matrix, the previously mentioned classification metrics can be derived more easily. Specifically, as reported in Table 7, the algorithm applied to the test set achieved an ACC, PPV, specificity, and TPR equal 96%.

3.4. Computation of the Confidence Interval Associated with Sensitivity and Specificity

The phenomenon under investigation falls within a success/failure framework, which is described by the binomial distribution. For a number of cases greater than 10, and assuming independence among observations, the binomial distribution can be approximated by a Gaussian distribution. To compute a 95% confidence interval, it is necessary to determine the z-score and the standard error (SE) of the distribution. In this case, the z-score corresponding to a 95% confidence level in a Gaussian distribution is 1.96. The standard error is calculated as follows:
S E = p ( 1 p ) N
where p represents either sensitivity or specificity, and N is the denominator (i.e., TP + FN for sensitivity and FP + TN for specificity).
Consequently, the confidence interval for sensitivity is given by the following equation:
C I s e n s i t i v i t y = s e n s i t i v i t y ± z s c o r e s e n s i t i v i t y ( 1 s e n s i t i v i t y ) T P + F N
Given a total of 103 subjects, with 99 true positives (TP) and 4 false negatives (FN), the resulting 95% confidence interval for sensitivity is
C I s e n s i t i v i t y = [ 0.922 ,   0.998 ] .
Similarly, for specificity, with 4 false positives (FP) and 99 true negatives (TN), the confidence interval is calculated as
C I s p e c i f i c i t y = s p e c i f i c i t y ± z s c o r e s p e c i f i c i t y ( 1 s p e c i f i c i t y ) F P + T N .
In conclusion, the resulting 95% confidence interval for specificity is
C I s p e c i f i c i t y = [ 0.922 ,   0.998 ] .
Based on the results obtained, it can be concluded that the deviation from the calculated values is within an acceptable range as it amounts to 0.038.

4. Discussion

Atrial fibrillation is the most prevalent cardiac arrhythmia. In the Western world, its estimated prevalence reaches up to 13%, with a steadily increasing trend. This condition leads to severe consequences such as stroke, ischemia, heart failure, and increased mortality. Real-time analysis is crucial for enabling continuous home monitoring, facilitating early diagnosis, and preventing further complications. AI represents a promising tool for disease diagnosis; however, their clinical application is hindered by the challenge of obtaining large datasets that accurately reflect real-world conditions, where signal degradation, thermal artifacts, and device-dependent variability exert a substantial influence on the fidelity and reliability of physiological data acquisition [39,40].
The proposed algorithm has been developed as a viable alternative to machine learning and deep learning approaches, particularly in scenarios characterized by limited data availability, achieving an accuracy, positive predictive value, and true positive rate of 96%, which is comparable to that of deep learning algorithms, which remain a fundamental tool to be leveraged for solving complex problems. Moreover, the deviation associated with sensitivity and specificity metrics is within acceptable limits, quantified at 0.038. In a clinical setting, the proposed contribution involves deploying the algorithm not within certified medical devices but in portable technologies, such as smartwatches, that can issue preliminary warnings regarding potential pathological conditions, thereby encouraging users to seek medical evaluation. The primary objective of our algorithm is not to achieve peak performance metrics but rather to enable early detection, operate using single-lead input, and maintain low computational complexity. These characteristics are essential for integration into miniaturized wearable devices, while still ensuring performance levels comparable to those reported in previously cited studies. Although derived from a relatively limited dataset, the results are promising, enabling us to test the algorithm on additional datasets in the future. This will increase the data volume and further demonstrate its robustness.

5. Future Work

Based on the encouraging performance achieved, we plan to validate the algorithm on additional datasets. Specifically, we will conduct a data acquisition campaign to assess the algorithm’s effectiveness in real-world clinical environments with the aim of achieving broader optimization beyond resting conditions [41]. Subsequently, a further phase is envisioned involving its deployment on portable devices, leveraging its computational lightness. This will be followed by testing data acquired directly in real-time. This phase will be made feasible through the integration of an online preprocessing step capable of operating in real-time conditions.

Author Contributions

Conceptualization, A.F. and P.B.; methodology, A.F., G.L., and R.A.; software, A.F., G.L., and R.A.; validation, A.F., G.L., and R.A.; formal analysis, A.F., G.L., and R.A.; investigation, A.F., G.L., M.L., and R.A.; resources, A.F. and G.L.; data curation, A.F., G.L., and R.A.; writing—original draft preparation, A.F.; writing—review and editing, A.F., P.B., M.L., G.L., R.A., and A.M.; visualization, A.F. and G.L.; supervision, A.M. and R.A.; project administration, P.B. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The original contributions presented in this study are included in the article. Further inquiries can be directed to the corresponding author.

Conflicts of Interest

All Authors was employed by the company Elettronica S.p.A and declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

References

  1. Friberg, L.; Bergfeldt, L. Atrial fibrillation prevalence revisited. J. Intern. Med. 2013, 274, 461–468. [Google Scholar] [CrossRef]
  2. Piccini, J.P.; Hammill, B.G.; Sinner, M.F.; Jensen, P.N.; Hernandez, A.F.; Heckbert, S.R.; Benjamin, E.J.; Curtis, L.H. Incidence and prevalence of atrial fibrillation and associated mortality among Medicare beneficiaries: 1993–2007. Circ. Cardiovasc. Qual. Outcomes 2012, 5, 85–93. [Google Scholar] [CrossRef]
  3. Stewart, S.; Hart, C.L.; Hole, D.J.; McMurray, J.J. A population-based study of the long-term risks associated with atrial fibrillation: 20-year follow-up of the Renfrew/Paisley study. Am. J. Med. 2002, 113, 359–364. [Google Scholar] [CrossRef]
  4. Soliman, E.Z.; Safford, M.M.; Muntner, P.; Khodneva, Y.; Dawood, F.Z.; Zakai, N.A.; Thacker, E.L.; Judd, S.; Howard, V.J.; Howard, G.; et al. Atrial fibrillation and the risk of myocardial infarction. JAMA Intern. Med. 2014, 174, 107–114. [Google Scholar] [CrossRef]
  5. Miyasaka, Y.; Barnes, M.E.; Gersh, B.J.; Cha, S.S.; Bailey, K.R.; Abhayaratna, W.; Seward, J.B.; Iwasaka, T.; Tsang, T.S.M. Incidence and mortality risk of congestive heart failure in atrial fibrillation patients: A community-based study over two decades. Eur. Heart J. 2006, 27, 936–941. [Google Scholar]
  6. Ko, D.; Chung, M.K.; Evans, P.T.; Benjamin, E.J.; Helm, R.H. Atrial fibrillation: A review. JAMA 2025, 333, 329–342. [Google Scholar]
  7. Schoonderwoerd, B.A.; Smit, M.D.; Pen, L.; Van Gelder, I.C. New risk factors for atrial fibrillation: Causes of ‘not-so-lone atrial fibrillation’. Europace 2008, 10, 668–673. [Google Scholar] [PubMed]
  8. Lippi, G.; Sanchis-Gomar, F.; Cervellin, G. Global epidemiology of atrial fibrillation: An increasing epidemic and public health challenge. Int. J. Stroke 2021, 16, 217–221. [Google Scholar] [CrossRef]
  9. Elliott, A.D.; Middeldorp, M.E.; Van Gelder, I.C.; Albert, C.M.; Sanders, P. Epidemiology and modifiable risk factors for atrial fibrillation. Nat. Rev. Cardiol. 2023, 20, 404–417. [Google Scholar]
  10. Couceiro, R.; Carvalho, P.; Henriques, J.; Antunes, M.; Harris, M.; Habetha, J. Detection of atrial fibrillation using model-based ECG analysis. In Proceedings of the 2008 19th International Conference on Pattern Recognition, Tampa, FL, USA, 8–11 December 2008; IEEE: New York, NY, USA, 2008. [Google Scholar]
  11. Attia, Z.I.; Noseworthy, P.A.; Lopez-Jimenez, F.; Asirvatham, S.J.; Deshmukh, A.J.; Gersh, B.J.; Carter, R.E.; Yao, X.; Rabinstein, A.A.; Erickson, B.J.; et al. An artificial intelligence-enabled ECG algorithm for the identification of patients with atrial fibrillation during sinus rhythm: A retrospective analysis of outcome prediction. Lancet 2019, 394, 861–867. [Google Scholar] [CrossRef]
  12. Mamun, M.M.R.K.; Alouani, A. Arrhythmia classification using hybrid feature selection approach and ensemble learning technique. In Proceedings of the 2021 IEEE Canadian Conference on Electrical and Computer Engineering (CCECE), Virtual, 12–17 September 2021; IEEE: New York, NY, USA, 2021. [Google Scholar]
  13. Jiang, K.; Huang, C.; Ye, S.M.; Chen, H. High accuracy in automatic detection of atrial fibrillation for Holter monitoring. J. Zhejiang Univ. Sci. B 2012, 13, 751–756. [Google Scholar] [CrossRef]
  14. Xu, X.; Wei, S.; Ma, C.; Luo, K.; Zhang, L.; Liu, C. Atrial fibrillation beat identification using the combination of modified frequency slice wavelet transform and convolutional neural networks. J. Healthc. Eng. 2018, 2018, 2102918. [Google Scholar] [CrossRef]
  15. Wan, X.; Liu, Y.; Mei, X.; Ye, J.; Zeng, C.; Chen, Y. A novel atrial fibrillation automatic detection algorithm based on ensemble learning and multi-feature discrimination. Med. Biol. Eng. Comput. 2024, 62, 1809–1820. [Google Scholar] [CrossRef]
  16. Chen, Z.; Li, J.; Li, Z.; Peng, Y.; Gao, X. Automatic detection and classification of atrial fibrillation using RR intervals and multi-eigenvalue. J. Biomed. Eng. 2018, 35, 550–556. [Google Scholar]
  17. Hammad, M.; Iliyasu, A.M.; Subasi, A.; Ho, E.S.; Abd El-Latif, A.A. A multitier deep learning model for arrhythmia detection. IEEE Trans. Instrum. Meas. 2020, 70, 1–9. [Google Scholar] [CrossRef]
  18. Lin, F.; Zhang, P.; Chen, Y.; Liu, Y.; Li, D.; Tan, L.; Wang, Y.; Wang, D.; Yang, X.; Li, Q.; et al. Artificial-intelligence-based risk prediction and mechanism discovery for atrial fibrillation using heart beat-to-beat intervals. Med 2024, 5, 414–431. [Google Scholar] [CrossRef]
  19. Petrutiu, S.; Sahakian, A.V.; Swiryn, S. Abrupt changes in fibrillatory wave characteristics at the termination of paroxysmal atrial fibrillation in humans. EP Europace 2007, 9, 466–470. [Google Scholar] [CrossRef] [PubMed]
  20. Schumann, A.; Bär, K. Autonomic Aging: A dataset to quantify changes of cardiovascular autonomic function during healthy aging (version 1.0.0). PhysioNet 2021. RRID:SCR_007345. [Google Scholar] [CrossRef] [PubMed]
  21. Khan Mamun, M.M.R.; Elfouly, T. AI-Enabled Electrocardiogram Analysis for Disease Diagnosis. Appl. Syst. Innov. 2023, 6, 95. [Google Scholar] [CrossRef]
  22. Sharmin, R.; Brindise, M.C.; Kolliyil, J.J.; Meyers, B.A.; Zhang, J.; Vlachos, P.P. Novel interpretable Feature set extraction and classification for accurate atrial fibrillation detection from ECGs. Comput. Biol. Med. 2024, 179, 108872. [Google Scholar] [CrossRef]
  23. Rizwan, A.; Zoha, A.; Mabrouk, I.B.; Sabbour, H.M.; Al-Sumaiti, A.S.; Alomainy, A.; Imran, M.A.; Abbasi, Q.H. A review on the state of the art in atrial fibrillation detection enabled by machine learning. IEEE Rev. Biomed. Eng. 2020, 14, 219–239. [Google Scholar] [CrossRef]
  24. Goldberger, A.; Amaral, L.; Glass, L.; Hausdorff, J.; Ivanov, P.C.; Mark, R.; Mietus, J.E.; Moody, G.B.; Peng, C.-K.; Stanley, H.E. PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals. Circulation 2000, 101, e215–e220, RRID:SCR_007345. [Google Scholar] [CrossRef]
  25. Moody George, E. Spontaneous termination of atrial fibrillation: A challenge from physionet and computers in cardiology 2004. Comput. Cardiol. 2004, 101–104. [Google Scholar]
  26. Kalsi, M.; Prakash, N.R. A new algorithm for detection of atrial fibrillation. In Proceedings of the 2016 International Conference on Electrical, Electronics, and Optimization Techniques (ICEEOT), Chennai, India, 3–5 March 2016; IEEE: New York, NY, USA, 2016; pp. 3177–3182. [Google Scholar]
  27. Aytemir, K.; Aksoyek, S.; Yildirir, A.; Ozer, N.; Oto, A. Prediction of atrial fibrillation recurrence after cardioversion by P wave signal-averaged electrocardiography. Int. J. Cardiol. 1999, 70, 15–21. [Google Scholar] [CrossRef]
  28. Clavier, L.; Boucher, J.-M.; Lepage, R.; Blanc, J.-J.; Cornily, J.-C. Automatic P-wave analysis of patients prone to atrial fibrillation. Med. Biol. Eng. Comput. 2002, 40, 63–71. [Google Scholar] [CrossRef] [PubMed]
  29. Iyengar, N.; Peng, C.K.; Morin, R.; Goldberger, A.L.; Lipsitz, L.A. Age-related alterations in the fractal scaling of cardiac interbeat interval dynamics. Am. J. Physiol. Regul. Integr. Comp. Physiol. 1996, 271, R1078–R1084. [Google Scholar] [CrossRef] [PubMed]
  30. Pan, J.; Willis, J.; Tompkins. A real-time QRS detection algorithm. IEEE Trans. Biomed. Eng. 1985, 3, 230–236. [Google Scholar] [CrossRef]
  31. Merri, M.; Alberti, M.; Moss, A.J. Dynamic analysis of ventricular repolarization duration from 24-hour Holter recordings. IEEE Trans. Biomed. Eng. 1993, 40, 1219–1225. [Google Scholar] [CrossRef]
  32. Spodick, D.H.; Raju, P.; Bishop, R.L.; Rifkin, R.D. Operational definition of normal sinus heart rate. Am. J. Cardiol. 1992, 69, 1245–1246. [Google Scholar] [CrossRef]
  33. Shaffer, F.; Rollin, M.; Christopher, L.Z. A healthy heart is not a metronome: An integrative review of the heart’s anatomy and heart rate variability. Front. Psychol. 2014, 5, 1040. [Google Scholar] [CrossRef] [PubMed]
  34. Sörnmo, L.; Pablo, L. Bioelectrical Signal Processing in Cardiac and Neurological Applications; Academic Press: Cambridge, MA, USA, 2005. [Google Scholar]
  35. Magnani, J.W.; Wang, N.; Nelson, K.P.; Connelly, S.; Deo, R.; Rodondi, N.; Schelbert, E.B.; Garcia, M.E.; Phillips, C.L.; Shlipak, M.G.; et al. Electrocardiographic PR interval and adverse outcomes in older adults: The Health, Aging, and Body Composition study. Circ. Arrhythmia Electrophysiol. 2013, 6, 84–90. [Google Scholar] [CrossRef]
  36. Nielsen, J.B.; Kühl, J.T.; Pietersen, A.; Graff, C.; Lind, B.; Struijk, J.J.; Olesen, M.S.; Sinner, M.F.; Bachmann, T.N.; Haunsø, S.; et al. P-wave duration and the risk of atrial fibrillation: Results from the Copenhagen ECG Study. Heart Rhythm. 2015, 12, 1887–1895. [Google Scholar] [CrossRef]
  37. Duan, J.; Wang, Q.; Zhang, B.; Liu, C.; Li, C.; Wang, L. Accurate detection of atrial fibrillation events with RR intervals from ECG signals. PLoS ONE 2022, 17, e0271596. [Google Scholar] [CrossRef]
  38. Keidar, N.; Elul, Y.; Schuster, A.; Yaniv, Y. Visualizing and quantifying irregular heart rate irregularities to identify atrial fibrillation events. Front. Physiol. 2021, 12, 637680. [Google Scholar] [CrossRef] [PubMed]
  39. Pratticò, D.; Carlo, D.D.; Silipo, G.; Laganà, F. Hybrid FEM-AI Approach for Thermographic Monitoring of Biomedical Electronic Devices. Computers 2025, 14, 344. [Google Scholar] [CrossRef]
  40. Laganà, F.; Pellicanò, D.; Arruzzo, M.; Pratticò, D.; Pullano, S.A.; Fiorillo, A.S. FEM-Based Modelling and AI-Enhanced Monitoring System for Upper Limb Rehabilitation. Electronics 2025, 14, 2268. [Google Scholar] [CrossRef]
  41. Laganà, F.; Pratticò, D.; Angiulli, G.; Oliva, G.; Pullano, S.A.; Versaci, M.; La Foresta, F. Development of an Integrated System of sEMG Signal Acquisition, Processing, and Analysis with AI Techniques. Signals 2024, 5, 476–493. [Google Scholar] [CrossRef]
Figure 1. Block diagram of the logical steps of the proposed algorithm.
Figure 1. Block diagram of the logical steps of the proposed algorithm.
Signals 07 00003 g001
Figure 2. Distributions of AAE obtained, respectively, from comparisons between the ground truth and proposed algorithms and the Pan-Tompkins algorithm on healthy subjects.
Figure 2. Distributions of AAE obtained, respectively, from comparisons between the ground truth and proposed algorithms and the Pan-Tompkins algorithm on healthy subjects.
Signals 07 00003 g002
Figure 3. Distributions of AAE obtained, respectively, from comparisons between the ground truth and proposed algorithms and the Pan-Tompkins algorithm on AF patients. An asterisk (*) denotes a statistically significant difference between the two distributions.
Figure 3. Distributions of AAE obtained, respectively, from comparisons between the ground truth and proposed algorithms and the Pan-Tompkins algorithm on AF patients. An asterisk (*) denotes a statistically significant difference between the two distributions.
Signals 07 00003 g003
Figure 4. Representation of a healthy ECG segment with detected points.
Figure 4. Representation of a healthy ECG segment with detected points.
Signals 07 00003 g004
Figure 5. Representation of an AF ECG segment with detected points.
Figure 5. Representation of an AF ECG segment with detected points.
Signals 07 00003 g005
Figure 6. Evolution of the cost function of P s l o p e with respect to the parameters M end t h r P s l o p e . The region highlighted in red represents the lowest value of the cost function.
Figure 6. Evolution of the cost function of P s l o p e with respect to the parameters M end t h r P s l o p e . The region highlighted in red represents the lowest value of the cost function.
Signals 07 00003 g006
Table 1. Table of p-value for healthy subjects.
Table 1. Table of p-value for healthy subjects.
First DistributionSecond Distributiontdfp
AAE (ground truth–proposed algorithm)AAE (ground truth–Pan-Tompkins)1.98290.079
Table 2. Table of performance on healthy subjects.
Table 2. Table of performance on healthy subjects.
DistributionNMeanSD
AAE (ground truth–proposed algorithm)100.1340.209
AAE (ground truth–Pan-Tompkins)100.0060.005
Table 3. Table of p-value for AF patients.
Table 3. Table of p-value for AF patients.
First DistributionSecond Distributiontdfp
AAE (ground truth–proposed algorithm)AAE (ground truth–Pan-Tompkins)−9.8979<0.001
Table 4. Table of performance on AF patients.
Table 4. Table of performance on AF patients.
DistributionNMeanSD
AAE (ground truth–proposed algorithm)100.0760.069
AAE (ground truth–Pan-Tompkins)100.4700.142
Table 5. Table of PE [%] obtained from the training set.
Table 5. Table of PE [%] obtained from the training set.
FeatureFantasia DatabaseAF Termination Challenge DatabaseMThr
P d i f f 3.23%0%70.1
P a r e a 6.45%1.45%100.5
P a m p 12.09%13.04%100.05
P s l o p e 0%0%70
Table 6. P s l o p e confusion matrix obtained from test set.
Table 6. P s l o p e confusion matrix obtained from test set.
PN
P0.9570.037
N0.0440.963
Table 7. Table of performance from test set.
Table 7. Table of performance from test set.
MetricPerformance [%]
ACC96%
TPR96%
FPR4%
Specificity96%
PPV96%
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Filisetti, A.; Bia, P.; Luciani, G.; Losardo, M.; Ardoino, R.; Manna, A. A Novel Deterministic Algorithm for Atrial Fibrillation Detection. Signals 2026, 7, 3. https://doi.org/10.3390/signals7010003

AMA Style

Filisetti A, Bia P, Luciani G, Losardo M, Ardoino R, Manna A. A Novel Deterministic Algorithm for Atrial Fibrillation Detection. Signals. 2026; 7(1):3. https://doi.org/10.3390/signals7010003

Chicago/Turabian Style

Filisetti, Alessandro, Pietro Bia, Germana Luciani, Margherita Losardo, Riccardo Ardoino, and Antonio Manna. 2026. "A Novel Deterministic Algorithm for Atrial Fibrillation Detection" Signals 7, no. 1: 3. https://doi.org/10.3390/signals7010003

APA Style

Filisetti, A., Bia, P., Luciani, G., Losardo, M., Ardoino, R., & Manna, A. (2026). A Novel Deterministic Algorithm for Atrial Fibrillation Detection. Signals, 7(1), 3. https://doi.org/10.3390/signals7010003

Article Metrics

Back to TopTop