{'fraction_non_alphanumeric': 0.03770747958371414, 'fraction_numerical': 0.01978242283086176, 'mean_word_length': 5.044191019244476, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Diagnostic and prognostic EEG analysis of critically ill patients: A deep learning study

Highlights • We use deep learning to analyze EEGs of 358 acute critically ill patients.• DL is effective for clinical EEG interpretation in real-world conditions.• Confidence of the network in its own prediction correlates with the accuracy.• Features learnt for classification resemble patterns from visual EEG interpretation.• This study is a further step toward use of AI for EEG in clinical setting.


Introduction
Acute consciousness impairment (ACI) represents a particular challenging condition for neurologists and intensive medicine specialists. Caregivers try to identify the underlying etiology in order to implement specific treatments (Edlow et al., 2014;Traub and Wijdicks, 2016); in case of delayed recoveries, there is need to estimate the chances that the patient will recover (Ramos et al., 2020;Sandroni et al., 2018). Both diagnostic and prognostic assessments are based on multimodal approaches (Edlow et al., 2014;Rossetti et al., 2016). Because EEG reflects the functioning of brain neurons -the activity of which is necessarily perturbed in case of impaired consciousness -it appears suitable for diagnostic and prognostic tool regardless of the underlying etiology (Sutter et al., 2015;Young, 2000). In practice, however, the diagnostic role of EEG in critically ill patients is essentially limited to detecting nonconvulsive status epilepticus or delayed vasospasm , whereas as prognostic tool it is mainly used in post hypoxic/ ischemic encephalopathy (HIE) (Nolan et al., 2021). The limited use of EEG is partly due to the progresses of neuro-imaging, but also to the methods of interpretation. Currently, EEGs are still visually analyzed by trained neurophysiologists. Consequently, many centers have restricted access to EEG especially during nights and holidays (Gelisse et al., 2021). In addition, visual analysis is time-consuming, has limited intraand inter-rate agreements (Arends et al., 2017;Benbadis et al., 2009;Jing et al., 2019), and is inherently restricted to features recognized by humans (Meyer et al., 2021;Tjepkema-Cloostermans et al., 2013).
Computer-based analysis has been proposed to circumvent these limitations (Zubler et al., 2016;Gemein et al., 2020). Deep learning (DL) appears particularly promising, since it offers the advantage to find out by itself which EEG features are relevant for classification ("feature extraction"). As such, DL is not limited to instructions provided by human experts, and is thus more likely to unravel new important EEG characteristics. DL has been successfully used for EEG analysis for brain computer interfaces or for specific neurologic or psychiatric conditions (for comprehensive reviews see (Craik et al., 2019;Roy et al., 2019)). In the context of critical care, EEG has been mainly used for prognostication in patients with hypoxic-ischemic encephalopathy after cardiac arrest (Jonas et al., 2019;Tjepkema-Cloostermans et al., 2019) or with epileptiform activity (Zafar et al., 2021). However, all these applications are somehow artificial in that only a specific question or a single pathology is considered at the time. While DL performs very well on these narrowly defined patient groups, real-word applications will require the ability to function on a broader set of (sometimes overlapping) pathologies and under noisier conditions, and without the need to redesign the network architecture before each application.
Here, we train a DL network on a prospectively acquired cohort of critically ill patients with ACI of various etiologies to predict both etiology and outcome. We also set out to quantify the confidence of the network in its predictions and to understand the reasons for the decision by comparing the predictions of the network with the raw EEG data, which represent crucial steps before a potential clinical use in the near future.

Data acquisition
Clinical and electroencephalographic data were acquired during the multicentric study CERTA (Continuous EEG Randomized Trial in Adults; NCT03129438). Details of the study have been published elsewhere (Rossetti et al., 2018. In summary, critically ill patients > 18 y with acute consciousness impairment (GCS ≤ 11 or FOUR ≤ 12) of any etiology hospitalized on the Intensive or Intermediate Care Units of four Swiss hospitals (Lausanne University Hospital/CHUV, Bern University Hospital/Inselspital, Basel University Hospital/USB, Sion Hospital) for whom an EEG was performed for medical reasons were included. As per design of the original study, patients who had electroencephalographic or clinical signs for epileptic seizures in the last 36 h or status epilepticus in the last 96 h were excluded, along with patients who were in a palliative situation. Immediately after inclusion, patients were randomized to undergo either a continuous EEG or two standard (20-30 min) EEGs. For the present study we only considered the first EEG (or a segment during the first 2 h in case of continuous EEG). The original study and the present post-hoc analysis were approved by the local ethic commissions (Project-ID 2017-00268).
Video-EEGs were recorded with a NicoletOne system (Viasys Neurocare, Madison WI, USA). Usually, 21 or 23 electrodes according to the international 10:20-system were used; however, in neurosurgical patients, several electrodes could be omitted due to bandages or drainages. For the present study we included the largest set of electrodes present in all patients, consisting of 9 electrodes placed at positions Fp1/2, T7/8, C3/4, O1/2, Cz (the reference electrode was placed near Fpz or Cz depending on the hospital). Five minutes in absence of external stimulation were selected. No EEG was excluded because of muscle, ECG, blinking or movement artifacts. The original sampling rate was usually 250 Hz (in some cases 1000 Hz). Prior to analysis the signals were down-sampled to 50 Hz and a high pass filter with cut-off frequency of 0.5 Hz was applied.

Defining prognosis and etiology
A detailed presentation of the prognostic and diagnostic categories can be found in (Müller et al., 2020). In short, we used two different binary prognostic categorizations, namely survival vs death at 6 months, and favorable vs unfavorable functional outcome based on the Cerebral Performance Category (CPC) assessed at 4 weeks and 6 months, whereby the best value was used ("best CPC"), and dichotomized into a favorable (CPC 1 or 2) or unfavorable outcome . For etiology, we used a categorization comprising four different diagnostic classes (based on the clinical information prospectively collected during the first week after inclusion): 1) Stroke: ischemic or hemorrhagic strokes, including nontraumatic subarachnoid hemorrhage; 2) TBI: traumatic brain injury and other non-vascular neurosurgical conditions; 3) MIII: metabolic disturbance, intoxication, infection, or inflammation; 4) HIE: Hypoxicischemic-encephalopathy after cardiac arrest. In case of multiple etiologies, the more "severe" condition was chosen (e.g. a patient with both HIE and metabolic disturbance was categorized as HIE; two patients with two equally severe conditions from different categories were excluded). Patients for whom the etiology was not known during the first week after inclusion were excluded from the diagnostic prediction.

