Real-Time Ventricular Cancellation in Unipolar Atrial Fibrillation Electrograms

Unipolar atrial fibrillation (AF) electrograms (EGMs) require far-field ventricle cancellation to recover hidden atrial activations. Current methods cannot achieve real-time cancellation because of the temporal delay they introduce. We propose a new real-time ventricular cancellation (RVC) method based on causal implementation optimized for real-time functioning. The method is similar to the classical average beat subtraction (ABS) method but it computes the ventricular contribution before the ventricular activation finishes. We compare the proposed method to the ABS on synthetic and real EGM databases for the time and frequency domains. All parameters and their optimal values are analyzed and validated. The RVC method provides a good reconstruction of the unipolar EGMs and a better local activation time detection than the classical approach with average F1scores 0.7307 and 0.7125, respectively. The spectral analysis shows that the average power after ventricular cancellation is reduced for frequency bands between 3 and 5.5 Hz, demonstrating that the proposed method removes the ventricular component present in the unipolar EGM signals compared to the ABS method. The phase mapping analysis on the RVC method presented lower error when comparing the annotated EGM cycles with the phase inversion intervals. In terms of performance ABS and RVC behave similarly, but the real-time capability of the latter justifies its preference over the offline implementations. In the clinical environment other online investigations, e.g., rotational activity assessment, dominant frequency or local activation time mapping, might benefit from the real-time potential of the proposed cancellation method.


INTRODUCTION
Atrial fibrillation (AF) is a cardiac arrhythmia characterized by irregular activations of the upper chambers of the heart, the atria. The disorganized electrical activity prevents the atria to deliver blood to the ventricles efficiently. Although AF is the most common arrhythmia in the clinical practice treatments remain suboptimal, in part due to the poor understanding of its initiating and perpetuating mechanisms (Kirchhof et al., 2016). To study AF electrophysiologists employ multi-electrode catheters advanced inside the atrial chambers. The catheters contain multiple electrodes that register voltage electrograms (EGMs) in contact with the atrial tissue, providing a measurement of the electrical activity of AF.
Signal processing algorithms applied on the EGMs provide useful insight into the mechanistical properties of AF, but the irregularity of the AF activation patterns in time makes it difficult to analyze their behavior (Ciaccio et al., 2011;Kogawa et al., 2015). To study AF current methods rely on local activation times (LATs) in unipolar EGMs to address the detection of anomalous propagation patterns, i.e., rotors or focal electrical discharges (Narayan et al., 2012;Daoud et al., 2017). In unipolar EGMs each activation is defined by a sharp deflection of voltage, and LATs can be identified at the maximum negative derivative of the signal − dV dt , independently of the direction of the propagating wavefront (Spach et al., 1979). However, unipolar EGMs also record far-field ventricular signal, which interferes with the atrial activity.
To overcome this problem the classical approach is to apply the average beat subtraction (ABS) method (Slocum et al., 1985;Shkurovich et al., 1998), which considers the ventricular activity to be uncoupled to AF. The method detects the ventricular activity in a single electrocardiogram (ECG) lead, calculates an average beat template of the contribution of the ventricular activity, and subtracts it from the unipolar EGM revealing the hidden atrial activity. Variations to the ABS method have been proposed using different interpolation approaches for the subtracted QRST interval (Ahmad et al., 2011), or finer alignment matching different pattern lengths (Salinet et al., 2013;Ríos-Muñoz et al., 2018).
However, these methods require signal acquisitions from several seconds to minutes, e.g., 7, 30 s, or even 2 min (Narayan et al., 2012;Salinet et al., 2013;Daoud et al., 2017), and they are applied offline, with a chance for the AF to have changed at the time the results are available. Hence the need to process the signals in real-time and also to reduce the overall procedure time for safety reasons regarding the life of the patient.
To address this problem we present a new method that applies real-time ventricular cancellation (RVC) on short EGM segments, i.e., 100 ms, to achieve real-time signal processing, as an alternative to other methods that work with longer acquisitions. Our method relies on the duration and morphology of the QT ECG signal, which at rest remains stable (El-Chami et al., 2010;Vančura et al., 2016). Hence, we can store previous EGMs to estimate the ventricle pattern. We subtract the farfield contribution using this pattern in real-time even for the segments that only contain a portion of the total QT interval. We align the segment with the pattern and we subtract only the portion of the pattern related to the segment. We do not require a complete QT interval to apply our method, reducing the delay between acquisition and result availability, as opposed to Shkurovich et al. (1998), Ahmad et al. (2011), and Salinet et al. (2013). Additionally, the pattern adapts in time as new ventricular activations are detected evolving with changes in the fibrillatory state.
The real-time feature of the RVC method reduces the time to provide processed signals to other existing technologies and contributes to improve the understanding of the AF problem, in addition to other studies that also employed unipolar EGMs (Allessie et al., 2010;de Groot et al., 2010).

