Studying Drowsiness Detection Performance while Driving through Scalable Machine Learning Models using Electroencephalography

Abstract: - Background / Introduction: Driver drowsiness is a significant concern and one of the leading causes of traffic accidents. Advances in cognitive neuroscience and computer science have enabled the detection of drivers' drowsiness using Brain-Computer Interfaces (BCIs) and Machine Learning (ML). However, the literature lacks a comprehensive evaluation of drowsiness detection performance using a heterogeneous set of ML algorithms, and it is necessary to study the performance of scalable ML models suitable for groups of subjects. - Methods: To address these limitations, this work presents an intelligent framework employing BCIs and features based on electroencephalography for detecting drowsiness in driving scenarios. The SEED-VIG dataset is used to evaluate the best-performing models for individual subjects and groups. - Results: Results show that Random Forest (RF) outperformed other models used in the literature, such as Support Vector Machine (SVM), with a 78% f1-score for individual models. Regarding scalable models, RF reached a 79% f1-score, demonstrating the effectiveness of these approaches. This publication highlights the relevance of exploring a diverse set of ML algorithms and scalable approaches suitable for groups of subjects to improve drowsiness detection systems and ultimately reduce the number of accidents caused by driver fatigue. - Conclusions: The lessons learned from this study show that not only SVM but also other models not sufficiently explored in the literature are relevant for drowsiness detection. Additionally, scalable approaches are effective in detecting drowsiness, even when new subjects are evaluated. Thus, the proposed framework presents a novel approach for detecting drowsiness in driving scenarios using BCIs and ML.

\section{Introduction}\label{sec:1_intro}
Drowsiness is defined as a person's tendency to fall asleep. This situation is especially critical in driving scenarios, where the dangerous combination of driving and sleepiness commonly happens. Particularly, the National Highway Traffic Safety Administration (NHTSA) reported between 2013 and 2019 a total of 5~593 fatalities in motor vehicle crashes involving drowsy drivers. In 2017, exclusively in the USA, 91~000 police-reported crashes involved drowsy drivers, which led to about 50~000 people being injured \cite{iii-drowsy-driving}.

In the past years, drowsiness assessment has become a topic of interest among researchers. In this sense, cognitive neuroscience, the area of knowledge responsible for studying the nervous system that supports mental functions \cite{neurobiology-Shepherd}, including drowsiness, has proposed different techniques for its quantification \cite{drowsiness-assessment-techniques}. The first ones are based on monitoring subjects' behavior such as facial expression, heart rate, and yawning in order to assess drowsiness. Although these techniques represent an advance in safety, they have significant limitations since they produce false positives and false negatives, not always being able to measure attributes related to fatigue or drowsiness.

Next, solutions based on self-assessment with scales emerged. This technique consists in asking the subject how drowsy he/she has felt in the last minutes. Examples of this technique are the Karolinska Sleepiness Scale (KSS) \cite{KSS} and the NASA Task Load Index (NASA-TLX) \cite{NASA-TLX}. However, the main drawback of these methods is the inclusion of subjectivity in their self-evaluation. Hence, the need to objectively quantify the sleepiness of an individual arises. For this reason, neurophysiological tests have been developed, based on monitoring the patient's brain signals to precisely identify drowsiness.

Brain signals are commonly obtained by\linebreak electroencephalography (EEG), which measures the electrical activity produced in the brain through electrodes acting as sensors \cite{bci-1020-system}. The different levels of brain activity are related to the different cognitive states of the subject. Due to this, there is a need to study the EEG signals in different frequency bands, being the lower frequency rhythms (delta, theta, and alpha) directly related to the states of relaxation and drowsiness, and the higher rhythms (beta, gamma) related to concentration and moderate mental load, and even stressful situations in the case of the gamma band \cite{libro-neurociencia-Ward, 10.1016/j.neucom.2016.10.024}.

Brain-Computer Interfaces (BCIs) are normally used when studying EEG, where two categories are distinguished depending on the degree of invasiveness of the electrodes. On the one hand, invasive BCIs locate the electrodes within the skull, requiring a surgical process. On the other hand, non-invasive BCIs' electrodes are placed directly on the subject's scalp, avoiding a surgical procedure. Nevertheless, non-invasive BCIs data must be processed afterward to remove artifacts caused by the subjects' activity \cite{bci-full,bci-team}. Due to their advantages and feasibility of experimenting with subjects, non-invasive BCIs are used for the drowsiness detection scenario. In addition to non-invasive BCIs, Machine Learning (ML) models are also used to assess drowsiness using the data collected by the BCI. For this purpose, the BCIs acquire the brain signals when the subject is driving. Then, they are processed to eliminate the noise from the signals added during the acquisition using certain techniques such as Notch and band-pass filters, sample reduction, and Independent Component Analysis (ICA). After that, features are extracted from the signals, allowing ML algorithms to classify the features according to patterns identified in the data and, therefore, to predict drowsiness.

Despite the advances and contributions of existing studies that combine BCIs and ML to detect drowsiness while driving, there is a lack of literature analyzing the performance of customized and heterogeneous ML algorithms. The current literature presents a substantial amount of studies using ML, but in most of them, Support Vector Machine (SVM) is used without analyzing and comparing other well-known and relevant algorithms. In addition, the state-of-the-art only explores the performance of customized and individual models trained with data from single subjects, presenting significant scalability issues for new subjects since a new training process per user is needed. In this sense, scalable models combining the brain activity of several subjects should be explored and analyzed to determine if they effectively detect sleepiness in various subjects, even if the models were not trained with their data.

To improve the previous challenges, this work presents the following main contributions:

\begin{itemize}
\item The design of a BCI and ML-based framework for drowsiness detection in driving scenarios employing EEG and Electrooculography (EOG) as features. The proposed framework considers ML classifiers and regressors for detecting different drowsiness levels in both individual users and groups of them.

\item The creation of a personalized algorithm for PERCLOS discretization to improve drowsiness labeling, which takes into account the subject behavior to establish the thresholds between three drowsiness levels.

\item The deployment and evaluation of the framework using a publicly available dataset, SEED-VIG \cite{seed-vig-dataset}, modeling the EEG of 21 subjects while driving. The following ML algorithms have been trained and evaluated with different amounts of subjects and features for regression and three-class classification tasks: SVM, k-Nearest Neighbors (kNN), Decision Trees (DT), Random Forest (RF), and Gaussian Processes (GP).

\item The obtained results indicate that algorithms such as RF or kNN offer better results than the most common in the literature, SVM. In particular, within individual models, RF performed the best with a mean f1-score of 78\% and SVM with 58\%. Similarly, RF is also the best alternative for scalable models, reaching an f1-score of 79\% while SVM gets 52\%.
\end{itemize}

The rest of this paper is organized as follows. Section~\ref{sec:2_realted_work} presents the state of the art from drowsiness detection in driving scenarios using BCIs. Subsequently, Section~\ref{sec:3_proposed_solution} presents the design of the proposed framework, followed by Section~\ref{sec:4_results} which states the results of detecting drowsiness using the framework. Finally, Section~\ref{sec:5_conclusions} presents the conclusion and potential future work.
\section{Related Work}\label{sec:2_realted_work}
This section analyzes how drowsiness assessment techniques using BCIs are implemented in the literature and what methodology is followed by each study. It has been analyzed what features are extracted from the subjects, what algorithms and models are used to classify the signals, and how well they perform. In the literature, both drowsiness and fatigue are related to the same concept of a person’s tendency to fall asleep. Every study analyzed shares the same starting point, an existing dataset. Some of them decide to generate their own one, whereas others opt for a public dataset \cite{Akbar:Recurrent_SVM:2019,Gwak:SVM_kNN_RF:2018,Lin:SVM_kernel_survey:2014}.

Moreover, features are extracted from three sources, each one corresponding to a domain where EEG signals can be studied \cite{Padfield:EEG_survey_MI:2019}. Each study analyzed chooses certain features that may differ from the rest. Firstly, time-domain features, based on mathematical models and other algebraic operations, where the most popular and\linebreak widespread is the Autoregressive Model (AR) \cite{Garces:ANN:2014, Chakladar:TD_SVM_RF:2020}. It is also common to extract statistical values from the signals such as variance, standard deviation and quantiles, or Hjorth parameters \cite{Akbar:Recurrent_SVM:2019,Chakladar:TD_SVM_RF:2020,Cui:Oz_survey:2021}. Secondly, frequency-domain features, where Fast Fourier Transform (FFT) enables the analysis of the predominant frequencies in the original EEG signals and their amplitude. Using FFT, the Power Spectral Density (PSD) is widely used to measure the energy in each frequency band of the brain signals, providing good results when estimating drowsiness \cite{Liu:RSEFNN:2016,Akbar:Recurrent_SVM:2019,Wei:PSD_survey:2018,Shen:PSD_SVM:2021,Zhu:PSD_SVM:2020,Cheng:SVM_CNN:2018}.

