Background {#Sec1}
==========

Atrial repolarization waves (*Ta* waves) are equally important as ventricular repolarization waves (*T* waves) and can exhibit significant potential as an effective biomarker for clinic diagnosis \[[@CR1], [@CR2]\]. However, depolarization is stronger than repolarization, and ventricular activities are even considerably stronger than atrial activities. To separate relatively weak activities in atria, existing studies have invested significant efforts in this aspect to help in myocardial diagnosis for either sinus rhythms and arrhythmia \[[@CR3]--[@CR8]\]. In the literature, no study has yet retrieved atrial repolarization activities because these activities can only be normally observed in patients under certain special ectopic pacing \[[@CR2]\].

In this study, we develop a method to reveal hidden *Ta* waves in the majority of patients. Unlike in the direct processing of electrocardiogram (ECG) signals, an independent cycle of atria electrical activities is obtained by extracting the atrial part of transmembrane potentials (TMPs) of whole-heart activities and mapping partial TMPs back onto the ECG of a body surface. Despite the simple back-forward process, obtaining *Ta* waves with acceptable quality is challenging in computational design because the accuracy of inverse transformation highly relies on the fidelity of organ geometries and conductivities \[[@CR9], [@CR10]\]. Constructing a 3D mesh model for each patient can be expensive, and thus, our solution for the inverse problem assumes that all the physical measures of an individual are unreliable, and these parameters should be re-estimated during computation. The algorithm only requires long observation periods to perform self-adaptive and reliable statistical inferences for unsure parameters.

The morphologies of *P* waves and hidden *Ta* waves are typically considered important among healthcare professionals. In \[[@CR1]\] and \[[@CR11]\], *Ta* waves were suggested to be an early sign of inferior injury, such as acute atrial infarction or arrhythmia. One example is atrial fibrillation if the waves can be observed during conduction system malfunction, such as long QT interval or atrioventricular block.

*P* waves alone are important in justifying heart diseases in both sinus rhythm and fibrillation \[[@CR12]\]. However, *P* waves are relatively weak, and thus, current understanding on atria activities are generally insufficient. Few studies have investigated activities from the atria part of myocytes. In \[[@CR13]\], the problem was initially addressed via computer simulation. Without involving inverse problems, \[[@CR13]\] facilitated a forward model, which mapped current dipoles onto atrial mid-myocardium to surface ECGs under a set of predetermined parameters to understand the contributions of right and left atria activities to the observed *P* waves during sinus rhythm and atrial fibrillation.

In clinical situations, *Ta* waves are not only hidden, but *P* waves are also tangled with the adjacent QRS complex. In \[[@CR7]\] and \[[@CR8]\], statistical and signal processing methods were, respectively used to single out *P* waves from the rest of the QRS part. Surface signals are complex combinations of current stimuli from millions of cardiomyocytes; thus, the signal separation task must be performed at the level of myocardium cells, and solving an ill-posed inverse problem is inevitable. Pioneer source models, such as those in \[[@CR14]--[@CR16]\], have been integrated into and advanced for contemporary computational electrocardiology models that establish models for various processes ranging from cellular bioelectrical activities to body surface potential distribution \[[@CR17]--[@CR19]\]. The forward problems involve mapping from inter- to intra-cellular currents onto body surface potential distributions \[[@CR20], [@CR21]\]. Given the nature of complexity in the biological field, the large degree of freedom poses a challenge in evaluating inverse problems.

When dealing with the inverse problem, most regulation methods can only condition numerical difficulty from the mathematical point of view; however, the problem of multiple solutions must be addressed by restoring possible missing constraints. In \[[@CR22]\], this difficulty was solved by reducing the inverse problem in limited mapping from epicardial to body surfaces. In \[[@CR23]\], the inverse problem was addressed by proposing a special equipment that could collect thousands of potentials on the body surface instead of the standard 12-lead ECG. Activation time sequencing or imaging can be evaluated for primitive diagnosis without retrieving detailed cellular activities \[[@CR24]--[@CR28]\]. However, electric current constraints from the ionic behavior of individual cells, such as in \[[@CR17]\], impose additional computational challenge given the millions of myocytes. Moreover, additional constraints introduce other unknown parameters, and the degree of freedom remains high. Therefore, advanced statistical methods should be applied to obtain reliable solutions.

Existing studies continuously contribute to addressing the problem of physiological models, and specific body surface electrical data from patients are always being corrupted by noise and the incorrect construction of organ geometries. In \[[@CR29]\], spatial covariance in a volume conductor was facilitated for maximum a posteriori (MAP) equation. In \[[@CR30]\], temporal and spatial covariances were estimated under certain mathematical assumptions based on structures that were inherent in the space--time correlation matrix. In \[[@CR31]\], the facilitation of multiple information sources to improve the efficiency of Bayesian MAP formulation was suggested. In \[[@CR32]\], TMPs were constrained using a diffusion--reaction model from cellular activation dynamics, which limited the inverse problem in both spatial and temporal dimensions. This work suggested relying on a statistical method to address both model and data errors in terms of prior knowledge on cell current dynamics and evidence for surface potential data. In \[[@CR33]\], the progress of statistical identification from the perspective of systems biology was reviewed.

Methods {#Sec2}
=======

As mentioned earlier, the extraction of *P* waves should be conducted at the electric current level in myocardial sources. The model for the cardiac computational system comprises two parts according to the component guideline in \[[@CR34]\]. The first part involves mapping between body surface potentials and intra-cellular TMPs. Evaluating TMPs is considered a difficult inverse problem given a potential map of a body surface \[[@CR35], [@CR36]\]. The second part aims to constrain the inverse problem, in which the constraint describes changes in TMPs in terms of electrical propagation between myocardia. Most electrophysiological models are diffusion--reaction systems \[[@CR17], [@CR36]--[@CR38]\].

Inverse problem {#Sec3}
---------------

We first consider the forward problem from equivalent current--dipole sources to body surface potentials. The sources of bioelectric currents across cell membranes excite the movement of cardiomyocytes and induce potential fields, which can be detected via surface electrodes. The total current density is presented as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{J}(\varvec{r}) = \varvec{J}_{s} (\varvec{r}) + \sigma \varvec{E}(\varvec{r})$$\end{document}$, where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{J}_{s}$$\end{document}$ is the net source current density ($\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$A/m^{2}$$\end{document}$); $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\sigma$$\end{document}$ is conductivity in homogenous dielectric media; and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{E}$$\end{document}$ is the electric field, which exhibits the relation $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{E} = - \nabla \varPhi$$\end{document}$ for potential function $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varPhi (\varvec{r})$$\end{document}$. Vector fields are denoted as bold face symbols, such as current density $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{J}(\varvec{r})$$\end{document}$, which is a vector field at location $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{r}$$\end{document}$. The total current $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\nabla \cdot \varvec{J} = 0$$\end{document}$ diverges without external current under quasi-static conditions. Thus, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\nabla \cdot (\sigma \nabla \varPhi ) = \nabla \cdot \varvec{J}_{s}$$\end{document}$, and the relation between measured potentials and heart sources is transformed into a Poisson equation. For cardiac volume $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$V_{H}$$\end{document}$, the potentials are primitively expressed as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varPhi (\varvec{r}) = \frac{1}{4\pi \sigma }\iiint_{{V_{H} }} {\varvec{J}_{s} (\varvec{r^{\prime}}) \cdot \nabla \left( {\frac{1}{{|\varvec{r} - \varvec{r^{\prime}}|}}} \right)d^{3} \varvec{r^{\prime}}}$$\end{document}$.

To model equivalent current density, the entire myocardium is divided into grid meshes. Following the suggestion in \[[@CR39]\], boundary element methods are applied. The potential $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varPhi$$\end{document}$ at the body surface is maintained as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varPhi$$\end{document}$, and TMP is denoted as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{u}$$\end{document}$. By tessellating and vectorizing all cardiac and thorax surfaces, a discrete matrix Eq. ([1](#Equ1){ref-type=""}) is obtained as suggested in \[[@CR32]\] and \[[@CR40]\].$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\phi (t) = \varvec{Lu}(t),$$\end{document}$$where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{L}$$\end{document}$ is the discretized transfer matrix that converts TMP $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{u}$$\end{document}$ to surface potential $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\phi_{8}$$\end{document}$. When the vectorized body surface potentials are only sampled at eight electrode positions for the standard 12-lead ECG signals, the potentials are denoted as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varPhi_{8}$$\end{document}$ for clarity.

The transfer matrix $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{L}$$\end{document}$ is synthesized with the geometries and conductivities of the organs inside the thorax. The geometric coordinates are segmented and discretized via magnetic resonance imaging (MRI) or computed tomography for a specific patient. Given numerical sensitivity and unavoidable movement, the forward model may suffer from geometric errors and should be incorporated as a part of modeling \[[@CR9], [@CR41]\]. In \[[@CR42]\], geometric errors were suggested to be overcome by using Bayesian MAP estimation or Kalman filtering with Gaussian geometric errors. In the present study, we do not rely on the accuracy of geometry and conductivity. We estimate the parameters along with the process of estimating TMPs \[[@CR43], [@CR44]\]. Bayesian estimation in error covariance enables performance analysis to statistically characterize solutions.

Reaction--diffusion systems {#Sec4}
---------------------------

Electrical propagation between myocardia is typically modeled differently in terms of complexity level---from the simplest Eikonal model at the tissue level, through bidomain/monodomain models and phenomenological models, to the most complicated ionic models at the cellular level. Phenomenological models focus at the macroscopic level and ranges from 2-variable equations \[[@CR14], [@CR37]\] to the complicated 15-variable Luo--Rudy model \[[@CR45]\]. Resolution is not a concern in extracting *P* waves. Electrical propagation is captured using the reaction--diffusion system \[[@CR37]\] with the same setting as that in \[[@CR46], [@CR47]\]. Considering the balance between precision and computation, a simple system is sufficient to constrain the ill-posed inverse problem. Therefore, we adopt the system from \[[@CR37]\] as follows:$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\left\{ {\begin{array}{*{20}l} {\frac{{\partial \varvec{u}}}{\partial t} = (\nabla (\varvec{D}\nabla \varvec{u}) + k\varvec{u},\varvec{u} - \varvec{a},1 - \varvec{u} - < \varvec{u},\varvec{v} > )} \hfill \\ {\frac{{\partial \varvec{v}}}{\partial t} = - e(\varvec{v} + k < \varvec{u},\varvec{u} - \varvec{a} - 1 > } \hfill \\ \end{array} } \right.,$$\end{document}$$where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{u}$$\end{document}$ and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{v}$$\end{document}$ are the column vectors of TMPs and recovery current, respectively; and the operator $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$< , >$$\end{document}$ represents a component-wise multiplication. $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$D$$\end{document}$ is the diffusion tensor; and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$k$$\end{document}$, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$a$$\end{document}$, and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$e$$\end{document}$ are the parameters. By converting the equation into finite element meshes \[[@CR47]\], the reaction--diffusion system can then be used as an effective constraint in solving the inverse problem. Let $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{x} = [\varvec{u},\,\varvec{v}]$$\end{document}$. The system can then be written as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\dot{\varvec{x}} = F_{d} (\varvec{x})$$\end{document}$, where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$F_{d} (\varvec{x}) = \left[ {\left( {\nabla \left( {\varvec{D}\nabla \varvec{u}} \right) + k\varvec{u},\varvec{u} - \varvec{a},1 - \varvec{u} - < \varvec{u},\varvec{v} > } \right)\;and \; - e(\varvec{v} + k < \varvec{u},\varvec{u} - \varvec{a} - 1 > } \right]$$\end{document}$.

Hierarchical estimation {#Sec5}
-----------------------

Our problem contains a large number of uncertainties, and thus, advanced Bayesian statistics can be a viable approach \[[@CR44]\]. The basic idea is to estimate the posterior probability of the unknown cardiac source $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\varvec{x}_{k} |\phi_{1:k} )$$\end{document}$ based on an a priori distribution of the sources $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\varvec{x})$$\end{document}$ and a group of affecting parameters. When ([1](#Equ1){ref-type=""}) and ([2](#Equ2){ref-type=""}) are combined, we obtain the data model as follows ([3](#Equ3){ref-type=""}):$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\left\{ {\begin{array}{*{20}l} {\dot{\varvec{x}}_{k + 1} } \hfill & = \hfill & {F_{d} (\varvec{x}_{k} ) + \varvec{w}_{k} ,} \hfill \\ {\phi_{k} } \hfill & = \hfill & {\varvec{Hx}_{k} + \varvec{z}_{k} ,} \hfill \\ \end{array} } \right.$$\end{document}$$where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{H} = [\varvec{L} + \Delta \varvec{L}\;;\;0]$$\end{document}$ is the output matrix with uncertainty $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta \varvec{L}$$\end{document}$, and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{w}$$\end{document}$ and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{z}$$\end{document}$ are two i.i.d. error processes with zero means and covariances $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{\xi}_{w}$$\end{document}$ and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{\xi}_{z}$$\end{document}$. Given that the model does not rely on the accuracy of the heart and torso geometries, the error terms in the elements of the transfer matrix $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$L$$\end{document}$ are embedded into the matrix with random variables $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta \varvec{L}$$\end{document}$. Let $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\theta = (k,a,e)$$\end{document}$ to incorporate the parameters in the reaction--diffusion function $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$F_{d} ( \cdot )$$\end{document}$. Therefore, the parameters for the process comprise $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta \varvec{L}$$\end{document}$ and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\theta = (k,a,e)$$\end{document}$.

The recursive estimation for the posterior probability density $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\varvec{x}_{k} |\phi_{1:k} )$$\end{document}$ can be conceptually achieved in two steps. The forecast term $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\varvec{x}_{k} |\phi_{1:k - 1} )$$\end{document}$ can be obtained through Chapman--Kolmogorov integration $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\mathop \smallint \nolimits P(\varvec{x}_{k} |\varvec{x}_{k - 1} )P(\varvec{x}_{k - 1} |\phi_{1:k - 1} )d\varvec{x}_{k - 1}$$\end{document}$, given that the posterior $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\varvec{x}_{k - 1} |\phi_{1:k - 1} )$$\end{document}$ is known from time $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$k - 1$$\end{document}$, and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\varvec{x}_{k} |\varvec{x}_{k - 1} )$$\end{document}$ is determined from the system equation. The current time posterior $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\varvec{x}_{k} |\phi_{1:k} )$$\end{document}$ is updated using the Bayes rule $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\frac{{P\left( {\phi_{k} |\varvec{x}_{k} } \right)P\left( {\varvec{x}_{k} |\phi_{1:k - 1} } \right)}}{{P\left( {\phi_{k} |\phi_{1:k - 1} } \right)}}$$\end{document}$, where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\phi_{k} |\phi_{1:k - 1} ) = \mathop \smallint \nolimits P(\phi_{k} |\varvec{x}_{k} )P(\varvec{x}_{k} |\phi_{1:k - 1} )d\varvec{x}_{k}$$\end{document}$.

To deal with a large number of parameters, the guideline in \[[@CR46]\] and \[[@CR47]\] indicates that the complicated joint distribution in data model ([3](#Equ3){ref-type=""}) can be formulated as a hierarchical model and factorized into a series of conditional distributions. The guideline suggests that the random variables to be estimated can be factored into three stages, such that $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$p({\text{process}},{\text{parameters}}|{\text{data}}) \propto$$\end{document}$ $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$p({\text{data}}|{\text{process}},{\text{parameters}})$$\end{document}$ $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$p({\text{process}}|{\text{parameters}})$$\end{document}$ $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$p({\text{parameters}})$$\end{document}$. Therefore, the joint posterior distribution can be written in a hierarchical form as follows:$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$P(\varvec{x},\Delta \varvec{L},\theta ,\varvec{\xi}_{w} ,\varvec{\xi}_{z} |\phi ) \propto P(\phi |\varvec{x},\Delta \varvec{L},\varvec{\xi}_{z} )P(\varvec{x}|\theta ,\varvec{\xi}_{w} )P(\Delta \varvec{L})P(\varvec{\xi}_{z} )p(\theta )P(\varvec{\xi}_{w} ).$$\end{document}$$

Following the suggestion in \[[@CR47]\], a Monte Carlo Markov chain (MCMC) slice sampler \[[@CR48]\] is applied in the Bayesian computation model because of the high dimension in our complex problem. A full Bayesian analysis of this problem is achieved by sampling the joint posterior distribution (13) using an MCMC technique called slice sampling \[[@CR49]\]. Another potential solution for reducing the constraining effects of prior knowledge is the simultaneous estimation of the TMP dynamics and electrophysiological properties of the myocardium. This method has the advantage that the constraining models can be modified according to the collected data of patients with filtering of unknown parameters.

Experiment setup {#Sec6}
----------------

To conduct the following experiments, 3D geometric models of a complete heart and torso are necessary. Cardiac geometric data were adopted from the ECGSim data set, which described a healthy normal young male using complete atria and ventricles (Fig. [1](#Fig1){ref-type="fig"}, with 1634 nodes for atria and 1500 nodes for ventricles) \[[@CR50]\]. Given that a 3D imaging will not be constructed on the epicardial surface, the requirement for grid size is low. Resolution is further reduced to prevent the introduction of excessive numerical difficulties from the source of the standard 12-lead ECG.Fig. 1Geometries of heart and torso

The geometry of a torso was adopted from the PhysioNet data archive, which also originated from the body surface mapping data of Dalhousie University \[[@CR51]--[@CR53]\]. Although accuracy is not a concern, mapping between surface nodes to the electrode positions of standard leads should be specified. Given the well-prepared recording and documentation in the data set, the detailed mapping from the surface nodes to the 15 standard leads was elaborated.

The ECG data were also adopted from PhysioNet: ptbdb and incartdb \[[@CR51]\]. The signals were preprocessed to eliminate electromagnetic interference, baseline wandering (e.g., electromyographic noise), and various artifacts (e.g., electrode motion) \[[@CR54]\].

The implementation programs for the experiments were developed in MATLAB and R. The transfer matrix was produced using the open source SCIRun/BioPSE from the Scientific Computing and Imaging Institute of the University of Utah \[[@CR18], [@CR55]\].

This study develops a model that retrieves hidden atrial repolarization waves by solving an inverse problem from surface ECG to cardiac TMPs (Fig. [2](#Fig2){ref-type="fig"}), where an ill-posed problem is constrained by temporal and spatial electrophysio-relations. The modeling approach can only be maintained at a coarse level because the source data are limited by the number of channels in the standard lead ECG. By contrast, cardiac electrical signals can be estimated by being modeled as a stochastic process with unknown excitation parameters and continuous acquisition of signals. In the solving process, several issues are encountered and need to discuss further.Fig. 2TMP and surface ECG

The experiment presents good results. As shown in Fig. [3](#Fig3){ref-type="fig"}, the top panel presents the inverse solution for TMPs in the atrial part of the myocardium. The figure reflects the correct excitation sequence starting from the atrium to the end of the apex. When we multiply the entire TMPs to the transfer matrix, the forward problem restores the original ECG, as shown in the third panel. The figure exhibits good approximation of the original ECG (second panel), except for several ripples near the end of the cycle. This result is considered good because the resolution is under 14 nodes on the body surface and 20 nodes in the myocardium. The bottom panel shows the extracted atrial electric activities. Each line in the graph corresponds to one of the 14 nodes that constitute the standard 12-lead ECG.Fig. 3Results of 12-lead ECG with MCMC. Top: atrial part of TMP; 2nd: original ECG; 3rd: simulated ECG; bottom: atrial part of simulated ECG

Discussions {#Sec7}
===========

The error caused by spatial digitization may overwhelm other sources of error terms because of the resolution limitation in mesh grids. The errors caused by modeling, geometric, and measuring uncertainties are integrated into a reaction--diffusion system, which is a stochastic state-space system with a powerful capability to estimate true values among noise background. The two-variable reaction--diffusion system ([2](#Equ2){ref-type=""}) is linearized for convenient computation experiments. All the parameters are embedded into each individual matrix element, which will be estimated in the subsequent MCMC step. Although sophisticated and accurate models for cardiac electrophysiological dynamics can be used, the estimation results may not improve in our case.

One of the error sources originates from the inhomogeneity and anisotropy of conductivity among different torso tissues. To obtain an acceptable imaging of the heart surface, the anisotropy of the intracellular conductivity tensor along the fiber structure of myocardia must be considered. In this study, we adopt a real-time estimation approach and leave all the parameters to be estimated during the online training step.

As mentioned earlier, given the lack of spatial resolution, we do not expect the complete accuracy of the inverse and forward simulations. Although an ordinary Moore--Penrose pseudo-inverse can obtain a perfectly low root-mean-square error after performing backward and forward projections, the cardiac potential maps obtained from this pseudo-inverse are meaningless. Therefore, the computation objective is to reconstruct a TMP distribution that closely mimics a real TMP distribution \[[@CR17]\]. We determine that the sequence and heterogeneity of TMPs throughout the myocardium significantly influence the final waveform of surface ECG.

The selection of prior distributions and initial conditions can influence the final results of the inverse solution when the Bayesian approach is used. During our MCMC estimation step, we perform our experiments by assuming that the noise and error terms are Gaussian distributed. Accordingly, we also select Gaussian as their conjugate prior for assigning prior distribution. The Gaussian assumption is reasonable for the coarse computation level. If further investigation is conducted, then non-Gaussian or empirical distribution can be used to estimate unknown parameters under the hierarchical Bayesian estimation framework.

By contrast, initial conditions are considerably sensitive to the algorithm. If parameters or matrices are available in published studies, then we will use their well-known values as initial amounts. Patient-specific variation should be accommodated by the random sampling process. A good initial condition can make convergence fast and accurate. In certain situations, convergence may not reach each selected initial value. For example, numerical difficulty may occur for a certain prior distribution. Several procedures can improve numerical stability, including increasing the condition numbers of covariance matrices. However, their details are considered state-of-art and require further elaboration.

For computational convenience, the reaction--diffusion system ([2](#Equ2){ref-type=""}) is linearized into a matrix equation because matrix operations are more efficient than the *n*th order Runge--Kutta methods with nonlinear cross-terms. However, the order of the system will increase significantly from nonlinear to linear. We artificially augment a large number of co-state variables in system ([2](#Equ2){ref-type=""}); that is, we add ten times more dummy variables following variable $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varvec{v}$$\end{document}$. The number of dummy variables significantly influences the quality of TMP reconstruction.

Conclusions {#Sec8}
===========

In this study, we consider only signals in the standard 12-lead ECG measurement. Unlike most studies, our approach relies on neither accurate geometries nor high-resolution body surface potential maps. We only use a rough model as an initial guess and then simultaneously estimate the inverse solutions and model parameters. In this setup, we eliminate the requirement to construct a geometric model of the heart using off-line MRI pictures. Our method simultaneously estimates inverse potential solutions and geometric details.

We separate the atrial part of ECG waves from the rest of the signals based on a standard clinical ECG recording. Traditional approaches \[[@CR7], [@CR8]\] work only on signal morphology and attempt to cancel out the large QRS-T complex from several standard templates. We proceed directly through TMPs in the myocardial cells and extract the electricity generated by atria only. The obtained surface ECG contains only *P* waves and is more robust than those obtained via waveform approach are.

Future development can focus on improving prior distribution specifications and initial conditions. We will additionally construct empirical distribution for all error terms to be a basis of the prior distribution. The algorithm will be continuously improved and parallelized for better computational efficiency.

**Authors' contributions** YJC designed the study, performed the experiments, analyzed the data, and wrote the manuscript. WHT and WHH participated in designing the study, analyzing the data, and editing the manuscript. All authors read and approved the final manuscript.

Authors' information {#FPar1}
====================

Dr. Wei-Hua Tang is with Division of Cardiology, Department of Internal Medicine, National Yang-Ming University Hospital, Yilan, Taiwan.

Wen-Hsien Ho is currently a Professor with Healthcare Administration and Medical Informatics, Kaohsiung Medical University, Taiwan. His research interests include intelligent systems control, computational intelligence, robust control, and quality engineering.

Yenming J. Chen received his Ph.D. in Systems Science and Mathematics in 1998 at Washington University in St. Louis. He is currently a professor of Logistics Management, National Kaohsiung University of Science & Technology in Kaohsiung, Taiwan. His research interests include industrial data analytics, IoT/AI, agriculture supply chain, and game theory.

Acknowledgements {#FPar2}
================

We thank the anonymous reviewers and editors for their careful reading of our manuscript and their many insightful comments and suggestions.

Competing interests {#FPar3}
===================

The authors declare that they have no competing interests.

Availability of data and materials {#FPar4}
==================================

The datasets generated and/or analysed during the current study are available in the PhysioNet repository, <http://www.physionet.org/physiobank/database/>.

Consent for publication {#FPar5}
=======================

Not applicable.

Ethics approval and consent to participate {#FPar6}
==========================================

Not applicable.

Funding {#FPar7}
=======

Publication of this article was funded by the Ministry of Science and Technology, Taiwan, under Grant MOST 105-2221-E-037-004, 104-2410-H-327-018-MY3, 106-2221-E-037-001, 106-2622-E-037-005-CC3, 106-2218-E-327-001, 107-2221-E-037-006, 107-2218-E-992-308, and the "Intelligent Manufacturing Research Center" (iMRC) from the Featured Areas Research Center Program within the framework of the Higher Education Sprout Project by the Ministry of Education (MOE) in Taiwan.

About this supplement {#FPar8}
=====================

This article has been published as part of BioMedical Engineering OnLine Volume 17 Supplement 2, 2018: Proceedings of the International Conference on Biomedical Engineering Innovation (ICBEI) 2016. The full contents of the supplement are available online at <https://biomedical-engineering-online.biomedcentral.com/articles/supplements/volume-17-supplement-2>.

Publisher's Note {#FPar9}
================

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