MATERIALS AND METHODS
In this section we detail the methodology of the study. We first present the synthetic and real AF signal databases that we employed to analyze and validate the method. Second of all, we describe the RVC method and its implementation in the clinical practice. To that end, we estimated the storage requirements for the data buffers to achieve real-time signal processing and we analyzed the ventricular pattern quality. Finally, we introduce the time and frequency domain analysis to compare the ventricular cancellation performance of the RVC and ABS methods.

Synthetic AF EGMs Database
We employed a synthetic unipolar EGM database to analyze and set the values of the parameters of the RVC method (Valinoti et al., 2018). We also used the signals to compare the cancellation performance to the ABS method for LAT detection in the unipolar EGMs. The database consists of seven sets of 50 different unipolar atrial EGMs of 10 s length. The sets differ from each other by an additive noise signal that is generated by modifying the variance value of a Gaussian random variable, zero mean and variance σ n = j · σ , where n ∈ [1, 7] noise levels, and j = 0, 0.1, 0.2, 0.5, 0.7, 0.9, 1. The value of σ is obtained by the autoregressive model in Valinoti et al. (2018). The different levels of noise are useful for testing and validating the performance and robustness of the algorithm at challenging situations, e.g., EGMs exhibiting low signal to noise ratio or fragmentation. The database includes the annotated LATs location for all the unipolar EGMs, and it contains ventricular far-field which is also delimited and known for all the signals. Figure 1 provides an example of the synthetic signals in the database for the different noise levels including LAT and ventricular far-field annotations.

Real AF EGMs Database
The real AF signals in the study were acquired and processed on 32 AF patients. All patients gave full informed consent and the study was approved by the Institutional Review Board of the center. The sampling frequency was f s = 1 KHz, unipolar EGMs referred to the Wilson central terminal were filtered 0.05-100 Hz, bipolar EGMs 30-240 Hz, and ECGs 0.05-100 Hz.
Each acquisition consists of one ECG signal and 15 unipolar EGMs recorded with a PentaRay catheter. A total of 890 acquisitions were made (mean 27.81 acquisitions per patient), i.e., 890 ECG and 13,350 unipolar EGM signals in the database. The acquisitions were recorded at different regions of the left atrium during the routine electro-anatomical mapping study (Carto 3 system, Biosense Webster) prior to catheter ablation of the pulmonary veins. The database includes signals from: pulmonary veins, left atrial appendage, roof wall, posterior wall, septum, ridge, mitral ring, and lateral wall. All signals were 10 s long at a sampling frequency f s = 1 KHz.

