CHAPTER 1 Introduction and Motivation Epilepsy, a prevalent and severe neurological disorder worldwide, affects individuals across all ages and regions. While some individuals experience remission from this dis- tressing condition, many continue to have seizures throughout their lives. The onset of epilepsy varies depending on the geographic location, with high-income countries showing a higher incidence in old age, In contrast, in development nations infants and early childhood are more commonly impacted due to obstetric complications or neonatal infec- tions. 1.1 Incidence and Prevalence
24Epilepsy is a common neurological disorder that affects a substantial number of people around the, which means they continue to have seizures despite trying two or more suitable anti-epileptic medications or alternative treatments. The likelihood of developing epilepsy is especially high during childhood, with about 75% of cases appearing during this stage of development. Globally, nearly 70 million individuals are affected by epilepsy. In high-income countries, the lifetime risk of developing epilepsy is around 6 per 1000 individuals, with approxi- mately 45 new cases per 100,000 people
1each year. These numbers are almost twice as high in low- and middle-income nations, possibly due to less advanced obstetric services and an increased likelihood of cerebral infections and head trauma. Epilepsy incidence displays notable variations according to age. Rates are higher in early childhood, lower during early adulthood, and show a second peak among individ- uals over the age of 65 (refer to the attached graph). Recent trends indicate a decline in the number of affected children and a notable rise in epilepsy cases among the el- derly. Consequently these days, the most prevalent age at which this illness develops in people is old age. 1.2 Prognosis Prognosis, a medical term used to predict the expected progression of a disease, plays a crucial role in epilepsy. The prognosis varies depending on the underlying cause and can greatly impact patients’ lives. While a majority of individuals with epilepsy experience favorable outcomes, the course of the condition differs among patients. In many cases, especially among children, epilepsy may remit, although a significant portion of individuals will continue to have the condition throughout their lives. After initiating treatment with antiepileptic drugs (AEDs), approximately 60-70% of patients achieve seizure freedom. Some individuals respond well to the first AED and maintain a seizure-free state, while others experience a more fluctuating pattern. Remission following AED withdrawal suggests a true resolution of the underlying causes. However, for 30-40% of patients, seizures persist with varying frequencies and intensities. Certain patients experience a pattern of epilepsy characterized by alternating periods of seizure freedom and relapse, commonly referred to as a "remitting-relapsing" course. There are several factors that suggest an unfavorable prognosis for controlling seizures, which include: • Underlying symptomatic cause of epilepsy • Pre-treatment high seizure frequency • Inadequate response to initial anti-epileptic drug (AED) therapy • Presence of
1generalized tonic-clonic seizures • Detection of generalized epileptic form activity on the electroencephalogram (EEG) • Family history of epilepsy • Coexistence of psychiatric comorbidities 1.3 Mortality, as revealed by the standardized mortality ratio, which evaluates the difference between actual and predicted deaths. While the cause of death often correlates with the epilepsy, a significant portion of fatalities can be attributed to a condition called sudden unexpected death in epilepsy (SUDEP), due to approximately 17% of all deaths related to epilepsy. SUDEP is characterized as an unforeseen and rapid death, whether witnessed or unwitnessed, not caused by trauma or drowning. It occurs in people who have epilepsy, regardless of whether there is proof of a seizure, and does not include postmortem results indicating toxicological or anatomical reasons
1of death. The documented occurrence of SUDEP varies from 0.35 to 10 cases per 1000 patients annually. The risk of SUDEP is particularly elevated when the seizure disorder is uncontrolled, indicating that a majority of SUDEP cases are associated with ongoing seizure activity. Furthermore, there are other factors that contribute to deaths related to epilepsy, including incidents like drowning, burns, aspiration, pneumonia, status epilep- ticus, and even suicide. 1.4 History Epilepsy originates from Greek term "epilambanein," which signifies "to seize" or "to assault." possesses a fascinating historical background. The earliest recorded instances of epilepsy in the Western world can be traced back to
1a Babylonian cuneiform treatise called "Sakikku" or "all diseases." These ancient tablets also acknowledged the existence of this disorder. Across different historical periods, epilepsy has been linked to supernatural or demonic forces in various cultures, attributed to its unique combination of symptoms and signs. However, a significant turning point in understanding epilepsy from a scientific perspec- tive occurred
1in 1875 when the English neurologist John Hughlings Jackson made a minutes before a focal dyscognitive or generalized seizure, and it is frequently reported by people with temporal lobe epilepsy. 1.5.2 Simple Partial Seizures The location of the aberrant electrical activity might cause simple partial seizures to manifest with different symptoms. For example, rhythmic motions of the arm, leg, or face
3on the opposite side of the body may result from a seizure that starts in the motor cortex. This particular type of seizure was previously known as Jacksonian seizures. On the other hand, when the seizure arises from sensory regions or areas linked to emo- tions and memory, it can lead to sensory phenomena like olfactory, visual, or auditory hallucinations. Moreover, individuals may encounter emotions such as fear, panic, or euphoria. Figure 1.
1212: Simple partial seizures 1.5.3 Complex Partial Seizures brief, lasting only a few minutes. During this period, individuals may exhibit an awake appearance but lose connection with their surroundings. Their response to instructions or questions becomes abnor- mal. Staring is a common feature, accompanied by either immobility or repetitive semi- purposeful actions known as automatisms. These automatisms can encompass facial grimacing, gestures, chewing, lip smacking, finger snapping, repetitive speech, walking, running, or even undressing. It is important to note that patients do not recall these hostile or aggressive behaviors after the seizure. Following the seizure, patients com- monly experience sleepiness, confusion,
1and complain of headaches. This postictal state can endure for minutes to hours. Figure 1.3: Complex partial seizures 1.5.4 Generalized Seizures Generalized seizures are distinguished by the simultaneous engagement of cortical re- gions on both sides of the brain from the beginning, often resulting in a diminished level of consciousness. Among these, the well-known tonic-clonic seizure, formerly referred to as "grand mal," typically commences with an abrupt cry. The patient experiences a sud- den collapse, followed by characteristic convulsive motions, which may involve
8tongue or mouth biting as well as urinary incontinence. Other subtypes of generalized seizures comprise absence seizures, myoclonic seizures, clonic seizures, tonic seizures, and atonic seizures. Absence Seizures Previously known as petit-mal characteristic finding. These seizures have a notable genetic predisposition, both for the occurrence of seizures themselves and for the abnormal EEG pattern. Around 40% of patients with absence seizures experience remission during adolescence. However, it is important to note that associated tonic-clonic seizures may persist into adulthood. Figure 1.5: Typical seizures Atypical Absence Seizures Onset of these seizures commonly occurs prior to the age of 5, often alongside other forms of generalized seizures and learning disabilities. Differing from typical absence seizures, Atypical Absence Seizures tend to have a longer duration and are frequently accompanied by alterations in muscle tone. Figure 1.6: Atypical seizures Myoclonic Seizures Myoclonic seizures are characterized by abrupt and
1brief muscle contractions, occurring either individually or in clusters, which can impact any muscle group. Generalized Tonic-Clonic (GTC) GTC seizures, previously referred to as grand mal seizures, encompass symmetrical convulsive movements that impact all limbs. They are characterized by initial stiffness followed by jerking motions. These seizures are accompanied by a loss of consciousness. Atonic Seizures Often referred to as "drop attacks," atonic seizures cause an abrupt loss of muscular tone and an instantaneous collapse, which frequently results in face or other injuries. 1.6 Diagnostic Evaluation The diagnosis of epilepsy relies on a detailed patient history and neurological examination. Witnesses’ accounts are crucial, and laboratory evaluations serve as supportive tests. Historical features and focal signs guide evaluation, treatment, and prognosis. General physical examination helps identify underlying conditions associated with epilepsy. 1.6.1 Electroencephalography (EEG) The neuro-electrophysiological signals known as EEG capture the brain’s electrical ac- tivities by utilizing electrodes. These electrodes can either be implanted subdurally (referred to as intracranial EEG) or positioned along the scalp (known as scalp EEG). The EEG has the capability to identify irregular electrical patterns,
2such as focal spikes or waves (associated with focal epilepsy), as well as diffuse bilateral spike waves (linked to generalized epilepsy inpatients, video monitoring during EEG sessions can provide valuable behavioral correlation. By extending the monitoring duration to span hours or even days, the diagnostic yield can be significantly enhanced, enabling a clear differentiation between epileptic seizures and nonepileptic events. This particular investigation holds crucial importance as an integral part of the assessment process for epilepsy surgery, serving as a key method to distinguish between epileptic and non-epileptic seizures. Magnetoencephalography Recent studies have examined this method, which measures
1the magnetic fields connected to the intracellular current flows in neurons in between seizures clinical management of epilepsy, particularly in identifying suitable candidates for surgical in- tervention when drug therapies prove ineffective. Ongoing research in this domain is actively exploring the application and efficacy of this approach.
1Prolonged Ambulatory Recording In cases where a routine EEG rather than a diagnostic tool. The standard teaching is to prioritize treating the patient’s condition rather than relying solely on the EEG results. However, there is an exception to this guideline in the case of absence epilepsy. Even if not accompanied by obvious clinical changes,
36brief generalized bursts of spike-wave. On the other hand, CT is valuable in acute scenarios, aiding in the detection of hemorrhages, calcifications, or tumors. Novel imaging tech- niques have emerged to assist in epilepsy assessments like functional MRI (fMRI). Mag- netic resonance spectroscopy measures neurochemical concentrations in different brain regions, aiding in seizure focus localization. Other imaging methods like
83positron emis- sion tomography (PET) and single-photon emission-computed tomography (SPECT) offer insights into regional glucose utilization and blood flow discrepancies, respectively, providing valuable information during seizures. In addition to traditional EEG, magnetoencephalography (MEG) is employed to assess the dynamic electromagnetic fields of the brain, enabling improved localization of epilep- tic dipoles, including those tangential to the scalp. These advanced techniques, such as MEG and functional imaging modalities, are primarily utilized in specialized epilepsy centers during presurgical evaluations. • Structural imaging: involves brain imaging studies to identify underlying struc- tural abnormalities, is essential in the
1diagnostic evaluation of most epilepsy pa- tients, particularly those presenting with partial onset seizures. Although their routine diagnos- tic role is limited, these techniques serve as valuable adjuncts in the workup for epilepsy surgery. CHAPTER 2 Literature Review Epilepsy classification is an important task in the diagnosis and treatment of epilepsy, which is a neurological disorder characterized by recurrent seizures. Machine learning classification models have been developed to identify different types of epilepsy based on electroencephalogram (EEG)
9signals generated by the brain during seizures. to generally straightfor- ward and it performs well with high-dimensional feature sets. Additionally, SVM offers manual control over the trade-off between complexity and error. The choice of a kernel plays a significant role in balancing computational performance and execution speed. Through the use of
110a kernel function, SVM can map the data into a) is a dimensionality reduction technique that assumes regular distribution of measurements within each class. QDA offers greater flexibility in handling the covariance matrix, making it more suitable for EEG signal datasets compared to LDA. However, QDA has more parameters to estimate, resulting in a significant increase in the number of parameters. This can pose challenges when dealing with a large number of classes but limited sample points.
53Figure 2.1: This is an image from a text that uses color to teach music achieved an impressive accuracy rate of 89.5% in accurately distinguishing between normal subjects and those with ASD. 2.1.5 Local Binary Pattern (LBP) They originated from a comparative study of texture measures, specifically as an image operator. Initially, LBP focused on a 3x3 pixel block within an image. By thresholding the center pixel with its neighboring 8 pixels, a local weight was generated. This resulted in an 8-bit binary code, which was then converted to a decimal value known as the LBP value for that center pixel. This two-dimensional method employed in image analysis can also be applied to analyze one-dimensional sampled EEG signals. Just as a 3x3 pixel block in an image comprises 8 neighboring points around the center pixel, the amplitude measure of 8 neighboring samples around an EEG sample point can be considered for LBP calculation. By adopting this approach, LBP can be utilized to extract meaningful information from EEG data. Figure 2.
243: The curved line is the decision boundary resulting from the QDA method reported by Ning and Lyu, Abdul-latif et al., and Paivinen et al. 2.2.3 K-Means Cluster (K-MC) The k-MC technique is an unsupervised learning approach that groups samples based on their shared properties, with ’k’ representing the number of clusters or classes. Each cluster consists of similar samples, distinguished from those in other clusters. This iterative process involves grouping samples based on their proximity to the mean and adjusting cluster positions until they stabilize over several iterations. An advantage of this technique is that it doesn’t require labeled input examples, and convergence is faster with a smaller ’k’. However, k-MC’s performance suffers when clusters have varying sizes, densities, or non-globular shapes. The initial placement of cluster centers also affects the results. Figure 2.5: Mapping process of multiband feature matrix
1182.2.4 Independent Component Analysis (ICA) ICA. The MATLAB R2012b environment alongside the EEGLAB toolbox can be used to apply this analysis technique. 2.2.5 Autocorrelation Function (ACF) Autocorrelation (ACF) is a numerical metric that quantifies the similarity between a value in a time series and its preceding value. The Statsmodels library offers a convenient way to compute autocorrelation in Python. By utilizing the autocorrelation function, the process of measuring the amplitude difference is made more straightforward and efficient. 2.2.6 Entropy Entropy, in machine learning and EEG signal analysis, quantifies the uncertainty or randomness in a dataset or signal. It measures the information content or complexity of a system. In machine learning, entropy helps evaluate the purity of nodes in decision trees, aiding in feature selection. In EEG analysis, entropy measures assess the irregularity and complexity of brain wave patterns, aiding in identifying brain states and abnormalities. Different entropy measures, like Shannon entropy and Renyi entropy, capture different aspects of information content and complexity. 2.2.7
27Kurtosis Skewness and kurtosis are statistical measures that provide insights into the shape and distribution of a time series. Skewness. To calculate skewness and kurtosis in a dataset, Python offers convenient functions such as ‘skew()‘ and ‘kurt()‘ from the SciPy Stats library. These functions enable the computation of these statistical measures, facilitating their use in various applications, including time series analysis and medical research. 2.3 State-of-the-Art: Seizure Detection Sriraam and Shivarudhrappa [10] collected 26 features of and trained an SVM classifier that had improved using 10-fold cross-validation to classify epilepsy-relevant activities. This technique showed an accuracy of 92.15%. Qi et al. [4] used ELM and non-linear characteristics to classify epilepsy. This method outperformed backward propagation and Support Vector Machines with a 96.5% accuracy rate in classification accuracy and training time. In [25], authors applied a random forest model to classify the data of epileptic and non-epileptic patients. They introduced a method to detect epilepsy in a noisy environment. They achieved the accuracy of sensitivity and specificity are 92%, 90%, and 93%, respectively. Lahmiri and Shmuel [11] classified recorded EEG information into seizure and non-seizure states using the Hurst exponent (HE) and got an accuracy of 97%. Guo et al. [1] achieved 96% accuracy using ANN classifiers to classify EEG signal record- ings. In [24], a deep learning model with an independent neural network with a dense structure obtained an accuracy of 88.69%. Saminu et al. [19] It focused at a variety of automated EEG seizure detection and classification strategies, including feature ex- traction methods and statistical and machine learning classifiers. Xinghua et al. [13] used a novel independent Recurrent Neural Network (RNN) to classify epileptic and non-epileptic seizures. They used 17 channels from the CHB-MIT database of 686 EEG recordings and achieved an accuracy of 88.69%. Choubey and Pandey [17] used HFD, sample entropy, and EAM features to compare the ANN and KNN models. They achieved an accuracy of 98% and 94%, respectively, on two distinct EEG data sets for epileptic seizures. Chirsani and Manikandan [22] imple- mented the hierarchical attention-based convolutional neural network to classify epilep- tic seizures using single-channel EEG epochs and obtained 97.03% accuracy. Khizar et al. [12] forecasted seizures using a single robust linear characteristic as a correlation vector of seizure-like events in the brain. They used discrete wavelet transform and SVM and extracted eight features with an accuracy of 99.8%. Baffa et al. [23] created a classification model based on morphological and textural parameters for FCD on MRI. By using a multi-layer perceptron, they were able to obtain an accuracy of 96.81%. Aslam et al. [21] used Short Term Fourier Transform (STFT) and Artificial Neural Network to classify the raw EEG into epileptic and non-epileptic seizures and achieved an accuracy of 100% in most cases. [14] used the K-means clustering method to extract DWT and classify the raw EEG data. They get an accuracy of 96.7%. Nahzat and Yaganoglu [18] used five classes of EEG patients and average persons. Then, different models were used
24to classify the epileptic and non epileptic seizures using the 128- channel system. They reduced the computational time using the random forest model with an accuracy of 97%. K-Nearest Neighbors (KNN) and Discrete Transform models have an accuracy of 96%, respectively. Mahjoub et al. [16] detect epileptic seizures using Machine Learning Techniques. They extract TQWT, IMFs, and MEMD features using a Support Vector Machine and get an accuracy of 98.78%. Shoeb and Guttag [2] used SVM to identify epileptic seizures in a scalp EEG dataset. According to test data, this method had a 96¬curacy rate. In [20], an SVM classifier to categorize epileptic seizures and a Bayesian optimization approach were used to optimize the SVM’s hyperparameters. Additionally, they compared the SVM classifier’s accuracy with linear and quadratic discriminant analyses in their study and achieved an accuracy of 97.05%. In [6] employed the dual-tree complex wavelet transform (DTCWT) to decompose the signals and generate the statistical measures, then trained a generic regression neural network classifier on all the statistical measurements and got an accuracy of 95.24%. In [15],
55deep convolutional neural networks based on transfer learning and the power spectrum density energy diagrams were Author Technique Channels Accuracy Sriraam and Raghu (2017) SVM 64 0.922 Tsinalis (2016) CNN 1 0.978 B.Suguna Nanthini (2017) SVM 16 0.952 Swami et al. (2021) DTCWT 128 0.952 Yandong et al. (2022) RF 18 0.92 Lahmiri (2017) HE 1 0.97 Guo et al. (2010) ANN 1 0.96 Xinghua et al. (2019) INN 17 0.887 Yuyuan et al. (2020) Deep CNN 23 0.926 Sateesh and Suchetha DNN 2 0.929 Hemant and Alpana (2020) KNN CNN 1 1 0.94 0.98 Usman et al. (2019) SVM 2 0.931 Kocadagli and Langari (2017) ANN 1 0.988 Senger and Tetzlaff (2016) CNN-UM 20 0.716 Shiao et al. (2017) SVM 16 0.878 Brinkmann et al. (2016) ANN 16-24 0.88 preictal I, preictal II, and interictal states as classes and achieved an accuracy of 92.6%. In [3], ANN was implemented to extract features. They used DWT at various levels to decompose the specific partitions into the detail and approximation coefficients and achieved 98.8% accuracy. Birjandtalab et al. [7] were employed to identify epileptic seizures. A Gaussian mixture model is used to detect epileptic and non-epileptic seizures. The F-measure of the experiment was 85.1%, and accuracies of 85.1% and 85.1%. Zabihi et al. [5] processed the dataset with Fourier transform characteristics using an SVM classifier and achieved 94% preciseness and 96% efficiency. CHAPTER 3 Surveys and Classification attempts During the project, the team conducted several visits to hospital facilities where they had the opportunity to meet with numerous experienced neurologists. Among these professionals were Dr. Zareen Mughal, Dr. Hiba, and Dr. Khalid Sher. The knowledge and insights gained from these visits are discussed in detail below. 3.1 National Epilepsy Centre (NEC) The medical technicians at the National Epilepsy Centre played a crucial role in enhanc- ing the team’s understanding of EEG machines. They provided a live demonstration, which involved a survey of ten patients’ EEG recordings, enabling the team to gain a better grasp of electrode placement as per the 10-20 System. The technicians also provided detailed explanations of the
95different types of brain waves, such as alpha, beta, delta, theta and other waves cycles for unconscious or somnolent patients. The team was shown the differences in frequencies of these waves, which allowed them to better understand the significance of each. The technicians also demonstrated how artefacts can occur due to machine or electrode misplacement, which can affect specific channels. Additionally, the team was shown how the signal morphology changes during blinking of the eye, which helped them to develop a basic understanding of EEG signals. Overall, this demonstration was an invaluable learning opportunity for the team, and it helped them to gain a deeper understanding of EEG machines and their applications in patient care. 3.1.1 10-20 System The 10-20 system is a universally accepted technique for positioning electrodes on the scalp to conduct EEG (electroencephalogram) recordings in a consistent and standard- ized manner. It is
109based on the measurements of the distances between specific points on the distances are measured between specific landmarks on the scalp, which are identified using a set of standardized measurements based on the individual’s head shape and size. The 10-20 system includes 21 electrode positions that are distributed across the scalp according to specific rules. The positions are labeled using a combination of letters and numbers. The letters refer to the region of the scalp where the electrode is placed, and the numbers indicate the position within that region. The regions are: Frontal, Temporal ,Central, Parietal, Occipital The numbers used to label the positions depend on the region of the scalp. For example, Within the frontal region, the left side of the head is where the
14odd-numbered electrodes are positioned, while the right side of the head accommodates the even- numbered head is where the even-numbered electrodes are positioned. The 10-20 system is widely used in EEG research and clinical practice because it provides a consistent method for electrode placement that can be replicated across individuals. This allows for more accurate comparisons of EEG data between individuals and across studies. In addition to the 21 electrode positions are placed by 10-20 system, there are also additional positions that can be added for specific research or clinical purposes. For example, the international 10-20 system includes 10% and 20% positions in between the standard electrode positions, which are labeled with a "z" to indicate their position along the front-back and right-left axes. CHAPTER 3: SURVEYS AND CLASSIFICATION ATTEMPTS The 10-20 system provides a standardized approach to accurately position EEG elec- trodes on the scalp, enabling reliable and consistent comparisons of EEG data among different individuals and studies. 3.1.2 REM and nREM Sleep Cycles
15The human sleep cycle is divided into two main stages: Rapid Eye Movement (REM) sleep and non-REM (NREM) sleep. 3 brain produces synchronized alpha and theta waves. Alpha waves are characterized by a moderately low frequency range (8-13 Hz) and exhibit high amplitude electrical patterns. On the other hand, theta waves have an even lower frequency range (4-7 Hz) and greater amplitude than alpha waves. Stage 1 sleep is classified as a relatively light sleep stage, susceptible to disturbances from external stimuli. During the transition to stage 2 sleep, the body experiences a decrease in muscle activity, heart rate, and respiration. Theta waves remain the dominant pattern of brain activity during this stage, occasionally interrupted by
18brief bursts of higher frequency brain waves called "sleep spindles." These sleep how long they have slept. In relation to the frequency of EEG signals, stage 1 sleep is primarily characterized by the presence of alpha waves, whereas stage 2 sleep is characterized by theta waves. Delta waves, on the other hand, dominate during stage 3 sleep. Moreover, as the NREM sleep stages progress, there is a gradual
19decrease in heart rate, respiration, and overall muscle tension tend to experience a REM rebound effect, indicating that REM sleep is regulated by homeostasis. Along with its role in learning and memory, REM sleep is associated with emotional processing and regulation. The consequences of sleep depri- vation, including REM sleep deprivation, have been extensively studied and are known to negatively impact physical and cognitive functioning. 3.1.3 Eye Blinking and other artefacts Blinking is a common event that can cause artifacts in EEG recordings. When a person blinks, there is a sudden and large amplitude change in the EEG signal, which can obscure underlying brain activity. These blink artifacts are typically observed in frontal and temporal regions of the scalp, where the muscles responsible for blinking are located. Figure 3.1: EEG reading during Eye blinking In addition to blink artifacts, there are other types of artifacts that can be present in EEG recordings, such as movement artifacts, electrical line noise, and muscle artifacts. Movement artifacts are caused by head and body movements, while electrical line noise can be caused by power lines or other electrical equipment in the environment. Muscle artifacts are caused by contractions of facial or scalp muscles. There are several methods that can be used to reduce artifacts in EEG recordings. One common approach is to use artifact rejection algorithms, which automatically identify and remove segments of the data that contain artifacts. These algorithms can be trained using manual annotation of the data by experts, or by using machine learning techniques to automatically identify artifacts based on their characteristics. Another approach is to use
9independent component analysis (ICA), which separates the EEG signal into independent components that correspond to different sources of activity in the brain and body. The components corresponding to artifacts can then be removed from the data, leaving only the components representing brain activity. Finally, it is important to properly prepare the subject before recording EEG data, including cleaning the scalp thoroughly, avoiding hair products that can interfere with the electrodes, and ensuring that the subject is comfortable and not moving excessively during the recording. These steps can help to reduce the amount of artifact present in the data and improve the quality of the EEG signal. 3.2 Aga Khan Development Network The team had the opportunity to collaborate with Mr. Imtiaz, who provided valuable insights and knowledge about various types of amplifiers and filters for Single-Channel EEG Acquisition System Design. In addition, Mr. Imtiaz generously provided direction to the team to purchase Ambu Electrodes, which are specialized electrodes used in medical settings for recording bio-potential signals. The team also acquired an E- health Sensor Module, which served as a starting point for the team to collect and analyze data related to facial muscle activity. 3.2.1
97E-Health Sensor Module Figure 3.2: E-Health Sensor Module The e-Health sensor kit, developed by Cooking Hacks, a division of Libelium, is specifi- cally designed to be compatible with Arduino and Raspberry Pi platforms. This versatile kit offers a cost-effective and user-friendly solution for researchers, developers, and artists (a) Amplitude curve for data captured during Blinking state (b) Statistics for Blink data Figure 3.3: Description of data collected during continuous eye blinking who require biometric sensor data for their projects. With a total of nine sensors, the kit allows for the measurement of various
34biometric parameters including pulse, blood pressure, SPO2 (oxygen in blood), EKG (electrocardiogram), airflow, glucometer, GSR (galvanic skin response), patient position, and body temperature. The primary objective behind the e-Health sensor kit is to provide an accessible and open alternative to the expensive and proprietary solutions currently prevalent in the medical market. By utilizing this kit, users can gather sensor data to monitor a patient’s condition or collect vital information for medical diagnosis. Furthermore, the collected data can be transmitted wirelessly to a laptop, smartphone, or the cloud for further analysis, using popular wireless protocols such as Wi-Fi, 3G, or Bluetooth. The team utilized the Ambu Electrodes and E-Health Sensor Module in conjunction (a) Amplitude curve for data captured during non- Blinking state (b) Statistics for non-Blink data Figure 3.4: Description of data collected during non-blinking state with the Arduino micro-controller platform to capture facial Electromyography (EMG) data from a single individual. Specifically, two separate datasets were obtained: one while the subject continuously blinked, and another while the subject refrained from blinking. Upon analyzing the obtained data as shown in 3.3b and 3.4b, it was discovered that the mean amplitude and other statistical values of the continuous blinking dataset were slightly different from those of the non-blinking dataset. Additionally, standard de- viation values for specific windows of data were calculated, aiding in the creation of threshold values for each dataset. With this information, the team proceeded to implement simple if-else conditions in the code to effectively control an LED output based on the subject’s blinking activity. The mean values derived from the previously collected datasets were utilized to trigger the LED when the subject blinked. This approach allowed for a successful demonstration of the potential for utilizing facial EMG data to control electronic devices.
114CHAPTER 4 Problem Definition 4.1 Problem Statement In Pakistan, where there is a shortage of neurology experts, there is a critical need for a faster and less labor-intensive diagnosis of epilepsy. Currently there are only 250 trained neurologists according to a 2023 report. Moreover, the neurologists vs population ratio is about 1:1,000,000, which is too less as compared to the demand of our country. To add, over 90% of medical equipment is imported to Pakistan, especially EEG Ma- chines, which are not developed locally due to limited RnD landscape in the country. 4.2 Solution Statement Following an extensive review of relevant literature and a thorough analysis of the prob- lem at hand, we present the proposed solution statement in the following manner: To develop a cost-effective and accessible tool for epilepsy diagnosis so as to reduce dependency on neurologists and expedite the diagnostic process. We now present the methodology used to tackle our project as well as its design and architecture. CHAPTER 5 Design and Methodology This study introduces a novel CNN with multi-headed attention to solve the problem of conventional CNNs missing important features during classification. The proposed model’s multi-head attention layers receive input from the features extracted by the preceding convolutional layers. With the addition of the multi-head attention mecha- nism, more relevant features can be highlighted and identified, leading to more accurate seizure classification. 5.1
94TUH EEG Seizure Corpus The TUH EEG Seizure Corpus is used as the primary source of data. It is the largest publicly available database of interictal and ictal recordings of over 2,500 seizures from nearly 1,000 patients [8]. The dataset comprises 11 seizure types; however, we only focus on the four types: absence, myoclonic, tonic, and tonic-clonic seizures, which fall under generalized epileptic seizures [9]. Additionally, the dataset includes demographic information about the patients, such as age and gender, as well as the seizures, such as onset and duration [8]. 5.2 Pre-Processing Pre-processing is used to clean and prepare EEG signals for the model by eliminating noise and artefacts and converting the data into a format from which the model can com- prehend and learn. The first step is to remove noise and artifacts from the signals. This Figure 5.
251: Histograms of seizure types in the TUH EEG Seizure Corpus for the evaluation and training sets principal component anal- ysis (PCA) to remove artifacts such as muscle activity and eye movements. Next, the EEG signals are segmented into smaller, non-overlapping windows of time. This step is essential because it allows the model to learn from shorter segments of the signals, which can help detect seizures that occur over a shorter time frame. After segmenting the EEG signals, they are transformed into a format that can be input into the classification model. The last step is to normalize the data. This is done by scaling the data
78with a mean of zero and a standard deviation of one. This is important because it ensures that all features in the dataset have the same scale, which helps the model converge faster and improves its performance. 5.3 Feature Extraction Feature extraction involves reducing the complex EEG dataset into relevant
107features that can be used to train the model. These EEG signals into constituent frequency bands. The power ratio in one frequency band to the power in another helps identify EEG patterns that may indicate distinct seizure types. For example, a high power ratio in the beta frequency band may indicate a tonic seizure. The FFT of the signal is calculated using equation 5.3.1. 𝑊(𝑘) = 𝛴𝑁−1 𝑥(𝑛)−𝑗·2𝜋𝑒𝑚𝑗𝑁 (5.3.1) n=0 where x(n) is the EEG signal x in time-domain signal
43and N is the number of samples . In specific frequency band. 5.3.2 Time domain analysis The time correlation provides insight into the relationships between different EEG sig- nals of different seizure types. It measures the similarity between two signals as a function of time and is calculated using equation 5.3.3. (𝑞𝑚 ) = ΣNn−=01 α(n) · β(n − τ ) (5.3.3) (𝑞𝑚) = ΣN−1 2 Σ Rαβ τ n=0 α (n) · Nn−=01 β 2 where
90N is the number of samples and τ is the time lag between the two signals α and β. In addition, sample entropy is used to measure the signal’s complexity. It is calculated by comparing the similarity of signal segments to each other as shown in equation 5.3.4. 𝑅 = − 𝑘𝑛 𝐶𝑚 𝐶𝑚+1 (5.3.4) where Cm is the number of m-length templates in the EEG signal x that match within a tolerance level. 5.3.3 Time-frequency domain analysis In Lifting Stationary Wavelet Transform (LSWT), the EEG signal is convolved with a wavelet waveform at different scales and locations to obtain wavelet coefficients rep- resenting the EEG signal’s contribution at each scale and location shown in equation 5.3.5. 1 NΣ− 1 n − b xa,b = √ h x (n) (5.3.5) a n=0 a where xa,b is the wavelet coefficient at scale a and location b, h(n) is the wavelet scaling function, and
39N is the number of samples in the distinguish between seizure types. Mean is the average value of a signal over time, and standard deviation measures the dispersion of a signal around its mean as shown in equation 5.3.6 and 5.3.7, respectively. Both mean and standard deviation provide insight into the variability and overall level of neural activity. N−1 µ = 1 𝛴 𝑥(𝑛) N n=0 (5.3.6) ‚ 𝜎 = . , 1 𝑁𝛴 − 1 (𝑥(𝑛) − µ)2 (5.3.7)
100N n=0 where N is the number of samples in the EEG signal EEG signal at different times. By weighting the importance of different features, it helps to improve the accuracy of the model and make it more robust to variations in the input data. The multi-headed attention component is made up of eight attention heads, each of which is responsible for attending to a different subset of the input data. The attention heads are implemented using a feed-forward approach, where they are trained to compute a weighted sum of the input data, with the weights determined by the importance of each input feature. One of the main advantages of the multi-headed attention component is that it allows the model to learn complex patterns and relationships between different parts of the input data. This is particularly useful in our EEG signal analysis, where the data is often highly complex and difficult to interpret. 5.4.2 Convolutional layers The CNN module plays a vital role in acquiring
44hierarchical representations of the input data, enabling the capture of intricate patterns typically have a large number of neurons and are designed to capture higher-level features of the data that are not captured by the convolutional layers. During training, the FC layers learn to extract these higher-level features by adjusting the weights on the inputs and biases. The weights and biases are updated iteratively using an optimization algorithm like stochastic gradient descent, which minimizes the error
77between the predicted output of the network and the actual output. The number of (CNN) model for seizure classification, a combination of multiple metrics is used to provide a com- prehensive assessment of its efficacy [24]. Given the skewed distribution of classes, the metrics are calculated separately to test the model’s robustness and practicality. The CNN model distinguishes between ’positive’ and ’negative’ seizures, categorizing them as generalized epileptic seizures or non-seizures. True positives (TP) refer to correctly identified positive seizures, while true negatives (TN) indicate correctly iden- tified negative non-seizures. False positives (FP) represent incorrectly classified positive seizures, and false negatives (FN) refer to incorrectly classified negative non- seizures. Evaluation metrics, discussed in the subsequent section, are derived from confusion ma- trices to assess the model’s performance. Apart from utilizing confusion matrices, the model’s performance is evaluated through multiple
93metrics, including accuracy, precision, recall, and F1 score. These evaluation metrics model, par- ticularly in medical diagnosis scenarios. Sensitivity measures the model’s capability to accurately detect positive cases, whereas specificity gauges its ability to accurately identify negative cases. Minimizing false positives and false negatives is of utmost im- portance in medical diagnosis due to their potential implications. By considering
45these metrics, a deeper understanding of the model’s performance in detecting positive and negative samples can be obtained. Figure 5.3: Confusion matrices for one-vs-all classification. 5.6 Results This study uses 44 EEG recordings from three patients, split in the 60:20:20 ratio for training, validation, and evaluation. 11 files were used for each seizure class: ABSZ, TCSZ, TNSZ, and MYSZ. The dropout value of the proposed model was set as 0.4. 5.6.1 Accuracy The accuracy (A) of the model is defined as
29the proportion of correctly classified seizures out of the total number of seizures. High accuracy is desirable, but it is important to note that this metric alone can be misleading as the classes are skewed. Table 5.1 shows the model’s training, validation, and evaluation accuracy. TP + TN A= (5.6.1) TP + FP + TN + FN 5.6.2 Precision The precision (P) measures the model’s ability to correctly identify seizure classes among the total number of seizures predicted as positive. A high precision is desirable, as it means that the model can correctly identify most seizures that it predicts as positive. The model reports precision rates of 0.955, 0.913, 0.947, and 0.887 for TNSZ, TCSZ, MYSZ, and ABSZ, respectively (Table 5.2). 𝑃= 𝑇𝑃 (5.6.2) 𝑇𝑃 + 𝐹𝑃 5.6.
203 Recall The recall (R), also known as sensitivity, is a measure of the ability of the model to identify two metrics. This metric is frequently employed when dealing with imbalanced datasets, as it takes into account both precision and recall. A higher F1 score indicates a well-balanced model performance, with satisfactory precision and recall values. It can correctly identify the most positive seizures while keeping the number of false positives low. The F1 scores for TNSZ, TCSZ, MYSZ, and ABSZ are calculated as 0.866, 0.882, 0.885, and 0.870, respectively, using equation 5.3.4. (5.6.4) 𝑃 × 𝑅 𝐹1 = 2 × 𝑃 + 𝑅 5.6.4
58Mathews correlation coefficient The Mathews correlation coefficient (MCC) is the correlation coefficient between the actual and predicted classes. It gives more valuable insights into the model’s performance as it considers all four outcomes of the confusion matrix and therefore is not affected by class skewness. MCC for TNSZ, TCSZ, MYSZ, and ABSZ are found to be 0.873, 0.861, 0.861, and 0.873, respectively (Table 5.2). MCC √ ( − ) (5.6.5) 5.6.5 Threat score The threat score (TS) measures
11the ratio between the number of correctly predicted positive seizures and the sum of is used in conjunction with other metrics to comprehensively evaluate the proposed model’s performance. TS for TNSZ, TCSZ, MYSZ, and ABSZ is 0.782, 0.770, 0.763, and 0.788, respectively (Table 5.2). TP TS = (5.6.6) TP + FP + FN Table 5.1: Model Accuracy Seizure Class Train Validation Evaulation ABSZ 0.996 0.960 0.982 TNSZ 0.996 0.978 0.983 TCSZ 0.996 0.960 0.984 MYSZ 0.996 0.969 0.985 Table 5.2: Performance metrics Seizure Class Precision Recall F1 MCC TS TNSZ 0.955 0.792 0.866 0.873 0.782 TCSZ 0.913 0.852 0.882 0.861 0.770 MYSZ 0.947 0.831 0.885 0.861 0.763 ABSZ 0.887 0.854 0.870 0.873 0.788 CHAPTER 6 EEG Data Acquisition System The ability to acquire, filter, and analyze low-power and random signals has improved, especially in the context of electroencephalography (EEG). However, traditional EEG systems are often expensive and not readily accessible to the general public.
120In this paper, we propose a low-cost EEG system design that EEG acquisition systems, signal processing, and their applications to inform the design of such a low-cost system. The proposed low-cost EEG system includes scalp electrodes, a signal instrumenta- tion amplifier, a bandpass filter, a variable amplifier, a notch filter, and an analog- todigital converter. We examine the challenges associated with suitable electrodes, high-integration acquisition chips, and analysis algorithms in EEG systems. By combining the design of a cost-effective EEG system with insights from current research, this paper aims to enhance accessibility to EEG-based diagnostics and treat- ments in neurology and psychiatry. This development holds the potential to make EEG technology more widely available and beneficial to a broader range of patients. 6.1 Data acquisition system The main Hardware modules consist of the the following parts: • EEG Electrodes • Signal Instrumentation amplifier • Band pass filter • Variable amplifier • Notch filter • Analog to digital converter 6.1.1 EEG Electrodes EEG electrodes are compact sensors that are positioned on the scalp to perceive and quantify the electrical signals originating from brain activity. To establish a reliable electrical connection between the electrode and the scalp, a specialized conductive gel or paste is applied during the attachment process. We used Ambu company disposable electrodes. Ambu’s EEG cup electrodes feature a high-quality silver/silver chloride electrode sensor, which provides accurate and reliable EEG recordings. The electrode cups are made of a soft, flexible material that conforms to the shape of the scalp, ensuring optimal contact and reducing the risk of skin irritation. Figure 6.1: EEG electrodes 6.1.2 Signal instrumentation amplifier The role of an instrumentation amplifier in an EEG system is
103to amplify the small electrical signals generated by the brain to a level that can be measured and analyzed. These signals are typically in the microvolt range, which is much lower than the noise level in the EEG system. The instrumentation amplifier helps to amplify these signals while rejecting common-mode noise and other sources of interference. Figure 6.2: Instrumentation amplifier An instrumentation amplifier consists of input buffer amplifiers and an output amplifier, functioning as a differential amplifier. It is designed to amplify and measure small differential signals, such as the output of a sensor, while rejecting common-mode signals, such as noise and interference. Typically, the input stage of an instrumentation amplifier incorporates two buffer am- plifiers designed to offer
108high input impedance and low output impedance. This. This is achieved through the use of a balanced differential input, which cancels out any common-mode signals that are present. This makes instrumentation amplifiers particularly useful in applications where noise and interference are present, such as in medical equipment in our circuit. Instrumentation amplifiers can be configured to provide different gains, bandwidths, and input impedance levels. 6.1.3 Band-pass filter In an EEG system to isolates the frequencies of interest, which typically range from 0.5 Hz to 50 Hz we used bandpass filter. These frequencies correspond to the different brain wave patterns associated with mental states, such as relaxation, sleep, and alertness. By filtering out the frequencies outside this range, the band-pass filter helps to increase
9the signal-to-noise ratio, we can effectively enhance the quality of the EEG signal. Figure 6.3: Bandpass filter Within an EEG system, a band-pass filter serves to isolate the desired frequencies of 0.5 Hz to 50 Hz, which align with specific brain wave patterns related to various men- tal states such as relaxation, sleep, and alertness. By eliminating frequencies outside this range, the band-pass filter contributes to enhancing
9the signal-to-noise ratio and elevating the overall quality of the EEG signal. In a standard band-pass filter, capacitors, inductors, and resistors are combined in a specific configuration. The frequency range of the filter is determined by the arrange- ment and values of these components. Within this range, the center frequency of the passband corresponds to the frequency at which the filter exhibits maximum attenuation or attenuation closest to zero dB. 6.1.4 Variable amplifier The ability to modify the amplification of signals through an adjustable amplifier is crucial due to variations in the electrical activity levels generated by different brain re- gions. By adjusting the gain of the amplifier according to the magnitude of the detected signals, it ensures that all signals are adequately captured and amplified, thereby facili- tating accurate analysis and interpretation of the electrical activity across various brain regions. Figure 6.4: Variable amplifier During electroencephalography (EEG), a variable amplifier is utilized to amplify the minute electrical signals produced by the brain. This amplified EEG signal is sub- sequently suitable for A/D converters. It is important to note that individuals may exhibit different ranges of EEG signals, and various
21A/D converters possess different input voltage ranges. The amplifier gain can be adjusted by modifying the resistance, thereby modifying the range of the EEG signal accordingly. 6.1.5 Notch filter Notch Filter remove unwanted electrical interference at a specific frequency, typically 50 or 60 Hz. This interference is often caused by electrical equipment or power lines and can be picked up by the electrodes on the scalp, resulting in noise in the EEG signal. In EEG, notch
101filters are commonly used to remove unwanted line noise from the recorded signals. Line noise is a type of interference typically caused by the power lines and electrical devices in the environment and can be present at 50 or 60 Hz, depending on the local power grid frequency. Line noise can be a major problem in EEG recordings, as it can obscure the small electrical signals produced by the brain. Notch filters attenuate the line noise frequency while preserving the EEG signals of interest. Figure 6.5: Notch Filter The notch filter is designed to attenuate or eliminate this interference by selectively reducing the amplitude of the signal at the frequency of the interference while leaving other frequencies unchanged. 6.1.6 Analog to digital converter In this project, Arduino is used to convert analog signal coming from brain to digi- tal signal to classify the EEG signals. Arduino acquires and process the EEG signals through non-invasive technique. It measure brain activity by detecting electrical signals generated by the neurons in the brain. 6.2 Components 6.2.1 INA 826 The INA126
111is a high-precision, low-noise instrumentation amplifier. Figure 6.6: Arduino Uno Figure 6.7: INA 826 DIP The INA826 features a differential input with a gain range of 1 to 10000, making it suitable for amplifying signals from a wide range of sensors, including strain gauges, thermocouples, and piezoelectric transducers. It has a high input impedance of 100 G, which helps to minimize loading effects on the input signal and reduce errors caused by sensor self-heating. Figure 6.8: Function of INA pins The INA826 also has
119a high common-mode rejection ratio of 120 dB, which allows it to reject common-mode signals such as noise and interference. This makes it well-suited for use in applications where the signal of interest is small compared to the noise and interference present in the system. Other features of the INA826 include low offset voltage, low offset drift, and low noise, which help to ensure high accuracy and stability over time. With a single power supply voltage ranging from 2.2 V to 36 V, the OP177 is capable of functioning under various power conditions. It exhibits
85a wide operating temperature range, spanning from - 40°C to +85°C, enabling reliable performance across a wide range of temperatures. Figure 6.9: INA 826 datasheet Ideal for applications demanding exceptional accuracy and stability, the OP177 opamp is a versatile and highly precise component. It boasts an impressively low input offset voltage, which quantifies the voltage discrepancy between the op-amp inputs when the output is at zero. The low input offset voltage of the OP177 makes it ideal for applications that require high precision and low drift over time and temperature. Figure 6.10: OP177 IC The low input offset voltage, the OP177 also features
105low input bias current, low input noise, and high open-loop gain control systems. The OP177 is a dual op-amp, meaning that it contains two separate op-amp circuits in a single package. This makes it convenient for applications that require multiple op-amps, as it reduces the number of components needed in the circuit. Figure 6.11: OP177 Schematics The OP177
66operates over a wide range of supply voltages, from ±2.5 V to ±18 V, respectively. The OP177 is an operational amplifier (op-amp) that can be used in an EEG (Electroencephalogram) acquisition system. It is a precision op- amp known for its low noise, high accuracy, and excellent performance characteristics, making it suitable for sensitive applications like EEG signal processing. The OP177 can be used as an instrumentation amplifier to amplify the weak EEG signals picked up by the electrodes. The instrumentation amplifier configuration typically consists of three op- amps, and the OP177 can be used as one of them to provide amplification and accurate signal conditioning. Filters can be implemented using passive components (resistors and capacitors) and additional op-amps, and the OP177 can be used as the operational amplifier in these filter circuits. The OP177 can be utilized to implement this variable gain amplifier, allowing the user to adjust the amplification factor as needed. The OP177 can be employed in the design of the notch filter to attenuate the specific frequency (e.g., 50 Hz or 60 Hz) associated with the power-line noise. Figure 6.12: OP177 datasheet 6.3 Data Acquisition System Explanation The process initiates by positioning
35electrodes on the scalp of the individual to capture the electrical signals of the brain, known as EEG (Electroencephalogram) signals. These specialized EEG electrodes are designed to detect the brain’s electrical activity, which is typically very weak, measuring in the micro-volt range. To enhance the strength of these weak signals and make them more suitable for further analysis, an instrumentation amplifier is employed. The instrumentation amplifier amplifies the amplitude of the EEG signals while preserving the integrity of the original signal. Following amplification, the EEG signals may contain unwanted high-frequency noise and artifacts that are unrelated to the brain activity we intend to analyze. To eliminate this undesirable noise, a low-pass filter is utilized. By using a low-pass filter, the low- frequency components are allowed to pass through while higher frequencies are attenuated. Similarly, a
32high-pass filter is employed to eliminate unwanted signals. In this case, the high-pass filter permits the passage of higher-frequency components while attenuating lower frequencies. It helps eliminate any DC offset or slow drifts in the signal.The signal strength of the EEG data may vary from person to person and also during different activities. Therefore, a variable amplifier is employed to adjust the gain of the signal as needed. This allows for optimal signal levels for further processing and analysis.Electrical power lines, such as AC mains, can introduce a 50 or 60 Hz noise into the EEG signals. To eliminate this interference, a notch filter is used. The notch filter attenuates signals at the specific frequency (50 Hz or 60 Hz) while allowing other frequencies to pass through.At this stage, the processed analog EEG signal needs to be converted into a digital format to be processed by a computer or micro-controller. An ADC
96is used to convert the continuous analog signal into discrete digital samples. The digitized EEG signal is then passed to a micro controller, which is a small integrated circuit that contains a processor, memory, and input/output peripherals. The micro controller can receive and process the digital EEG data, perform computations, store data, and interface with other devices or systems for further analysis or display.By following these steps, the EEG data is acquired from the electrodes, amplified, filtered to remove unwanted noise, adjusted for optimal gain, notch filtered to remove power-line interference, converted to digital form by an ADC, and finally processed by a micro- controller for further analysis or transmission to other devices or systems. Figure 6.13: Circuit Block Diagram CHAPTER 7 Results The electroencephalogram (EEG) signals were obtained using cup electrodes and pro- cessed for analysis. The cup electrodes served to pick up the signals, which were then amplified and filtered before being digitized and transferred to a computer. To ensure a common reference point, a common electrode was used for signal input. The signal underwent amplification using an instrumentation amplifier, increasing its magnitude from microvolts to millivolts. The specific equation for the instrumentation amplifier can be expressed as follows: Gain = 1+ (49.9 KW)/Rg = 1+(49.9 KW)/500 Gain = 100 The EEG signal is characterized by its weak nature and susceptibility to strong interfer- ence from noise signals. Therefore, the design of the pre-amplifier is crucial, as it needs to possess specific qualities such as
21high input impedance, high common mode rejection ratio, low noise, non-linearity, strong anti-interference capability, and appropriate fre- quency and dynamic range amplifier performance. The pre-amplifier serves the essential function of extracting the application, we selected the INA826 chip, which perfectly aligns with our re- quirements. It features a low offset voltage of 0.5uV and an impressive 120dB capability for rejecting common signals. The INA128 configuration consists of three operational amplifiers, with each input being buffered by an individual op-amp. This setup ensures proper impedance matching and generates the desired output for our application. Subsequently, the signal from the instrumentation amplifier passed through a bandpass filter, allowing specific frequencies to pass through the system. Our system was designed to accommodate frequencies above 0.2 Hz but below 102 Hz. The calculation of the bandpass filter values can be described using the following equation: F(low pass) =1/2RC F=1/(210KW0.1uF) F=102.43Hz F(High pass)=1/(2CR13R1 4) F =1/(20.1uF(500KW1MW)) F=0.23Hz The Result of the band pass filter is shown in the below diagram Figure 7.2: Result of Bandpass Filter Then the signal was passed by by the variable amplifier where the certain amount of gain is required to observe and take the signal to the micro controller. This gain can be set by 100 while using calculation. The equation of variable amplifier is written as: 1 + (𝑅1 + 𝑅2) 1 + (1𝐾𝑊 + 98𝐾𝑊) 𝐹𝑎𝑖𝑛 = 𝑅4 𝐹𝑎𝑖𝑛 = 1𝐾𝑊 𝐹𝑎𝑖𝑛 = 100 The results of variable amplifier proteus are shown below After signal passing through the variable amplifier, our signal can obtained but having nosie in it, which can be removed with the help of notch filter. this filter can remove the noise from the enviroment. The equation and results of notch filter are shown below. 𝑒𝑐 = 1 = 1 = 50.017𝐹𝑧 4𝑅3𝐶1 (415.91𝐾𝑊0.1𝑢𝐹) To achieve effective EEG signal acquisition, the signal is directed through a notch filter. However, even in environments with strong noise control, a persistent 50Hz interference Figure 7.3: Results of Variable amplifier Figure 7.4: Results of Notch Filter originating from the AC electrical line current can still be present. This interference may infiltrate the circuit and disrupt the signal. To address this issue, a notch filter, specifically designed to eliminate 50Hz activity from the signal, is employed. Given the weak nature of the EEG signal and the severity of the interference, the inclusion of a 50Hz notch filter circuit is crucial. By incorporating this circuit into the EEG amplifier, the interference can be significantly reduced, simplifying subsequent software processing stages. Subsequently, the signal is transmitted to a micro-controller for display on the screen and utilized for the classification of epileptic and non-epileptic seizures. CHAPTER 8 Limitations and Future Work The research project undertaken by the team was aimed at being the first in line for the upcoming Final-Year-Project groups in the coming years to expand and augment the project. However, the team encountered several challenging obstacles and limitations that impacted the research project, which may serve as tackling points for future students taking it up to expand it. 8.1 Lack of Demographic Dataset The research project undertaken by the team was aimed at developing a deep learning model to detect and classify epileptic seizures accurately. However, the lack of demo- graphic dataset was a significant limitation, as the team needed real-world, noisy data to train and validate the model effectively. The team attempted to acquire Pakistani- collected data of epileptic patients from Aga Khan Hospital to test the accuracy of the trained models on real demographic Pakistani data. Using real demographic data from Pakistan would have been highly beneficial in testing the model’s accuracy in detecting seizures among patients with different demographic characteristics. Furthermore, it would have provided an opportunity to evaluate the effectiveness of the model in a different clinical setting, thereby enhancing the model’s overall generalizability. Additionally, any such research has yet not been conducted, which would make it eligible for big international conferences and journals, thus adding to the body of knowledge in the field. However, despite the team’s best efforts, the hospital declined to provide the data, citing Figure 8.1: Aga Khan University Hospital HIPPA violation as the primary reason. HIPPA regulations mandate that patient data must remain confidential, and any breach of these regulations can result in severe legal and financial consequences for healthcare providers. The team made several attempts to persuade the hospital management, but their efforts were unsuccessful. Figure 8.2: Dr. Ziauddin Hospital Undeterred, the team then approached Ziauddin Hospital and Jinnah Postgraduate Medical Centre to acquire the necessary data. JPMC showed their machine and helped the team understand the EEG acquisition process, but they declined to provide the data. According to JPMC, a key was required to access the files on any other computer than the one installed in the hospital, and purchasing the key from China was prohibitively expensive. Furthermore, they were concerned about the possibility of a virus infecting their system, which could compromise their entire network. Despite the challenges faced by the team in acquiring the necessary data, they were able to make significant progress in the research project. The team used the cleaned (a) Jinnah Postgraduate Medical Centre (b) National Epilepsy Centre Figure 8.3: Jinnah Postgraduate Medical Centre and it’s subsidiaries data collected by TUH and CHB-MIT to train and validate the model, and the results were promising. The team is hopeful that future research will be able to overcome the limitations faced in this study and further advance the development of deep learning models for epileptic seizure detection and classification. 8.2 Specialized Sensors, Integrated Circuits and Electrodes unavailable in Pakistan The research project undertaken by the team faced additional challenges and limita- tions beyond data acquisition. One major hurdle was the unavailability of specialized integrated circuits (ICs) such as the Instrumentation Amplifier (INA) and certain Oper- ational Amplifier (OPA) series within Pakistan. These ICs are crucial components in the design and development of accurate and reliable EEG signal acquisition systems. Un- fortunately, due to their unavailability domestically, the team had to consider importing them from abroad. However, the process of importing these ICs came with its own set of obstacles. It in- volved navigating through complex taxation systems and complying with stringent im- port protocols. The team had to allocate additional time, effort, and financial resources to ensure the successful importation of these critical components. Such logistical chal- lenges added an extra layer of complexity to the research project, further highlighting the need for proper funding and resources in this domain. In addition to the specialized ICs, the team also encountered difficulties in sourcing suitable electrodes for EEG signal acquisition. Electrodes play a vital role in ensur- ing accurate and reliable measurements of brain activity. However, they proved to be not only scarce within Pakistan but also exorbitantly expensive when available. This scarcity and high cost posed significant challenges for the team in acquiring the necessary electrodes for their research. 8.3 Lack of Proper Research Funding Consequently, conducting comprehensive research in medical domain necessitated substantial funding to overcome these sourcing issues and obtain the essential components and equipment. Adequate financial resources were crucial to cover the costs associated with importing specialized ICs and procuring high-quality electrodes. Without proper funding, it would be challenging to carry out thorough investigations and make signifi- cant advancements in the field of EEG signal processing and epileptic seizure detection. Overcoming these limitations required a multidimensional approach that involved not only addressing the data acquisition challenges but also securing the necessary resources and funding for the project. The team recognized the importance of proper financial support to conduct in-depth research and make meaningful contributions to the field of epileptic seizure detection. By ensuring adequate funding, it becomes possible to overcome sourcing difficulties and import the essential components required for the development of advanced EEG signal acquisition systems. This study presents a novel CNN with multi-headed attention to classify generalized epileptic seizures. The performance measures show that the model minimizes the num- ber of false positive results, as they can lead to unnecessary treatments and emotional distress for the patients. High precision rates, which correspond to a low false posi- tive rate, ensure that the patients are not subjected to unnecessary interventions and treatments. The proposed model classifies epileptic seizures as either tonic-clonic, tonic, absence, or myoclonic, with sufficiently high accuracy. The sequence of features in the attention layer is made by order of importance assigned to each feature’s weight. The model’s per- formance is critically evaluated using precision, sensitivity, specificity, F1 score, Mathews correlation coefficient, and threat score. The results demonstrate the model’s potential to digitize the labor-intensive and time-consuming process of epilepsy diagnosis. CHAPTER 9 Discussion and Conclusion For our Final Year Project, we aimed to classify epileptic seizures via Deep Learning using existing datasets. As a supplementary part of our work, we also designed a low cost EEG headset machine. As we know that the EEG signal is of micro-volt level and difficult to acquire. For this purpose, Instrumentation and Operational amplifiers, notch filter, bandpass filter and variable amplifier were designed. A single-channel acquisition system has been constructed based on the described ac- quisition circuit, enabling analysis and identification of EEG signals. The system is characterized by its simplicity and affordability. Experimental results demonstrate its effectiveness, showcasing satisfactory amplification capabilities and suitability for Brain- Computer Interface (BCI) applications. However, certain limitations remain within the BCI system that must be addressed in future work, particularly regarding signal iden- tification and processing enhancements. The next phase involves the development of a more robust and powerful BCI system that yields superior signal quality compared to the existing setup. Achieving this goal necessitates improved clarity in EEG signal recording and enhanced accuracy in signal processing. Moreover to conclude, this project includes a comprehensive research on epileptic seizure detection and classification algorithms, where a range of techniques have been examined, from basic machine learning algorithms like Support Vector Machines to advanced deep learning algorithms such as neural networks. This study presents a novel CNN with multi-headed attention to classify generalized epileptic seizures. The performance mea- sures show that the model minimizes the number of false positive results, as they can lead to unnecessary treatments and emotional distress for the patients. High precision CHAPTER 9: DISCUSSION AND CONCLUSION rates, which correspond to a low false positive rate, ensure that the patients are not subjected to unnecessary interventions and treatments. The proposed model classifies epileptic seizures as either tonic-clonic, tonic, absence, or myoclonic, with sufficiently high accuracy using Multi-Headed Attention CNN. The model’s performance is critically evaluated using precision, sensitivity, specificity, F1 score, Mathews correlation coefficient, and threat score. An accurate system was de- veloped to classify seizure types, offering potential benefits for quick patient treatment and reducing the workload of neurologists. This research marks a significant milestone in improving the efficiency and effectiveness of seizure analysis, with opportunities for further exploration and refinement in the future.
12CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 2: LITERATURE REVIEW CHAPTER 3 2 4 6 8 10 12 14 15 16 18 19 20 21 22 23 24 25 26 27 29 31 33 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71