## 2 Materials and Methods
### Dual-Q Tunable Q-Factor Wavelet Transform  
Since atrial fibrillation can exhibit some oscillatory characteristics, we decided to use a tunable wavelet transform, which would allow the observation of oscillatory and transient components of the ECG signal in different frequency sub-bands. The tunable Q-factor wavelet transform (TQWT) is a type of WT that can decompose a signal into multiple sub-bands. Using the inverse TQWT, the signal can then be reconstructed from the sub-bands with the highest energy [50]. The traditional WT is characterized by the invariant Q-factor, i.e., the constant ratio of its center frequency to its bandwidth [51]. The operation of the TQWT relies on the combination of three essential parameters: the Q-factor (Q), redundancy (\(r\)), and level of decomposition (\(J\)). It is imperative to have prior knowledge of these parameters before performing TQWT decomposition. The Q-factor significantly impacts the wavelet's oscillatory behavior, whereas the redundancy \(r\) is calculated as the total number of wavelet coefficients divided by the signal length to be used for the TQWT. The value of \(J\) is the level of two-channel filter banks that attach to the low-pass filter output, resulting in sub-bands \(J+1\)[50; 52]. The application of the dual-Q TQWT includes the simultaneous use of the two Q-factors of the WT and was first introduced in [51; 53]. This transformation decomposes the signal \(\mathbf{x}\) into two components, \(\mathbf{x}_{1}\) and \(\mathbf{x}_{2}\), where \(\mathbf{x}_{1}\) mainly consists of sustained oscillations and \(\mathbf{x}_{2}\) mainly consists of non-oscillatory transients [52]. Let TQWT\({}_{1}\) and TQWT\({}_{2}\) denote the TQWT with two different Q-factors (high and low Q-factors); then, the decomposition of \(\mathbf{x}\) can be derived by solving an optimization problem with constraints in the sub-band-dependent regularization form [51]:  
\[\arg\min_{\mathbf{w}_{1},\mathbf{w}_{2}}\sum_{j=1}^{J_{1}+1}\lambda_{1,j}|| \mathbf{w}_{1,j}||_{1}+\sum_{j=1}^{h+1}\lambda_{2,j}||\mathbf{w}_{2,j}||_{1}, \tag{1}\]  
such that  
\[\mathbf{x}=\text{TQWT}_{1}^{-1}(\mathbf{w}_{1})+\text{TQWT}_{2}^{-1}(\mathbf{ w}_{2}), \tag{2}\]  
where \(\mathbf{w}_{ij}\) denotes wavelet coefficients of TQWT\({}_{i}\) for \(i=1,2\), and TQWT\({}^{-1}\) is the inverse transform. To start the decomposition, knowledge of six parameters is required: Q\({}_{1}\), \(r_{1}\), and  
Figure 3: Examples of atrial activity (thick red line) without (**a**) and with (**b**) atrial fibrillation (signal 4048 from MITBIH AFDB). \(J_{1}\) for the high-Q-factor TQWT and Q\({}_{2}\), \(r_{2}\), and \(J_{2}\) for the low-Q-factor TQWT. According to ref. [52], to protect against the problem of wavelet ringing, the parameter \(r\) should be greater than or equal to 3. The high-resonance and low-resonance components of the \(\mathbf{w}_{1}\) and \(\mathbf{w}_{2}\) sub-bands are used for further analysis. The percentage of energy from each sub-band is determined on the basis of \(\mathbf{w}_{1}\) and \(\mathbf{w}_{2}\) according to  
\[E_{i,j}=\sum_{j=1}^{I_{i}+1}|w_{i,j}|^{2}, \tag{3}\]  
where \(J_{i}\) is the decomposition level of the TQWT. Then, the peak and average energy, respectively, are estimated as  
\[E_{i,peak}=\max_{1\leq j\leq I+1}\left(E_{i,j}\right) \tag{4}\]  
and  
\[E_{i,ave}=\text{mean}(E_{i,j})|_{j=1}^{I_{i}+1}. \tag{5}\]  
Finally, two factors are calculated as the ratio of the peak energy to the average energy for high- and low-resonance components, respectively, according to  
\[\zeta_{i}=\frac{E_{i,peak}}{E_{i,ave}}, \tag{6}\]  
where \(i=1,2\). Having obtained the wavelet coefficients \(\mathbf{w}_{1,2}\) with the DQ-TQWT, the wavelet entropy is also calculated as the maximum entropy value in individual sub-bands for the high- and low-resonance components of the transformation. WT-based entropy measures the degree of both order and disorder in a signal, as well as the underlying dynamic process associated with it.