Real-Time Ventricle Cancellation Proposed Method
Ventricular cancellation methods require complete ventricular contributions to be applied. Online signal processing deals with smaller signal segments, e.g., 100 ms segments, hence no complete QRST complex is guaranteed in an acquisition, as Figure 2 shows. The ECG and EGM signals consist of seven consecutive segments, i.e., s 0 − s 6 . In the figure, segments s0 and s5 − s6 are free of ventricular activity (in green), while s1 − s4 are partially or fully affected (in red). Current cancellation methods narrow the temporal window affected by the ventricular contribution by knowing when the T-wave finishes (T end ), and they remove the ventricle signal, that spans until segment s4 in Figure 2. To overcome this situation, we propose a RVC method that estimates the ventricular pattern contribution based on previous activations, and automatically updates the pattern when a new complete ventricular activation is available. The RVC can therefore be applied before T end is acquired. Notice that in Figure 2 the R-peak appears in segment s1, 3 acquisitions before T end finishes in s4.
The predictive nature of the method relies on R-peak detections in the ECG signal to trigger the online cancellation. The R-peak is detected based on a maximum peak voltage search in the ECG segment and imposing two conditions. First condition requires a blanking period between R-peaks, FIGURE 1 | Synthetic EGM database signals for different levels of noise (Valinoti et al., 2018). Top signal corresponds to the presence of no noise (level 1) and bottom signal to the highest noise value (level 7). All signals include LATs and ventricular activations annotations. To improve the visualization only the first 5 s of the signals are displayed.
FIGURE 2 | ECG and EGM containing far-field ventricular contribution. From top to bottom: reference ECG to narrow the ventricular component, unipolar EGM affected by the far-field ventricular activity, and 100 ms acquisitions illustrating the segments affected (red) and not affected (green) by the ventricular contribution. Fiducial points corresponding to the Q-peak, R-peak and T end time instants are annotated in the ECG signal.
i.e., 300 ms, to prevent any spurious artifact or the T-wave to be misidentified as an R-peak. The second condition applies a minimum threshold that directly depends on the last V ventricular activations, and it is recalculated after every new R-peak detection. This threshold is adjusted to meet the ECG morphology of the patient (Supplementary Figure 1). The Qpeak is directly detected as the minimum value in a 50 ms window before the R-peak. We considered other methods in the literature based on wavelet transform, and Gilbert transform for R-peak detection. However, the high signal-to-noise ratio that the electrophysiology amplifier offered when acquiring the signals, and the simplicity of the proposed R-peak detection justified or preference for the R-detection method.
The T end time instant is calculated with a method designed for positive T-waves by Zhang et al. (2006). In a 12-lead ECG several leads provide a positive T-wave, e.g., II, V5, or V6. The ECG exhibiting a significant larger R-peak than the T-wave amplitude is selected prior to the initialization of the system, as other electrophysiology and electro-anatomical mapping systems do (Narayan et al., 2012;Daoud et al., 2017). Supplementary Figure 1 further illustrates the fiducial point detection for continuous acquisitions in real-time in a patient.
The position of the R-peak varies within the segments, and the previous acquisition can contain part of the QR interval. Hence the RVC method buffers the previous signal acquisitions. For each channel we buffer the unipolar EGM signal segments, Q × L samples, where L is the acquisition segment size and Q the number of segments of length L to be stored in the buffer. Then, we estimate the ventricle pattern as the average of the last V stored ventricle activations. We take advantage of the low variability between consecutive ventricular contributions to set the value of Q segments (El-Chami et al., 2010). Q can be adequately adapted to the electrophysiological QRST duration of the patient, e.g., Q = 5-6 segments.
The steps of the RVC method are simplified in the diagram flow in Figure 3. As a result of buffering the signals, at time t the method provides the cancellation for the signal s t−1 at t − 1, and the output for s t is available at time instant t + 1, as Figure 3 depicts. We associate each segment s t with a pointer to the QRST buffer where the signal containing the ventricular contribution is to be stored, namely q ∈ [0, Q − 1]. Following the diagram flow several cases occur whether a new R-peak is detected in the ECG segment or if the signal falls in the QRST range: • Case q = 0 and no R-peak in the current segment: we store the EGM segment s t in the QRST buffer at position q = 0 in the event the next segment contains one R-peak. Segment s t−1 is provided free of ventricle cancellation. • Case q = 0 and R-peak present in the current segment: a new R-peak is detected, q is set to 1, and segment s t is stored at position q = 1. We search for the Q-peak in the segments s t−1 and s t , and predictive ventricle cancellation is applied to segments s t−1 and s t . The pre-computed ventricle pattern is aligned by direct correlation with respect to the current signal in the QR interval and subtraction is performed. Segment s t−1 is provided at the output, and buffer storing pointer gets incremented, i.e., q = q + 1. • Case 2 ≤ q ≤ Q − 1: similarly, segment s t is stored at position q in the QRST buffer and ventricle cancellation is applied to it. We search for the T end fiducial point and if not found q = q+1. If found, the ventricular pattern is updated, we remove the oldest QRST contribution in the QRST buffer and compute the new pattern with the V − 1 remaining contributions plus the new contribution. Finally, the pointer is reinitialized to q = 0, ventricular free segment s t−1 is provided, and the RVC starts again, ready to detect the next R-peak.

Signal Buffering for Real-Time Achievement
The RVC method requires to buffer the signals to apply the cancellation in real-time. To provide evidence that the Q-peak is contained in the proposed buffered signal, i.e., 100 ms, we studied the QR interval duration of all the database ECGs. Figure 4A shows the histogram for the QR duration of 9,836 ventricular activations in 890 ECGs from the real AF EGM database. The mean QR interval is 40.94 ms with a standard deviation of 6.97 ms. The QR interval range justifies the choice of 100 ms data segments, even for the most extreme case we encountered for a patient with a QR interval equals 50 ms. Additionally, the QRST duration was analyzed to set the buffer size Q for the EGMs to be averaged. In the histogram in Figure 4B, the average interval lasts 430.09 ms with standard deviation equals to 76.06 ms, based on 9,836 detected QRST activations. Therefore a buffer of Q = 6 segments (600 ms) can store the unipolar EGM segments comprising the ventricular contribution. In the event of longer QRST intervals this buffer can be extended to match the needs of the patient.