Thirdly, time-frequency domain features, due to the non-stationary, non-linear and non-Gaussian behavior exhibited by the EEG signals, are useful to have a representation and decomposition of the frequency information of the signals linked to the time domain. This is why methods such as Discrete Wavelet Transform (DWT) are used \cite{Garces:ANN:2014,Chen:DWT_SVM_ELM:2015}. In addition to EEG features, it is common to combine them with other features which are extracted from the subject's behaviour. These include heart rate (HR), blink rate (BR), or the number of blinks \cite{Naurois:adapted_ANN:2018,Hu:SVM:2009}.

Finally, after feature extraction, the signals are classified. There are two aspects in common while classifying in the analyzed studies. First, most works use a supervised learning approach and, second, the use of a close range of algorithms which are known to give good results \cite{Padfield:EEG_survey_MI:2019}, being the most popular and widespread SVM \cite{Chen:DWT_SVM_ELM:2015,Mervyn:SVM:2009,Akbar:Recurrent_SVM:2019,Lin:SVM_kernel_survey:2014, Hu:SVM:2009}. This algorithm is followed by linear models, such as Ridge Regression, Logistic Regression, or Lasso Regression, Naive Bayes and kNN \cite{Igasaki:logistic_regression:2015,Cuui:kNN_ridge_MLPNN:2019,Padfield:EEG_survey_MI:2019}. To a lesser extent, and with more popularity in other branches of EEG analysis, Linear Discriminant Analysis (LDA), DT and RF are also chosen \cite{Padfield:EEG_survey_MI:2019,Gwak:SVM_kNN_RF:2018,Wei:PSD_survey:2018}.

Regarding Deep Learning (DL), the most widely used neural networks are Convolutional Neural Networks (CNN), Long Short-Term Memory (LSTM), Extreme Learning Machines (ELMs) and Recurrent Self-Evolving Fuzzy Neural Networks (RSEFNNs). They are gaining relevance as they produce better results, in many cases, compared to traditional ML methods in drowsiness assessment \cite{Chen:DWT_SVM_ELM:2015,Liu:RSEFNN:2016, Naurois:adapted_ANN:2018,Garces:ANN:2014,Padfield:EEG_survey_MI:2019}.

When estimating sleepiness with supervised learning, the labels used for regression models are the values measured by KSS, NASA-TLX, Auditory Vigilance Task (AVT) or PERCLOS. If the problem is approached with a classification model, the values of the labels used in the regressive methods are discretized to different levels of drowsiness \cite{Igasaki:logistic_regression:2015,Shen:SVM:2008,Zhuang:PERCLOS:2020,Savas:PERCLOS:2020,Chakladar:TD_SVM_RF:2020}.

\subsection{Performance of Literature Works}
An in-depth examination is conducted to perceive how the algorithms perform among the literature while also taking into account the features that researchers adopt when estimating drowsiness. Therefore, to validate the stability of the developed ML models and to examine their efficiency for later comparison with our results.

Table~\ref{tab:related-work-results} presents a summary of the examined studies. Specifically, the set of features, data labeling and the algorithms used are specified. After these fields, the results obtained are indicated. If regression is used, the results are offered based on the Root Mean Square Error (RMSE), with results between 0.15 and 0.5. In addition to RMSE, Pearson correlation coefficient (CC) or Coefficient of determination ($R^2$) are used. On the other hand, classification models used accuracy as metric.

In particular, it is worth highlighting the work performed by \cite{Chen:DWT_SVM_ELM:2015}, where neurologists removed data artifacts and labeled the signals by visual inspection. Moreover, SVM is used for classification, reaching an accuracy of 94.7\%, using DWT and eye features as well. In terms of regression, \cite{Akbar:Recurrent_SVM:2019} achieved 0.15 RMSE and 0.83 $R^2$. SVM is again the algorithm of choice. Time-domain features such as Hjorth parameters and PSD from the frequency-domain are used, and KSS is employed to self-assess drowsiness.

The work done by Li et al. (2018) \cite{Li:SEED-VIG_SVR:2018} is relevant for our study since the dataset employed is also SEED-VIG. In this work, a Support Vector Regressor (SVR) is used as baseline together with 100 EEG and 36 EOG features, resulting in a model that achieved a RMSE of 0.17$\pm$0.06 and CC of 0.76$\pm$0.23.

In studies like \cite{Bajaj:Hjorth(WT)_ANN_SVM_ELM_DNN:2020,Gwak:SVM_kNN_RF:2018, Cui:Oz_survey:2021, Wei:PSD_survey:2018, Padfield:EEG_survey_MI:2019}, different surveys of algorithms are presented, being some of them not so popular among the literature, such as kNN, DT or RF. In those studies, SVM is also included and, in some cases, there are other algorithms with better results. For example, in \cite{Bajaj:Hjorth(WT)_ANN_SVM_ELM_DNN:2020}, Ensemble
Boosted Trees (EBTs) reached 77.3\% accuracy while SVM achieved 76.7\%. Furthermore, in \cite{Gwak:SVM_kNN_RF:2018}, RF got 81.4\% while SVM only got 78.6\%. The results highlight that, although SVM is the most widespread choice, there are alternatives which presented better results in their studies.

Regarding DL, its use is increasing in these studies and often produces results surpassing traditional ML algorithms.
An example of this is shown by Cheng et al. (2018) \cite{Cheng:SVM_CNN:2018} since with the same features and labeling, an accuracy of 69.19\% is obtained with CNN compared to 64.05\% using SVM.

After analyzing in detail the most related works, it can be seen that SVM is generally present among the literature but, at the same time, there is evidence of other approaches, such as neural networks or other ML algorithms, that offer similar or even better results. In addition, there is also a lack of studies that consider scalable models since all of the identified studies focus on individual models which can only detect drowsiness in a specific subject.

 \begin{table*}[!ht]
    \centering

    \caption{Summary of the literature works reviewed and their results.}
    \label{tab:related-work-results}

    \resizebox{\textwidth}{!}{
    \begin{tabular}{lL{6cm}L{3cm}L{3.5cm}L{2.5cm}}
    \hline
    \textbf{Reference} & \textbf{Features} & \textbf{Labeling} & \textbf{Classification Methods} & \textbf{Results} \\
    \hline

    \multirow{2}{*}{\begin{tabular}{@{}c@{}}Chen et al. \\ (2015) \cite{Chen:DWT_SVM_ELM:2015}\end{tabular}} & \multirow{2}{*}{Four from DWT} & \multirow{2}{*}{Visual inspection} & SVM & 96.90\% \\

     &  &  & ELM & 97.30\% \\
    \hline

    \begin{tabular}{@{}c@{}}Igasaki et al. \\ (2015) \cite{Igasaki:logistic_regression:2015}\end{tabular} & HR and breathing & KSS & Logistic regression & 84\% \\
    \hline

    \begin{tabular}{@{}c@{}}Liu et al. \\ (2016) \cite{Liu:RSEFNN:2016}\end{tabular} & PSD & Reaction time & RSEFNN & 96.18\% \\
    \hline

    \multirow{2}{*}{\begin{tabular}{@{}c@{}}Cheng et al. \\ (2018) \cite{Cheng:SVM_CNN:2018}\end{tabular}} & \multirow{2}{*}{PSD} & \multirow{2}{*}{Reaction time} & SVM & 64.05\% \\

     &  &  & CNN & 69.19\% \\
    \hline

    \multirow{3}{*}{\begin{tabular}{@{}c@{}}Gwak et al. \\ (2018) \cite{Gwak:SVM_kNN_RF:2018}\end{tabular}} & \multirow{3}{6cm}{PSD, HR, EOG and simulator data} & \multirow{3}{2.5cm}{Expressions and performance} & SVM & 78.60\% \\

     &  &  & kNN & 75.30\% \\

     &  &  & Random Forest & 81.40\% \\
    \hline

    \begin{tabular}{@{}c@{}}Li et al. \\ (2018) \cite{Li:SEED-VIG_SVR:2018}\end{tabular} & 100 from EEG and 36 from EOG & PERCLOS & SVR & CC: 0.76$\pm$0.23
    RMSE: 0.17$\pm$0.06 \\
    \hline

    \multirow{3}{*}{\begin{tabular}{@{}c@{}}Wei et al. \\ (2018) \cite{Wei:PSD_survey:2018}\end{tabular}} & \multirow{3}{*}{PSD} & \multirow{3}{*}{Reaction time} & SVM & 80.0$\pm$8.6\% \\

     &  &  & kNN & 77.3$\pm$10.7\% \\

     &  &  & LDA & 79.4$\pm$8.7\% \\
    \hline

    \multirow{2}{*}{\begin{tabular}{@{}c@{}}Akbar and\\Igasaki \\ (2019) \cite{Akbar:Recurrent_SVM:2019}\end{tabular}} & \multirow{2}{*}{Three from EEG and PSD} & \multirow{2}{*}{KSS} & SVM & $R^2$: 0.64
    RMSE: 0.56 \\

     &  &  & Recurrent SVM & $R^2$: 0.83
    RMSE: 0.15 \\
    \hline

    \multirow{2}{*}{\begin{tabular}{@{}c@{}}Cuui et al. \\ (2019) \cite{Cuui:kNN_ridge_MLPNN:2019}\end{tabular}} & \multirow{2}{*}{PSD} & \multirow{2}{*}{Reaction time} & kNN & CC: 0.439
    RMSE: 0.268 \\

     &  &  & Ridge regression & CC: 0.504
    RMSE: 0.362 \\
    \hline

    \multirow{2}{*}{\begin{tabular}{@{}c@{}}Chakladar et\\al. (2020) \cite{Chakladar:TD_SVM_RF:2020}\end{tabular}} & \multirow{2}{6cm}{PSD, mean, SD, Skewness, Kurtosis, AR and Approximate Entropy} & \multirow{2}{3cm}{NASA-TLX from 1 to 9} & SVM & 83.33\% \\

     &  &  & Random Forest & 83.00\% \\
    \hline

    \begin{tabular}{@{}c@{}}Zhu et al. \\ (2020) \cite{Zhu:PSD_SVM:2020}\end{tabular} & PSD & Reaction time & SVM & 93.6\% \\
    \hline

    \multirow{5}{*}{\begin{tabular}{@{}c@{}}Cui et al. \\ (2021) \cite{Cui:Oz_survey:2021}\end{tabular}} & \multirow{5}{*}{Oz EEG channel} & \multirow{5}{*}{Reaction time} & Decision trees & 60.70\% \\

     &  &  & Random Forest & 62.60\% \\

     &  &  & kNN & 63.42\% \\

     &  &  & Gaussian Naive Bayes & 67.44\% \\

     &  &  & SVM & 69.72\% \\
    \hline

    \begin{tabular}{@{}c@{}}Shen et al. \\ (2021) \cite{Shen:PSD_SVM:2021}\end{tabular} & PSD & Reaction time & SVM & 62.51\% \\
    \hline

     \end{tabular}}
 \end{table*}
