An SNN Based ECG Classifier For Wearable Edge Devices
Abstract
In situ real-time monitoring of ECG signal at wearable and implantable devices such as smart watch, ILR, Pacemaker etc. are crucial for early clinical intervention of Cardio-Vascular diseases.
Existing deep learning based techniques are not suitable to run on such low-power, low-memory, battery driven devices.
In this paper, we have designed and implemented a Reservoir based SNN & a Feed-forward SNN, and compared their performances for ECG pattern classification along with a new
Peak-based spike encoder and two other spike encoders.
Feed-forward SNN coupled with Peak-based encoder is observed to deliver the best performance spending least computational effort and thus minimal power consumption.
Therefore, this
SNN based system running on Neuromorphic Computing (NC) platforms can be a suitable solution for ECG pattern classification at the wearable edge.
Introduction
The electrocardiogram (ECG) is most common tool that is used by doctors to diagnose CardioVascular diseases (CVD) such as atrial fibrillation (AF), ventricular ectopics etc [27, 18].
The ECG morphology consists of the P-wave, QRS-complex and T-wave [32].
Cardiologists look at these morphological features, their spatial and temporal interplay to make ECG based diagnosis.
In modern smart healthcare, complementing manual interpretation of ECG done by expert physicians with automated screening done by AI-enabled diagnostic tools is common and it helps in increasing overall speed and accuracy of the diagnostic system.
However, continuous monitoring and analysis of ECG on wearable and implantable edge devices (such as smart watch, implantable loop recorders (ILR), pacemakers etc.), without sacrificing their battery life, would enable life saving alerts and early clinical intervention.
In last few years several deep learning based ECG classification models [3, 20, 15, 25] have been developed that can classify ECG signals with quite high accuracy based on features like heart rhythms.
However, these deep learning based models for ECG classification, being heavy in terms of computational complexity, memory and power requirement, are not fit to run on aforementioned memory constrained battery driven low-power edge devices.
Few attempts have been made so far to perform ECG analysis at edge [23].
AliveCor’s KardiaMobile [1, 17] captures ECG data via a smart wearable band but analyses the data in cloud.
Such platforms may fail to handle & transport large volume of data generated from continuous ECG monitoring with weak or no network connection.
Techniques like pruning and compressing have also been tried on existing deep learning models to make them fit to run on edge devices.
Ukil et.
al [31] have shown that, a compressed ResNet based ECG classifier [30] can achieve similar accuracy as that of the original ResNet model but using much less memory.
Spiking Neural Networks (SNNs), a 3rd generation ML framework [22], coupled with non-von
Neumann Neuromorphic Computing (NC) platforms such as Intel Loihi [19], Brainchip Akida [2] etc. can be another alternative for ECG time series classification at edge.
Owing to (i) event based asynchronous data processing in form of spikes, (ii) collocation of memory and compute in spiking neurons and (iii) natural ability of temporal feature extraction, SNN-NC combo is inherently a very low-power & low-compute approach.
However, real valued ECG signal needs to be encoded into spike format before being processed by SNNs.
Rana et.
al
[24] used binarized weight based SNN to classify ECG patterns.
but have not achieved high accuracy.
Corradi et.
al [9] have tried continuous on-device ECG monitoring using recurrent SNN on a custom VLSI neuromorphic processor achieving 95% accuracy on MIT-BIH dataset [21].
Balaji et.
al [5] have shown converting a complex CNN into
SNN can reduce computational effort without compromising much on the accuracy.
In this paper, we have designed and implemented two SNN architectures - one based upon recurrent reservoirs and the other being Feed-forward.
We also have proposed a Peak based spike encoding scheme for ECG time series data.
Unlike existing SNN-based works, we have tested classification accuracy of our SNNs coupled with the proposed peak encoder and two other popular spike encoders on five single lead ECG datasets namely ECG200, ECG5000, ECGFiveDays [11], PhysioNet 2017 [8] and MIT-BIH [21].
It is observed that Peak Encoding coupled with Feed forward SNN achieves highest accuracy for all 5 datasets and indicates to consume least power when implemented on NC platforms.
Proposed System Workflow
The workflow of the proposed system is depicted in Fig.
The incoming ECG data is first encoded into spike trains (aka events) via the spike encoding technique.
Then the spike train is passed into the
SNN for feature extraction and learning.
Neuronal activities are then presented to a simple linear classifier for final classification.
Spike Encoders: Mainly two types of spike encoders, namely rate encoder and temporal encoder are used in SNN domain.
Timing precision based temporal encoder works better for time series data than the number of spike based rate encoder [13].
Three such temporal encoding schemes are described and compared below:
(i) Gaussian encoder , a neuron-population based temporal encoding scheme [6], is frequently used due to its ability to capture granular details of the input signal.
Here, multiple neurons encode different segments of the input range.
It encodes one input-value into a time magnified spike train.
Dey et al.
[12] have proposed the encoder as better suited for time series classification tasks.
(ii) Delta modulator is an ECG specific spike encoder where the change in value of ECG signal between two consecutive timesteps is encoded as spike events (ON or OFF based on positive or negative change) if the difference is above a certain threshold.
Threshold will determine the sparsity and pattern of encoded spike train.
Corradi et.
al [9] have shown its efficacy with respect to MIT-BIH dataset using a recurrent SNN.
The on-demand nature of the encoding (i
e. if input signal is not changing, no output spikes are produced) increases its efficiency.
(iii) Peak encoding is our proposed new temporal encoder for ECG signal where traditional ECG peak detection algorithm [14] is used.
The peaks, onsets and offsets of ECG components (i
e. P-waves, QRS complex and T-waves) [32] are detected and their precise timings are taken as spike event times.
For each of these components, we get a separate spike trains but the temporal correlation is maintained in spike domain.
Fig.
2a shows a small segment of a ECG signal of length 300 timesteps.
As shown in Fig.
2b, a 15-neuron Gaussian encoder represents the original ECG signal as a dense spike train (15 times magnified in time scale) resulting in more number of computations and processing time.
On the other
[Figure]
hand, the Delta modulator encoder (refer Fig.
2c)
encodes the ECG signal into two representative
ON/OFF spike trains.
Our proposed Peak encoder processes only the peaks and waves which are relevant for understanding the ECG signature.
As a result, the number of spikes are very low and sparsely distributed in the time axis (refer Fig. 2d).
While spike trains from both Gaussian and Delta modulator encoder have more granular information about the ECG signal, they may also include redundant noise that might hamper the final classification task.
However, Peak encoder stresses upon
ECG signal morphology instead of concentrating each and every value in the signal.
Spiking Networks:
The encoded spike trains corresponding to ECG signal are then fed into the spiking network.
The SNNs are created using the Leaky-Integrate and Fire (LIF) [7] neuron model as it is computationally easier to simulate and work with.
Here, We have used two different types of network architectures as explained below:
(i)
Reservoir:
The reservoir is a recurrently connected population of excitatory and inhibitory neurons.
The connectivity between neurons are sparse, probabilistic and remain within the same population so that dynamical stability of the network is ensured.
This neuronal population is very efficient in extracting spatio-temporal features from time series.
Recurrent weights with directed cycles act as a non-linear random projection of the sparse input feature space to a higher dimensional spatio-temporal embedding, thereby generating explicit temporal features.
These embeddings are captured in the form of neuronal traces of the reservoir neurons.
(ii) Feed forward: It is a simple network topology where the neurons connected across consecutive layers but not within same layer.
Here we have used full connectivity.
Once the input spike train is fed into the network, these connections learn via STDP rule [29].
Post training, the network captures the learned features (aka corresponding neuronal activities) in neuronal trace values.
Classifier:
For both architectures, the neuronal trace values of the excitatory reservoir neurons or the feed forward neurons are fed into a Logistic Regression based classifier that is trained with corresponding class labels.
Once training is done, the neuronal trace values corresponding to testing data are fed into this classifier to get the final classification output.
Datasets, Experimental Setup and Results
Datasets: The system has been validated with ECG Atrial Fibrillation datasets with different attributes and complexity.
First, it was validated with UCR datasets [11], namely ECG200, ECG5000,
ECGFiveDays .
Each of these datasets contains ECG of people from different age group, gender recorded over different time period and having different features.
The 2017 PhysioNet Challenge dataset [8] provides ECG recording (between 30 sec and 60 sec in length), where the recording shows 4 classes i.e. normal sinus rhythm, atrial fibrillation (AF), an alternative rhythm, or is too noisy
[Table] [Table]
to be classified.
The last one is widely known Massachusetts Institute of Technology arrhythmia database(MIT-BIH) [21] having 48 half hour long two-channel ECG recordings of 47 participants.
Experimental Setup:
The workflow has been implemented using a GPU based SNN simulator,
BindsNet [16].
For each of the datasets, both the networks are tuned with parameters such as number of neurons & connections, neuronal model parameters etc.
to obtain the best performance.
The details of the network hyper-parameters are discussed below.
An undersampling technique has been used to mitigate the class imbalance problem for PhysioNet and MIT-BIH datasets.
Network parameters: The stability and performance of a spiking network depends heavily on careful tuning of different network parameters. Here, this tuning for both the networks have been conducted using a Grid Search method [28] for each dataset. For the Reservoir architecture, the major parameters we tuned are number of excitatory and inhibitory neurons ( N ex & N inhi , respectively), number of recurrent connections ( N rec ) and various connectivity parameters like input encoder outdegree ( Input outdegree ) which controls the connection between the spike encoder and the reservoir. Moreover, a 5-tuple of weight scalar values of ( input-to-excitatory, excitatory-to-input, inhibitory-to-excitatory, inihibitory-to-inihibitory ) are tuned and fixed for the inter-population network connections.
We have kept N rec =
{+( N ex )/
+}
for all the cases.
For the Feed forward architecture, N FF is the number of neurons in the SNN layer.
For both the network architectures, the threshold voltage = -55.0 and resting potential =
-65.0 for LIF neuron model.
The membrane time constant ( τ m ) of LIF controls the decay of the neuronal membrane potential and has been set to different values for different cases.
Table 3 below captures the details of values of above mentioned parameters.
Results & Discussion: Reservoir network is expected to better understand the dynamics of the temporally varying ECG data.
However, the classification accuracy of Reservoir, irrespective of spike encoding scheme used, is observed to be lower than that of existing deep learning based best state of the arts (refer Table 1).
Gaussian encoder, instead of focusing on specific ECG wave signatures (or sequences), magnifies the whole ECG signal in temporal spike domain.
As a result, a lot of spike enters into the Reservoir network and the neuronal activities of Reservoir start to overlap for different classes, thereby reducing the accuracy.
Delta modulator encoder improves the accuracy of Reservoir to some extent thanks to on-demand encoding and resulting sparsity in spikes.
Coupled with Peak encoder, the Reservoir network achieves better or at par accuracy compared to other two encoders.
Upon replacing the Reservoir with a computationally light Feed-forward SNN (with Peak encoder), the accuracy does not degrade too much; instead, it improves in some cases.
For both, Reservoir and Feed-forward, Peak encoder achieves highest accuracy across all five datasets having variety in terms of size of training & testing dataset, data complexity, length of each sample ECG time series and number of classes (last two columns of Table 1).
To note, if the Feed-forward network is tried on Physionet data to classify “normal” and “abnormal AF” classes only, then it has achieved 92% accuracy.
Peak encoder performs best because of efficient ECG morphology specific spike encoding. [Table] [Figure] [Table]
[Figure]
[Table] [Figure] [Table] [Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Table]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
WeightScalar (2.0, 0.6, 1.9, 0.5, 1.8) (2.0, 1.7, 0.9, 0.1, 1.4) (2.0, 0.3, 1.1,
[Table]
[Table]
[Table]
Overall classification performance of the spiking networks may not be highest compared to SoA but are acceptable.
However, the real benefit comes when computational cost and energy consumption is looked into.
Energy requirement of an SNN is directly proportional to total number of synaptic operations (SOP) executed during runtime.
Usually, number of SOP is considered as the average number of spikes per timestep for the entire training and inference.
Here, for all four networkencoder combinations and for all five datasets, we have compared SOP per timestep that indicates an estimated energy consumption on NC platforms.
Table 2 shows the best estimates for number of SOP per timestep.
As expected, owing to large spike activity, Gaussian encoder with reservoir is computationally most expensive whereas Peak encoder with Feed forward is the least thanks to sparse spike encoding and less number of neurons in network.
Conclusion, Limitation & Future works: In this work, we have proved the efficacy of a new Peak based encoder along with different spiking networks for ECG classification by testing them on five widely varying ECG datasets.
Encoding performance of Peak encoder can be improved by removing the noise peaks in ECG signal by correlating the signal from another auxiliary low energy sensor like an accelerometer.
Our SNNs are not tested on real NC hardware such as Brainchip Akida [2] and
Intel Loihi [19].
Our future goal is to benchmark the SNNs and encoders on those hardware.
[-( N ex )/
-]