Signal Conditioning and Implementation
Prior to apply the RVC method the signals are conditioned. A causal 500 ms median filter removes the respiratory movement of the patient present in unipolar EGMs as in de Chazal et al. (2003). Since the filter length is longer than the acquired segments, the signals are stored in a buffer so we can apply the median filter. The buffer size is B × L samples, where L is the acquisition segment size and B the number of segments of length L. For L = 100 ms acquisitions and a 500 ms median filter we set B = 5 segments. The filtering is performed sequentially for each channel. After the baseline is removed, the oldest 100 ms buffered segments are discarded and updated with the next acquired segments. Hence, the pre-processing step can be applied for filter orders greater than the acquisition segment length. The reader is referred to the frequency response function of the implemented median filter in Figure 4B in the article (Ríos-Muñoz et al., 2018) that further describes how the frequency components of the signals are affected.
The RVC method was implemented in Python 3.7, C, and employs the NVIDIA GPU Computing Toolkit v.10.0. The implementation is open source and no license dependent of any other commercial software. This grants feasibility and reproducibility for the software to be implemented in other systems at no supplementary license costs. A Graphical user interface (GUI) in python is in charge of calling the C and CUDA kernel functions for the real-time signal processing, and atrial signals free of ventricle contributions are available for display or further post-processing.
The hardware specifications of the system are: one 8-core Intel R Xeon R CPU 3.40 GHz processor, 16 GB RAM, on 64 bits Windows 7 Professional. The graphical processing unit (GPU) is one Nvidia Tesla K20c with 2496 CUDA cores, and a Titan V model was used for validating and testing the methods. The signals were acquired and digitalized using an analog to digital converter (ADC) manufactured by National Instruments connected to a ClearSign TM amplifier (Boston Scientific) which offers 16 analog output signals.
To achieve real-time results, we used short segments of unipolar EGM and ECG signals, with a duration of L = 100 ms which is the minimum segment size the ADC hardware offered (National Instruments, USA). Since the signal amplifier only offers 16 signals to the ADC, we selected one ECG lead and 15 unipolar electrode channels of the total 20 electrodes of the catheter to apply the RVC method.
We ran 500 continuous 100 ms segment acquisitions for 15 EGMs and one reference ECG using Python 3.7 and C dll functions. The averaged execution time for the code was 1.482 ms with standard deviation equals 0.546 ms. We emulated the acquisition and signal processing for an increasing number of virtual EGMs ranging from 15 to 200 channels. Supplementary Figure 2 shows the average execution time performance for different number of channels. The results provide evidence that the RVC method works in real-time since it processes the data faster than the 100 ms acquisition period, even for 200 simultaneous channels.

Estimated Ventricular Pattern Analysis
The stability of the pattern in time plays an important role in the RVC method. The number of ventricle contributions to provide a stable pattern is important regarding its implementation in the clinical practice. For each of the signals in both databases, incremental patterns were obtained by cumulatively averaging the number of contributions, namely and v i is the number of ventricle contributions in the i − th acquisition for i ∈ [1, 350] in the synthetic database, and i ∈ [1, 890] in the real AF EGM database. As an example, p 3 is obtained as the average of three consecutive EGM segments affected by ventricle contribution. Figure 5 shows the averaged patterns for V = 1-12 contributions, the total number of QRST events in a real AF signal. The pattern for only one contribution contains strong atrial activity, see Figure 5 bottom signal. On the other hand, as the number of averaged contributions increases, the atrial component fades and the ventricular contribution is enhanced, which is the main foundation of ventricular cancellation methods.
To set the value of V that produces the most stable pattern, the quality of the patterns with respect to the number of contributions employed was measured. The mutual information for consecutive patterns was calculated, i.e., I(p j ; p j−1 ) for j ∈ [2, v i ] (Cover and Thomas, 2006). Mutual information measures how much information one signal tells us about another, namely I(p j ; p j−1 ) = H(p j ) − H(p j |p j−1 ). Particularly, how much new information a pattern with more ventricular contributions provides given one computed with less components. The function H(p j ) is the entropy of pattern p j , and H(p j |p j−1 ) is the conditional entropy of pattern p j given p j−1 . If the signals are independent, i.e., very different, H(p j |p j−1 ) ≈ H(p j ) hence I(p j ; p j−1 ) ≈ 0. If they are similar, H(p j ; p j−1 ) ≈ 0, and I(p j ; p j−1 ) is maximized.
To reinforce the pattern analysis the Pearson's correlation coefficient measurement on the patterns is included. The correlation coefficient is calculated over two vectors, i.e., two patterns, for an increasing number of averaged ventricular contributions, similarly to the mutual information study. The correlation coefficient of two random variables measures their linear dependence, i.e., two patterns in our case p i and p i+1 . For each pattern of length equals L samples, the Pearson's correlation coefficient is defined as where n refers to the time instant n ∈ [1, L] samples, andp i and p i+1 are the mean values of the patterns.
Following this methodology, the pattern becomes more stable when the mutual information converges to a maximum value. In the synthetic data the mean mutual information for all the noise levels is maximum at V = 4 contributions with I(p 4 ; p 3 ) = 4.439 bits in Figure 6A. We see how the mutual information decreases as more contributions are used to obtain the averaged pattern. In our real AF data in Figure 7A, we achieved the maximum at V = 12 contributions with I(p 12 ; p 11 ) = 5.086 bits. For higher number of contributions the pattern does not longer improve and mutual information decays.
Similarly to mutual information, the correlation of patterns for an increasing number of averaged ventricular contributions will increase as the patterns become more similar to each other. The maximum correlation value r p i ,p i+1 = 1 will be reached when the patterns are identical.
The synthetic database achieves the maximum correlation point for V = 8 contributions, r p 8 ,p 7 = 0.996 in Figure 6B. For V > 4 contributions the correlation value slows down as it converges to 1. The real AF EGMs database achieves the maximum correlation value for V = 12 contributions, r p 12 ,p 11 = 0.991 in Figure 7B. Once again, for fewer number of contributions, i.e., V > 8, the correlation value does not improve significantly as it converges to 1.

