Wearable Epileptic Seizure Prediction System with Machine-Learning-Based Anomaly Detection of Heart Rate Variability

A warning prior to seizure onset can help improve the quality of life for epilepsy patients. The feasibility of a wearable system for predicting epileptic seizures using anomaly detection based on machine learning is evaluated. An original telemeter is developed for continuous measurement of R-R intervals derived from an electrocardiogram. A bespoke smartphone app calculates the indices of heart rate variability in real time from the R-R intervals, and the indices are monitored using multivariate statistical process control by the smartphone app. The proposed system was evaluated on seven epilepsy patients. The accuracy and reliability of the R-R interval measurement, which was examined in comparison with the reference electrocardiogram, showed sufficient performance for heart rate variability analysis. The results obtained using the proposed system were compared with those obtained using the existing video and electroencephalogram assessments; it was noted that the proposed method has a sensitivity of 85.7% in detecting heart rate variability change prior to seizures. The false positive rate of 0.62 times/h was not significantly different from the healthy controls. The prediction performance and practical advantages of portability and real-time operation are demonstrated in this study.


Introduction
Epilepsy is a chronic neurological disorder characterized by recurrent seizures that affects approximately 1% of the world's population [1]. Antiepileptic drugs are ineffective in controlling seizures in up to 30% of patients to whom it is administered, who can develop intractable epilepsy with the administration of more than three antiepileptic drugs [2].
Convulsions or loss of consciousness associated with uncontrolled seizures may cause serious injuries to the patients themselves and the people around them. Early detection of epileptic seizures prior to symptoms allows for early intervention with fast-acting medication, vagus nerve stimulation, or evasive action against accidents. A questionnaire answered by 141 epilepsy patients showed that more than 90% of the patients desired seizure prediction [3].
Although epileptic seizure prediction using electroencephalogram (EEG) data has achieved reliable sensitivity and specificity [4][5][6][7], intolerance to motion artifacts with scalp EEG and craniotomy techniques required for invasive EEG would be a major barrier to dissemination. In addition, because the real-time analysis of the EEG channels acquired at a sampling rate higher than 500 Hz requires huge machine power for calculation, the current application software achieving standalone seizure prediction can hardly be implemented on a handheld device, such as a smartphone.
As epileptic seizures affect the autonomic nervous function, peri-ictal changes are seen in the heart rate and electrocardiogram (ECG) data [8][9][10]. The parasympathetic and sympathetic outputs to the heart are modulated by the central autonomic network, which includes the insular cortex, orbitofrontal cortex, cingulate, amygdala, hypothalamus, and periaqueductal gray matter. Excessive neural activation associated with epileptic seizures distributed in these brain regions affects the functioning of the central autonomic network, which is reflected by heart rate variability. Hence, the practicality of prediction care can be improved by monitoring the cardiac autonomic changes in the early ictal phase [11][12][13] and preictal phase [14] by heart rate variability (HRV) analysis [15,16] with a portable Holter monitor. A systematic review of HRV and epileptic seizures was performed, which showed that the HRV and heart rate change before seizure onset [17]. Feature extraction from HRV indices preceding seizure onset using the machine learning technique should contribute toward realizing automatic seizure prediction, whereas the Lorenz-plot-based method predicted seizures in only three of the seventeen patients [18]. Although time-frequency analysis [19], nonlinear analysis of HRV using fuzzy clustering [20], and the machine learning method based on support vector machine [21] demonstrated greater prediction sensitivity than the random predictor in retrospective analysis of preictal ECG collected from video-EEG recording, the feasibility of real-time analysis and prospective clinical applications has not been examined. Evaluation of the real-time capability through ECG data acquisition, calculation of HRV indices, and calculation of analytic features operating on a wearable system is crucial for demonstrating the feasibility of the prediction system, because seizure warnings would help avoid seizure-related accidents, improve patient quality of life, and provide novel treatment strategies, particularly for intractable epilepsy.
To improve the positive predictive value in the seizure prediction, our group reported a novel analytical method using machine learning. The method employs multivariate statistical process control (MSPC) [22] for anomaly detection to identify minority samples that have different characteristics to the remaining samples.
In this study, the feasibility and reliability of seizure prediction as a diagnostic tool that is practical for daily use by patients is evaluated with a prototype in hospitals during long-term video-EEG monitoring, which is categorized as the phase 2 validation framework [23]. Section 2 describes the bespoke wearable system for HRV measurement and analysis for seizure prediction. The experimental methods for evaluating the seizure prediction capability are explained in Section 3 and the results are shown in Section 4. Section 5 discusses the results from instrumentation engineering and biomedical significance perspectives. Section 6 concludes the study. Figure 1 shows an overview and a flowchart of the proposed seizure prediction system. The developed wearable system consists of an R-R interval (RRI, the time elapsed between two successive R-waves of the QRS signal on the electrocardiogram) telemeter and a smartphone. Although many wearable heart rate monitors are available on the market, the provided functions have limitations for use in the proposed system, which requires a sampling rate higher than 500 Hz for HRV analysis, device-embedded real-time RRI calculation to reduce the calculation load of the smartphone, and an automated gain control function to be operated by a nonspecialized user. Thus, we developed an original telemeter to realize the functions shown in the upper half of Figure 1 within a small and lightweight form factor. Figure 2a shows the block diagram of the telemeter that measures the RRIs of the ECG. The device has small dimensions of 74 × 34 mm, with a thickness of 12 mm, excluding the three one-meter ECG lead wires, as shown in Figure 2b, and a long battery life for wearable healthcare applications. The analog front-end circuitry of the telemeter amplifies the AC-coupled ECG signal obtained from the three disposable electrodes using an instrumentation amplifier, and reduces the noise using a 50/60 Hz notch filter and a variable gain low-pass filter. ECG signals preprocessed in the analog front end are sampled by a 1 kHz 10-bit analog-to-digital converter and analyzed using threshold-based R-wave detection [24] in a cortex-M0 microcontroller built into a Bluetooth module (EYSFCNZXX, Taiyo Yuden, Japan). The sampling frequency was compatible with the 1 kHz sampled video-EEG data used for the phase 1 validation of our previous method [22]. In a simple threshold discrimination, the low-frequency baseline drift and P-and T-waves (which have the same polarity as R-waves in the Standard Lead II configuration) of ECG signals may lead to false positives of R-wave detection. Accordingly, a quasi-band-pass filtering program determines the pulse width of the digitized ECG and forwards the digitized ECG to a comparator when the pulse width is within 3-50 ms. A timer counts and transmits RRIs to the smartphone via the Bluetooth 4.0-LE wireless connection, which operates under the smartphone's heart rate profile. Here, the RRIs for 60 beats are stored in the telemeter's memory to avoid data loss due to transmission errors in the wireless connection. An automatic gain control function programmed in the telemeter microcontroller enables easy operation, which can be performed by nonspecialized subjects with simple instructions [25,26].   current heart rate appears on the heart while monitoring. Instrumentation amplifier (Inst. Amp), analog-to-digital converter (ADC), receiver and transmitter (Rx/Tx).

