You are on page 1of 6

2021 IEEE International Conference on Biomedical Engineering, Computer and Information Technology for Health (BECITHCON)

2021 IEEE International Conference on Biomedical Engineering, Computer and Information Technology for Health (BECITHCON) | 978-1-6654-6621-9/21/$31.00 ©2021 IEEE | DOI: 10.1109/BECITHCON54710.2021.9893602

Accelerometer-based Convulsive Seizure Detection


using CNN

Erina Binte Motahar* Farhan Ishtiaque* Md. Sharjis Ibne Wadud


Department of Biomedical Engineering Department of Biomedical Engineering Department of Biomedical Engineering
Military Institute of Science and Military Institute of Science and Military Institute of Science and
Technology Technology Technology
Dhaka, Bangladesh Dhaka, Bangladesh Dhaka, Bangladesh
erinaoishy@gmail.com farhanishti32@gmail.com sharjis@bme.mist.ac.bd

Abstract— Convulsive seizures contribute to a significant loss of senses, and uncontrolled muscular movements.
portion of the seizure-associated injuries, accidents, and sudden Epilepsy itself is a harmless condition. Though seizures
unexpected deaths in Epilepsy (SUDEP). An ambulatory seizure caused by epilepsy don't harm the patient, they can interrupt
detection system may prevent such accidents and improve the daily life. Also, people with epilepsy may lose their life due to
quality of life. Conventional seizure detection methods require various accidents that occur while they are experiencing
specialized approaches such as video or EEG analysis, which are seizures. This phenomenon is known as SUDEP [4]. The rate
frequently ineffective in non-clinical settings such as during of SUDEP is also very high across the world. A study in the
daily activities. In recent years, a couple of wearable USA shows the mortality rate of epileptic patients is 11.59 per
accelerometer-based seizure detection systems have been
million [5]. It is risky to leave epileptic patients unattended.
proposed. But the common problem these devices face is low
specificity and high False Alarm Rate (FAR). In this work, we
As the occurrence of seizures is unpredictable, they need to be
proposed an improved way to study and classify accelerometer kept under constant surveillance. But it is very difficult to
data using Convolutional Neural Network (CNN) to detect ensure constant surveillance in person. Also, in developing
General Tonic Clonic Seizures (GTCS), also known as countries, there is a lack of trained people for the job. So, to
Convulsive Seizures. Due to the unavailability of a dataset of reduce the chances of SUDEP, a fast, reliable, as well as
accelerometer data related to seizure movements, an portable seizure detection and monitoring technology is
accelerometer-based wrist-worn data acquisition device was required.
constructed to develop a dataset mimicking seizure-like
Present seizure detection techniques are time-consuming
movement. The accelerometer data were then converted to RGB
images for training and testing with three different CNN
and mostly require medical settings. Usually, a seizure is
architectures: DenseNet, ResNet-50, and VGG16, to determine diagnosed by a physician inspecting the EEG of a patient [6].
which architecture is best suited for these types of data. Among Another common method is video surveillance, where
these three, the DenseNet architecture achieved the highest multiple cameras observe patients from multiple angles, and
accuracy of 99.2%, sensitivity of 98.4%, and specificity of with the help of Artificial Intelligence seizure is detected from
100%. Hence, an algorithm was developed based on the the movements recorded by those cameras [7]. Seizures are
DenseNet model to detect convulsive seizures with a feature to also detected from the EMG of a patient [8]. But these
tune according to the patient’s seizure type. The proposed methods don’t offer portability or wearability, which are
method can be implemented to develop an ambulatory seizure required for ambulatory monitoring of seizures during daily
monitoring device to detect seizures before accidents occur. activities.
Keywords—Epilepsy, General Tonic Clonic Seizure (GTCS), Some recent studies are trying to develop a cheap and easy
Epileptic Seizure Detection, Accelerometer, Convolutional Neural way to efficiently detect seizures when patients are not in a
Network (CNN) hospital. In [9], an accelerometer-based seizure detection
technique was proposed, implementing K-nearest neighbor
(KNN) cluster analysis. But the algorithm only works on
I. INTRODUCTION
patients with specific types of movement during a seizure,
Epilepsy can be defined as a neurological disorder where which makes the method limited to specific types of seizure
brain activity becomes unusual, causing recurrent seizures. As patients. Another study proposed a threshold-based detection
reported by the World Health Organization (WHO), around method from accelerometer data [10]. But this type of method
49 out of 100,000 people are diagnosed with Epilepsy each suffers from low selectivity and high false alarm rate (FAR),
year [1]. Epilepsy is seen all over the world, but most of the making its reliability questionable. In another machine
cases (around 80%) are seen in developing countries [2]. learning-based study, features were extracted from
According to a survey, there are about 1.5 to 2 million patients accelerometer data and classified using Support Vector
with epilepsy in Bangladesh [3]. Patients with epilepsy suffer Machine (SVM) [11]. This proposed method also suffers from
more in developing countries due to social stigma. An a high False Alarm Rate. Another accelerometer-based study
Epileptic Seizure is defined as a period of unusual behavior, promises high sensitivity but low selectivity as it also has the
*These authors contributed equally problem of high FAR [12]. Some state-of-the-art non-EEG-
based seizure detection methods use multiple accelerometer
sensors along with other sensors such as surface EMG
978-1-6654-6621-9/21/$31.00 ©2021 IEEE