\section{Proposed Solution}\label{sec:3_proposed_solution}
This section describes the design and implementation of the proposed framework to detect drowsiness while driving. An overview of the framework is shown in \figurename~\ref{fig:framework-overview}, presenting its different components. Starting from the upper side, the first two components refer to the data acquisition process and its processing. Next, a feature extraction stage, where the most relevant aspects of the acquired data are selected. Finally, it consists of a data classification block, where individual models for each subject and scalable models with data from several users are implemented based on different ML algorithms.

\begin{figure}[h]
\centering
    \includegraphics[width=\columnwidth]{Figure1.pdf}
    \caption{Framework overview.}
    \label{fig:framework-overview}
\end{figure}

\subsection{Data Acquisition}
The design and implementation of the proposed framework is generic enough to be compatible with different datasets, as well as data acquired in real-time using a BCI. Nevertheless, this work has used the SEED-VIG dataset \cite{seed-vig-dataset} due to its realistic conditions, the suitability with the study purpose, and the amount and quality of the data provided.

More in detail, the SEED-VIG dataset consists of 23 experiments among 21 different subjects (two subjects repeated the experiment). Each experiment has about two hours of EEG signals recorded while the subjects were using a driving simulator. The data were acquired from 17 electrode channels according to the 10-20 system (see \figurename~\ref{fig:electrodes-placement}), using a sample rate of 200 Hz. Particularly, a \textit{Neuroscan} device was used to measure EEG and EOG \cite{bci-dataset}. The raw data from the different experiments are provided, together with a variety of already processed data. Particularly, the following data subsets are used during this study: 1) raw EEG data from the 17 channels, 2) moving average PSD relative to the five frequency bands of the brain signals and, 3) raw data from the EOG vertical channel.

The dataset was labeled every eight seconds with subjects' PERCLOS values obtained by an eye-tracking device from \textit{SensoMotoric Instruments} \cite{glasses-dataset}. PERCLOS is a psycho-physiological measure of the subject that quantifies the percentage of time that a subject has been with the eyes at least 80\% closed during the time interval of measurement \cite{perclos-definition}.

\begin{figure}[h]
\centering
    \includegraphics[width=0.85\columnwidth]{Figure2.pdf}
    \caption{Placement of the EEG electrodes used in the SEED-VIG dataset, highlighted in color.}
    \label{fig:electrodes-placement}
\end{figure}

\subsection{Data Processing}
As a result of using a non-invasive BCI, the EEG signals obtained contain artifacts, so they must be filtered following the process presented in \figurename~\ref{fig:EEG-filtering}. Initially, the signals are processed with two filtering techniques. First, a Notch filter is applied at 60 Hz in order to eliminate the artifact introduced by the power grid. Secondly, a band-pass filter between one and 30 Hz is applied since this is the frequency range of interest for the study of drowsiness \cite{libro-neurociencia-Ward}. The signals are then downsampled to 60 Hz following the Nyquist–Shannon sampling theorem to reduce the size of the data and speeding up its subsequent classification without losing information and, finally, ICA is applied to remove the remaining artifacts such as subjects' blinks while the essential information for detecting drowsiness is preserved. Once the artifacts are removed from the initial raw data, it is also necessary to split the signals in portions (Epochs) of eight seconds. This allows to perform a correct feature extraction since there is a PERCLOS value every eight seconds.

\begin{figure}[h]
\centering
    \includegraphics[width=0.85\columnwidth]{Figure3.pdf}
    \caption{EEG signals processing phase.}
    \label{fig:EEG-filtering}
\end{figure}

\subsection{Feature Extraction}
\tablename~\ref{tab:features-description} shows the sources where features are extracted, their description, and the total number of features extracted. Focusing on EEG features, the eight extracted features for each channel are: mean, standard deviation, variance, 5th percentile, 1st quartile, median, 3rd quartile and 95th percentile. Thus, a total of $8\times17=136$ features are obtained. Subsequently, three feature vectors are assembled to train the models. The first one, referring to the 136 EEG features; the second, making use of the five PSD features alone; and the third, combining PSD with the EOG, containing a total of six features.

\begin{table}[]
\centering

\caption{Feature sources and description for each Epoch.}
\label{tab:features-description}

\begin{adjustbox}{width=\columnwidth}
\begin{tabular}{L{1.5cm}L{7cm}}
    \hline
    \textbf{Feature sources} & \textbf{Description} \\
    \hline
    EEG & Eight features representing the behavior of the signal for each particular electrode in a summarized version via statistical measures. Therefore, 136 features are obtained. \\
    \hline
    PSD & Five features, each one corresponding to the averaged power of a particular frequency band among the 17 EEG channels.\\
    \hline
    EOG & One feature corresponding to the number of blinks from the subject.\\
    \hline
\end{tabular}
\end{adjustbox}
\end{table}

\subsection{PERCLOS Discretization Algorithm and Drowsiness Classification}
There are two main categories of supervised learning techniques: regression, which predicts numerical values, PERCLOS values in this study; and classification, which produces class assignments. Both categories are used in the framework since either approaches are used in the literature, thus facilitating subsequent comparison of the results.

Since PERCLOS values range from zero to one, it is necessary to map them into three levels of sleepiness as recommended by Trejo et al. (2007) \cite{three-class} and Chang et al. (2007) \cite{psd-bands-AND-three-class}. Regarding the literature, fixed thresholds are commonly chosen to divide the PERCLOS range of values into the levels of sleepiness. Nevertheless, Gu et al. (2018) \cite{Gu:perclos-thresholds} stated that it is not possible to directly borrow other studies' thresholds since they are related to the different detection methods used by different researchers, concluding that the PERCLOS thresholds should be obtained from experiments themselves.

Based on the above, the proposed framework proposes a dynamic PERCLOS discretization algorithm to calculate the thresholds between classes for each subject. With this algorithm, the physiological particularities of each subject are taken into account and, therefore, a personalized division of drowsiness levels that improves data labeling is obtained. The threshold between the \textit{minor} and \textit{moderate} drowsiness levels (th\_minor) is calculated with equation~(\ref{eq:moderate-threshold}) while the threshold between moderate and severe drowsiness levels (th\_moder) is obtained by equation~(\ref{eq:severe-threshold}). In each equation, there is a fixed value that is obtained after testing different possibilities to find the best option that divides the data for the subjects in the experiments.

\begin{dmath}\label{eq:moderate-threshold}
    \texttt{th_minor}=min(PERCLOS) +\\ (max(PERCLOS)-min(PERCLOS))*0.125
\end{dmath}

\begin{dmath}\label{eq:severe-threshold}
    \texttt{th\_moder}=min(PERCLOS) +\\ (max(PERCLOS)-min(PERCLOS))*0.30
\end{dmath}

A visual output of the PERCLOS discretization with the proposed algorithm in this study is shown in \figurename~\ref{fig:PERCLOS-discretization}. The green zone, marked as (1), contains the values where the subject's drowsiness is considered \textit{minor} or fully awake. Subsequently, the yellow zone, marked as (2), indicates \textit{moderate} drowsiness while the red zone, highlighted by (3), represents severe drowsiness.

\begin{figure}[h]
\centering
    \includegraphics[width=\columnwidth]{Figure4.pdf}
    \caption{Output of the PERCLOS discretization algorithm with tree levels of drowsiness.}
    \label{fig:PERCLOS-discretization}
\end{figure}

During the classification stage, the framework uses two different model approaches. The first one focuses on training individual and customized models for each user. The second category is based on training scalable models suitable for groups of subjects. Particularly, the two best-performing combinations in the individual models, together with the best one from SVM, are used for the scalable analysis, aiming to reduce the complexity of the experimentation. A combination is defined as a ML algorithm together with a vector of features.