HRV Analysis
The bespoke smartphone software receives and analyzes RRI data in real time ( Figure 2c) to derive HRV indices of autonomic nervous activities. The HRV indices used for the epileptic seizure prediction consist of four time-domain indices (mean of RRI (meanNN), standard deviation of the RRI (SDNN), root mean square of the differences of adjacent RRIs (RMSSD), and the number of pairs of adjacent RRIs whose difference is greater than 50 ms within a given length of measurement time (NN50)) and four frequency-domain indices (total power (TP), variance of RRI, power of the lowfrequency band of 0.04-0.15 Hz (LF), power of the high-frequency band of 0.15-0.4 Hz (HF), and ratio of LF to HF (LF/HF)) [15].
HRV indices are derived from statistical or frequency analysis of a three-minute moving window, so an outlier contamination in the RRIs would adversely affect the indices for the following three minutes. Hence, the outlier RRIs should be replaced using the following real-time compensation techniques, which were implemented as a function on the smartphone app in this work.
The observed RRIs for 180 s are stored in a first-in, first-out buffer. The median absolute deviation RRIMAD of the i-th RRI, i.e., RRIi, is calculated with the stored RRIs (RRIn | n: 1~i-1) as where the function "median" gives the median of the input variables. The normal RRI range is current heart rate appears on the heart while monitoring. Instrumentation amplifier (Inst. Amp), analog-to-digital converter (ADC), receiver and transmitter (Rx/Tx).

HRV Analysis
The bespoke smartphone software receives and analyzes RRI data in real time ( Figure 2c) to derive HRV indices of autonomic nervous activities. The HRV indices used for the epileptic seizure prediction consist of four time-domain indices (mean of RRI (meanNN), standard deviation of the RRI (SDNN), root mean square of the differences of adjacent RRIs (RMSSD), and the number of pairs of adjacent RRIs whose difference is greater than 50 ms within a given length of measurement time (NN50)) and four frequency-domain indices (total power (TP), variance of RRI, power of the low-frequency band of 0.04-0.15 Hz (LF), power of the high-frequency band of 0.15-0.4 Hz (HF), and ratio of LF to HF (LF/HF)) [15].
HRV indices are derived from statistical or frequency analysis of a three-minute moving window, so an outlier contamination in the RRIs would adversely affect the indices for the following three minutes. Hence, the outlier RRIs should be replaced using the following real-time compensation techniques, which were implemented as a function on the smartphone app in this work.
The observed RRIs for 180 s are stored in a first-in, first-out buffer. The median absolute deviation RRI MAD of the i-th RRI, i.e., RRI i , is calculated with the stored RRIs (RRI n | n: 1~i-1) as where the function "median" gives the median of the input variables. The normal RRI range is median RRI n − 4σ < RRI i < median RRI n + 4σ (2) where the standard deviation of the RRI is σ = 1.4826 × RRI MAD . The RRI outliers, which are less than the lower limit, are removed from the RRI data used for HRV analysis. However, when the observed RRI is greater than the upper limit, it is assumed that multiple heartbeats have been missed. Accordingly, the number of missed heartbeats N is estimated as where the function "round" returns the rounded value of the input value and the outlier is replaced with the N-th corrected RRIs by The time-domain indices are calculated from the buffered RRIs. For the frequency-domain indices, the stored RRIs are resampled to ensure uniform intervals for the frequency analysis. The third-order spline is used for the RRI interpolation and the sampling rate is 4 Hz. The power spectrum density of the resampled RRI data is calculated using an autoregressive model of the order of 40 and the frequency-domain indices are derived from the power spectrum density according to Fujiwara et al. [22].