Time Domain Approach to Compare Cancellation Methods
The real-time RVC method is compared to the offline ABS algorithm (Shkurovich et al., 1998). We evaluated the performance based on the detection of unipolar EGM LATs after ventricular cancellation on the annotated synthetic database. Both methods share concepts like the averaged pattern calculation, they are similar to implement, and involve analogous signal processing operations, e.g., signal alignment or pattern subtraction. They handle as input signals the same unipolar EGMs and a reference ECG. The F1score for LAT detection was used as the metric for comparison.
The F1score is a standard statistical performance measure obtained as the harmonic mean of sensitivity and precision, also  know as true positive ratio (TPR) and positive predictive value (PPV), respectively: where true positive (TP) is the number of correctly detected LATs, false negative (FN) is the failure when detecting existing LATs, false positive (FP) is the detection of an non-existent LAT, and P the number of annotated LAT events. Hence the F1score is calculated as: Thousands of simulations were performed for the different parameters involved in the implementation of the RVC algorithm. The analyzed variables were the LAT detection parameters M, σ abs , and τ which correspond to the slope approximation filtering parameter, the minimum detection threshold and the exponential adaptive threshold, respectively as in Ríos-Muñoz et al. (2018), and as an additional parameter for the RVC method the number of ventricular contributions V. Table 1 includes all the analyzed parameter values, for a total of 11,310 parameter combinations. The performance F1score was calculated on the synthetic LAT database prior to employ the best parameters with real AF EGMs. The first ventricular far field component of the synthetic signals was canceled using a precomputed pattern using eight different random contributions from the dataset. This approach mimics the behavior of the real-time implementation of the RVC method, which always has an available pattern as the catheter is moving inside the atrial chambers.
To compare the RVC method in real AF signals, the number of ventricular contributions was fixed to V = 8 regarding the performance results for the synthetic signal database in Table 1. Although a value of V = 2 contributions shows no relevant differences in mutual information in Figure 7, its pattern does exhibit higher voltage variations than patterns with greater V values, as Figure 5 shows. What is more, using V = 8 contributions instead of 12 the necessary time that the catheter needs to be deployed and stabilized before acquiring the signal is reduced by a 33% factor. Hence the clinical procedure duration is minimized. Correlation values on the synthetic and real EGM databases present saturated values of correlation around 0.98 − 0.99, meaning that patterns are very similar for an increasing number of averaged ventricular contributions. Performance is measured for all the LATs in the EGMs and also restricting the LAT detection to the segments affected by ventricular far-field. Bold values represent the best F1score performance for each noise level.
The cancellation was performed online while the signals were being acquired directly from the patients using the acquisition system detailed in the Methods section. For the ABS method, the signal processing was performed offline. We used all the QRST contributions in the 10 s signals to calculate the pattern and we applied the cancellation. Figure 8 contains an example of the ventricular cancellation using both methods. In the top ECG signal we can identify two ventricle activations. The ABS and the RVC outputs applied to the U 1 signal correspond to the signals at the bottom of Figure 8. By visual inspection both methods manage to cancel the ventricular contribution. However, there is no straightforward error measurement to compare their performance. We propose to use the local activity information contained in the bipolar EGM to quantify true atrial activations. Following this reasoning, we can quantify the number of LATs after the ventricular cancellation related to the bipolar activity. Whenever there is an activation in the bipolar EGM, atrial activity exists in the unipolar recording.
Unfortunately, there is no consensus when defining the LAT in a bipolar EGM. As opposed to the unipolar case, where the LAT corresponds to the maximum negative slope of the signal, i.e., − dV dt , the bipolar case remains unclear. Bipolar LATs can be identified as the mean value between bipolar onsetoffset (El Haddad et al., 2013), as the maximum negative or positive slope of the signal (De Bakker et al., 1995), or even identified by a predefined annotated signal database (Treo et al., 2013). In the following, we define the presence of bipolar activity when the bipolar EGM contains energy over a predefined threshold. We take into consideration the temporal window of the bipolar activations and generate a binary bipolar mask b[n], i.e., b[n] = 1 if there is activity and b[n] = 0 otherwise, see the squared pulse train in Figure 8. To obtain the binary bipolar mask the EGM is filtered similarly to El Haddad et al. (2013).
After the mask, the LATs in the ventricular-free unipolar signals are detected for both ABS and RVC methods. A LAT detection algorithm enhances the slope of the voltage signal prior to the detection of its maximum negative slope (Ríos-Muñoz et al., 2018). The best performance RVC method parameter combination was used.