To train each model, the PSD and EOG features are normalized using a \textit{MinMax scaler}. Then, the split strategy is to shuffle the data before splitting 25\% of the data as the test set and the remaining 75\% as the training set, except for some scalable models which have their own evaluation sample proportion. Ten-fold cross validation together with hyperparameter search allows finding the best configuration parameters of a model and achieving the best performance while avoiding overfitting. The algorithms of choice are: SVM, kNN, DT, GP, and RF. DT, kNN, and RF, which are selected via the conducted literature review, where it is observed that in some cases, these models perform better than SVM. Finally, GP is selected because it is based on Gaussianity while the EEG signals behavior is non-Gaussian but measures such as PSD are not, so it is interesting to evaluate its performance.
\section{Experiments and Results}\label{sec:4_results}
This section presents a set of experiments aiming to evaluate the drowsiness detection performance of individual and scalable ML models using regression and three-class classification techniques.

Concerning trained models, there is one type of individual models while three types are explored for scalable models:
\begin{itemize}
    \item Individual models: Individual classifier and regressor trained and evaluated for each subject.

    \item 100 models: General classifier and regressor trained and evaluated with the 100\% of subjects.

    \item 90-10 models: General classifier and regressor trained with the 90\% of subjects and evaluated with the remaining 10\%.

    \item 70-30 models: General classifier and regressor trained with the 70\% of subjects and evaluated with the remaining 30\%.
\end{itemize}

Regarding regressive models, two metrics are used to measure the quality of the results: RMSE and $R^2$. On the contrary, for classification models, four metrics are used to measure how well the models performs: accuracy, precision, recall, and f1-score. Particularly, f1-score is prioritized because it involves both precision and recall, making it the most robust and meaningful metric for the analysis.

Since the results of individual, 90-10, and 70-30 models present multiple combinations of different algorithms and subjects tested, the results are presented averaged, subsequently indicated with the following format: \texttt{Mean}~$\pm$~\texttt{SD}. On the other hand, there is no need to do this for 100 model, since there is only one test set with the data reserved from every experiment.

\subsection{Individual Models}
The performance of the trained regressive individual models is shown in \tablename~\ref{tab:individual-regression}, where the three assembled feature vectors (EEG, PSD, and EOG+PSD) are used to train each model to observe the performance of each one together with the different ML algorithms evaluated. Generally, it is observed that the lowest RMSE occurs in most cases when only the PSD features are used, followed closely by those using PSD together with EOG and, finally, those using only EEG data. It should also be noted that, although the EEG gives the worst results in all cases, these results are acceptable to obtain a good prediction of sleepiness.

As expected, GP performs the worst for all three feature sets since this algorithm is based on the probabilistic theory of the Gaussian distribution, as discussed above. On the other hand, SVM and DT offer similar results in terms of their error, improving the results of GP. Finally, KNN and RF are the algorithms with the lowest RMSE. The combination offering the best performance is RF with PSD and EOG features both in RMSE ($0.08\pm0.02$) and $R^2$ ($0.83\pm0.09$).

\begin{table}[h]
\centering

\caption{Regression performance for the individual models.}
\label{tab:individual-regression}

\resizebox{\columnwidth}{!}{\begin{tabular}{lcC{2.5cm}cc}
    \hline
    \textbf{Algorithm} & \textbf{Features} & \textbf{RMSE} & \textbf{\boldmath$R^2$} \\
    \hline
    \multirow{3}{2cm}{SVM} & EEG & $0.16\pm0.05$ & $0.42\pm0.22$ \\
     & PSD & $0.12\pm0.04$ & $0.67\pm0.20$ \\
     & PSD+EOG & $0.12\pm0.04$ & $0.65\pm0.21$ \\
    \hline
    \multirow{3}{2cm}{kNN} & EEG & $0.15\pm0.05 $ & $0.49\pm0.20 $ \\
     & PSD & $0.09\pm0.03 $ & $0.82\pm0.09 $ \\
     & PSD+EOG & $0.10\pm0.04 $ & $0.75\pm0.18 $ \\
    \hline
    \multirow{3}{2cm}{DT} & EEG & $0.21\pm0.06$ & $0.06\pm0.39$ \\
     & PSD & $0.12\pm0.04$ & $0.68\pm0.19$ \\
     & PSD+EOG & $0.12\pm0.03$ & $0.68\pm0.17 $ \\
    \hline
    \multirow{3}{2cm}{GP} & EEG & $0.21\pm0.06 $ & $-0.07\pm0.69$ \\
     & PSD & $0.13\pm0.04 $ & $0.55\pm0.26 $ \\
     & PSD+EOG & $0.17\pm0.05 $ & $0.26\pm0.54 $ \\
    \hline
    \multirow{3}{2cm}{RF} & EEG & $0.14\pm0.05 $ & $0.56\pm0.17 $ \\
     & PSD & $0.09\pm0.03 $ & $0.83\pm0.09 $ \\
     &\textbf{PSD+EOG} & \boldmath$0.08\pm0.02 $ & \boldmath$0.83\pm0.09 $ \\
    \hline
\end{tabular}}
\end{table}

In the same way, the best combinations for classification are quite similar to those previously shown for regression since the algorithms are the same but focused on classification. Particularly, they are presented in \tablename~\ref{tab:individual-classification}. Nevertheless, it is worth commenting on the best combinations of the classification approach since the metrics used are different and yield a series of considerations that cannot be studied from the regressive point of view. The three best combinations, regarding now f1-score, are again the same but in a different order. In this case, the best one is RF with PSD as features with an f1-score of $0.78\pm0.07$.

\begin{table}[h]
\centering

\caption{Classification performance for the individual models.}
\label{tab:individual-classification}

\resizebox{\columnwidth}{!}{
\begin{tabular}{lcC{2.cm}cccc}
    \hline
    \textbf{Algorithm} & \textbf{Features} & \textbf{Accuracy} & \textbf{Precision} & \textbf{Recall} & \textbf{f1-score} \\
    \hline
    \multirow{3}{1.8cm}{SVM} & EEG & $0.72\pm0.10$ & $0.71\pm0.16$ & $0.51\pm0.12$ & $0.50\pm0.13$ \\
     & PSD & $0.76\pm0.10$ & $0.78\pm0.12$ & $0.58\pm0.13$ & $0.58\pm0.14$ \\
     & PSD+EOG & $0.76\pm0.09$ & $0.074\pm0.12$ & $0.58\pm0.12$ & $0.58\pm0.13$ \\
    \hline
    \multirow{3}{1.8cm}{kNN} & EEG & $0.71\pm0.09$ & $0.61\pm0.13$ & $0.52\pm0.10$ & $0.51\pm0.11$ \\
     & PSD & $0.85\pm0.05$ & $0.81\pm0.50$ & $0.77\pm0.08$ & $0.78\pm0.07$ \\
     & PSD+EOG & $0.79\pm0.08$ & $0.73\pm0.12$ & $0.63\pm0.12$ & $0.64\pm0.12$ \\
    \hline
    \multirow{3}{1.8cm}{DT} & EEG & $0.67\pm0.11$ & $0.63\pm0.14$ & $0.47\pm0.09$ & $0.46\pm0.10$ \\
     & PSD & $0.80\pm0.08$ & $0.73\pm0.09$ & $0.71\pm0.08$ & $0.71\pm0.09$ \\
     & PSD+EOG & $0.80\pm0.09$ & $0.74\pm0.09$ & $0.72\pm0.07$ & $0.72\pm0.08$ \\
    \hline
    \multirow{3}{1.8cm}{GP} & EEG & $0.71\pm0.10$ & $0.70\pm0.13$ & $0.48\pm0.09$ & $0.46\pm0.09$ \\
     & PSD & $0.70\pm0.11$ & $0.79\pm0.17$ & $0.46\pm0.12$ & $0.42\pm0.13$ \\
     & PSD+EOG & $0.71\pm0.10$ & $0.77\pm0.12$ & $0.48\pm0.11$ & $0.45\pm0.12$ \\
    \hline
    \multirow{3}{1.8cm}{RF} & EEG & $0.74\pm0.09$ & $0.74\pm0.12$ & $0.54\pm0.10$ & $0.54\pm0.10$ \\
     & \textbf{PSD} & \boldmath$0.86\pm0.06$ & \boldmath$0.83\pm0.06$ & \boldmath$0.76\pm0.08$ & \boldmath$0.78\pm0.07$ \\
     & PSD+EOG & $0.85\pm0.06$ & $0.83\pm0.05$ & $0.74\pm0.08$ & $0.76\pm0.07$ \\
    \hline
\end{tabular}}
\end{table}

\subsection{Scalable Models}
Once the results of the individual models are available, the two best-performing algorithms in the individual approach (kNN and RF) and the most promising features for each one are selected for further study. In addition, the best combination for SVM is also included due to its large presence in the literature. These three combinations are used to evaluate a single model. Subsequently, each scalable model created is presented along with its performance.

\subsubsection{100 Models}
Regression performance is shown in \tablename~\ref{tab:m100-regression} where it can be seen that both kNN with PSD and RF with PSD plus EOG have a fairly good RMSE and $R^2$. SVM with PSD, however, provides inferior performance compared to the other options. These results follow the same trend as the individual models presented in \tablename~\ref{tab:individual-regression}.