Deep learning pipeline and network architecture
We used the t-VGG GAP architecture described in (Jonas et al., 2019). Hyper-parameters were not optimized for the present study. The 1D-CNN network consisted of three blocks, each containing two convolutional layers and one max-pooling layer, followed by a global average pooling layer and an output layer. The output layer consisted of a single neuron (with sigmoid activation function) when predicting the outcome; it consisted of four neurons (with softmax activation function) when predicting the etiology. The input was one-dimensional, corresponding to the voltage in µV for a 10-second epoch, with nine channels (1 × 500 × 9). Each EEG was decomposed into 10-second epochs with 75 % overlap, which were presented independently to the network; the overall prediction for one EEG patient was obtained by averaging the prediction of all its epochs. We performed a stratified 5-fold crossvalidation to ensure that no patient was classified by a network it helped training, using each time 80 % of the patients for training the network and the remaining 20 % as the test group. Each fold contained the same percentage of each class. For training, we used the Adam optimizer to minimize the cross-entropy loss function. The DL network was implemented in Python using the Keras framework (https://keras. io) v2.3.1; the code is provided as Supplementary Material.

Model output and certainty factor
When predicting the prognosis, the value of the final output neuron encoded the predicted probability p for survival or for favorable outcome. Accordingly, the probability for death or unfavorable outcome was 1-p. The cutoff to make a binary prediction was set at p = 0.5. We introduced the certainty factor, defined as the maximum class probability max (p, 1-p), as a straightforward way to estimate the confidence of the network in its own prediction. When predicting the etiology, the output was a four-dimensional vector (p 1 , p 2 , p 3 , p 4 ) encoding the probability distribution over all four diagnostic groups. Similarly, we defined the certainty factor as max i (p i ). For both tasks we computed the detailed performance for all patients, as well as for the subgroups of patients classified with a certainty factor ≥ 0.6 and ≥ 0.75 (without retraining the network).

Explainability
Two different methods were used to explain a posteriori the decisions taken by the network. First, we analyzed visually all EEGs containing epochs classified (correctly or not) with a certainty factor ≥ 0.9. We restricted the analysis to the outcome classification based on best CPC. Second, we used the so-called Gradient-weighted Class Activation Mapping (Grad-CAM) algorithm (Selvaraju et al., 2017). This method quantifies how the classification result would be affected if different temporal segments within an epoch were to be modified, indicating which segments were discriminative for a specific class. For predicting the outcome, since the network had a single output neuron, each temporal segment was discriminative for a single class (favorable or unfavorable). For predicting the etiology, since the network had four output neurons, thus the same temporal segment could be discriminative for more than one class.

Patients
364 patients were recruited, for details see . For 6 (1.7 %) the EEG could not be exported (missing or corrupted file), resulting in the inclusion of 358 patients for the present study (32 % female, median age 67 years (interquartile range 55-75), mean age 64 +/-15). The etiology of ACI was known in 277 patients. Patients demographics are shown in Table 1.

Classification performance
Outcome Prediction: The detailed performance of the DL network for predicting the clinical outcome is presented in Table 2. When considering all patients (corresponding to a certainty factor of 50 %), the AUC was 0.721 for predicting survival and 0.703 for predicting a favorable outcome. Restricting analysis to patients for whom the certainty factor was at least 60 % increased the AUC to 0.776 for survival and 0.755 for favorable outcome; for patients with a certainty factor of at least 75 % the AUCs were 0.852 and 0.879, respectively. The performance for other values of certainty factors is illustrated in Fig. 1.
Etiology: The truth table for predicting the etiology is shown in Fig. 2. When all patients were considered (certainty factor of 25 %), the correct etiology was predicted in 54.4 % of patients; the accuracy was 36.3 % for patients with stoke, 46.8 % for TBI, 47.7 % for MIII, 74.5 % for HIE. Here also, considering only patients with a higher certainty factor increased the accuracy (Table 3).

Visual analysis of epochs classified with high confidence
157 EEGs contained at least one epoch classified with a certainty factor of ≥ 0.9, of which 68 were true positives (TP) for favorable outcome. In those TP epochs, the background was continuous with a single predominant frequency in 40 cases (e.g. Fig. 3A), continuous with mixed or alternating frequencies in 20 cases (often with short segments of monomorphic rhythmic activity, e.g. Fig. 3BC), discontinuous in 7 cases. In one case the background could not be characterized because of opened eyes. The only rhythmic or periodic patterns (Hirsch et al., 2021) were generalized rhythmic delta activity (G-RDA, present in 18 cases; Fig. 3C) and generalized periodic triphasic discharges (2 cases). Eye blinking artifacts were present in 8 cases.
Nineteen EEGs contained false positives (FP) with a certainty factor ≥ 0.9. The patterns were very similar to those in TP: continuous monomorphic rhythmic activity in 10 cases, continuous mixed frequency activity in 8 cases; one EEG contained repetitive epileptic seizures, of which the epochs at the beginning of the seizures displaying low amplitude fast activity were falsely classified as favorable outcome. As for TP, several FP epochs contained G-RDA and triphasic discharges.
Eighty-three EEGs contained true negatives (TN): 20 cases had a suppressed background; 9 an attenuated background; 25 a burstsuppression (Fig. 3E); 23 a continuous irregular background (often with fast on slow activity, whereby the fast activity was of higher amplitude than for TP or FP; Fig, 1D), 5 cases were seizures or status epilepticus, and one EEG was continuous with sporadic interictal discharges. Rhythmic or periodic patterns found in TN epochs were lateralized rhythmic delta activity (1 case) and triphasic periodic discharges (2 cases).
Finally, 34 EEGs contained false negatives (FN), which appeared similar to those in TN: 2 cases were attenuated background, 5 were burst-suppression, 29 irregular continuous background, 3 seizures, 4 sharply contoured triphasic periodic discharges (Fig. 3F), 4 cases contained large movement artifacts, 3 a high amplitude EMG artifact, and 3 showed a interhemispheric asymmetry in frequency and/or amplitude.

Discriminative features for predicting outcome
GradCAM provided two heat maps for favorable and unfavorable outcome (Fig. 3), which confirmed that the EEG patterns observed in epochs classified with high certainty were indeed relevant for prediction. In particular, posterior dominant rhythm (Fig. 3A), short segments of monomorph low amplitude fast activity such as sleep spindles (Fig. 3B), or generalized rhythmic delta activity (Fig. 3C), were discriminative for favorable outcome. By contrast, polymorphic (especially theta) activity, mixed frequencies with temporal and spatial heterogeneity (including focal slowing) or faster activity of higher amplitude superimposed on slow waves were usually discriminative for an unfavorable outcome (Fig. 3D). Suppressed segments and epileptiform activity were discriminative for unfavorable outcome (Fig. 3E). Triphasic waves were associated with unfavorable outcome when fast and sharply contoured (Fig. 3F), but could be discriminative for favorable outcome when broader and of lower amplitude. Eye blinking artifacts were discriminative for favorable, muscle artifact usually for unfavorable outcome. In many segments, however, it was not possible by inspecting the EEG data to identify the reasons for the Grad-CAM result.

Discriminative features for predicting etiology
Grad-CAM provided four maps, one for each diagnostic class (Fig. 4). A left-right asymmetry was usually discriminative for stroke (Fig. 4A); high amplitude delta activity was often associated to TBI (Fig. 4B); a mixed frequency background was usually discriminative either for MIII (when of high amplitude, or with triphasic transients) or for HIE (Fig. 4CD). Segments with a suppressed background or highly epileptiform activity were systematically discriminative for HIE (Fig. 4DF). Often, these different elements were found within the same epoch. Here also, in many cases it was difficult to understand the reasons for the GradCAM results.

Discussion
In this work we trained a deep-learning network to predict the clinical outcome of patients with ACI of various etiologies based on the EEG recorded on the intensive or intermediate care unit. The network architecture was not optimized for the present study, but taken unmodified from a previous study on prognostication in patients with HIE (Jonas et al., 2019). When considering all patients, the AUCs were slightly above 0.7 for both outcome measures; when restricting the analysis to patients with a certainty factor ≥ 60 %, the AUCs increased to ca. 0.75, and for a certainty factor ≥ 75 % to over 0.85.
Most studies using computational methods for EEG-based prognostication in the ICU are conducted on homogeneous groups, typically on patients with HIE (Beudel et al., 2014;Tzovara et al., 2016;Zubler et al., 2017;Tjepkema-Cloostermans et al., 2017Jonas et al., 2019;Alnes et al., 2021). Only a handful have been conducted on patients with impaired consciousness of various etiologies, using predefined visual (Müller et al., 2020;Zhang et al., 2011;Vassallo et al., 2021;Kang et al., 2015;Selioutski et al., 2019) or quantitative (You et al., 2018;Zubler et al., 2016) or mixed (Zafar et al., 2021) features. To the best of our knowledge, it is the first time that DL is used for this task.
In a previous work on the same cohort, a mixed approach was taken whereby a random forest classifier (RF) was used to predict the clinical outcome based on pre-defined EEG features scored visually by human experts (Müller et al., 2020). The mixed visual/RF approach reached a Fig. 3. EEG features discriminative for favorable or unfavorable outcome. 10-second EEG epochs in reduced (9 electrodes) pseudo-monopolar montage; the scale bar represents 100 µV. The two color bars under each EEG indicate the temporal segments recognized by the Grad-CAM algorithm as class-discriminative for favorable (upper bar) or unfavorable (lower bar) outcome [arbitrary units]. (A) Well-modulated alpha activity with posterior-anterior gradient discriminative for favorable outcome (M, 75y, hypoxic ischemic encephalopathy, CPC 2, predicted probability for favorable outcome (P) 0.98). (B) Rhythmic monomorphic fast activity (sleep spindles) discriminative for favorable outcome; in the same epoch a K-complex was slightly discriminative for unfavorable outcome (M, 47, hypoxic ischemic encephalopathy, CPC 1, P 0.98). (C) As illustrated in this example, generalized rhythmic delta activity (G-RDA) was much more suggestive of favorable outcome than rhythmic theta activity (M, 77y, delayed awakening after surgery not involving the brain, CPC 2, P 0.90). (D) Diffuse monomorphic theta activity of relatively high amplitude, without clear modulation or posterior-anterior gradient, discriminative for unfavorable outcome (F, 56y, ischemic stroke, CPC 5, P 0.07). (e) Suppressed segment and epileptiform bursts discriminative for unfavorable outcome; in this particular example the slower and "smooth" parts at the beginning and end of the burst were discriminative for favorable outcome. (M, 88y, hypoxic ischemic encephalopathy, CPC 5; P 0.05). (f) Triphasic waves were often predictive for unfavorable outcome, especially when sharply contoured as in this example (F, 55y, subarachnoid hemorrhage, CPC 1, P 0.03 [i.e. false negative]).
higher AUC (0.812 for survival, 0.79 for favorable outcome) than the DL network when applied to all patients (i.e. irrespective of the certainty factor). Several reasons may explain this discrepancy: First, in the visual-RF approach, classification was based on the presence of standardized visual EEG-features (Hirsch et al., 2013) scored by neurophysiologists with specific training for intensive care EEG. Thus, the algorithm relied heavily on pre-existing theoretical and practical knowledge gathered by experts over many years. By contrast, the DL network learned within few minutes based on 246 EEGs (the amount of training data in each of the 5 cross-validation trials) without any previous knowledge or explicit instruction from the programmers. Second, background reactivity was one of the features provided to the RF classifier (it became the single most important feature for outcome prediction when patients of all etiologies were included). The DL network did not benefit from this important clue since only EEG recordings without stimulus were used for this study. Finally, RF is known to be particularly efficient with small data sets, because the risk of overfitting is low. By contrast, since it performs both feature extraction and classification, DL is particularly prone to overfitting and typically requires larger amount of data (Aellen et al., 2021). Conducting a similar analysis using thousands of patients may improve a DL-based algorithm performance (Jing et al., 2019;van Leeuwen et al., 2019). The extreme variability in EEG patterns found in patients with various pathologies probably further increases the risk of overfitting. Indeed, the same DL architecture performed extremely well when applied to a more homogeneous population of patients with HIE (AUC of 0.90) (Jonas et al., 2019).
The versatility of DL is illustrated by the fact that the same network architecture, with four neurons instead of one in the output layer, could be trained to predict the etiology of ACI. When all patients were included, the accuracy was of 54 % (at a chance level of 25 %). Even though the accuracy increased for subgroups of patients with higher certainty factor, the performance might seem limited. However, the task was complicated by the overlap in diagnostic categories (for instance, a patient with HIE could also have a metabolic disturbance or an infection, Fig. 4. EEG features discriminative for specific etiologies. 10-second EEG epochs in reduced (9 electrodes) pseudo-monopolar montage; the scale bar represents 100 µV.
Color bars indicate the temporal segments discriminative for the four etiology groups: Stroke, traumatic brain injury or other neurosurgical diagnosis (TBI); metabolic, intoxication, infectious or inflammatory disorders (MIII); hypoxic-ischemic encephalopathy (HIE) [arbitrary units]. (A) Focal slowing posterior left discriminative for stroke (F, 66y, probability for stroke 0.96). (B) High amplitude rhythmic delta waves discriminative for TBI (M, 21y, TBI, probability for TBI 0.90) (C) Mixed frequencies of reduced amplitude discriminative for MIII or HIE (M, 75, metabolic encephalopathy, probability for MIII 0.76) (D) Suppressed segments and highly epileptiform activity strongly discriminative for HIE (M, 65, HIE, probability for HIE 83 %). (E) Continuous variable background with a few triphasic configured transients; the temporal segments were discriminative for MIII and/or HIE (80, F, true diagnostic HIE, probability for MIII 0.76 [i.e. error]). (F) This EEG epoch contains features that typically discriminate all four etiologies: The temporal segment with largest left-right asymmetry (between channels T3 and T4 in middle of the burst) was discriminative for stroke; the slow delta component of the same burst was discriminative for TBI; the polymorph, non-epileptiform theta activity in the second burst was suggestive of MIII; suppressed and polymorph epileptiform segments were strongly discriminative for HIE (M, 65, true diagnostic HIE, probability for stroke 0.37, probability for HIE 0.36 [i.e. error]). but only the first category would be considered as correct). More importantly, diagnostics based on the sole EEG is a very difficult task. In current clinical practice the diagnostic role of EEG is often restricted to seizure detection (Herman et al., 2015). A few studies used visual (for instance based on the Young scale (Alkhamis and Nazish, 2020)) or quantitative (using signal correlation measures (Zubler et al., 2016)) analysis for comparing patients with various etiologies at group level, however no attempt was made for classification of individual subjects.
The accuracy was better for HIE than for the other diagnostic categories. This is not surprising considering that in this pathology the cerebral grey matter is primarily lesioned, that is, the very structure producing the EEG signal. Furthermore, some EEG patterns (such as a suppressed background) were only found in this category. Finally, it is the category with the largest number of patients, so that learning might be more robust.
Artificial intelligence, and DL in particular, has often been used as a "black box". For medical applications, however, trust and explainability are of paramount importance (Kundu, 2021;Markus et al., 2021). We have addressed these crucial points by introducing the certainty factor and by confronting the network decisions with visual analysis.
The certainty factor, corresponding to the prediction probability attributed to the winning class, was used to quantify the network's trust in its own prediction. More complex alternatives exist (Gal and Ghahramani, 2016) and probabilities expressed by modern DL network do not usually correspond exactly to real probabilities (Guo et al., 2017). Despite its theoretical limitations the certainty factor was clearly related to the performance: When all patients were considered (corresponding to a certainty of 50 %), prognostication was accurate in about 2/3 of cases. By contrast, in the subgroup of patients with a certainty factor ≥ 75 %, 4/5 predictions were correct -but the number of predictions that could be made was reduced. The same applied for diagnostics. This type of reasoning is familiar to clinicians, who are used to distinguish the situations where the result of a test is useful, from those where the results lie in a grey area and do not contribute to the clinical assesment.
The certainty factor, however, was provided by the network itself, and could thus not be used to exclude biases in the training process. Moreover, it did not explain on which criteria each particular subject has been classified ("explainability"). Therefore, we compared the network output with the EEG given as input. Visual examination of epochs classified with high confidence confirmed the presence of features used also by human specialists, such as a continuous rhythmic background (Beuchat et al., 2021;Hofmeijer et al., 2015;Westhall et al., 2016), sleep spindles (Vassallo et al., 2021), G-RDA (Beuchat et al., 2021) in epochs classified as favorable outcome; or such as suppressed background and burst-suppression (Hofmeijer et al., 2015;Ruijter et al., 2019;Westhall et al., 2016), or epileptiform activity (Zafar et al., 2021) in epochs classified as unfavorable outcome.
The presence of these typical features in misclassified EEGs can explain some of the errors: A suppressed EEG in a patient with favorable outcome could be due to sedation, whereas a continuous rhythmic background with posterior to anterior gradient would also be recognized by a human expert as heralding favorable outcome, even though the patient might suffer a later complication.
Also, eye blinking and movement artifacts were found in epochs classified as favorable outcome, which makes sense, since a moving patient usually indicates a less deep coma. Incidentally, this is a reminder that biological artifacts can contribute to the clinical assessment (Caporro et al., 2019).
The use of Grad-CAM allowed us to refine our explainability analysis by ensuring that not only was a typical pattern present in an epoch, but that the time frame when it occurred was important for decisionmaking. Grad-CAM also suggested at least one new diagnostic criteria that will have to be confirmed in future studies, namely the relative amplitude of superimposed fast on low activity -low amplitude being discriminative for favorable (Fig. 3B) and larger amplitude for unfavorable outcome (Fig. 3DE). We and others have already shown that Grad-CAM can be used with EEG (Jonas et al., 2019;Li et al., 2020). The present study illustrates that Grad-CAM also works for prognostication when multiple etiologies are involved, as well as for diagnostic predictions with non-binary classes. It is important to mention, however, that saliency maps methods such as Grad-CAM highlight regions with discriminative features, but do not explain why these features are discriminative (Ghassemi et al., 2021), so that currently interpretation by a expert is still needed.
DL has become the standard technology for automatic translation, fraud detection, self-driving cars. Whether it will play an important role in clinical decision-making in the future remains an open a question. Besides obvious considerations on cybersecurity and quality of training data, the technology would have to become more accessible to medical doctors without a computer science background, which means a friendly user interface, allowing continuous learning tailored to local conditions, but without the need to reprogram the algorithm for each specific situation. This was our motivation for taking an existing architecture and train it using new data without re-optimizing the hyper parameters. Explainability will be necessary to inform patients and family and to ensure that continuous training is not done on artifacts. Finally, since most medical decisions (especially decision to withdraw life supporting treatment in comatose patients) are taken using multiple clinical and paraclinical modalities, one has to accept that a DL-system using a single modality will not reach the extremely high performance seen in other DLapplications. However, this does not mean that the information provided by a DL-based EEG reader could not be useful in a clinical setting, once its sensitivity and specificity have been well characterized. For instance the pupillary light reflex has a poor sensitivity for predicting unfavorable outcome, but can still be very useful when combined with other tests . A further step would be to integrate these different modalities (Moeskops et al., 2016;van Leeuwen et al., 2019).
Our study has several limitations, most of which derive from the design of the original prospective study during which the data was acquired. First, patients with recent status epilepticus or seizures prior to enrolment were excluded. Accordingly, we did not incorporate a category defined by an epileptic origin of ACI. Other studies have shown that DL can be effective in detecting epileptiform activity (Craik et al., 2019;Roy et al., 2019). The cohort size is relatively large for prognostication studies using intensive care EEGs, but is still relatively low for typical DL studies. Self-fulfilling prophecy is a risk in all prognostication studies. However, we estimate that this risk was low for the present study since we analyzed the first EEG, whereas only the second EEG could be used along with several other criteria (listed in (Caporro et al., 2019)) for decisions to withdraw life-supporting therapy (WLST) in patients with HIE. Moreover, EEG was not used to determine WLST in other etiologies. Finally, the definition of diagnostic classes was performed a posteriori, and contained very broad categories with clear overlap, such as metabolic disturbance or infection in patients with other categories.
The strengths of our study are that the data were carefully acquired prospectively. Since the decision to perform an EEG was made by treating physicians based on clinical considerations only, the population is very likely to resemble real-world situations where an EEG interpretation is required . Importantly, we did not exclude patients because of the presence of artifacts. Finally, we did not consider performance only, but took into account the degree of certainty with which a prediction was made, and systematically compared the input and the prediction to gain insight in the criteria learnt by the networktwo aspects which are often neglected in DL studies.

Conclusion
In this work we applied deep learning to a real-world complex clinical problem. We found that after training on a few hundred samples, a basic convolutional neural network was capable of interpreting EEGs from patients with acute consciousness impairment of various etiologies. We showed that the maximum output probability is a simple and efficient way to determine the confidence of the network in its own prediction, and that this confidence reflects the accuracy. Finally, we confirmed that a saliency map algorithm such as GradCAM was effective for EEG, even for non-binary categories. This visualization algorithm allows the neurologists and electrophysiologists to verify that the network uses legitimate EEG features (and not, for instance, nonbiological artifact). It also helps explaining errors and limitations of the methods, and -possibly -discovering new EEG patterns. The present study represents a further step towards future inclusion of DL in clinical settings.

Funding
The Swiss National Science Foundation supported this study (grant 320030_169379 to AOR, SR, VA, KS); the funding agency had no role in design of the study, analysis or decision to publish.

Data and material availability
Free release of patient information and EEG recordings has not been granted for further research by the local Ethics Commissions. Data can be obtained for verification purposes from the corresponding author.

Code availability
Code for the network and GradCAM implementation are provided as Supplementary Material.

Declaration of Competing Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.