46
Authorized licensed use limited to: Universidad Simon Bolivar (Colombia). Downloaded on March 02,2023 at 01:22:32 UTC from IEEE Xplore. Restrictions apply.
(sEMG), Electro-dermal Activity (EDA) sensors to detect The selected accelerometer is equipped with a 16-bit analog
seizures [13], [14]. Although, in some cases, they offer high to digital conversion hardware, which gives accurate
sensitivity and low FAR, they come with their limitations. vibrational data. Data were primarily stored on a Micro SD
These sensors are usually affected by external factors such as card, which was connected to the system via a Micro SD
motion artifacts, temperature, and humidity, leading to module. The device was powered using a DC power bank. The
inconsistent results. On top of that, the addition of many hardware layout is shown in Fig. 1. A volunteer wore the
sensors increases the cost of the device as well as sometimes device on her wrist. 3-dimensional accelerometer data of daily
compromises the wearer's comfort in daily usage. So, more activities were recorded and saved on the SD card. Such
study is needed to make the accelerometer-based seizure activities are as follows – walking, running, jogging, driving,
detection technique more feasible and reliable as it offers exercising, etc. Seizure movement data were recorded by
some benefits over other sensors in terms of cost, portability, mimicking seizure-like movements. The seizure-like
and comfort. Accurate classification of seizure and non- movements were seen from different videos found on the web
seizure movements from accelerometer data is one of the and mimicked by the volunteer. The selected accelerometer
prime concerns at the moment. This concern demands focus range was 16G, and data were collected at a rate of 50Hz. The
to obtain high sensitivity and specificity in seizure detection. accelerometer has three channels, x, y, and z. So, a single data
point had three values. A similar type of data collection
Taking these into account, the goal of this study was to method was followed in [9] to make a dataset of seizures using
find an improved way to study and classify accelerometer data an accelerometer. In total, 184 minutes of data were collected.
to detect general tonic-clonic Seizures, which can help The data were then transferred to a computer for further data
develop a wearable seizure monitoring device to prevent processing. The block diagram of our methodology is given in
unexpected death due to epileptic seizures. Fig. 2.

II. METHOD B. Data Pre-processing


A. Data Acquisition For better training and classification of the recorded
accelerometer data of seizure and non-seizure movements, the
There were no open-source accelerometer data of seizure data were preprocessed in several steps. First of all, the raw
movements available in literature and databases. So, we had data had plenty of corrupted values. The corrupted values
to develop a device to record accelerometer data of seizure- were deleted using typecasting method. After that, the raw
like movements and non-seizure-like movements. The data data were used to create plots taking 50 data points for each
acquisition device was made using ESP8266 NodeMcu, plot. No overlapping windows were used. The plots were
which is a microcontroller, and a 6DOF Accelerometer saved as images of 256x256 pixels. About 9,000 RGB images
Gyroscope GY-521 (MPU-6050) sensor to record were constructed. The sample rate of our dataset was 50 Hz
accelerometer data of seizure and non-seizure movements. that means 50 data points were recorded each second.

Fig. 1. Hardware layout of the data collection device. Fig. 2. Block diagram of methodology.

Fig. 3. Some examples of constructed images from accelerometer data. Each image is 256 x 256 pixels and plotted using 50 data points from the dataset.