\begin{table}[h]
\centering

\caption{Regression performance for the 100 models.}
\label{tab:m100-regression}

\resizebox{\columnwidth}{!}{
\begin{tabular}{lcC{2.5cm}cc}
    \hline
    \textbf{Algorithm} & \textbf{Features} & \textbf{RMSE} & \textbf{\boldmath$R^2$} \\
    \hline
    SVM         & PSD               & $0.21$            & $0.43$ \\
    kNN         & PSD               & $0.14$            & $0.75$ \\
    \textbf{RF} & \textbf{PSD+EOG}  & \boldmath$0.12$   & \boldmath$0.80$ \\
    \hline
\end{tabular}}
\end{table}

As for the scalable classification models (\tablename~\ref{tab:m100-classification}), and in the same way as the regression models, the best options are again kNN and RF, in this case, both using PSD as features. Similarly to the results evaluating individual models, SVM has been the worst in performance.
\begin{table}[h]
\centering

\caption{Classification performance for the 100 models.}
\label{tab:m100-classification}

\resizebox{\columnwidth}{!}{
\begin{tabular}{lcC{2cm}cccc}
    \hline
    \textbf{Algorithm} & \textbf{Features} & \textbf{Accuracy} & \textbf{Precision} & \textbf{Recall} & \textbf{f1-score} \\
    \hline
    SVM         & PSD           & $0.63$ & $0.59$ & $0.51$ & $0.52$ \\
    kNN         & PSD           & $0.79$ & $0.76$ & $0.76$ & $0.76$ \\
    \textbf{RF} & \textbf{PSD}  & \boldmath$0.83$ & \boldmath$0.80$ & \boldmath$0.78$ & \boldmath$0.79$ \\
    \hline
\end{tabular}}
\end{table}

\subsubsection{90-10 Models}
Since there are a total of 23 experiments among 21 different subjects in the dataset, two subjects (avoiding those who had more than one experiment) corresponding to $\sim$10\% of the total are reserved for the evaluation of the model. Subsequently, 21 experiments from a total of 19 subjects are used for training the model.

As presented in \tablename~\ref{tab:9010-regression}, SVM offers the worst performance of the three combinations studied. After that, kNN presents better results using PSD, followed by RF using PSD and EOG data as the most promising combination.

\begin{table}[h]
\centering

\caption{Regression performance for the 90-10 models.}
\label{tab:9010-regression}

\resizebox{\columnwidth}{!}{
\begin{tabular}{lcC{2.5cm}cc}
    \hline
    \textbf{Algorithm} & \textbf{Features} & \textbf{RMSE} & \textbf{\boldmath$R^2$} \\
    \hline
    SVM         & PSD               & $0.26\pm0.06$ & $-1.91\pm0.10$ \\
    kNN         & PSD               & $0.20\pm0.08$ & $-0.66\pm0.04$ \\
    \textbf{RF} & \textbf{PSD+EOG}  & \boldmath$0.16\pm0.07$ & \boldmath$0.03\pm0.18$ \\
    \hline
    \end{tabular}}
\end{table}

Relative to the 90-10 classification models (see \tablename~\ref{tab:9010-classification}), it is important to note that, in this case, kNN with PSD as features performs slightly better than RF with PSD. On the other hand, SVM together with PSD offers results almost similar to the last two combinations mentioned, but always a step below.

\begin{table}[h]
\centering

\caption{Classification performance for the 90-10 models.}
\label{tab:9010-classification}

\resizebox{\columnwidth}{!}{
\begin{tabular}{lcC{2cm}cccc}
    \hline
    \textbf{Algorithm} & \textbf{Features} & \textbf{Accuracy} & \textbf{Precision} & \textbf{Recall} & \textbf{f1-score} \\
    \hline

    SVM & PSD & $0.57\pm0.23$ & $0.37\pm0.14$ & $0.41\pm0.18$ & $0.38\pm0.15$ \\

    \textbf{kNN} & \textbf{PSD} & \boldmath$0.60\pm0.17$ & \boldmath$0.46\pm0.12$ & \boldmath$0.48\pm0.12$ & \boldmath$0.46\pm0.12$ \\

    RF & PSD & $0.61\pm0.19$ & $0.44\pm0.18$ & $0.45\pm0.19$ & $0.43\pm0.17$ \\
    \hline
\end{tabular}}
\end{table}

\subsubsection{70-30 Models}
Analogous to the reasoning in the previous models, in this case, 16 experiments (from 14 different subjects) are assigned to model training while the remaining seven experiments, from seven different subjects, are reserved for evaluation.

\tablename~\ref{tab:7030-regression} presents the regression results while the corresponding to classification are shown in \tablename~\ref{tab:7030-classification}. In both approaches, SVM is always the worst of the three combinations. In regression, RF with PSD and EOG remains the best alternative, followed by kNN with PSD. Moving to classification, both kNN and RF with PSD are alternatives to consider, as RF offers a better accuracy compared to kNN but the second one slightly outperforms it in the rest of the metrics. It is interesting to mention that the average f1-score has fallen in all three cases below 40\%, which makes this set of models not as interesting as others presented above.

\begin{table}[h]
\centering

\caption{Regression performance for the 70-30 models.}
\label{tab:7030-regression}

\resizebox{\columnwidth}{!}{
\begin{tabular}{lcC{2.5cm}cc}
    \hline
    \textbf{Algorithm} & \textbf{Features} & \textbf{RMSE} & \textbf{\boldmath$R^2$} \\
    \hline
    SVM & PSD & $0.26\pm0.07$ & $-1.90\pm3.02$ \\

    kNN & PSD & $0.22\pm0.05$ & $-0.70\pm0.65$ \\

    \textbf{RF} & \textbf{PSD+EOG} & \boldmath$0.18\pm0.05$ & \boldmath$-0.17\pm0.45$ \\

    \hline
\end{tabular}}
\end{table}
\begin{table}[h]
\centering

\caption{Classification performance for the 70-30 models.}
\label{tab:7030-classification}

\resizebox{\columnwidth}{!}{
\begin{tabular}{lcC{2cm}cccc}
    \hline
    \textbf{Algorithm} & \textbf{Features} & \textbf{Accuracy} & \textbf{Precision} & \textbf{Recall} & \textbf{f1-score} \\
    \hline

    SVM & PSD & $0.40\pm0.20$ & $0.38\pm0.07$ & $0.41\pm0.09$ & $0.29\pm0.14$ \\

    \textbf{kNN} & \textbf{PSD} & \boldmath$0.45\pm0.16$ & \boldmath$0.44\pm0.07$ & \boldmath$0.44\pm0.11$ & \boldmath$0.37\pm0.11$ \\

    \textbf{RF} & \textbf{PSD} & \boldmath$0.46\pm0.15$ & \boldmath$0.41\pm0.06$ & \boldmath$0.41\pm0.07$ & \boldmath$0.35\pm0.08$ \\

    \hline
\end{tabular}}
\end{table}

\subsection{Discussion}
The results for both individual and scalable models suggest that there are better algorithms than SVM when estimating subjects' drowsiness, which is surprising given the tendency in the literature of using SVM. In addition, it is observed that the feature vectors containing PSD features, both used individually or along with EOG, tend to produce the best results for every trained algorithm. In the case of classification algorithms, to make a fair comparison with the literature, this section relies on accuracy and not on f1-score.

Regarding individual models, and comparing the metrics with \cite{Li:SEED-VIG_SVR:2018}, who used the same dataset but different features, the RMSE obtained in almost every combination of algorithm and features in the framework improves the RMSE of 0.17$\pm$0.06 provided in their research with SVR. Moreover, the accuracy of 93.6\% obtained in \cite{Zhu:PSD_SVM:2020} is close to the 86$\pm$6\% obtained by the best combination in the framework.

As can be seen in \tablename~\ref{tab:discussion}, the best results for the trained individual models are in line with the claims of Gwak et al. (2018) \cite{Gwak:SVM_kNN_RF:2018} where RF performed better than SVM. On the contrary, the results contradict Cui et al. (2021) \cite{Cui:Oz_survey:2021} and Chakladar et al. (2020) \cite{Chakladar:TD_SVM_RF:2020} since in both studies, SVM performed better or similarly than the other tested algorithms.

This, which may look controversial, can be explained by the features employed by Gwak et al. (2018) \cite{Gwak:SVM_kNN_RF:2018} and the present study, where PSD and EOG features are used. On the contrary, Cui et al. (2021) \cite{Cui:Oz_survey:2021} used an entire EEG channel as feature and Chakladar et al. (2020) \cite{Chakladar:TD_SVM_RF:2020} combined PSD with time-domain features. Therefore, a common pattern is observed. If PSD is used, the model performance obtained is increased compared to not using it and, thus, algorithms such as RF tend to perform better or, at least, similar to SVM. This pattern is also found in studies like \cite{Gwak:SVM_kNN_RF:2018} with an accuracy of 81.40\% using RF and \cite{Chakladar:TD_SVM_RF:2020} with 83.33\% in SVM and 83.00\% in RF. This may contribute to a clearer understanding of which features and algorithms should be taken into account when considering training a model for the prediction of drowsiness while driving.