Frequency Domain Approach to Compare Cancellation Methods
We investigated the frequency spectrum impact of the ventricular cancellation methods with respect to the original raw EGMs. We computed the average dominant frequency (DF) of the signals using the settings in Botteron and Smith (1995). We also analyzed the average energy spectrum ratio in the EGM signals for two frequency bands 3-5.5 and 5.5-12 Hz that quantifies the performance of the T-wave subtraction (Salinet et al., 2013). The P ratio is defined as where P a−b is the area under the power spectrum curve for the frequency interval a and b in Hz, and P(f ) is the frequency spectrum function of the EGM signal being analyzed. The P ratio aims to measure the quality and global effect of the ventricular cancellation methods. The higher the value of the P ratio , the better the T-wave repolarization subtraction is achieved. Table 2 contains the results. Raw unipolar EGM U 1 where ventricle cancellation is applied. Unipolar EGM U 2 used to compute the bipolar EGM. Differential bipolar signal obtained as U 2 − U 1 . Bipolar activity mask, active when there is signal in the bipolar EGM and zero otherwise. Offline ABS method applied to U 1 with LATs circled in red. Online RVC method applied to U 1 with LATs circled in red. Bipolar activity is highlighted in the unipolar EGMs to illustrate the scope of the atrial activation.

Phase Domain Approach to Compare Cancellation Methods
To complete the study of the methods, we also investigated the phase domain of the signals. Phase mapping is commonly used to analyze AF signals regarding reconstruction of the atrial wavefronts and rotor singularity points detection (Narayan et al., 2012). We analyzed the synthetic signal database and applied the phase mapping method by Kuklik et al. (2015). The method uses sinusoidal recomposition for unipolar EGMs based on the Hilbert Transform of the signal, where the output signal is the combination of different sinusoidal wavelets with amplitude proportional to the EGM negative slope. We followed a similar approach as in Kuklik et al. (2015) to assess the performance of the methods in the phase domain. We compared the cycles of the annotated intervals in the database and compared them to the time instants at which the phase value of the ABS and RVC signals is inverted, which are known to exhibit a good correlation (Kuklik et al., 2015). We computed the mean absolute error as performance metric for all the noise levels in the synthetic database and included the results in Table 4.

RESULTS
This section is devoted to the performance results of the RVC and ABS methods in synthetic and real AF signals. Firstly, we report the ventricular cancellation performance of the RVC method to the ABS for the synthetic database signals for LAT detection. Secondly, we present the frequency domain analysis results of the methods. Then, phase mapping results for both methods is investigated. Finally, we present the results of applying the RVC on real AF signals in real-time. Figure 9A presents the best F1score results for the ABS method for the different noise levels of the synthetic database sets. As expected performance degrades as the noise level increases, exhibiting an average F1Score = 0.7125. For the RVC method the same parameter combination simulations were employed, including the additional V number of ventricular contributions parameter. The total number of simulations for the RVC was 124,410. Figure 9B shows the analysis for the different values of contributions and the different noise levels. The best average performance was obtained for V = 8 contributions with F1Score = 0.7307. We included the performance of the LAT detection taking into account only the activations within the interval affected by the far field. The ABS method achieved an average F1score = 0.7050 (Figure 9A), and the RVC method F1score = 0.7110 ( Figure 9C). Table 1 summarizes the simulation results for both methods. In the absence of noise both methods perform similarly, but globally the RVC method performs better and specially for clinical EGMs that suffer from additive noise. Parameter settings for the RVC method were: M = 6, σ abs = 1 · 10 −4 , and τ = 1 · 10 −4 . The best parameter settings for the ABS were achieved for: M = 8, σ abs = 0, and τ = 3 · 10 −4 .

Real AF EGMs
The number of detected LATs in the signals was quantified, and the performance of the methods only during the QRST interval was evaluated. Table 3 shows that both methods achieve similar results, with the RVC method detecting more and better LATs in both the whole 10 s EGMs, and additionally for the EGMs segments comprised in the QRST intervals. One of the reasons the ABS provides a lower number of LATs is related to the number of ventricular activations that are used to compute the averaged pattern. In some signals the number of QRST contributions might be too high (up to 21 in our database as shown in Figure 7), and since the AF nature is indeed irregular, the atrial recording can vary in time which can worsen the quality of the pattern.
Some of the undetected LATs in the bipolar mask corresponded to activations associated to multiple deflections in the unipolar EGM that were detected before or after the bipolar binary mask. This is an expected result of unipolar configuration, since these activations might be associated to double potentials of the atrial tissue, activations when the catheters touch each other inside the atrial chamber, fragmented EGMs related to electrical remodeling of the cardiac tissue, or even to additional muscular far-field.