Anomaly Detection Prior to Epileptic Seizure
Univariate statistical process control monitors each variable with upper and lower limits, which is a simple approach to anomaly detection. However, univariate statistical process control is unsuitable for anomaly detection because it cannot monitor changes in correlated variables. To consider the correlation between the HRV indices, we employed MSPC, which is a machine learning technique that has been applied to anomaly detection in multivariate systems [27][28][29].
In MSPC, principal component analysis models linear correlations, referred to as principal components. In this study, six principal components with the highest contribution rates describe major trends in the changes of the HRV indices.
MSPC defines the normal operating conditions as two indices, namely the Q and T 2 statistics [30], which monitor the gap between sample and model data. The Q statistic is the squared distance between a sample and the subspace spanned by the principal components; that is, the Q statistic measures the dissimilarity between the sample and the model data from the viewpoint of the correlation between the variables. The T 2 statistic is the Mahalanobis distance between a sample and the origin in the subspace spanned by the principal components. When the T 2 statistic is low, the sample is close to the mean of the model data. The statistics are obtained by the following determinants where x denotes the column vector consisting of the eight sampled HRV indices. Here, V R ∈ R 8×6 is a loading matrix, the r-th column represents the direction of the r-th principal component; O R ∈ R 6×6 is a diagonal matrix, where the diagonal elements are standard deviations of the corresponding principal components; and I is the identity matrix. Equations (5) and (6) are not computationally expensive, so MSPC is suitable for real-time monitoring of HRV. There are few instances of epileptic seizures (i.e., anomalies) that are collected in data, so MSPC models the normal data. The collected RRI data and calculated parameters are analyzed for seizure prediction according to Algorithm 1. 14 end while In this algorithm, y[t] denotes the t-th RRI and t denotes the number of samples fr the analysis. Here, τ is a time counter variable and C is a binary indicator (Ɲ or Ƥ, ¬Ɲ = Ƥ status, where Ɲ and Ƥ indicate "interictal" and "preictal," respectively. To ignore instan changes such as those due to rapid motion, the patient status is determined as preicta the T 2 or Q statistic exceeds its control limit for more than ten seconds continuously. The control limits (CLs) of the Q and T 2 statistics are defined as α% confidence l determined by the lower α% and upper α% of the confidence interval for samples represent condition. The sensitivity and the specificity of the MSPC are controlled by α, which was s The analysis method mentioned above was implemented on an Android app progr the Java programing language. In this study, the modeling parameters of VR and ΣR w Fujiwara et al. [22].

MSPC Model Construction
The interictal HRV data for constructing the MSPC model were collected fr epilepsy patients who were admitted to three departments in Japan: the D Neurosurgery, Medical Hospital, Tokyo Medical and Dental University (TMDU); the D Psychiatry, National Center Hospital of Neurology and Psychiatry (NCNP); and the D Epileptology, Tohoku University Hospital (TUH). Patients underwent clinical video-EE for presurgical evaluation or seizure assessment. Data from fourteen patients collecte et al. (2016) were used with the approval of the Medical Research Ethics Commi participating departments. Two or more experts from the Japan Epilepsy Society labele epileptic interictal spikes from video-EEG data of the awake state to allow creation containing only normal data. The HRV indices were calculated from the cropped learning procedure of the MSPC model was performed by MATLAB according to (Nov The MSPC does not model abnormality (i.e., seizures), and collecting clean ECG data du is difficult because of the contamination of seizure motion artifacts and the low frequen

Measurement Setup and Protocols
The prospective study was conducted on epilepsy patients admitted to TMDU, N Department of Psychiatry of Nara Medical Center (NMC), Japan, for clinical video-EE  (5) and (6). 13 Wait until the next RRI data y [t + 1] are measured. 14 end while In this algorithm, y[t] denotes the t-th RRI and t denotes the number of samples from the start of the analysis. Here, τ is a time counter variable and C is a binary indicator ( Sensors 2020, 20, x FOR PEER REVIEW 2 while do 3 Collect the newly measured t-th RRI y[t].

5
Calculate the t-th T 2 [t] and Q[t] from x[t] by using Equations (7) and (8) 14 end while In this algorithm, y[t] denotes the t-th RRI and t d the analysis. Here, τ is a time counter variable and C is status, where Ɲ and Ƥ indicate "interictal" and "preicta changes such as those due to rapid motion, the patien the T 2 or Q statistic exceeds its control limit for more t The control limits (CLs) of the Q and T 2 statistic determined by the lower α% and upper α% of the confide condition. The sensitivity and the specificity of the MSPC The analysis method mentioned above was imple the Java programing language. In this study, the mod Fujiwara et al. [22].

MSPC Model Construction
The interictal HRV data for constructing the M epilepsy patients who were admitted to three Neurosurgery, Medical Hospital, Tokyo Medical and Psychiatry, National Center Hospital of Neurology an Epileptology, Tohoku University Hospital (TUH). Pati for presurgical evaluation or seizure assessment. Data et al. (2016) were used with the approval of the M participating departments. Two or more experts from t epileptic interictal spikes from video-EEG data of th containing only normal data. The HRV indices wer learning procedure of the MSPC model was performed The MSPC does not model abnormality (i.e., seizures), is difficult because of the contamination of seizure mot

Measurement Setup and Protocols
The prospective study was conducted on epileps Department of Psychiatry of Nara Medical Center (NM or Sensors 2020, 20, x FOR PEER REVIEW 2 while do 3 Collect the newly measured t-th RRI y[t]. (7) and (8) 14 end while

Calculate the t-th T 2 [t] and Q[t] from x[t] by using Equations
In this algorithm, y[t] denotes the t-th RRI and t de the analysis. Here, τ is a time counter variable and C is a status, where Ɲ and Ƥ indicate "interictal" and "preictal changes such as those due to rapid motion, the patient the T 2 or Q statistic exceeds its control limit for more th The control limits (CLs) of the Q and T 2 statistics determined by the lower α% and upper α% of the confiden condition. The sensitivity and the specificity of the MSPC The analysis method mentioned above was implem the Java programing language. In this study, the mode Fujiwara et al. [22].

MSPC Model Construction
The interictal HRV data for constructing the M epilepsy patients who were admitted to three d Neurosurgery, Medical Hospital, Tokyo Medical and D Psychiatry, National Center Hospital of Neurology and Epileptology, Tohoku University Hospital (TUH). Patie for presurgical evaluation or seizure assessment. Data et al. (2016) were used with the approval of the Me participating departments. Two or more experts from th epileptic interictal spikes from video-EEG data of the containing only normal data. The HRV indices were learning procedure of the MSPC model was performed b The MSPC does not model abnormality (i.e., seizures), a is difficult because of the contamination of seizure motio

Measurement Setup and Protocols
The prospective study was conducted on epilepsy Department of Psychiatry of Nara Medical Center (NM Calculate the t-th T 2 [t] and Q[t] from using Equations (7) and (8).
Wait until the next RRI data y [t measured.
14 end while In this algorithm, y[t] denotes the t-th R the analysis. Here, τ is a time counter variabl status, where Ɲ and Ƥ indicate "interictal" an changes such as those due to rapid motion, the T 2 or Q statistic exceeds its control limit f The control limits (CLs) of the Q and T determined by the lower α% and upper α% of t condition. The sensitivity and the specificity of The analysis method mentioned above w the Java programing language. In this study Fujiwara et al. [22].

MSPC Model Construction
The interictal HRV data for construct epilepsy patients who were admitted to Neurosurgery, Medical Hospital, Tokyo Med Psychiatry, National Center Hospital of Neu Epileptology, Tohoku University Hospital (T for presurgical evaluation or seizure assessm et al. (2016) were used with the approval participating departments. Two or more expe epileptic interictal spikes from video-EEG containing only normal data. The HRV ind learning procedure of the MSPC model was p The MSPC does not model abnormality (i.e., is difficult because of the contamination of se

Measurement Setup and Protocols
The prospective study was conducted o Department of Psychiatry of Nara Medical C Calculate the t-th T 2 [t] and Q[t] from using Equations (7) and (8) 14 end while In this algorithm, y[t] denotes the t-th RRI the analysis. Here, τ is a time counter variable a status, where Ɲ and Ƥ indicate "interictal" and changes such as those due to rapid motion, th the T 2 or Q statistic exceeds its control limit for The control limits (CLs) of the Q and T 2 s determined by the lower α% and upper α% of the condition. The sensitivity and the specificity of th The analysis method mentioned above wa the Java programing language. In this study, t Fujiwara et al. [22].

MSPC Model Construction
The interictal HRV data for constructin epilepsy patients who were admitted to Neurosurgery, Medical Hospital, Tokyo Medic Psychiatry, National Center Hospital of Neuro Epileptology, Tohoku University Hospital (TU for presurgical evaluation or seizure assessme et al. (2016) were used with the approval o participating departments. Two or more expert epileptic interictal spikes from video-EEG da containing only normal data. The HRV indic learning procedure of the MSPC model was per The MSPC does not model abnormality (i.e., se is difficult because of the contamination of seiz

Measurement Setup and Protocols
The prospective study was conducted on Department of Psychiatry of Nara Medical Cen   (7) and (8).
Wait until the next RRI data y [t + 1] are measured.
14 end while In this algorithm, y[t] denotes the t-th RRI and t denotes the number of samples from the start of the analysis. Here, τ is a time counter variable and C is a binary indicator (Ɲ or Ƥ, ¬Ɲ = Ƥ) of the patient status, where Ɲ and Ƥ indicate "interictal" and "preictal," respectively. To ignore instantaneous HRV changes such as those due to rapid motion, the patient status is determined as preictal when either the T 2 or Q statistic exceeds its control limit for more than ten seconds continuously. The control limits (CLs) of the Q and T 2 statistics are defined as α% confidence limits. CLs are determined by the lower α% and upper α% of the confidence interval for samples representing the normal condition. The sensitivity and the specificity of the MSPC are controlled by α, which was set to 99%.
The analysis method mentioned above was implemented on an Android app programmed using the Java programing language. In this study, the modeling parameters of VR and ΣR were used from Fujiwara et al. [22].

MSPC Model Construction
The interictal HRV data for constructing the MSPC model were collected from refractory epilepsy patients who were admitted to three departments in Japan: the Department of Neurosurgery, Medical Hospital, Tokyo Medical and Dental University (TMDU); the Department of Psychiatry, National Center Hospital of Neurology and Psychiatry (NCNP); and the Department of Epileptology, Tohoku University Hospital (TUH). Patients underwent clinical video-EEG monitoring for presurgical evaluation or seizure assessment. Data from fourteen patients collected by Fujiwara et al. (2016) were used with the approval of the Medical Research Ethics Committees from all participating departments. Two or more experts from the Japan Epilepsy Society labeled seizures and epileptic interictal spikes from video-EEG data of the awake state to allow creation of a dataset containing only normal data. The HRV indices were calculated from the cropped ECG and the learning procedure of the MSPC model was performed by MATLAB according to (Novak et al., 1999). The MSPC does not model abnormality (i.e., seizures), and collecting clean ECG data during a seizure is difficult because of the contamination of seizure motion artifacts and the low frequency of seizures.

Measurement Setup and Protocols
The prospective study was conducted on epilepsy patients admitted to TMDU, NCNP, and the Department of Psychiatry of Nara Medical Center (NMC), Japan, for clinical video-EEG monitoring. 14 end while In this algorithm, y[t] denotes the t-th RRI and t denotes the number of samples from the start of the analysis. Here, τ is a time counter variable and C is a binary indicator (Ɲ or Ƥ, ¬Ɲ = Ƥ) of the patient status, where Ɲ and Ƥ indicate "interictal" and "preictal," respectively. To ignore instantaneous HRV changes such as those due to rapid motion, the patient status is determined as preictal when either the T 2 or Q statistic exceeds its control limit for more than ten seconds continuously. The control limits (CLs) of the Q and T 2 statistics are defined as α% confidence limits. CLs are determined by the lower α% and upper α% of the confidence interval for samples representing the normal condition. The sensitivity and the specificity of the MSPC are controlled by α, which was set to 99%.
The analysis method mentioned above was implemented on an Android app programmed using the Java programing language. In this study, the modeling parameters of VR and ΣR were used from Fujiwara et al. [22].

MSPC Model Construction
The interictal HRV data for constructing the MSPC model were collected from refractory epilepsy patients who were admitted to three departments in Japan: the Department of Neurosurgery, Medical Hospital, Tokyo Medical and Dental University (TMDU); the Department of Psychiatry, National Center Hospital of Neurology and Psychiatry (NCNP); and the Department of Epileptology, Tohoku University Hospital (TUH). Patients underwent clinical video-EEG monitoring for presurgical evaluation or seizure assessment. Data from fourteen patients collected by Fujiwara et al. (2016) were used with the approval of the Medical Research Ethics Committees from all participating departments. Two or more experts from the Japan Epilepsy Society labeled seizures and epileptic interictal spikes from video-EEG data of the awake state to allow creation of a dataset containing only normal data. The HRV indices were calculated from the cropped ECG and the learning procedure of the MSPC model was performed by MATLAB according to (Novak et al., 1999). The MSPC does not model abnormality (i.e., seizures), and collecting clean ECG data during a seizure is difficult because of the contamination of seizure motion artifacts and the low frequency of seizures.

Measurement Setup and Protocols
The prospective study was conducted on epilepsy patients admitted to TMDU, NCNP, and the Department of Psychiatry of Nara Medical Center (NMC), Japan, for clinical video-EEG monitoring.
indicate "interictal" and "preictal," respectively. To ignore instantaneous HRV changes such as those due to rapid motion, the patient status is determined as preictal when either the T 2 or Q statistic exceeds its control limit for more than ten seconds continuously.
The control limits (CLs) of the Q and T 2 statistics are defined as α% confidence limits. CLs are determined by the lower α% and upper α% of the confidence interval for samples representing the normal condition. The sensitivity and the specificity of the MSPC are controlled by α, which was set to 99%.
The analysis method mentioned above was implemented on an Android app programmed using the Java programing language. In this study, the modeling parameters of V R and Σ R were used from Fujiwara et al. [22].

MSPC Model Construction
The interictal HRV data for constructing the MSPC model were collected from refractory epilepsy patients who were admitted to three departments in Japan: the Department of Neurosurgery, Medical Hospital, Tokyo Medical and Dental University (TMDU); the Department of Psychiatry, National Center Hospital of Neurology and Psychiatry (NCNP); and the Department of Epileptology, Tohoku University Hospital (TUH). Patients underwent clinical video-EEG monitoring for presurgical evaluation or seizure assessment. Data from fourteen patients collected by Fujiwara et al. (2016) were used with the approval of the Medical Research Ethics Committees from all participating departments. Two or more experts from the Japan Epilepsy Society labeled seizures and epileptic interictal spikes from video-EEG data of the awake state to allow creation of a dataset containing only normal data. The HRV indices were calculated from the cropped ECG and the learning procedure of the MSPC model was performed by MATLAB according to (Novak et al., 1999). The MSPC does not model abnormality (i.e., seizures), and collecting clean ECG data during a seizure is difficult because of the contamination of seizure motion artifacts and the low frequency of seizures.

Measurement Setup and Protocols
The prospective study was conducted on epilepsy patients admitted to TMDU, NCNP, and the Department of Psychiatry of Nara Medical Center (NMC), Japan, for clinical video-EEG monitoring. The experiments were approved by the Medical Research Ethics Committees of TMDU, NCNP, and NMC, and written informed consent was obtained from each participant.
The subjects rested in a supine or sitting position in a bed inside a monitoring room and their prescribed antiepileptic drugs were reduced from the usual dosage, according to the standard procedure of video-EEG monitoring. The video, ECG, and EEG data were recorded simultaneously using a long-term video-EEG monitoring system (Neurofax EEG-1200, NIHON KOHDEN, Japan) with sampling frequencies of 500 or 1000 Hz for both ECG and EEG.
The fabricated wearable RRI telemeter, which has disposable ECG electrodes and a bipolar CS5 lead configuration, was used simultaneously with the video-EEG monitoring system. Data were collected with an Android smartphone (Blade S Lite g02, ZTE Japan K. K., Japan) fixed to the bedside and tethered for continuous power. The internal clock of the smartphone was manually synchronized with the clock of the video-EEG monitoring system, because the network security regulations do not permit use of the network time protocol. The recording with the wearable system was continued as long as possible during the video-EEG monitoring.
The CLs were calculated during post-processing after video-EEG monitoring, because the interictal periods must be determined from the video-EEG data diagnosed by clinical specialists. Therefore, only steps 6-12 in Algorithm 1 were executed on the PC after the experiments.
The system was evaluated with video-EEG monitoring, which is considered the gold standard for commercial seizure detection devices [31][32][33]. However, video-EEG monitoring restricts body motion and autonomic change from normal daily life, which may lead to the underestimation of the number of false positives. Therefore, in addition to the recommended validation methods [34], the system was evaluated on the healthy subjects (controlled to be consistent in gender and age) and focused on false positives from the uncontrolled situation of their daily life. The healthy subjects without a history of cardiac and neuronal diseases were asked to wear the system during their daily life, except while sleeping. The same criteria for data exclusion with the patient data was used.

Patient Attribution
Eighteen focal epilepsy patients were admitted to the study who were not involved previously. Data from two patients were removed because they did not have a seizure. The data obtained during the nocturnal period between 20:00 and 08:00 and during naps (observed in video) were removed from the assessment, as the risk of accidental injury due to focal seizures during sleep is significantly lower than those during awake periods. Moreover, the HRV is affected by micro-arousal and sleep stage transitions [35,36], which may increase false positives. Thus, nine patients were excluded as they had seizures only during sleep. Tables 1 and 2 detail the remaining seven patients and their analyzed episodes, respectively. Premature ventricular contraction may also cause false positives.   To independently evaluate the performance, periods of data affected by such pathophysiologic contaminants were identified by cardiovascular specialists certified by the Japanese Circulation Society and were removed from the evaluation. Additionally, contaminated motion artifacts in the EEG traces increase the difficulty to accurately determine seizure onsets and interictal discharges. These noisy intervals of EEG data are defined with the analyzed results, such as the anomalies in the HRV indices, Q/T 2 statistics, and RRI interpolation performed by Equations (1)-(4), then removed from the validation of the seizure prediction performance under visual inspection performed by two or more specialists certified by the Japan Epilepsy Society. The remaining data were reviewed and diagnosed by two or more specialists certified by the Japan Epilepsy Society and the start of the seizure symptoms was labeled as the seizure onset. On the other hand, the time intervals greater than 30 min from seizure onsets, sleep activity, and interictal discharges were labeled as the interictal periods by the specialists observing the video and EEG. The interictal data were used to evaluate the false positives due to the malfunction of the proposed method; they were independent from the pathological physiologic changes in the patients.
In addition, the data from seven healthy controls whose age and gender were balanced with the patients were collected with the proposed system during their daily life, as shown in Table 2.

Measurement Accuracy and Reliability
The interictal RRIs obtained using the proposed system and from the video-EEG monitoring system were compared using Bland-Altman analysis [37]. The RRIs were derived from the ECG channel recorded on the video-EEG data with the same MATLAB features used in [22]. These RRIs were aligned with those collected by the developed system to be on the same timeline in order to calculate the statistical indices of the Bland-Altman analysis. The Bland-Altman plot (Figure 3) describes the compatibility of the two compared systems. The horizontal and vertical axes represent the mean and the difference (subtracting the device RRI from the reference RRI) of the RRIs, respectively, obtained from the compared systems. The dashed horizontal line and the adjoining number indicate the mean of the difference and represent the measurement bias of the proposed system against the reference system. The two solid horizontal lines represent the intervals of the limits of agreement of the measurement difference from the Bland-Altman analysis. Table 3 lists the measurement failure rates of the RRIs calculated from the number of RRI outliers beyond the range defined by Equation (2). Here, the RRI outliers have been replaced using the outlier modification method (from Section 2.2), so that the effects of the outliers on the HRV indices are removed to avoid inducing false positives.

Seizure Prediction
Seizure prediction between 15 min prior to seizure onset and the moment immediately before seizure onset was considered to be successful [22], i.e., the prediction horizon was 15 min. Table 4 lists the durations when the Q and T 2 statistics exceed the control limit for more than 10 s, where the seizure starts at t = 0.
The seizures were identified by a character for the patient identity and a number for the seizure instance, e.g., A1 was patient A's first seizure. Twelve of the fourteen seizures were predicted correctly with a sensitivity of 85.7% by the Q statistic and two of fourteen seizures were predicted correctly with a sensitivity of 14.3% by the T 2 statistic. The one-sided sign test [38,39] of the Q and T 2 statistics showed that the sensitivity of our algorithm was significantly greater than and lower than the chance level, respectively (both p = 0.0065). Figures 4 and 5 show examples of how the Q and T 2 statistics change before a seizure onset and during the interictal period, respectively. The colored band in the figures highlights the duration when [ ] = Ƥ was satisfied, indicating that the statistic exceeded CL (represented with the colored horizontal line) by 10 s and was discriminated as preictal in Algorithm 1.
The false positives during the interictal periods were analyzed and summarized for each patient in Table 5 using a popular method in the field of seizure detection systems [40]. The false positive rate is defined as the number of false positives per hour. Table 4. Seizure prediction performance. The duration of prediction is shown with the start and the end of exceedance (e.g., −05:28 to −05:17) means that the statistic exceeded the control limit from 5 min 28 sec to 5 min 17 sec prior to a seizure. NA indicates not available, meaning that the statistic did not exceed the control limit. Sen (sensitivity) summarizes the true positive ratio of seizure prediction.

Seizure Prediction
Seizure prediction between 15 min prior to seizure onset and the moment immediately before seizure onset was considered to be successful [22], i.e., the prediction horizon was 15 min. Table 4 lists the durations when the Q and T 2 statistics exceed the control limit for more than 10 s, where the seizure starts at t = 0.
The seizures were identified by a character for the patient identity and a number for the seizure instance, e.g., A1 was patient A's first seizure. Twelve of the fourteen seizures were predicted correctly with a sensitivity of 85.7% by the Q statistic and two of fourteen seizures were predicted correctly with a sensitivity of 14.3% by the T 2 statistic. The one-sided sign test [38,39] of the Q and T 2 statistics showed that the sensitivity of our algorithm was significantly greater than and lower than the chance level, respectively (both p = 0.0065). Figures 4 and 5 show examples of how the Q and T 2 statistics change before a seizure onset and during the interictal period, respectively. The colored band in the figures highlights the duration when C[t] = P was satisfied, indicating that the statistic exceeded CL (represented with the colored horizontal line) by 10 s and was discriminated as preictal in Algorithm 1.
The false positives during the interictal periods were analyzed and summarized for each patient in Table 5 using a popular method in the field of seizure detection systems [40]. The false positive rate is defined as the number of false positives per hour. Table 4. Seizure prediction performance. The duration of prediction is shown with the start and the end of exceedance (e.g., −05:28 to −05:17) means that the statistic exceeded the control limit from 5 min 28 sec to 5 min 17 sec prior to a seizure. NA indicates not available, meaning that the statistic did not exceed the control limit. Sen (sensitivity) summarizes the true positive ratio of seizure prediction.

Seizure
Duration (min:s to min:s)

Discussion
EEG is the most popular biomarker for seizure prediction, but HRV is rarely used [41], although the effects of epileptic seizures on the cardiac autonomic function have been reported in the early ictal phase [11][12][13] and the preictal phase [14]. Previous approaches of seizure prediction achieved comparable performance with HRV and time-frequency analysis [19], fuzzy clustering [20], and a support vector machine classifier [21]. However, only retrospective analysis of video-EEG data was performed, and real-time analyses are not reported. In this study, a wearable system was used with video-EEG monitoring. The HRV indices were calculated in real time on a smartphone that contained a precalibrated MSPC model. Only the control limit, which is a discrimination threshold of seizure prediction, was calculated after measurement, since the interictal periods should be defined by specialists through a diagnosis of the video-EEG data. In clinical situations, the proposed system would be used after a definitive diagnosis has been made with video-EEG monitoring, with the control limits being calculated prior to use. In addition to prediction, the smartphone app sends data to a server, so remote monitoring in telemedicine may enable rapid fine-tuning of CLs and τ via the network. Thus, the proposed system demonstrated adequate real-time HRV monitoring and seizure prediction.
The small size of the proposed system, consisting of a telemeter and a smartphone, allows patients to hold the system. The battery life depends on the smartphone model and the telemeter's operating duration of more than 48 h after a full charge. Considering that a fully charged Android smartphone depletes its 3010 mAh battery in 14.12 ± 0.68 h (mean ± SD, n = 6) under continuous operation, the proposed wearable system has sufficient battery life for daily activity monitoring from 09:00 to 18:00. Although the fabricated telemeters failed to measure the RRIs of 3.46 ± 1.91% (mean ± SD) in the interictal episodes, the failure rates are sufficiently small to be used for HRV analysis,

Discussion
EEG is the most popular biomarker for seizure prediction, but HRV is rarely used [41], although the effects of epileptic seizures on the cardiac autonomic function have been reported in the early ictal phase [11][12][13] and the preictal phase [14]. Previous approaches of seizure prediction achieved comparable performance with HRV and time-frequency analysis [19], fuzzy clustering [20], and a support vector machine classifier [21]. However, only retrospective analysis of video-EEG data was performed, and real-time analyses are not reported. In this study, a wearable system was used with video-EEG monitoring. The HRV indices were calculated in real time on a smartphone that contained a precalibrated MSPC model. Only the control limit, which is a discrimination threshold of seizure prediction, was calculated after measurement, since the interictal periods should be defined by specialists through a diagnosis of the video-EEG data. In clinical situations, the proposed system would be used after a definitive diagnosis has been made with video-EEG monitoring, with the control limits being calculated prior to use. In addition to prediction, the smartphone app sends data to a server, so remote monitoring in telemedicine may enable rapid fine-tuning of CLs and τ via the network. Thus, the proposed system demonstrated adequate real-time HRV monitoring and seizure prediction.
The small size of the proposed system, consisting of a telemeter and a smartphone, allows patients to hold the system. The battery life depends on the smartphone model and the telemeter's operating duration of more than 48 h after a full charge. Considering that a fully charged Android smartphone depletes its 3010 mAh battery in 14.12 ± 0.68 h (mean ± SD, n = 6) under continuous operation, the proposed wearable system has sufficient battery life for daily activity monitoring from 09:00 to 18:00. Although the fabricated telemeters failed to measure the RRIs of 3.46 ± 1.91% (mean ± SD) in the interictal episodes, the failure rates are sufficiently small to be used for HRV analysis, because an RRI failure that is less than 5% does not cause a significant error in the HRV indices when they are compensated properly [16,42]. Meanwhile, the effect of the RRI outliers can be minimized through RRI outlier compensation (Section 2.2). The intersubject variance in the RRI failure rates suggests that it was affected by the stability of the electrodes and patients, because the threshold-based R-wave detection method adopted in the proposed telemeter is relatively weak against the baseline drift of ECG. Since the present study showed that the original telemeter exhibited sufficient performance only in situations where patient activity was limited and the false positive rates in healthy controls were relatively higher than that in patients, device lead-off and motion artifacts in daily life activity should be discussed in the upcoming phase 3 and 4 studies. Garment-type ECG electrodes could be a solution for improving usability and reducing motion artifacts originating from multiplied wire leads [43].
Although the numbers of seizures and patients used for evaluation are relatively small in comparison to the retrospective studies for seizure prediction [44], the number of patients used for the learning dataset is comparable because the MSPC model was constructed from fourteen subjects in our previous study [22]. In general, the number of events per variable is recommended to be as least ten [45] when a statistical model is built. The proposed MSPC model has eight input HRV features that were calculated from an RRI between two heartbeats. The model was constructed with 18.9 h of interictal data that included more than ten thousand heartbeats [22]. Thus, the sample size for model construction was appropriate for this study. Meanwhile, statistical significance was shown for the prediction sensitivity, because fourteen seizures were obtained from seven patients. A study with a larger number of subjects with controlled syndromes and focus locations may help in understanding the variance in prediction latency.
In Fujiwara et al. [22], epileptic seizure prediction with a sensitivity of 91% and a false positive rate of 0.7 times/h was performed using an offline retrospective analysis of the ECG extracted from long-term video-EEG monitoring. In this current study, the measurement and analysis functions were implemented in the wearable system and operated in real time. The developed system realized a sensitivity of 85.7% and a false positive rate of 0.62 times/h, where the MSPC model was constructed with previously unseen data (i.e., different patients) and the Q statistics were used independently for seizure prediction. The proposed system's sensitivity is comparable to previous systems (78-100%) introduced in the review papers, which summarized 23 seizure prediction methods [40,46]; however, most of them did not consider wearability or real-time analysis capability, so are not considered suitable for practical use. Conversely, the retrospective studies of EEG-based seizure prediction achieved a false positive rate within the range of 0.06-0.39 times/h. The clinical studies of the seizure detection (not prediction) system [33,47] were comparable within the range of 0.04-0.16 times/h. In recent retrospective studies on seizure prediction using HRV analysis, Pavei et al. [48] presented an epileptic seizure prediction algorithm adopting an SVM classifier for HRV signals that forecasted seizures with a sensitivity of 94.1% and a false positive rate of 0.49 in patients with epilepsy and 0.19 in healthy subjects. Billeci et al. [21] proposed an HRV-based patient-specific seizure prediction method using recurrence quantification analysis, with an average sensitivity of 89.6 and a false positive rate of 0.41 per hour. The interview-based patient survey [3] showed that patients require high sensitivity from seizure prediction devices, whereas they regard specificity as secondary. However, the majority of patients required false alarms to be less than the correct predictions. Therefore, the present method requires further development to reduce the false positive rate.
There was no significant reduction in the false positive rate from our previous study. The results support our previous study's hypothesis that the false positives may be due to body motion affecting the autonomic nervous system and HRV. As the patients rested in a sitting or supine position for most of the time during the video-EEG monitoring, the probability of body motion occurrence in the present study is considered similar to the previous study. The calculation of the t-test showed that the difference in the false positive rate of Q and T 2 statistics between the patient and healthy groups was not statistically significant (p > 0.05). These results suggest that the autonomic activity rates of the healthy subjects and the epilepsy patients are not significantly different during interictal periods, where there is no effect from the interictal discharges.
The false positive rate of the Q statistic was significantly high in patient A. The data length of the extracted interictal periods of patient A was shorter than other patients because the patient had more seizures and interictal discharges than others. The insufficient length of the interictal data made the control limit unreliable. In patient C, two of the four false positives occurred while eating in the Q statistic, while three of the four false positives in T 2 occurred while eating. Patients A and C had temporal lobe epilepsy (TLE), the severity of which may be related to abnormal heart rate regulation [49,50]. Considering preictal episodes A3 and C2, which were not predicted by the Q statistic, the interictal period should be carefully selected for appropriate control limit definition. However, the extracted interictal episodes were shorter than those in previous studies [5], because the severe exclusion criteria were defined to strictly exclude the epileptiform activity from the learning and CL tuning dataset [22]. Further work is required to determine sufficient durations of the interictal episodes for tuning of CLs and to develop a MSPC model specific to TLE patients.
Patient F showed a significantly high false positive rate in the T 2 statistic. According to the results of the video-EEG assessment, four of thirteen false positives occurred during a cognitive function test and seven occurred when the patients were focused on their hobbies (e.g., making plastic models), which suggests that HRV changes occurred due to the mental workload, as seen from the T 2 statistic. This hypothesis coincides with our previous results, which showed that the T 2 statistic exerted a better discrimination performance than the Q statistic in preventing drowsy driving accidents using HRV analysis and MSPC [51].
This study has several limitations that should be focused on in future work. Only Japanese patients with limited epilepsy syndrome (focal epilepsy) were selected, which should be addressed in future work. The developed system was examined under limited conditions at the hospital, as precise evaluation of the prediction sensitivity requires the determination of accurate seizure onset and because the false positive rate requires reliable evidence of isolation from the effect of interictal discharges or sleep. Hence, we selected this limited situation that could facilitate simultaneous video-EEG monitoring, and the results were compared with the healthy controls in unlimited situations. However, evaluation of the proposed system considering practical situations in a patient's daily life will be performed in future work to demonstrate the efficacy of a wearable seizure alert system. The ictal and interictal data while sleeping were excluded from the analysis. As suggested in the clinical trial in a seizure detection device [33], the development of an alternative MSPC model constructed only from the interictal sleep data may have the ability to predict sleep seizures, which remains to be developed and evaluated in future work. In addition, the intervals that were difficult for labeling preictal or interictal phases due to artifact contamination in the EEG data were removed from analysis retrospectively, although this offline preprocessing cannot be achieved in real-world situations. This may lead to the underestimation of the number of false positives and should be addressed in the upcoming phase 3 trial.

Conclusions
A prototype of a wearable system for epileptic seizure prediction was developed in this study. A bespoke telemeter operated by a nonspecialized person demonstrated sufficient accuracy and reliability for RRI measurement in comparison with the reference ECG of the video-EEG monitoring system. The Q and T 2 statistics for the MSPC model were computed in real time and there was a sensitivity of 85.7% with a false positive rate of 0.62 times/h for the Q statistic. The prototype's real-time seizure prediction and continuous operation of the wearable system will allow applications in the real world.
The MSPC model can be refined whilst it is operational via patient data updates. This could improve the model's sensitivity and allow the model to adapt to shifts in a patient's normal state.
The evaluation of the proposed system in the actual daily life of epilepsy patients is desired in future works.