Concerning scalable models, the 100 model performance is similar to the individual models, implying that having just one model for all users could be enough, compared to having one model per subject. Moreover, the 90-10 and 70-30 models reach an accuracy of $0.60\pm0.17$ and $0.46\pm0.15$ respectively. In both cases, the performance is greater than 33\%, which represents the accuracy of predicting the level of sleepiness randomly. Because of that, these results suggest that it could be possible to develop a scalable model which can predict drowsiness in subjects that are not involved in the experimentation and training phase of the model, although this may depend on the similarity of the subject's features distribution to those used during training.

Nevertheless, the generalization of the results is limited by the data provided by the dataset as the models are trained for a specific group of 21 subjects who participated in its creation. Further research is needed to establish the generalization of our findings, making use of a larger number of subjects during the training phase.

\begin{table*}[!ht]
    \centering

    \caption{Summary of the literature analyzed focusing on individual models and comparison with our results.}
    \label{tab:discussion}

    \resizebox{\textwidth}{!}{
    \begin{tabular}{lL{6cm}L{3cm}L{3.5cm}L{2.5cm}}
    \hline
    \textbf{Reference} & \textbf{Features} & \textbf{Labeling} & \textbf{Classification Methods} & \textbf{Results} \\
    \hline

    \multirow{3}{*}{\begin{tabular}{@{}c@{}}Gwak et al. \\ (2018) \cite{Gwak:SVM_kNN_RF:2018}\end{tabular}} & \multirow{3}{6cm}{PSD, HR, EOG and simulator data} & \multirow{3}{2.5cm}{Expressions and performance} & SVM & 78.60\% \\

     &  &  & kNN & 75.30\% \\

     &  &  & Random Forest & 81.40\% \\
    \hline

    \begin{tabular}{@{}c@{}}Li et al. \\ (2018) \cite{Li:SEED-VIG_SVR:2018}\end{tabular} & 100 from EEG and 36 from EOG & PERCLOS & SVR & CC: 0.76$\pm$0.23
    RMSE: 0.17$\pm$0.06 \\
    \hline

    \multirow{2}{*}{\begin{tabular}{@{}c@{}}Chakladar et\\al. (2020) \cite{Chakladar:TD_SVM_RF:2020}\end{tabular}} & \multirow{2}{6cm}{PSD, mean, SD, Skewness, Kurtosis, AR and Approximate Entropy} & \multirow{2}{3cm}{NASA-TLX from 1 to 9} & SVM & 83.33\% \\

     &  &  & Random Forest & 83.00\% \\
    \hline

    \multirow{5}{*}{\begin{tabular}{@{}c@{}}Cui et al. \\ (2021) \cite{Cui:Oz_survey:2021}\end{tabular}} & \multirow{5}{*}{Oz EEG channel} & \multirow{5}{*}{Reaction time} & Decision trees & 60.70\% \\

     &  &  & Random Forest & 62.60\% \\

     &  &  & kNN & 63.42\% \\

     &  &  & Gaussian Naive Bayes & 67.44\% \\

     &  &  & SVM & 69.72\% \\
    \hline

    \multirow{5}{*}{\begin{tabular}{@{}c@{}}Our \\ framework\end{tabular}} & \multirow{5}{*}{PSD and EOG} & \multirow{5}{*}{PERCLOS} & SVM & 76$\pm$10\% \\

     &  &  & kNN & 85$\pm$5\% \\

     &  &  & Decision Trees & 80$\pm$9\% \\

     &  &  & Gaussian Process & 71$\pm$10\% \\

     &  &  & Random Forest & 86$\pm$6\% \\
    \hline

    \end{tabular}}
\end{table*}
\section{Conclusions}\label{sec:5_conclusions}
Drowsiness while driving is a major source of accidents and fatalities. To try to improve this situation, this research presents a framework for drowsiness detection in driving scenarios employing BCIs based on EEG, where different algorithms and feature vectors are used for regression and three-class classification. This is done for both individual and scalable models, where the first ones offer predictions for just one subject, whereas the latter are capable of estimating sleepiness in various subjects despite not having been trained with data from them. In particular, three configurations of scalable models are evaluated, based on the percentage of users used to evaluate the models that are not included in the training phase. To evaluate the framework, the SEED-VIG dataset is used, which contains a total of 23 experiments performed in a driving simulator involving 21 different subjects. The labels to be predicted are PERCLOS values whose discretization is obtained via a dynamic PERCLOS discretization algorithm, taking into account the physiological particularities of each subject.

The results obtained suggest that PSD features are highly relevant when estimating drowsiness since the best performance for almost every tested algorithm involved PSD, regardless of the learning technique or type of model used. Also, this research illustrates that algorithms such as kNN, RF, or DT may perform better than SVM, the most used algorithm in the literature. Furthermore, GP algorithms are the worst in performance, due to the intrinsic properties of the EEG signals.

Lastly, looking at the drowsiness detection performance of the different trained models, the individual models offer the best results, with the limitation of being restricted to a single subject, not being scalable and valid for new subjects. Next, 100 models, which use the 100\% of the subjects for training and testing, provide remarkably similar results to the previous ones while reducing the complexity of the experimentation into a single model. Finally, the performance of 90-10 and 70-30 models, which reserve the 10\% and 30\% of subjects for evaluating the models, respectively, show the possibility of predicting drowsiness in subjects not involved during the training phase of the model.

As future work, this study first proposes the generation of a dataset using a BCI of our own, aiming to compare the current results with those obtained with this equipment. Next, it is intended to apply deep learning algorithms for drowsiness estimation, as they are becoming increasingly popular in the literature and could provide better results. It is worth mentioning that preliminary tests have been performed with this approach, offering promising results. Lastly, it is planned to continue working with the scalable 90-10 and 70-30 models to obtain more realistic and robust models capable of predicting drowsiness on a larger set of new subjects.
\section*{Funding}
This work has been partially supported by (a) Bit \& Brain Technologies S.L. under the project CyberBrain: Cybersecurity in BCI for Advanced Driver Assistance, associated with the University of Murcia (Spain), (b) the Swiss Federal Office for Defense Procurement (armasuisse) with the CyberSpec (CYD-C-2020003) project, and (c) the University of Zürich UZH.

Signal Processing (eess.SP); Machine Learning (cs.LG)


Electronic structure of Ba(Fe,Ru)2As2 and Sr(Fe,Ir)2As2 alloys

Abstract: The electronic structures of Ba(Fe,Ru)$_2$As$_2$ and Sr(Fe,Ir)$_2$As$_2$ are investigated using density functional calculations. We find that these systems behave as coherent alloys from the electronic structure point of view. In particular, the isoelectronic substitution of Fe by Ru does not provide doping, but rather suppresses the spin density wave characteristic of the pure Fe compound by a reduction in the Stoner enhancement and an increase in the band width due hybridization involving Ru. The electronic structure near the Fermi level otherwise remains quite similar to that of BaFe$_{2}$As$_{2}$. The behavior of the Ir alloy is similar, except that in this case there is additional electron doping.

\section{introduction}

The discovery of unconventional superconductivity
in proximity to magnetism for layered Fe-based
materials\cite{kamihara08,delacruz,singh-du,mazin,dong,chen}
has led to considerable interest in both establishing the interplay
between magnetic order and superconducting state,
and searching for effective ways of tuning them.
The phase diagrams typically show a spin density wave (SDW)
that competes with superconductivity, i.e. superconductivity
generally appears when the SDW is suppressed either by doping with electrons
or holes, which reduces the nesting by making the electron and
hole Fermi surfaces mismatched or by pressure,
\cite{alireza}
which increases hybridization and broadens the bands again working against
nesting.

A remarkable feature of these compounds is that, in contrast to the cuprates,
they may be doped into a superconducting state
by substitutions on the Fe-site, e.g. in Ba(Fe,Co)$_2$As$_2$ and
Ba(Fe,Ni)$_2$As$_2$. \cite{sefat,ni-dope}
In these alloys the electronic structure remains very similar
to that of the parent Ba(Sr)Fe$_2$As$_2$, but the Fermi level is
shifted upwards corresponding to the increased electron count.
Thus one difference from cuprates is that substitution of Co and Ni
lead to the formation of a coherent alloy electronic structure rather
than the introduction of localized states associated with those ions.
Recently, it has been shown that in addition to the 3$d$ dopants, Co and
Ni, superconductivity can be induced by alloying with some 4$d$ and 5$d$
elements, including Ru, Rh, Ir and Pd.
\cite{ru_1,ru_2,ru_3,han-rh,sr_ir,zhu-pd}

Transition elements in the 4$d$ and 5$d$ rows differ from their
3$d$ counterparts in several respects.
Since $4d$ and $5d$ orbitals are much more extended than the
$3d$ orbitals there is a greater tendency towards covalency both
with ligands (e.g. As) and also in stronger metal -- metal $d$ bonds.
For example, mid-$5d$ transition elements have some of the highest
melting points of any material
(the melting points of Ir and Ru are 2739 K and
2607 K, respectively, as compared to 1811 K for Fe and 3695 K for W),
and compounds of these elements are
often extremely hard.
Thus one may expect broader bands and more hybridization with As in
the alloys with these elements. Secondly, again because of the
more extended $4d$ and $5d$ orbitals, the Hund's coupling on these
atoms is weaker than on $3d$ atoms, which works against magnetism and
is reflected in lower values of the Stoner parameter for $4d$ and $5d$
elements and compounds. Finally, the larger orbitals lead to a tendency
for higher valence states in the $4d$ and $5d$ series, so that
Ru$^{4+}$ and Ru$^{5+}$ compounds are more stable and more common than
the corresponding Fe compounds.

