{'fraction_non_alphanumeric': 0.03529761462435907, 'fraction_numerical': 0.008248495206955487, 'mean_word_length': 4.724372607401106, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
An intracardiac electrogram model to bridge virtual hearts and implantable cardiac devices

Virtual heart models have been proposed to enhance the safety of implantable cardiac devices through closed loop validation. To communicate with a virtual heart, devices have been driven by cardiac signals at specific sites. As a result, only the action potentials of these sites are sensed. However, the real device implanted in the heart will sense a complex combination of near and far-field extracellular potential signals. Therefore many device functions, such as blanking periods and refractory periods, are designed to handle these unexpected signals. To represent these signals, we develop an intracardiac electrogram (IEGM) model as an interface between the virtual heart and the device. The model can capture not only the local excitation but also far-field signals and pacing afterpotentials. Moreover, the sensing controller can specify unipolar or bipolar electrogram (EGM) sensing configurations and introduce various oversensing and undersensing modes. The simulation results show that the model is able to reproduce clinically observed sensing problems, which significantly extends the capabilities of the virtual heart model in the context of device validation.


I. INTRODUCTION
With the growing use of implantable cardiac devices [1], it has become increasingly important to validate the devices under broader physiologically relevant conditions. This necessitates real-time virtual heart development to facilitate closed-loop validation. In closed-loop validation, virtual heart models provide physiologically relevant responses to the device [2], [3], [4], [5]. These models are usually based on timed automaton (TA) [6] or hybrid automaton (HA) [7], which is amenable to formal analysis [2], [3] and real-time implementations [8], [9]. This is desirable for the verification of safety-critical systems.
However, modeling the heart-device interface has received limited attention. In [3], the heart model is connected with the device via specific computational nodes, which means that the device can only sense the immediate local signals. Synthetic EGM are generated by summing the distancedependent Gaussian factor [10]. This can not reflect the real sensed signals, i.e. EGM, by the devices in patients, which include local activation, far-field signals and pacing artifacts [11].
The device senses these unexpected signals, referred to as oversensing, which can cause inappropriate pacing inhibition, pacemaker tracking or mode switching [11], [12]. For instance, an unintended mode switch is reported because of prolonged atrial activation [13]. As a large proportion of the functionality of cardiac devices is designed to handle unexpected signals, we must be able to represent these behaviors in order to validate the functionality.
To the best of our knowledge, no existing work explicitly models far-field signals and pacing artifacts for the virtual heart [2], [3], [4] in the context of closed-loop validation. Yip et.al [4] use HA to model an abstracted network of cardiac conduction system. The network is composed of cardiac cells connected by paths to capture characteristics of action potential propagation in tissue. This paper focuses on the approach to derive realistic EGM from the abstract heart model [4], but the methodology can also be applied to other work, like [2], [3], [4].
We develop an EGM model to capture local cardiac activities, stimuli afterpotentials and far-field signals. The model is designated for the virtual heart in the context of closed-loop validation. The same HA formalism is employed, which enables us the amenability to formal analysis and realtime implementation. It expands the capability of validating timing cycles by introducing various oversensing and undersensing modes. The simulation results show that the model is able to reproduce sensing problems discussed in the literature like [11], [12], [13].

A. IEGM module
The proposed IEGM module acts as an interface between the heart and the device, as shown in Fig. 1, consisting of four components (Fig. 2). We extend the heart model [4] with the events Cell i , Cell j and so on to signify the propagation status, which are used to synchronize the EGM computation model detailed in Section II-B. Section II-C describes the T wave generated by the ventricular repolarization, pacing pulses AP and V P from the device create pacing afterpotentials likely leading to crosstalk [11], depicted in Section II-D. The sensing controller, Section II-E, is used to control the sensing configurations and introduce various sensing signals. The outputs atrial EGM (AEGM ) and ventricular EGM (V EGM ) go to the device sensing circuits.

B. Intrinsic EGM
The separation of electrical charges generated at the border between activated and resting myocardium creates moving electric dipoles [14], [15], as shown in Fig. 3. When the activation front moves nearby an electrode, the potential sensed by the electrode can be calculated by (1) [15], where C represents the dipole moment, r is the distance from the dipole to the electrode, and ϕ is the angle between the dipole and the distance vector. The amplitude decreases as the distance r increases. As a consequence, the local activation contributes much greater amplitude to the potential than farfield signals.  [15].
The heart model [4] is composed of nodes and paths. The EGM computation module is connected with the path model. The event Cell i /Cell j denotes that the action potential from Cell i /Cell j starts traveling along the path. Relay i/j means that the action potential reaches the other end of the path. Cell i&j represents both action potentials moving to each other and Anni indicates that they collide in the middle of the path.
We assign each node with the coordinate (x i , y i ) and the conduction velocity v ci along the path such that we can compute the instantaneous position of the moving action potential (x(t), y(t)), cosϕ(t), r(t) and then obtain the potential V at any specified electrode (x p , y p ) according to (1) with the synchronization events. Fig.4 shows the synchronizing control of the EGM computation with the P ath ij . Given any electrode, the sensed EGM is the superposition of potentials generated by dipoles moving along all the paths within the heart model [4], including the local activation as well as far-field signals.
In our model, we specify the coordinates of the tip and the ring electrodes in the right atrium and right ventricle. The sensed signals by these electrodes are denoted as V adt , V adr , V vdt , V vdr respectively.

C. T wave
The T wave reflects the ventricular repolarization [16]. In our model, we take the process of repolarization as a virtual dipole with advancing negative charges rather than the positive charges of the depolarization wave. The computation process is similar to Section II-B.

D. Pacing afterpotential
A low-amplitude wave of opposite polarity is followed by a pacing pulse, referred to as afterpotential [11]. The amplitude is directly related to both the amplitude and the duration of the pacing pulse. The afterpotential exponentially decreases and the decay characteristics are determined by the time constant formed by the product of the coupling capacitor C and the load (combination impedance of lead, electrode to tissue interface, and myocardium) [17], as shown in (2). As shown in Fig. 5, we can detect the start and the termination of the stimulation from the device, i.e., AP or V P , and employ (2) to compute the afterpotential. The outputs V vpa , V apa denote atrial oversensing of ventricular pacing events (VA crosstalk) and ventricular oversensing of atrial pacing impulse (AV crosstalk).

E. Sensing controller
Both oversensing and undersensing may trigger various algorithms of cardiac devices. These problems arise from many factors [11], such as sensing threshold, configurations and so on. We develop a sensing controller to model these factors affecting EGM contents. In this module, AEGM and VEGM are the signals sensed by the atrial and ventricular leads, computed by (3) and (4) respectively.
The variables a, b, c va , c av , d, e are used to determine which signals are present to the device, including desired local activations and far-field signals V adt , V adr , V vdt , V vdr , T wave V vrt , V vrr and afterpotentials V vpa , V apa . These variables can be changed over time according to the validation requirements.

III. RESULTS AND DISCUSSION
The clinically observed physiologic intracardiac signals EGM on the atrial channel and the ventricular channel are listed in Table I and II respectively. The sources of these signals can be found in the given references. The clinical significance column indicates how often these problems could occur in real patients. The corresponding variables in our model to control the presence of the signals are also given. While all of these signals can be reproduced by the proposed model, we only present some examples (Fig. 6) in this paper due to the space limitation.

AEGMs
Clinical Significance

P-wave
The desired signal a, b, cva; A P-wave double counting [11], [13] Rare [11] Atrial conduction D Far-field R-wave (FFRW) Relatively frequent [11] a, b B VA crosstalk [11] Rare [11] cva - We use the heart model to produce various rhythms and present the electrical activities via the proposed IEGM module to the device. The presence of signals is varied over time controlled by the sensing controller. The simulation plots in Fig. 6 show (from top to bottom): AEGM, AS raw (Level High shows that AEGM signal is greater than the sensing threshold and could be detected by the device),

VEGMs
Clinical Significance Controls Segment R-wave The desired signal d, b, e, cav A Far-field P-wave [11] Rare in adults [12] for ICDs and uncommon for pacemaker [11] d -R-wave double counting [12] Exceptional with pacemakers but may occur with ICDs [11] Ventricular conduction -

T-Wave
Oversensing [12] Rare in pacemakers and more frequent in ICDs [11] e -AV crosstalk [12] Rarely encountered but may still occur [11] cav C  Fig. 6 shows the desired AEGM and VEGM. These signals only reflect the local activations and are detected by the device once at a time. A far-field R wave is present in Segment B. The signal falls into the refractory period so no extra AS is detected by the device. In Segment C, the ventricular lead senses the afterpotential of atrial pacing pulse AP . We mimic the interatrial block in Segment D by slowing the conduction velocity of partial atrium such that the AEGM is prolonged. In this example, the device double counted the atrial signals.
While the dipole theory has been applied in numerous cardiac electrophysiology studies [18], our integration of the classical dipole model into an abstract HA-based heart model is novel. The simulation result shows that it is a feasible and effective approach. This integration has unique advantages: 1) The HA formalism is amenable to formal analysis and real-time implementations. This is vital for the verification of safety-critical cardiac devices. 2) HA-based models favor compositional design. This benefits future expansion of the model. 3) Due to the nature of the dipole theory, the morphology of EGM can capture realistic signals by refining the heart model with 3D anatomical data. This would be necessary for implantable cardioverter defibrillator (ICD) validation. 4) The electrocardiogram (ECG) could also be modeled by extending the heart model with an appropriate torso model. The ECG can be used to validate the heart model. 5) Stochastic features could also be captured by extending the sensing controller with probabilistic automaton. This enables us more flexibility in the context of device validation.
As the morphology of EGM created by dipole models relies on the geometry of the heart, the current EGM is an approximation of real signals because of the abstract nature of the existing heart model. In particular, the T wave records the ventricular repolarization but cannot reflect patterns of epicardium to endocardium activation. For a pacemaker, the major algorithms depend on the timing of the signals rather Time (s) Fig. 6: Simulation EGMs. Segment A demonstrates desired AEGM/VEGM. B includes far-field R wave indicated by the red arrow. AV crosstalk is present in C due to the atrial pacing pulse AP . In D, the prolonged P-wave is double counted by the device indicated by the red arrow. than morphology. Therefore, the current model can meet the need of the pacemaker validation. We connected the virtual heart and the proposed IEGM module to a pacemaker model, and Fig. 6 shows the device can sense the EGM and deliver pacing pulses if bradycardia is present. As we discussed, the morphology can be improved by refining the heart model for ICD validation.

IV. CONCLUSION
We have developed an intracardiac electrogram (IEGM) model capturing local excitation, far-field signals and pacing afterpotentials. The results show that we are able to cover sensing problems discussed in the literature. We have integrated classical dipole model into the HA-based virtual heart to enable the amenability to formal analysis. This is desirable for the verification of safety-critical systems. The compositional feature of HA and the nature of the dipole theory provide us with a promising potential for future expansion of the work.