47
Authorized licensed use limited to: Universidad Simon Bolivar (Colombia). Downloaded on March 02,2023 at 01:22:32 UTC from IEEE Xplore. Restrictions apply.
So, each image represents 1 second of movement. Among 2) Model Training
these images, 70% were of non-seizure movement, and 30% We trained the models with a batch size of 4 for a total of
were of seizure movement. 15 Epochs, each with an ADAM optimizer with a learning
Some examples of the type of images constructed from rate of 1e-5 to enhance the CNN ability in classification, and
seizure and non-seizure-like movement data are shown in Fig. used Categorical Cross-Entropy as our loss function. A
3. Different types of seizure-like movements are also shown reduced learning rate was introduced in case validation
in Fig. 3. reached a plateau. These hyperparameters were selected
using trial and error.
C. Data Classification 3) Model Testing
In our problem, we expect the images to have different After training, the models were tested using 250 images
complex pattern sequences, which can be used as a feature belonging to 2 classes, namely seizure and non-seizure
for classification. For this purpose, we trained CNN models. movements.
For training, 8500 images were used. 250 images were 4) Hardware Specification
separated for testing. Among the 8500 images, 20% were A GTX 1050 Ti 4GB DDR4 GPU was used to train the
used for validation, and the rest 80% were used for training. models.
1) Model Description
We compared three well-known CNN models in this III. RESULTS AND DISCUSSION
study. We took DenseNet, VGG16, and ResNet-50 as our
base model. These three models are well-known for their A. Model Evaluation Metrics
ability to recognize patterns in images. To implement transfer To find out which model performs best, we evaluated the
learning, we added some extra layers to prepare the model for models based on three parameters; accuracy, sensitivity, and
our dataset. On top of the base model, we added a Global- specificity. Accuracy (Acc) is defined as the percentage of the
Average Pooling layer which replaces the fully connected correctly predicted output of the model. Sensitivity (Se)
layer and creates a feature map for each category. After that, evaluates the percentage of how many times the model can
we added a dense layer with activation function Relu and correctly predict seizure events if only seizure events are given
another dense layer with activation function Softmax with as inputs. Specificity (Sp) is the estimation of the percentage
two binary classifiers as non-seizure and seizure. A dropout of how many times the model can correctly predict non-
layer of 50% was added in between to eliminate overfitting. seizure events when only non – seizure events are given as
The model’s layout is shown in Fig. 4. inputs. In order to calculate these parameters, we need four
pieces of information [15]. These are,

(a)

(b)

(c)

Fig. 4. CNN architectures with added layers are used for the classification of the images. (a) DenseNet architecture with added layers. (b) VGG16
architecture with added layers. (c) ResNet-50 architecture with added layers.

48
Authorized licensed use limited to: Universidad Simon Bolivar (Colombia). Downloaded on March 02,2023 at 01:22:32 UTC from IEEE Xplore. Restrictions apply.
 True-Positive (TP): Successfully predicted a dataset. The DenseNet model’s confusion matrix is shown in
Seizure like movement. Fig. 5(b). From the figure, we can see the model outputs 2
false negatives and 0 false positives.
 True-Negative (TN): Successfully predicted a
non-Seizure movement. For the VGG16 model, the best accuracy while training
was found about 99.69%. The best validation accuracy was
 False-Positive (FP): Falsely predicted a Seizure 99.2%. The accuracy per epoch graph is given in Fig. 6(a).
like movement. where the best accuracy was at epoch 11. The confusion
 False-Negative (FN): Falsely predicted a non- matrix of the test is shown in Fig. 6(b). The model outputs five
Seizure movement. false negatives and 0 false positives, as seen in the figure.

The three metrics are defined in the following: For the ResNet-50 model, the best accuracy while training
was 99.95%. The best validation accuracy was 99.33%. The
accuracy per epoch graph is given in Fig. 7(a). The increasing
( ) accuracy of the model per epoch can be seen in the figure. The
% of Accuracy = × 100 (1)
( ) confusion matrix of the test on the ResNet-50 model is
presented in Fig. 7(b). In this case, the model outputs five
false-negative and 1 false positive.
% of Specificity = × 100 (2)
( ) Using the confusion matrices, we calculate the evaluation
parameters of the three models. The evaluation results of the
models are presented in Table 1. From the table, it is clear that
% of Sensitivity = × 100 (3) DenseNet is the best performing model as it offers the highest
( ) accuracy, sensitivity, and specificity.

B. Model Evaluation SUMMARIZED EVALUATION METRICS


