ECG-based Heartbeat Classification in
ECG-based Heartbeat Classification in
Federico Corradi1 , Sandeep Pande1 , Jan Stuijt1 , Ning Qiao2 , Siebren Schaafsma1 ,
Giacomo Indiveri2 , and Francky Catthoor3,4
1 Stichting IMEC Nederland, High Tech Campus 31, Eindhoven 5656 AE, The Netherland
2 Institute of Neuroinformatics, University of Zurich and ETH Zurich, Switzerland 3
IMEC Leuven, Kapeldreef 75, 3001 Heverlee, Belgium
4 KU Leuven, ESAT Department, B-3001 Leuven, Belgium
Email: [email protected]
Abstract—Heart activity can be monitored by means of Specifically, we demonstrate heartbeat classification using
ElectroCardioGram (ECG) measure which is widely used to Spiking Neural Network (SNN) in a neuromorphic hardware
detect heart diseases due to its non-invasive nature. Trained implementation.
cardiologists can detect anomalies by visual inspecting recordings
of the ECG signals. However, arrhythmias occur intermittently The key contributions of this work are:
especially in early stages and therefore they can be missed in
routine check recordings. We propose a hardware setup that • We introduce a method for encoding and compressing
enables the always-on monitoring of ECG signals into wearables. the ElectroCardioGram (ECG) signals into a stream of
The system exploits a fully event-driven approach for carrying asynchronous digital events (i.e. spike trains).
arrhythmia detection and classification employing a bio-inspired
spiking neural network. The two staged Spiking Neural Network • We demonstrate that the compressed ECG signals can
(SNN) topology comprises a recurrent network of spiking neurons be correctly classified after a dimensionality expansion
whose output is classified by a cluster of Leaky integrate- performed by a recurrent SNN.
and-fire (LIF) neurons that have been supervisely trained to
distinguish 17 types of cardiac patterns. We introduce a method • We demonstrate high accuracy of classification after
for compressing ECG signals into a stream of asynchronous training Leaky integrate-and-fire (LIF) neurons to dis-
digital events that are used to stimulate the recurrent SNN. Using criminate one out of 18 classes (see table II) in a
ablative analysis, we demonstrate the impact of the recurrent SNN supervised manner, from a large number of spatio
and we show an overall classification accuracy of 95% on the temporal spike patterns produced by the recurrent
PhysioNet Arrhythmia Database provided by the Massachusetts SNN.
Institute of Technology and Beth Israel Hospital (MIT/BIH).
The proposed system has been implemented on an event-driven • We validate our system exploiting a state-of-the-art
mixed-signal analog/digital neuromorphic processor. This work custom mixed-signal analog/digital Very Large Scale
contributes to the realization of an energy-efficient, wearable, Integration (VLSI) neuromorphic processor that im-
and accurate multi-class ECG classification system. plements the recurrent SNN.
The second step is commonly carried with wavelet transform, and convert the high-fidelity ECG trace in a four channel
Kalman filtering or other standard signal processing algorithms spiking outputs. Every ECG channel is encoded in two outputs
[6]–[8]. The heartbeat segmentation is based on the detection (ON/OFF channels), digital events from each channel mark the
of the QRS complex of the ECG signals [9], [10]. Feature time at which the input signal has changed more (ON) or less
extraction is carried with different methods that include fil- (OFF) than a fixed threshold. The encoding of the input signal
tering, embeddings and wrapper methods. Filter methods rely is executed for each ECG input channel with the following
on the statistical properties of the signal and are based on algorithm 1.
correlations matrix or linear decomposition with independent
component analysis [11]. Embeddings and wrapper methods Data: ECG single-lead trace
are more computationally expensive than filtering techniques Result: UP; DN (two vectors of spikes)
as they require a trained classifier and their role is to optimize dc = 0;
the output with a variety of feature sets. The classification while input trace do
of ECG signals have been performed using Support Vector read_trace_current ;
Machine (SVM) [12], [13], neural network approaches [14], current_time ;
[15], and feature based clustering methods [16], [17]. if read_trace_current > dc + δ then
In this work, we propose an alternative approach that dc = read_trace_current;
is compatible with state-of-the-art spike based neuromorphic UP.append(current_time);
processors of the kind recently realized as research prototypes end
by different companies and research institutions [3]–[5]. In fact, if read_trace_current < dc − δ then
our method exploits a spiking neural network that operates on dc = read_trace_current;
streaming data, without the need to use memory buffers for ex- DN.append(current_time);
tra signal filtering steps, without segmenting the heartbeat and end
without a clever feature extraction method. In our approach, end
Algorithm 1: Delta modulator algorithm. Given a high-
we directly convert ECG signals into digital pulses (i.e. spike
fidelity ECG trace, this algorithm outputs two vectors of
trains); we cast the problem of ECG signals classification into
spikes (UP,DN).
a temporal spike patterns classification problem. This problem
is still a major challenge in computational neuroscience, and
machine learning. It can have great influence in the design of The threshold δ represents the incremental or decremental
embedded electronic systems [18], [19]. Many key mechanisms change of the input signal that causes a single spike. Given
are already available thanks to recent efforts devoted to the an ECG input trace in the normalized range [0, 1], we set the
understanding of the role of spike-timing in neural information threshold δ = 0.003. The lower threshold results in dense spike
processing system [20], [21]. We base our work on these efforts patterns and vice versa. With this parameterization an ECG
and we propose a fully spike-based system for ECG arrythmia complex is encoded in about 250 spikes in total. The temporal
detection and classification. precision has been fixed to one microsecond.
+
-
num spikes
+
- class id
i
Vmem = Vrst + ∑ wi ∑(t − ti j )
j j
1.0 1.0
amplitude [au]
amplitude [au]
0.5 0.5
0.0 0.0
- OFF ch 30
- OFF ch 30
num. spikes
num. spikes
20 20
ON ch ON ch
OFF ch 10 OFF ch 10
0 0
0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.00 0.05 0.10 0.15 0.20 0.25 0.30
time [sec] time [sec]
Fig. 3: Delta modulator and ECG input signal. top) ECG trace from the MIT/BIH dataset superposed to its reconstruction after compression carried by delta
modulator. bottom) Delta modulator output. Spikes are shown as vertical bars (ON/OFF). The average number of spikes is shown as continuous and dotted
lines, the time bin used to calculate the number of spikes has a size of 170ms.
ON
B. VLSI implementation of the Recurrent Spiking Neural Net-
DELTA MOD OFF
ON work
OFF
The recurrent SNN has been implemented in a custom
f(tl) VLSI neuromorphic processor, the "CX-Quad" [5]. The neuro-
morphic processor is an asynchronous multi-neuron chip that
(t)
includes analog neuron and synapse circuits, as well as an
FILTER k
asynchronous digital logic. The "CX-Quad" is optimized for
maximizing re-configurability, scalability while at the same
RECURRENT
time minimizing power consumption as well as latency. The
SYNAPTIC
NEURON ID
SNN
"CX-Quad" device contains 1024 neurons organized in 4 cores
of 256 units. Each unit contains one neuron and one synapse
block. The synapse block is constituted by an analog linear
integrator circuit which integrates input events from 64 12-
bit programmable Content Addressable Memory (CAM) cells.
The proposed recurrent SNN requires only 2 cores. One core
for hosting 256 excitatory neurons, and a second one for
instantiating 64 neurons of the inhibitory population. The neu-
LIF ral dynamics is emulated using subthreshold analog circuits,
READOUTS THRESHOLD
and the neuron model is a bio-realistic adaptive-exponential
I&F neuron circuit. The on-chip analog synaptic dynamics
num spikes
96
hardware parameters (biases) of the "CX-Quad" as synaptic 16 bits
8 bits
time constants, mean synaptic efficacy, neuron’s refractory 95 4 bits
period, and neuron’s firing threshold such that network dy-
namics does not fall in stable states. If the network dynamics 94
Accuracy
pattern of activity performing a dimensionality reduction of
92
the input stimulus [28]. On the other hand, if the network
dynamics would be completely driven by the input, there would 91
not be transient activity and reverberation, which is essential
in discriminating temporal spike patterns. Therefore we have 90
selected to work in a state in which there is some balance
among excitatory and inhibitory contributions [29]. 89
0.0000 0.0005 0.0010 0.0015 0.0020 0.0025 0.0030
2) Software SNN parameters : we have explored the im- e
pact of different SNN parameters on the overall classification Fig. 5: Synaptic decay constant exploration: a peak of accuracy is evident for
accuracy. When building a computationally efficient neural τe = 3x10−5 for all experiments.
network hardware it is necessary to explore the precision of
the representations for synaptic values, this will delineate the
memory requirements and the complexity of the neural and
synaptic hardware units. In our exploration, we kept constant depends on the number of support vectors. For example the
the number of synaptic connections and the number of neurons LIF neuron whose role is the decision among classes %N vs
in the recurrent SNN as described for the VLSI implementation %J has a synaptic dendritic tree (input connections) composed
in the neuromorphic processor. However, we have gradually of 1219 + 6 = 1225 input weight vectors.
varied the precision of the representation for the synaptic
weights. We have explored configurations in which synaptic
weights are represented in fixed-point with different number of D. Classification Accuracy
bits (4,8,16) for both integer and fractional part. Given these Classification accuracy is reported in table I as the cross
representations we have trained the full system and measured validated performance on the full dataset that has been ran-
the classification accuracy. Note that this exploration has been domly split as in table II. The number under training and
carried only for the recurrent SNN, while the LIF neurons and testing refer to the number of single ECG complexes selected.
their synapses has been maintained to full precision (32-bit During the split we kept constant the distribution of examples
floating point). In fig: 5 we show the classification accuracy in each class as in the MIT/BIH dataset. The variation in
for a variety of parameters settings, including the exponential table I refers to the variation over a 5-fold cross-validation.
decay time constant τe . From this results it is clear that the Every line in the table refers to a different experiment. These
choice of τe = 3x10−5 is well motivated, as reported already results demonstrate the effect of the recurrent SNN on the
in section III-E. performance of the system (i.e. classification accuracy).
3) Software LIF parameters: the learned support vectors
are encoded as synaptic weights of the connections between The classification carried with SVMs on the full resolution
each SNN neuron with all LIF readout neurons (153 in total). (320Hz sampling rate) ECG signals is able to obtain a classi-
The support vectors are the points in the dataset that are the fication accuracy of 94.2%, this result is obtained without the
closest to the decision boundaries, some of them represent use of any spiking neuron, only with the use of the dataset
examples that are wrongly classified (i.e. at the wrong side of with a standard machine learning approach (implemented with
the decision boundary) and for which a penalty is assigned libsvm as in section III-E1). This requires about 6 hours of
during the learning process. This representation allows to training time in a 8 core i7 standard desktop computer.
retrieve the decision boundaries by simply calculating the dot If the signals are encoded into spikes and used to excite the
product between input test patterns and weight connections. recurrent SNN the accuracy of the classification carried by a
In our spiking implementation, this dot product is computed linear SVM increases up to 95.6%. This performance can then
between the output spikes of the recurrent SNN, after the be mapped one-to-one to a pool of LIF neurons. This requires
application of the synaptic filter k(t), weighted by the synap- only 20 minutes of training time in a 8 core i7 standard desktop
tic input connections for all LIF readout neurons. Decision computer. Is addition, if the output of the two delta moulators
boundaries are the threshold values of the membrane potential (ECG ENC in table I) is used without the recurrent SNN but is
of the LIF neurons; if a LIF neuron receives enough positive applied directly to the synaptic kernel and then classified with
contributions it will reach the threshold, and it will emit a a SVM the performance drop significantly (only 84%). This is
spike. The spike will signal a vote for the selected class among a confirmation of the fact that the recurrent SNN is performing
the two of its own competence. Since the MIT/BIH dataset is interesting dimensionality expansion of the compressed ECG
highly unbalanced, the number of support vectors varies for signals.
each class, therefore every LIF has a different number of input
synapses. Our training process results in a total of 3745 support The three last rows in table I, show the performance of
vectors. The number of support vector per class varies from a the system when a fixed-point representation is used for the
maximum of 1219 (%N) to a minimum of 6 (%J). Each LIF synaptic weights in the SNN. By reducing the number of bits
neuron receives inputs via a number of synaptic contacts that from 32 to 8 accuracy only drops with about 2.5%.
[11] J.-J. Wei, C.-J. Chang, N.-K. Chou, and G.-J. Jan, “Ecg data compres-
sion using truncated singular value decomposition,” IEEE Transactions
on Information Technology in Biomedicine, vol. 5, no. 4, pp. 290–299,
2001.
[12] E. D. Übeyli, “Ecg beats classification using multiclass support vector
machines with error correcting output codes,” Digital Signal Processing,
vol. 17, no. 3, pp. 675–684, 2007.
[13] F. Melgani and Y. Bazi, “Classification of electrocardiogram signals
with support vector machines and particle swarm optimization,” IEEE
transactions on information technology in biomedicine, vol. 12, no. 5,
pp. 667–677, 2008.
[14] S. Osowski and T. H. Linh, “Ecg beat recognition using fuzzy hy-
brid neural network,” IEEE Transactions on Biomedical Engineering,
vol. 48, no. 11, pp. 1265–1271, 2001.
[15] Z. Dokur and T. Ölmez, “Ecg beat classification by a novel hybrid neural
network,” Computer methods and programs in biomedicine, vol. 66, no.
2-3, pp. 167–181, 2001.
[16] P. De Chazal, M. O’Dwyer, and R. B. Reilly, “Automatic classification
of heartbeats using ecg morphology and heartbeat interval features,”
IEEE transactions on biomedical engineering, vol. 51, no. 7, pp. 1196–
1206, 2004.
[17] M. Lagerholm, C. Peterson, G. Braccini, L. Edenbrandt, and L. Sornmo,
“Clustering ecg complexes using hermite functions and self-organizing
maps,” IEEE Transactions on Biomedical Engineering, vol. 47, no. 7,
pp. 838–848, 2000.
[18] S. Mitra, S. Fusi, and G. Indiveri, “Real-time classification of complex
patterns using spike-based learning in neuromorphic vlsi,” IEEE Trans-
actions on Biomedical Circuits and Systems, vol. 3, no. 1, pp. 32–42,
2009.
[19] A. Mohemmed, S. Schliebs, S. Matsuda, and N. Kasabov, “Training
spiking neural networks to associate spatio-temporal input–output spike
patterns,” Neurocomputing, vol. 107, pp. 3–10, 2013.
[20] R. Gütig and H. Sompolinsky, “The tempotron: a neuron that learns
spike timing–based decisions,” Nature neuroscience, vol. 9, no. 3, p.
420, 2006.
[21] M. Ambard and S. Rotter, “Support vector machines for spike pattern
classification with a leaky integrate-and-fire neuron,” Frontiers in com-
putational neuroscience, vol. 6, p. 78, 2012.
[22] aiCTX AG, https://ai-ctx.com.
[23] C.-W. Hsu and C.-J. Lin., “A comparison of methods for multi-class
support vector machines,” IEEE Transactions on Neural Networks,
vol. 13, pp. 415–425, 2002.
[24] C.-C. Chang and C.-J. Lin, “LIBSVM: A library for support vector
machines,” ACM Transactions on Intelligent Systems and Technology,
vol. 2, pp. 27:1–27:27, 2011, software available at http://www.csie.ntu.
edu.tw/~cjlin/libsvm.
[25] F. Corradi and G. Indiveri, “A neuromorphic event-based neural record-
ing system for smart brain-machine-interfaces,” IEEE transactions on
biomedical circuits and systems, vol. 9, no. 5, pp. 699–709, 2015.
[26] W. Maass, T. Natschläger, and H. Markram, “Real-time computing
without stable states: A new framework for neural computation based
on perturbations,” Neural computation, vol. 14, no. 11, pp. 2531–2560,
2002.
[27] M. Giulioni, P. Camilleri, M. Mattia, V. Dante, J. Braun, and P. Del Giu-
dice, “Robust working memory in an asynchronously spiking neural
network realized with neuromorphic vlsi,” Frontiers in neuroscience,
vol. 5, p. 149, 2012.
[28] M. Giulioni, F. Corradi, V. Dante, and P. Del Giudice, “Real time
unsupervised learning of visual stimuli in neuromorphic vlsi systems,”
Scientific reports, vol. 5, p. 14730, 2015.
[29] N. Bertschinger and T. Natschläger, “Real-time computation at the edge
of chaos in recurrent neural networks,” Neural computation, vol. 16,
no. 7, pp. 1413–1436, 2004.
[30] O. Barak, M. Rigotti, and S. Fusi, “The sparseness of mixed selectivity
neurons controls the generalization–discrimination trade-off,” Journal
of Neuroscience, vol. 33, no. 9, pp. 3844–3856, 2013.