Returning to superconductivity in alloys
of BaFe$_2$As$_2$ with $4d$ and $5d$ elements,
the case of Ru is particularly interesting
because Ru is isoelectronic with Fe and therefore it may or
may not serve as a dopant.
Transition temperatures
up to $T_{c}$ $\sim$ 21 K may obtained with substantial
nominal Ru content in Ba(Sr)Fe$_{2-x}$Ru$_{x}$As$_{2}$, $x_{\rm nom}\sim$0.7
although
Ba(Sr)Ru$_{2}$As$_{2}$ shows neither magnetic order
nor superconductivity.\cite{baru2as2}
One possibility is that Ru serves as a dopant, supplying carriers
to the Fe planes. \cite{ru_1,ru_3}
For example, Ru might occur as Ru$^{4+}$, in which case empty localized
$d$ states associated with Ru atoms would occur above the Fermi energy,
while the Fe derived valence bands would show higher filling reflecting
electron doping by two carriers per Ru.
Another possibility is that alloy shows a coherent electronic structure
that is distorted from the pure Fe compound, but does not show additional
states,
similar to the Co and Ni doped materials.
In this case, the effect of Ru could be similar to that of pressure,
broadening the bands, increasing hybridization and/or lowering the
effective Hund's coupling and thereby destroying the SDW in favor
of superconductivity.

Here, we report density functional studies of the electronic structure
of BaFe$_{2-x}$Ru$_{x}$As$_{2}$.
It is found that the substitution of Fe with Ru gives a
quite similar electronic structure
to that of BaFe$_{2}$As$_{2}$
near the Fermi level $E_{F}$.
Importantly, this substitution
does not result in doping since we find no additional flat
bands reflecting Ru states in supercell calculations and consequently
the exact Luttinger's theorem compensation of electron and hole surfaces is
maintained in the same way as in the pure compound without the SDW.
Thus, Ru substitution does not
introduce additional electrons to this system.
Instead the SDW magnetic order is suppressed by the decreasing Stoner
term and increased hybridization.
We also performed the calculation for 5$d$ transition metal,
Ir alloyed SrFe$_{1-x}$Ir$_{x}$As$_{2}$,
which was reported to superconduct with $T_{c}$ $\sim$ 22 K.\cite{sr_ir}
We also find an electronic structure characteristic of a coherent alloy
for this non-isoelectronic, Co column transition metal.
We find electron doping as expected with additional one electron per Ir,
which cooperates with the reduction of Hund's coupling
to destabilize the SDW order.

\section{first principles calculations}

Our first principles electronic structure
calculations were performed within the
generalized gradient approximation (GGA) of
Perdew, Burke, and Ernzerhof (PBE),\cite{pbe}
using the general potential linearized augmented planewave
(LAPW) method, with the augmented planewave plus local orbital implementation.
\cite{wien,sjostedt,singh_book}
LAPW spheres of radii 2.3$a_{\rm 0}$ for Ba, Ir and
2.1$a_{\rm 0}$ for Fe, As, Ru were employed.
We used well converged basis sets determined
by $R_{\rm min}K_{\rm max}$=8.5, where $R_{\rm min}$ is the radius
of the smallest LAPW sphere and $K_{\rm max}$ corresponds to the
planewave cutoff for the interstitial region.
We included relativity at the scalar relativistic level.
Local orbitals were included to accurately treat the semi-core states.
The Brillouin zone sampling for self-consistent calculations was
done using the special \textbf{k}-point method,
with a 24x24x24 grid for body-centered ThCr$_{2}$Si$_{2}$
structure and a 21x21x9 grid for the quadrupled
tetragonal supercells with partial Ru and Ir
substitution (see below).

\section{Ruthenium Substitution}

We first calculated the electronic structure of completely Ru substituted
non-superconducting BaRu$_{2}$As$_{2}$ to check
whether additional bands or significant changes in the
band shapes are introduced by Ru.
The experimental tetragonal lattice constant
$a$ = 4.152 {\AA} and $c$ = 12.238 {\AA}\cite{ru_latt}
were employed and the internal As coordinate $z_{\rm As}$ were optimized
by total energy minimization as 0.3528.
For this material, we checked for but did not find
magnetic order of either
ferromagnetic or antiferromagnetic character,
consistent with recent experiments.\cite{baru2as2}
Fig. \ref{bands} shows the calculated band structure,
in comparison with that of
non-spin-polarized BaFe$_{2}$As$_{2}$ as obtained with the same approach.
As may be seen, the general features of band structures around
$E_{F}$ for two compounds show quite close similarity and no new bands appear
in BaRu$_{2}$As$_{2}$.
In particular, there are similar compensating electron Fermi surface
sections at the zone corner and hole sections at the zone
center ($\Gamma$-Z direction).
Especially at the zone corner, there is a very strong similarity of the
electron cylinders in the two compounds.
However, for BaRu$_{2}$As$_{2}$ we do find a somewhat different structure
of the hole Fermi surfaces, which are
centered near Z as compared to BaFe$_{2}$As$_{2}$ where
hole bands exist along the $\Gamma$-Z direction.
This yields a closed hole Fermi surface in the $k_z$ direction
in BaRu$_2$As$_2$.
This more 3D shape is suggestive of more Ru -- As hybridization,
which is also seen in the projections of the electronic density of
states (DOS).
In any case,
the position of $E_F$ with respect to the compensating position between
the hole and electron band edges is maintained similar to non-spin-polarized
BaFe$_2$As$_2$.
This is different from the non-isoelectronic compounds,
BaCo$_{2}$As$_2$\cite{baco2as2} and
BaNi$_{2}$As$_2$,\cite{bani2as2} which also show rather
similar electronic structures to the Fe compound,
but with the $E_{F}$ shifted to higher energy corresonding to the
higher electron count. This shift of the Fermi energy results in
dramatically different physical properties.

\begin{figure}
\includegraphics[width=2.5in,angle=0]{band.eps}
\includegraphics[width=2.5in,angle=0]{band_fe.eps}
\caption{Calculated electronic band structure of
(a) BaRu$_{2}$As$_{2}$ with the relaxed $z_{\rm As}$,
comparing with that of
(b) BaFe$_{2}$As$_{2}$.
The bands are plotted along high-symmetry directions in the
body-centered tetragonal Brillouin zone, and $X$ point corresponds to the zone
corner $M$ point in the tetragonal Brillouin zone.
For BaFe$_{2}$As$_{2}$,
we used the experimental lattice parameter
$a$ = 3.9625 {\AA} and $c$ = 13.0168 {\AA} (Ref. \onlinecite{fe_latt})
and non-spin-polarized GGA optimized As height $z_{\rm As}$ = 0.344.}
\label{bands}
\end{figure}

\begin{figure}
\includegraphics[width=3.0in]{supercell_dos.eps}
\caption{(Color online)
Comparison of the calculated electronic DOS for the three
BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$ supercells, $A$, $B$ and $C$
as described in the text.
}
\label{ss-comp}
\end{figure}

\begin{figure}
\includegraphics[width=3.0in]{Ru_dos.eps}
\includegraphics[width=3.0in]{Fe_dos.eps}
\caption{(Color online)
Calculated total DOS and projections
for BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$ (top),
using the quadrupled supercell $A$ (see text).
The total DOS is on a per formula (BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$) basis
while the projections are per atom.
The total and Fe $d$-projected DOS for BaFe$_{2}$As$_{2}$ (bottom)
are presented for comparison.
}
\label{Ru-Fe_dos}
\end{figure}

\begin{figure}
\includegraphics[width=3.2in]{Ir_dos.eps}
\caption{(Color online)
Total and projected electronic DOS of
SrFe$_{1.5}$Ir$_{0.5}$As$_{2}$,
calculated in the same way as that of BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$.
The tetragonal lattice parameters from experiment (Ref. \onlinecite{sr_ir})
$a$ = 3.95 {\AA} and $c$ = 12.22 {\AA} were used for supercell simulation.}
\label{Ir_dos}
\end{figure}