Frequency Analysis Results
For the synthetic database, the mean DF for raw EGMs, the ABS method and the RVC method were 4.4864, 5.1784, and 5.0619 Hz, respectively. For the real AF signals, the mean DF for the raw EGMs, the ABS method and the RVC method were Bold values represent the method that detected more LATs.
5.4119, 5.7065, and 5.9276 Hz, respectively. All DF distributions were compared with a paired t-test and p-values were obtained. Significance was assumed if p-value < 0.01. Results in Table 2 show that the DF for both cancellation methods is significantly increased with respect to the raw real AF EGMs (both ABS and RVC p-values were smaller than 0.01).
The P ratio results in Table 2 also provided evidence that the ventricular cancellation methods had an impact in the frequency spectrum. In the synthetic database, the mean P ratio for the raw EGMs was 1.6959, whereas the ABS method achieved 1.7638 and the RVC 1.7175. For the real AF signals, mean P ratio for the raw EGMs was 1.8851, whereas the ABS method achieved 2.1914 and the RVC 2.4644. Significance t test between the methods distributions and the raw signals confirmed the significance of the results (p-value < 0.01.) The RVC method achieved the highest mean P ratio .

Phase Mapping Analysis Results
We applied phase mapping to the synthetic database signals to evaluate the impact of the ventricular cancellation methods on the phase domain. We compared the mean cycle length of the signals calculated from the annotated LATs and the mean cycle obtained from the phase inversion times of the phase signal as proposed in Kuklik et al. (2015). The results in Table 4 show evidence of the good correlation between the phase mapping intervals and the time domain for low noise level signals. For noise level 1 the ABS method obtained a mean absolute error of 1.2678 ms and the RVC method scored 0.9189 ms. Error was calculated as the mean of the absolute error of all the independent intervals. The performance worsened for higher noise levels, in which the RVC method obtained lower error values compared to the ABS. Overall phase results showed that the mean error of the ABS was 16.9832 ms and the RVC 15.8243 ms for the complete database.

DISCUSSION
The most widely used method for ventricle cancellation in unipolar AF signals is ABS. The ABS method is applied offline, which introduces a delay ranging from a few seconds to even minutes depending on the implementation and the length of the acquired signals. To reduce this latency we need an online method instead of one that is applied to batches of signals or lengthy acquisitions. What is more, the method must be predictive to not depend on complete QRST ECG complex detection to be applied. In consequence, the proposed RVC method introduces an important innovation in the cardiac electrophysiology field, since it estimates the ventricular pattern affecting the unipolar atrial signal based on previous stored contributions in real-time. This feature avoids the complete QRST interval detection requirement of other methods and it enables online signal processing, the main contribution of this paper. This advantage allows other algorithms to receive signals at reduced delay boosting their response time, e.g., real-time rotor detection (Daoud et al., 2017;Ríos-Muñoz et al., 2018), dominant frequency analysis (Botteron and Smith, 1995), or causality EGM relationships (Luengo et al., 2019). To evaluate the RVC method, the quality of the patterns was analyzed with respect to the number of averaged contributions with a novel approach based on mutual information and correlation measurements (see Figures 6, 7). Although it may seem sensible to use as many contributions as possible, obtaining a pattern with a higher number of contributions is not advisable, as our results confirmed. Firstly because of safety reasons, since the catheter would be required to be placed for a longer period at the same position, extending the overall duration of the clinical procedure. What is more, certain areas of the atria are more difficult to map, and providing a stable position with the catheter becomes a challenge for lengthy acquisitions. Secondly, due to the computational time cost for processing more contributions, which also increases memory buffer allocation in the system. We consider that 8-12 contributions provide a good pattern for the real-time ventricle cancellation, while preserving the quality of the pattern. The results on the synthetic and real AF EGM support this choice.
In this sense, we provided a safe way to validate the RVC method using a LAT annotated unipolar EGM database. We quantified the number of true detected LATs based on the activity of bipolar EGMs. We concluded that our method was able to detect more and better the LATs compared to the ABS approach. We can relate this behavior to the number of ventricular contributions employed to calculate the cancellation patterns. The more contributions that are used the worse the pattern becomes, which is the case of cancellation methods that use higher number of contributions, as the mutual information and correlation measurements confirmed in Figure 7.
As for the real AF EGM database, we are aware of potential limitations when using bipolar signals which are very sensitive to the electrical wavefront directionality with respect to the differential electrodes calculating the bipolar measurement. As an example, if two electrodes are activated at the same time the resulting bipolar signal will contain no electrical activity information since the signals cancel each other. For this reason we cannot conclude that the activations that do not match the binary bipolar mask correspond to false atrial activity or spurious deflections derived from the ventricle cancellation method. We are also aware that the binary bipolar mask proposed works with regular bipolar EGMs, but fragmentation might affect this methodology. To that end we resorted to validate the method using a pre-existing annotated database of unipolar LATs, which granted us the best parameter values to tune our RVC method for different noisy signals. The ABS and RVC methods behave similarly, but the LAT performance and its real-time implementation, support the choice of RVC over ABS.
The frequency domain analysis of the method also provides evidence that the method achieves to cancel the ventricular contributions as the value of P ratio is larger than the original signals. In terms of frequency performance, both methods managed to provide similar results, so the preference of RVC over ABS is justified because of its online and low delay implementation.
The phase domain provided smaller error values for low signal-to-noise in Table 4. As expected, as noise level increased the error metric became worse, due to the multiple deflections introduced by the additive noise in the signals. Phase mapping is a powerful and useful technique to analyze AF EGMs, however in the presence of noise or abundant fragmentation, its performance degrades and it is not advisable to use it due to the low correspondence between the phase transitions and temporal activations. In terms of phase information both ABS and RVC methods behave similarly, so similarly to the frequency results, the real-time feature of the RVC is the main reason for preferring it over ABS.
Finally, we include the output of the real-time ventricle cancellation algorithm applied to three signals exhibiting different morphology in Figure 10. The EGM database consists of signals recorded in all the areas of the left atrium, e.g., pulmonary veins, left atrial appendage, or posterior wall. In the example the dashed signals represent the signals before the RVC algorithm, and the continuous ones free of ventricular contribution. For low voltage signals the effect of the ventricle on the atrial activations is larger if compared to an EGM near a high voltage signal like the areas surrounding the atrial appendages. For these high energy atrial signals we see how the real-time ventricle cancellation has little effect. But it is for the rest of low atrial energy signals when the ventricle cancellation becomes more useful. In Figure 10 the first two signals exhibit a higher ventricular contribution, and the real-time cancellation achieves to recover the hidden atrial information. Additional examples of different atrial sites are included in Supplementary Figures 3, 4.