For the DenseNet model, the best accuracy while training
Model Acc (%) Se (%) Sp (%)
was found about 99.75%. The best validation accuracy was
99.63%. The accuracy per epoch graph shows the DenseNet 99.2% 98.4% 100%
improvement of the model at each epoch. The graph is shown VGG16 98% 96% 100%
in Fig. 5(a). Here we can see the best validation accuracy
ResNet-50 97.6% 96% 99.2%
occurred in epoch 5. The confusion matrix of a test of a model

(a) (b)

Fig. 5. (a) Accuracy vs Epoch curve for DenseNet model. (b) Confusion Matrix for DenseNet model.

(a) (b)

Fig. 6. (a) Accuracy vs Epoch curve for VGG16 model. (b) Confusion Matrix for VGG16 model.

49
Authorized licensed use limited to: Universidad Simon Bolivar (Colombia). Downloaded on March 02,2023 at 01:22:32 UTC from IEEE Xplore. Restrictions apply.
(a) (b)

Fig. 7. (a) Accuracy vs Epoch curve for ResNet-50 model. (b) Confusion Matrix for ResNet-50 model.

to integrate into embedded systems, making it ideal for


C. Seizure Detection Algorithm developing IoT devices. The accelerometer data which were
Among the three models that were used for training, the recorded have three channels. Simple Machine Learning
DenseNet model performed relatively well. Hence, we techniques such as SVM, kNN, and others can be used to
selected the DenseNet model to develop an algorithm that classify such data. However, as previous studies have shown,
predicts a Seizure event by taking multiple images as input. the main problem with such techniques is their high False
As each image represents 1 second of seizure or non-seizure- Alarm Rate. That's why we investigated whether CNN could
like wrist movement, the multiple images (‘n’ number of be used to detect convulsive seizures.
images) represent the last ‘n’ seconds of wrist movements.
Using this data, the algorithm predicts if a seizure has occurred The data that we used for seizures were recorded by
or not. The developed algorithm uses a parameter (‘s’) to mimicking the movements of convulsive seizures. This type
determine if a seizure has occurred or not. The value of ‘s’ of dataset will not 100% accurately represent a patient having
ranges from 1 to ‘n’, which can be set before implementation. a convulsive seizure but is sufficient to evaluate a model’s
The algorithm finds how many pictures are detected as performance as it has been done in many literatures
seizures and compares the number with the value of ‘s’. Then, previously.
using a simple if-else condition, the model outputs if a seizure The three different models used for classifying the dataset
has occurred or not. Thus, by changing the value of ‘s’, we can had satisfactory performance, proving the viability of the
control the sensitivity of the algorithm. We can also change method for future research to detect a convulsive seizure. In
the value of ‘n’ to tune the algorithm. This makes the the future, we plan to take data from real patients having
algorithm robust. As we know, Seizure events vary a lot from seizures and use those to train CNN models. Such models
patient to patient; this allows us to prepare the algorithm should outperform current seizure detection methods based on
according to a particular patient. The working procedure of the our research.
algorithm is given in Fig. 8.
IV. CONCLUSION
D. Discussion
In this work, we proposed an effective convulsive seizure
In this paper, we evaluated Convolutional Neural Network
classification method using a two-dimensional convolutional
as a tool for Convulsive Seizure Detection. We chose an
neural network from seizure and non-seizure-like wrist
accelerometer as our sensor because it is inexpensive and easy
movement data. Due to the unavailability of such datasets, we

Fig. 8. Workflow of the algorithm. The algorithm outputs Non-Seizure or Seizure based on the given input.