We used supercell calculations to explicitly study the effects of
partial Ru and Ir substitution.
For this purpose we used a $\sqrt{2}$x$\sqrt{2}$ doubling
in plane, and also doubled the cell along the $c$-axis by going to
the conventional tetragonal cell as opposed to the body centered cell.
This leads to a quadrupling of the ThCr$_2$Si$_2$ structure cell.
We then replaced one Fe by Ru or Ir in each plane.
This corresponds to a composition of BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$
(nominal Ba$_{4}$Fe$_{6}$Ru$_{2}$As$_{8}$) or
SrFe$_{1.5}$Ir$_{0.5}$As$_2$.
For Ba$_{4}$Fe$_{6}$Ru$_{2}$As$_{8}$ we did calculations for three
different arrangements of the Ru. These were with the two Ru directly
on top of each other ($A$), shifted by one Fe-Fe distance ($B$) and
shifted by one lattice parameter, $a$ ($C$).
The tetragonal lattice parameter for BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$,
$a$ = 3.98 {\AA} and $c$ = 12.95 {\AA} were taken from Ref. \onlinecite{ru_1}
and the internal coordinates were optimized by energy minimization.
As shown in Fig. \ref{ss-comp}, the electronic structures for these
three supercells are very similar. The values at the Fermi energy for the
three cells are
$N(E_F)$=3.17 ($A$), $N(E_F)$=3.14 ($B$), and $N(E_F)$=3.17 ($C$).
In the following we focus on results for supercell $A$, since
the same conclusions would be drawn based on the others.

It is found that, as the result of larger size for Ru$^{2+}$,
apart from expanding distances within Fe-Ru planes,\cite{ru_1}
the Ru-As distance (2.41 {\AA}) is also slightly larger than the
Fe-As distances (2.30 {\AA} -- 2.35 {\AA}), and accordingly the Ba layers
are also distorted.
The calculated DOS is shown in
Fig. \ref{Ru-Fe_dos} in comparison with that of BaFe$_{2}$As$_{2}$.
We did not find any additional peak associated with extra flat bands
introduced by Ru substitution.
This and the shape of the DOS reflecting bands of mixed Fe and Ru character,
as opposed to separate Fe and Ru derived bands,
indicate that the electronic structure of
the Fe-Ru system is that of a coherent alloy as might be anticipated
from the similar electronic structures of
BaRu$_{2}$As$_{2}$ and BaFe$_{2}$As$_{2}$.
In addition, it can be clearly seen that the shape of total
DOS near $E_{F}$ is almost unchanged after Ru substitution,
except that the values decrease somewhat.
This decrease
mainly results from the enlarged $d$ band width as the result of
increased hopping between transition metals and hybridization
involving Ru.
$N(E_{F})$ is reduced to
3.17 eV$^{-1}$ per BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$,
as compared to 3.28 eV$^{-1}$ for BaFe$_{2}$As$_{2}$
(note that these GGA values are somewhat larger than the LDA values,
e.g. $N(E_F)$=3.06 eV$^{-1}$ for BaFe$_2$As$_2$
in Ref. \onlinecite{bafe2as2}).
In any case, we can conclude that no additional electron carriers are
introduced to Ru alloyed system in the sense
that the band filling is unchanged.

The general shape of our density of states is similar to that reported by
Paulraj and co-workers. \cite{ru_1}
However, there are significant differences in detail.
As mentioned, we
find a decrease in the value of $N(E_F)$ upon alloying rather than
an increase.
We find that for BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$
the distribution of Fe $d$ states is almost the
same as in non-spin-polarized BaFe$_{2}$As$_{2}$,
giving the main contribution to the states near $E_{F}$ and
only modestly mixing with As $p$ states.
In contrast, Ru $d$ derived bands form a peak at $\sim$-3.5 eV and overlap
in energy with As $p$ states concentrated within the region of
-5.5 eV to -2.5 eV, and thus more strongly hybridized with them in
spite of the larger Ru-As distance.
This results in a reduced Ru $d$ contribution to the states
near $E_{F}$.
Thus the contribution to $N(E_{F})$ from Ru $d$ states is lower by
half than that of the Fe $d$ states. This plays an important role in
the
decreased $N(E_{F})$ for the BaFe$_{1-x}$Ru$_{x}$As$_{2}$ system
and is a consequence of Ru-As hybridization.

\section{suppression of the SDW}

As mentioned, understanding the suppression of the SDW order is
important.
It is convenient to discuss the magnetic susceptibility,
$\chi({\bf q})$, which is given in the random-phase approximation
by the enhanced Lindhard susceptibility
$\chi({\bf q})=\chi_0({\bf q})~[1-I({\bf q})\chi_0({\bf q})]^{-1}$,
where
$\chi_0({\bf q})$ is the bare susceptibility, which is a density of
states like term
and $I({\bf q})$ is the Stoner parameter, whose ${\bf q}$ dependence
reflects the changing band character on the Fermi surface.
In BaFe$_2$As$_2$ and other undoped Fe-based materials,
the high $N(E_F) \propto \chi_0(0)$
with the large Stoner parameter $I$ ($\sim$0.9 eV,
characteristic of a 3$d$ transition element,
with $N(E_F)$ now on a per spin per Fe basis)
\cite{andersen}
puts them near the Stoner criterion ($N(E_{F})I >$ 1) for itinerant
ferromagnetism magnetism. \cite{singh-du}
Further, the strong Fermi nesting between approximately
size-matched electron and hole sections yields on top of this a
peak in $\chi_0({\bf q})$ at the zone corner.
This explains the SDW instability at the nesting
vector (1/2,1/2).

Turning to the Ru alloyed system, on the one hand,
more hybridization with As $p$ states and the larger size of the Ru
4$d$ orbital relative to the
Fe 3$d$ orbital cause a reduction in $N(E_{F})$, as mentioned.
On the other hand, the atomic-like $I$ is reduced to the value
of $\sim$0.6 eV for the mid-4$d$ transition metal, Ru.\cite{andersen}
For this coherent alloy system,
the Stoner parameter is the average of the atomic Stoner parameters
weighted by the squares of the partial contributions of the
different $d$ orbitals to the $\chi_0$ (i.e. $N(E_F)$ for ${\bf q}$=0).
\cite{andersen,averageI}
The rather smaller $N(E_{F})$ of Ru $d$ states as mentioned would further
reduce the contribution from Ru to the average Stoner parameter.
Considering both $I$ and $N(E_F)$ it is clear that the
Ru alloy is much less magnetic than the pure Fe compound.
The same factors will apply to the SDW instability, and provide
the explanation for its suppression upon Ru alloying seen both
experimentally, and in our direct density functional calculations.

\section{iridium substitution}

Finally,
we also calculated the electronic structure for 5$d$ transition metal,
Ir alloyed system, SrFe$_{1.5}$Ir$_{0.5}$As$_{2}$,
As shown in Fig. \ref{Ir_dos}, the substitution of Fe with Ir also leads
to an electronic structure characteristic of a coherent alloy.
Compared with BaFe$_{1.5}$Ru$_{0.5}$As$_{2}$,
the scale of total DOS is further reduced,
reflecting still stronger hybridization and expanded band width.
This is seen for example in the large Ir contribution to the
As $p$ derived bands at $\sim$ -4 eV and the correspondingly
reduced Ir contribution to the metal $d$ bands from
$\sim$ -2 eV to 2 eV relative to $E_F$.
More importantly, $E_{F}$ clearly shifts upwards towards the
bottom of the pseudogap, which reflects additional electrons that are
doped into the $d$ bands
by alloying this Co column transition metal.
The doping amounts to one carrier per Ir since, as for Ru, the electronic
structure is coherent and no additional bands are introduced.
The value of $N(E_{F})$ is 2.91 eV$^{-1}$ per formula of
SrFe$_{1.5}$Ir$_{0.5}$As$_{2}$.
In addition, we note that
the Stoner parameter of Ir is rather low, $I_{\rm Ir}$ $\sim$ 0.5 eV.
\cite{andersen}
Thus, the suppression of SDW order in this Ir-alloyed system\cite{sr_ir}
may be attributed to effects of both a
decreased Stoner factor and electron doping.

\section{summary and conclusions}

In summary,
we show based on density functional calculations
the alloying BaFe$_2$As$_2$ with Ru and SrFe$_2$As$_2$ with Ir
results in the formation of a coherent electronic structure without
additional localized states associated with the impurity atoms.
As such,
the suppression of SDW magnetic order
for the Ru alloyed Ba(Sr)Fe$_{2}$As$_{2}$ system is due to the increased
hybridization and a reduced average Stoner parameter reflecting the
different chemistry of $3d$ and $4d$ transition elements.
A similar consideration applies to alloying with Ir, although in that
system Ir also provides doping.
We note that scattering due to Ru/Ir disorder in the actual alloys
might also play a role in suppressing the SDW, since scattering
generally works against a nesting induced instability.
Also it
should be mentioned that the detailed role of 4$d$ and 5$d$ transition
metals on the interplay
between magnetism and superconductivity in Fe-based superconductors
might be quite complex.
For example, Ru alloying is found to completely suppress
SDW order in the PrFe$_{1-x}$Ru$_{x}$AsO system but no superconductivity
emerges, at least in samples investigated to date.\cite{1111_ru}
However,
Ir doped LaFe$_{1-x}$Ir$_{x}$AsO is reported to show
superconductivity with $T_{c}$ up to 10.5 K.\cite{1111_ir}
Further studies will be helpful in understanding these differences.
In any case, substitution of Fe with 4$d$ and 5$d$ transition metals
in Fe-based materials provides another avenue for suppressing SDW
magnetic order and thereby inducing superconductivity in Fe-based materials,
even in the absence of doping.

\acknowledgements

We are grateful for helpful discussions and
assistance from A. Subedi.
This work was supported by the Department of Energy,
Division of Materials Sciences and Engineering.