CONCLUSIONS
We have presented a real-time signal processing method that predicts and removes the far-field activity present in unipolar EGMs recorded during AF. As opposed to other offline methods, the RVC method reduces the delay to process the signals, which allows real-time cancellation. The online cancellation method has been tested on synthetic and real AF EGMs. We have compared its performance to other existing offline method for LAT detection after ventricular cancellation, and we also investigated the cancellation impact on the frequency and phase domains. The online method achieved better results, was more robust, and its implementation in the clinical practice provided real-time results for simultaneous multi-electrode AF signals. In the clinical environment other online investigations, e.g., rotational activity assessment, dominant frequency or local activation time mapping, might benefit from the real-time potential of the proposed cancellation method.

DATA AVAILABILITY STATEMENT
The synthetic datasets for this study are available upon request to the corresponding author in the article by Valinoti et al. (2018). The code for the RVC method presented in this paper is also available upon request to the corresponding author.

ETHICS STATEMENT
All patients gave full informed consent and the study was approved by the local ethical committee of the Hospital General Universitario Gregorio Marañón, Madrid, Spain.

AUTHOR CONTRIBUTIONS
ÁA, FF-A, and AA-R acted as supervisors of the research and contributed in methodological aspects. GR-M and ÁA acquired the signals from patients. GR-M was responsible for performing the data analysis and developing the algorithms and methods. All authors contributed equally to the conception and design of the study, contributed to the manuscript revision, read, and approved the submitted version.

FUNDING
This study was supported by grants PI18/01895 from the Instituto de Salud Carlos III, and RD16/0011/0029 Red de Terapia Celular from the Instituto de Salud Carlos III, projects RTI2018-099655-B-I00; TEC2017-92552-EXP from Ministerio de Ciencia, Innovación y Universidades, Y2018/TCS-4705, PRACTICO-CM Comunidad de Madrid, and the support of NVIDIA Corporation with the donation of the Titan V GPU used during this research.

ACKNOWLEDGMENTS
GR-M would like to acknowledge the support of NVIDIA Corporation with the donation of the Titan V GPU used for this research.

SUPPLEMENTARY MATERIAL
The Supplementary Material for this article can be found online at: https://www.frontiersin.org/articles/10.3389/fbioe. 2020.00789/full#supplementary-material Supplementary Figure 1 | Real-time ECG fiducial points detection for V = 8 ventricular contributions in an AF patient. Example of a buffered ECG lead in which real-time R-peak detection is applied regarding the maximum peak voltage and R-peak threshold, red dots and horizontal line, respectively. Q-peak and T end detection depend on the R-peak detection and are also displayed in the figure, black crosses and magenta diamonds, respectively.