50
Authorized licensed use limited to: Universidad Simon Bolivar (Colombia). Downloaded on March 02,2023 at 01:22:32 UTC from IEEE Xplore. Restrictions apply.
developed a wrist-worn device equipped with an study,” BMJ Open, vol. 10, no. 8, p. e035767, Aug. 2020.
accelerometer sensor to create a dataset of seizure and non- [6] S. J. M. Smith, “EEG in the diagnosis, classification, and management
seizure-like movements. The seizure-like movements were of patients with epilepsy,” J. Neurol. Neurosurg. Psychiatry, vol. 76,
no. suppl 2, pp. ii2–ii7, Jun. 2005.
mimicked by seeing videos of the movements of patients
[7] A. Rakshasbhuvankar, S. Rao, L. Palumbo, S. Ghosh, and L.
experiencing a seizure. The dataset was trained using three Nagarajan, “Amplitude Integrated Electroencephalography Compared
different CNN models to determine which model suited the With Conventional Video EEG for Neonatal Seizure Detection: A
best. The models were evaluated against three performance Diagnostic Accuracy Study:,” J. Child Neurol., vol. 32, no. 9, pp. 815–
metrics: accuracy, sensitivity, and specificity. Among the 822, May 2017.
three models, the best performing model was DenseNet, with [8] S. Beniczky, I. Conradsen, O. Henning, M. Fabricius, and P. Wolf,
99.2% accuracy, 100% specificity, and 98.4% sensitivity. The “Automated real-time detection of tonic-clonic seizures using a
wearable EMG device,” Neurology, vol. 90, no. 5, pp. e428–e434, Jan.
model did not output any false-positive results, which makes 2018.
the method viable for accurate seizure detection. Hence, based
[9] A. Hildeman, “Classification of epileptic seizures using
on the DenseNet model, an algorithm was designed with two accelerometers,” Chalmers university of technology, 2011. [Online].
controllable parameters to tune the algorithm according to the Available:http://publications.lib.chalmers.se/records/fulltext/145997.p
patient’s seizure types. The proposed method could help df
develop a wearable seizure detection device for epileptic [10] J. Lockman, R. S. Fisher, and D. M. Olson, “Detection of seizure-like
patients to prevent unexpected death, thus making epileptic movements using a wrist accelerometer,” Epilepsy Behav., vol. 20, no.
patients' lives much easier and safer. 4, pp. 638–641, Apr. 2011.
[11] S. Kusmakar, C. K. Karmakar, B. Yan, T. J. O’Brien, R.
Muthuganapathy, and M. Palaniswami, “Automated detection of
convulsive seizures using a wearable accelerometer device,” IEEE
Trans. Biomed. Eng., vol. 66, no. 2, pp. 421–432, Feb. 2019.
REFERENCES [12] S. Kusmakar, C. K. Karmakar, B. Yan, T. J. O’Brien, R.
[1] World Health Organization, “Epilepsy: Fact Sheet,” 2019. Muthuganapathy, and M. Palaniswami, “Onset Detection of Epileptic
https://www.who.int/news-room/fact-sheets/detail/epilepsy Seizures From Accelerometry Signal,” Annu. Int. Conf. IEEE Eng.
[2] Q. D. Mohammad et al., “Prevalence of epilepsy in Bangladesh: Med. Biol. Soc., vol. 2018, pp. 1–4, Jul. 2018.
Results from a national household survey,” Epilepsia Open, vol. 5, no. [13] M.-Z. Poh et al., “Convulsive seizure detection using a wrist-worn
4, pp. 526–536, Dec. 2020. electrodermal activity and accelerometry biosensor,” Epilepsia, vol.
[3] M. F. Mian et al., “Common Factors Responsible for Uncontrolled 53, no. 5, pp. e93–e97, May 2012.
Epilepsy Patients attended at a Tertiary Care Hospital in Bangladesh,” [14] M. Milosevic et al., “Automated Detection of Tonic-Clonic Seizures
J. Natl. Inst. Neurosci. Bangladesh, vol. 3, no. 1, pp. 42–47, Apr. 2017. Using 3-D Accelerometry and Surface Electromyography in Pediatric
[4] S. Shorvon and T. Tomson, “Sudden unexpected death in epilepsy,” Patients,” IEEE J. Biomed. Heal. Informatics, vol. 20, no. 5, pp. 1333–
Lancet, vol. 378, no. 9808, pp. 2028–2038, Dec. 2011. 1341, Sep. 2016.
[5] C. M. DeGiorgio, A. Curtis, A. Carapetian, D. Hovsepian, A. [15] A. Baratloo, M. Hosseini, A. Negida, and G. El Ashal, “Part 1: Simple
Krishnadasan, and D. Markovic, “Why are epilepsy mortality rates Definition and Calculation of Accuracy, Sensitivity and Specificity,”
rising in the United States? A population-based multiple cause-of-death Emergency, vol. 3, no. 2, p. 48, 2015. Accessed: Aug. 23, 2021.
[Online]. Available: /pmc/articles/PMC4614595/

51
Authorized licensed use limited to: Universidad Simon Bolivar (Colombia). Downloaded on March 02,2023 at 01:22:32 UTC from IEEE Xplore. Restrictions apply.

You might also like