{'fraction_non_alphanumeric': 0.02712206457925636, 'fraction_numerical': 0.007644324853228962, 'mean_word_length': 5.055360118496575, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Small Cohort of Epilepsy Patients Showed Increased Activity on Facebook before Sudden Unexpected Death

Sudden Unexpected Death in Epilepsy (SUDEP) remains a leading cause of death in people with epilepsy. Despite the constant risk for patients and bereavement to family members, to date the physiological mechanisms of SUDEP remain unknown. Here we explore the potential to identify putative predictive signals of SUDEP from online digital behavioral data using text and sentiment analysis. Specifically, we analyze Facebook timelines of six epilepsy patients deceased due to SUDEP, donated by surviving family members. We find preliminary evidence for behavioral changes detectable by text and sentiment analysis tools. Namely, in the months preceding their SUDEP event patient social media timelines show: i) increase in verbosity; ii) increased use of functional words; and iii) sentiment shifts as measured by different sentiment analysis tools. Combined, these results suggest that social media engagement, as well as its sentiment, may serve as possible early-warning signals for SUDEP in people with epilepsy. While the small sample of patient timelines analyzed in this study prevents generalization, our preliminary investigation demonstrates the potential of social media data as complementary data in larger studies of SUDEP and epilepsy.


Introduction
Sudden Unexpected Death in Epilepsy (SUDEP) remains a leading cause of death for people with epilepsy (PWE), and includes all epilepsy-related deaths not due to trauma, drowning, status epilepticus, or other identifiable causes. The incidence of SUDEP is about 0.35 cases per 1,000 person-years [1]. While research into the physiological mechanisms underlying SUDEP continue to be thoroughly studied, and new SUDEP-related guidelines for clinicians treating PWE have been published in order to minimize SUDEP risk, SUDEP incidence remains steady [2,3]. To date, the most espoused preventive strategy for SUDEP remains seizure control via appropriate self-management [4], and especially medication adherence, since a clear risk factor for SUDEP is a higher frequency of seizures [5]. While these risk factors have been disseminated broadly, including to the public, SUDEP remains a leading cause of death for PWE, leading organizations such as The Institute of Medicine, American Epilepsy Society, and Epilepsy Foundation to call for increased study into SUDEP.
Apart from research related to the ways in which providers, patients, and their families discuss SUDEP [2,6], very little behavioral research has been conducted to reveal potential behavioral or social attributes that may precede SUDEP. Should such specific attributes exist, they would provide an area of preventive intervention for SUDEP. In this study, we utilize digital behavioral data and investigate its potential for uncovering behavioral signatures preceding SUDEP that could be leveraged as early-warning signals to inform self-management interventions in PWE. As patients are known to not fully recall important events or even display recognizable behavior change during clinical consultations, digital behavioral data, such as social media data, can offer a complementary view of patient behavior of clinical significance [7]. Specifically, we use text and sentiment analysis to evaluate temporal changes in emotional states and communication patterns of the subjects in the study. The methodology gives us the unique opportunity to examine longitudinally the emotional states of a cohort of PWE with a known outcome of SUDEP. Our preliminary results show that social media may reveal behavioral experiences leading up to SUDEP, and thus guide areas for SUDEP-preventing interventions. This study also demonstrates the successful use of alternative, real-world data sources in studying SUDEP [7,8].
Psychological stress is known to increase the risk of certain diseases, like the common cold [9]. Directly related to PWE, stress and major life events are known to increase the risk of seizures, which in turn can increase the risk of SUDEP [10,11]. However, direct physiological measurements of stress involves expensive and invasive tools. A compelling alternative is to measure stress and other cognitive states indirectly in self-reported digital behavioral data, such as in social media posting on Facebook. This is one of the focuses of the interdisciplinary field of affective computing, which has developed methods to measure human emotion (including stress) via linguistic and other computer-based features, such as keystroke dynamics [12]. For instance, Pennebaker [13] found a correspondence between textual features and physiological signals of stress. Similarly, Vizer, Zhou, & Sears [14] found that increased lexical complexity (diversity of words) tends to correspond with increased physical or cognitive stress. However, such studies are often conducted in controlled laboratory conditions, asking participants to write essays with particular prompts. This is not the case with social media, where users write posts spontaneously without being prompted in laboratory settings. Our assumption is that stress and other mood states influence whether and how a social media post is written, and can thus be measured via textual analysis of those posts. A substantial body of literature already reports that social media data enables quantitative measurement and prediction of various behavioral processes of biomedical relevance, i.e. a real-world data source to study "humans as their own model organism" [7]. Indeed, social media data has already been shown to be useful, alone or in combination with other data sources, for a variety of other biomedical problems. For instance, data from Twitter and Instagram helps in the detection of health conditions including the spread of flu pandemics [15], warning signals of drug adverse reactions [16], human reproduction [17], and even depression [18]. Social media users who self-reported their diagnosis of depression have been shown to exhibit distorted modes of thinking (cognitive distortions) in their writing, an early warning that can lower the burden of this underdiagnosed condition and leading cause of disability worldwide [19]. A long list of successful applications using social media data for biomedical and health-related problems is discussed in our recent review [7].
To infer relevant cognitive states in our cohort of deceased SUDEP subjects we use textual and sentiment analysis of their social media posts. These methods were originally developed to determine the positive or negative feelings expressed in natural language texts towards specific product ratings, often used for marketing purposes [20,21]. However, a number of sentiment analysis tools have been developed from psychological experiments, and can be used to model the emotional states of authors based on their written text [7]. In fact, sentiment analysis has been very useful to track various individual and cohort specific behaviors of relevance to biomedicine, especially mental health [17,7,19]. Similarly to other domains, these computational methods are likely to be useful to characterize the behavior of SUDEP cohorts, including any possible stress markers hidden in their social media discourse that can be leveraged to inform interventions aimed at improving self-management, a key predictor of epilepsy-related outcomes. Next, we detail the data gathering, textual methods, and three different sentiment analysis tools we apply to our SUDEP cohort.

Materials and methods
We began by eliciting families from which a member was known to have died of SUDEP. To do so, we advertised our research goals on the bulletin boards of the Epilepsy Foundation website and epilepsy-related Facebook groups. We also distributed information about our study to the Epilepsy Foundation's SUDEP Institute, which passed on the information to members of SUDEP bereavement groups within the Institute. The Epilepsy Foundation website is one of the most popular sites for people with epilepsy. All procedures were evaluated by the Indiana University Institutional Review Board, who ultimately deemed that the study was exempt/not human subjects research. Family members self-referred to our study via email, and were given information about the study, its goals, and were also informed that participation was voluntary. We received about 20 inquiries from families who wanted to donate social media content from their deceased family members. From these, a majority of users had Facebook accounts, and only a few had Twitter or Instagram accounts. Due to data availability we decided to focus our analysis solely on Facebook timelines. This yielded a small cohort of n = 12 Facebook timelines (four males and eight females) from which we had timelines to collect data from. For six subjects we obtained full login information, and for the remaining we had varying viewing access to timeline posts, as listed in Table 1.
Data collection for subjects with login information was conducted through an in-house developed application using Facebook 's official application programming interface (API). Family members logged into the deceased Facebook account and accessed a specific app webpage. The app then collected all of the subject's timeline posts, including text, metadata (e.g., date, posting device, etc), and the number of likes, comments and shares. Similarly, when only viewing access to the subject's timeline was available, family members (or a researcher when family was unable/unavailable) were instructed to scroll the deceased timeline, thus loading all posts, and export the subject's timeline content as an html file. A script developed in-house was used to process the html file, collecting text, available meta-data, and number of likes, comments, and shares from posts. Importantly, unlike the app-collected timelines that made use of subject's login information, timelines collected via the html-scraping script may not contain all subject posts, as privacy settings putatively put in place by the subject may have blocked the person collecting the data from viewing them in the first place. In addition, in 2009 Facebook made a significant change to their interface: the prompt to the post box changed from "Update your Status", followed by "<Subject name> is..." to "What's on your mind?". Naturally, we believe this interface change may elicit a different response from the user. To avoid any possible interface bias in our analysis, we only consider subject posts that occurred after 2009, when the change took place. All collected data were securely stored within our servers for further analysis. For each subject Table 1 lists basic demographic, subject posting time range, and any notable life event discussed by the subject on their Facebook timeline in the month preceding their SUDEP, which was manually annotated by the researchers. The number of posts collected for each subject varies widely, from only 4 posts written by Subject 12, all the way to 2,271 posts written by Subject 2 (see Table 1). The average number of posts per subject is 726. In total, we collected and processed 8,717 posts with text that were written after 2009, when considering all 12 subjects. However, because some subjects had very little number of posts-as is the case of Subject 12-we opted to limit our analysis to subjects with more than 500 posts that contained text and were written after 2009. In other words, next we only present results on subjects 1-3, 6, 8, and 10, a cohort of n = 6 subjects. These subjects are highlighted in Table 1.
Textual content of individual posts were processed using the dictionaries of three sentiment analysis tools: Affective Norms for English Words (ANEW) [22], Valence Aware Dictionary for sEntiment Reasoning (VADER) [23], and Linguistic Inquiry and Word Count (LIWC) [24]. These three tools are widely used in the sentiment analysis literature. In fact, VADER and LIWC were consistently among the best tools for 3-class polarity classification (negative, neutral, or positive emotion) across a number of corpora in a benchmark comparison study [25].
Dictionaries were used to match against single words in subject posts. Matched words were then scored over several sentiment and textual dimensions per post. For instance, ANEW includes ratings from 1 to 9 in a dictionary of 1,034 words along three dimensions: valence, from unhappy to happy; arousal from calm to excited; and dominance from controlled to in-control. These ratings were originally collected from surveys given to undergraduates in a psychology class using a 9-point Likert-like scale [22]. We used ANEW to find the mean sentiment along these three dimensions for each post by averaging the sentiments  Table 1: Demographics and data collection details for study subjects. Six subject timeline posts were collected via a custom-built app accessed using subject's login and password information. Six subject timelines were collected via html scraping of pages as visible to the public, to Facebook friends, or to friends of friends (FoF), as noted. The number of posts column tallied only posts with written text after 2009 (due to a significant Facebook interface change). * Column "window of posts" denote the number of days between a subject's first and last post.
of each word, while neglecting words absent from the dictionary. VADER [23] is a tool for measuring the intensity of positive or negative affect through lexical scores modified by syntactical rules, and is readily available as part of the Natural Language Toolkit for python [26]. In addition to dictionary-based sentiment scores, VADER looks at nearby words and modifies sentiment scores based on 5 simple rules: the presence of exclamations, capitalization, adverbs, negations, and contrasting conjunctions. Using this tool, we computed normalized scores describing the intensity of positive, neutral, and negative emotion present in each subject post. LIWC (pronounced Luke) is the third dictionary-based tool used. It was developed with a well-documented procedure of consistent categorization between a majority of human judges. The latest version of the software, LIWC2015, has dictionaries containing nearly 6,400 words and evaluates text across nearly 90 linguistic and sentiment variables, including summary variables, pronouns, articles, cognitive processes, time focus, personal concerns, and informal language categories [24,27].

Results
Assuming some type of stressor prior to SUDEP, which in turn could manifest as a change in the subject's digital verbosity, first we characterize the number of words per subject Facebook post (word count) with a simple negative binomial regression. The binomial regression tests whether there was a significant difference in the amount of words per post when comparing posts written in two different epochs of the subject's digital behavior. More specifically, we compare the average number of words per post in the two months (56 days) preceding the subject's SUDEP against the average number of words per post in the rest of the available timeline. We choose the last two months as a conservative time range for a subject behavioral change that at the same time holds enough examples (posts) for a robust statistical analysis-as a 10 samples minimum is a frequently recommended heuristic for an accurate estimation of model parameters [28]. However we note that posting behavior varies between subjects and we do not know whether, or when, stressors proceedings SUDEP may appear for each subject. We also tested different epochs, ranging from one to twelve weeks prior to SUDEP. Results are consistent for subjects with sufficient data in the last period being considered, and are shown in Fig. S1. From our six analysed subjects, subjects 1, 2, 6, and 10 had significantly higher word count in the two months preceding their SUDEP. Subject 8 also had a higher word count in the last two months, albeit not significant at p < 0.05. Conversely, subject 3 had a significantly lower word count in the last two months. Results are shown in Table 2 and Figure 1 shows the average word count for each subject timeline. Two regressions are fitted to the data highlighting the slope of the increase (or decrease) in subject verbosity: one considering the complete subject timeline (dotted line) and one only considering the last two months of posts (solid line).  Table 2: Significance tests for differences in word counts in posts during the last two months preceding SUDEP compared to other posts. The mean word count for the posts written during the last two months (µ last with n last samples) are compared to the mean word count of all other posts written by the subject before this period (µ early with n early samples). Significance is estimated from a negative binomial regression, with p < 0.05 highlighted in bold. Subjects are ordered according to the rank-product of the number of samples during the last month and the number prior to the last month.
Since digital behavioral changes may be reflected not only in post length but also in how frequent posts are made, next we use a zero-inflated negative binomial regression to examine whether the observed verbosity (word count) and frequency of posting prior to SUDEP was significantly different from subject's previous epochs. A zero-inflated negative binomial regression is an extension of the binomial regression where there is an assumption that a different process governs the likelihood that a subject makes no posts in a day (zero word count), which is then modeled by a logistic regression. Results are consisted and are presented in Table S2; different epochs considered are shown in Figure S2. In general we see that both subjects 1 and 2 were more likely to post in the two months preceding SUDEP, as well as writing longer posts. Perhaps due to increased model complexity, changes in subject 6's posting behavior are less significant, being less likely to post in weeks preceding SUDEP with little difference in the number of words written per day. Subject 8 and 10 were significantly less likely to post in the final weeks before SUDEP, with a non-significant increase in words per day when they did. Lastly, subject 3 did not have a significant change in the number of days with a post, but did write significantly fewer words.  Having analyzed subject verbosity, we now turn to the sentiment of the text they wrote. We remember each sentiment dimension is calculated by averaging per-word sentiment scores calculated for ANEW, LIWC, and VADER, three independent sentiment tools. In the following Figures 2-4, line plots denote the average of a specific sentiment dimension measure over all posts each week. Some particular sentiment trends can be observed in these figures. For instance, four of the six subject show an over time increase in happiness sentiment, as measured by ANEW's valence dimension (see dotted lines in Fig. 2). Only two subjects, 3 and 10, show a decrease in happiness in the last two months (solid line). Importantly, Subject 3 has an overall happiness increase but the a sharp sentiment shift in the last two months, reflected by her described feelings of loneliness of being a college freshmen. On the other hand, subject 6 has an over time happiness decrease, but a sharp happiness increase in the last two months, reflecting a sentiment shift due to her European travels. Overall, despite some subjects having reversed valence sentiment, when their complete timeline sentiment is compared to the sentiment in the last two months of posting, they all have something in common: a significant sentiment shift, as measured by the difference in slope of the two regressions.
To show this phenomena is not simply an effect of the sentiment tool of choice, Figures 3  & 4 show subject use of emotion-neutral words and functional words, measured by VADER and LIWC, respectively. Functional words includes a broad category of words such as pronouns ('him', 'she'), articles ('the', 'a'), conjunctions ('and', 'but'), interjections ('oh', 'ah'), pro-sentences ('yes', 'no', 'okay'), and others. We observe an over time increase in the average number of such words used per post for 5 of the 6 subjects (see Fig. 4). In addition, for 4 subjects the amount of functional words used increases substantially in the last two months of posting. In regards to emotion-neutral words, five of the six subjects show an increase use of emotion-neutral words-a sentiment dimension that other tools, such as ANEW, ignores (see Fig. 3). However, similarly to subject verbosity, all subjects have a drastic shift in the analyzed sentiment categories when their complete timeline is compared to the last two months, again as measured by the regression slope (see red lines in aforementioned plots).

Discussion
First, we would like to emphasize that we cannot claim SUDEP causation, or the predictive accuracy of these tools applied to the social media posts of living individuals. However, the noticeable increase in functional words and the overall verbosity preceding SUDEP for a number of subjects is particularly suggestive of some detectable changes in the digital behavior of subjects, and that may serve as early-warning signals correlating with SUDEP. It is known that stress and major life events are likely to increase the risk of epilepsy [10,11], and that in turn may increase the risk of SUDEP. Several of our subjects had major life changes in the weeks preceding their death, from concussions, moving to another city, returning from an overseas trip, or feeling lonely as a new college freshmen. In addition, the misuse of functional words has been associated with Aphasia, a language impairment attributed to the Wernicke's area, a brain area in the left (dominant) temporal-parietal region characterized by EEG abnormalities in epilepsy patients [29,30,31]. Unlike impairment to Broca's area where patients speak slow, in hesitating ways, and phrases are devoid of functional words, impairment to the Wenicke's area cause patients to speak warmly and fluidly but using functional words with no content at all [29]. We manually checked sentence construction in the   last two months of posting for our subjects and found no trace of functional words misuse aside from their increased occurrence. Nonetheless, if an increase in verbosity or changes in functional word use is indicative of stress or major life changes, the use of textual and sentiment tools may allow for a predictive, quantitative measure in larger studies, comple-menting current qualitative analyses. But we do stress that the lack of appropriate sample size and a rigorous case-control in our current study hinders generalization of our findings at this point. Nonetheless, our preliminary results serve to invite additional research into this problem, especially to encourage attention to social media and other digital behavior data, thus contributing to better prediction of warning signals of SUDEP.
One possible avenue to evaluate the potential of sentiment analysis for predicting SUDEP is to employ statistical machine learning models using the text and sentiment analysis tools we described above. We attempted to build such models to predict changes in the last day or week of posts in a subject's timeline-instead of the last two months of posts shown in regressions above. However, we encountered two common machine-learning problems, especially in shorter window scenarios. The first was over-fitting and the subsequent false positive prediction. Since sentiment tools possess many sentiment variables (dimensions), it is easy to perfectly fit posts used in training the algorithm. Yet, the resulting prediction/classification models do not generalize to predicting subject posts left out for testing. Stricter model regularization and dimensionality reduction methods can help, but in the end, using shorter prediction windows results in a classification scenario with a very large class imbalance with very few positive instances (i.e., posts preceding SUDEP) which does not allow automatic machine learning classification. This is because most posts occur when subjects are deemed healthy, and only very few instances can be safely set as being SUDEP related-those that happened right before death. Given this problem of class imbalance, classifiers for automatic prediction are not possible with our current dataset.
The second problem pertains to the labeling of posts as SUDEP-relevant. Assuming that only the last posts before SUDEP are relevant, may miss prior days and posts (positive instances) that may have been close calls for SUDEP. Without the proper labeling of these instances, our algorithms are potentially missing several learning opportunities. The twomonth window prior to SUDEP we used in the regression analysis is reasonable for the observed cohort, allowing a reasonable amount of positive posts for most subjects (see Table  S2). But the regression serves as an observation tool more than an automatic predictor. Indeed, at the current stage, social media analysis can only enhance and provide a different perspective to other health data, such as electronic health records, personal diaries, epilepsy warning devices, service animals, etc. A more systemic and complete picture of SUDEP may emerge by combining these seemingly heterogenous data sources.
Going forward, our goal is to combine clinical (e.g., physician notes, laboratory exams, genetic profiling, questionnaire responses, electronic health records) with non-clinical digital behavioral data (e.g. electronic diaries, discussion boards, email exchange, phone usage patterns, social media posting and consumption) into research design. This is planned via recruitment of epilepsy patients who consent the to the collection of their digital behavioral data, such as social media IDs [7]. Our own work with focus groups of epilepsy patients and their caretakers have demonstrated willingness to donate digital behavioral data for studies. Indeed, as shown in the work we report here, this can be even done postmortem to avoid an observer bias-patients changing their behavior by knowing they are being observed. With enough subjects to account for the increase in variables, the next step is to validate the predictive power of social media signals in case-control experiments. We intend to focus on specific questions such as: why are subjects writing or using certain words more often prior to their death? Can this be statistically correlated with an increased risk of SUDEP? Can we pinpoint a behavioral phase shift to inform self-and caretaker-management as an early warning? The preliminary results we now report demonstrate the feasibility of extracting such signals. As we recruit additional subjects in planned larger studies, it will be possible to answer these questions more quantitatively and conclusively.
To compile additional digital behavioral data sources, our team is currently developing myAura [32], a personalized web service for epilepsy management. MyAura will include self-reported patient diaries, such as seizure tracking, food and water intake, medication adherence, physician encounters, among others. One of its goals is to test a variety of clinical and non-clinical temporal variables that may be proven useful in epilepsy management. The use of patient donated social media timelines, as we have shown here, can prove to be the next frontier in informing our understanding of SUDEP and other epilepsy outcomes. MyAura will include the option for users to donate their social media timelines, thus allowing the recruitment of larger patient cohorts. Findings from analysis of the data of larger cohorts is likely to inform self-management recommendations for PWE, including allowing for SUDEPpredicting behaviors to be identified. For instance, patients with epilepsy could be monitored for an increased risk for SUDEP. In addition, our text and sentiment analysis could be used to inform individualized self-management interventions based on patient's posts and behaviors. At the same time behavioral results can help direct physiologic studies, as cellular-level or biomarker changes can, for example, ultimately be correlated with behavioral experiences (e.g. cortisol and physiologic or psychological stress).
As a small pilot, our study has demonstrated the feasibility of mining social media data for SUDEP (and other epilepsy-related) research, as well as very preliminary findings regarding increased social media activity preceding SUDEP. While the sample size of this study is too small to render generalizations in terms of SUDEP prediction, our work here demonstrates the feasibility of a novel way of investigating epilepsy-related phenomena, including SUDEP. This work also demonstrates the value in the interdisciplinary collaboration between clinical/behavioral epilepsy researchers and informatics/complex systems scientists.  Table S1: Statistics from a Negative Binomial Regression on Word Count per Post. µ 1 and n 1 correspond to the mean word count and number of posts before the last two months, while µ 2 and n 2 correspond to the mean word count and number of posts during the last two months before SUDEP. Also included are the intercept of the regression, the coefficient on the last month indicator variable time coef , its standard error time se , the p-value of the coefficient time p , and the dispersion parameter θ with its standard error θ se .

Supplementary Materials
A negative binomial model is often used to model over-dispersed count data, i.e. when the variance is considerably larger than the mean [33]. Here a negative binomial model is estimated through a generalized linear regression with log link function on word count per post over a dummy variable representing whether the post's word count occurs during the last month. The significance of the time-indicator dummy variable estimates the significance of the change in the last month over all other posts. As shown in Table S1 we see significant increases in the word count per post for four subjects at p < 0.05. The table is ordered according to the rank product of the number of posts before and during the last two months preceding SUDEP, and the two with the greatest number of posts in both periods by rank product are also the two with the greatest increase in word count, subjects 2 and 1, with two additional subjects showing significant increases, subject 6 and 10. There are five subjects with decreases in word count per post, with subject 11 and subject 3 with significant decreases.
An alternative formulation is to examine word count per day rather than per post. Perhaps some subjects additionally start posting short posts with increased frequency during periods of stress. However, many days contain zero posts, thus zero words, for most subjects. We can model this with a zero-inflated negative binomial model that also estimates a probability that no words will be posted [33,34]. As shown in Table S2 we see that subject 2 and 1 still have significant increases in word count per day (columns time coef and time p ) and both are significantly more likely to post during the last 2 months (columns 0 time coef and 0 timep , note the negative coefficient corresponds to a lower probability of having no posts on a given day). Subjects 8 and 10 are significantly less likely to post during the last two months. Subject 11, however, is significantly more likely to post during the last two months, although with significantly fewer words per day. Subject 3 is seen to have a significant drop in word count per day. Additionally, subjects 7 and 5 are significantly more likely to post in the last two months, but with non-significant changes in word count. This view of the posting behavior also reveals interesting patterns but is not particularly more informative than the negative binomial model per post.      Table S2: Statistics of a Zero-Inflated Negative Binomial Regression on word count per day. This is similar to Table S1, but models the word count per day rather than per post, with the addition of a logistic regression model representing the likelihood of no post at all. Included are the intercept of the regression, the coefficient on the last month indicator variable time coef , its standard error time se , the p-value of the coefficient time p . Additionally, parameters of the logistic regression on no-post probabilities are shown: the intercept 0 intercept , the coefficient on the time indicator 0 time coef and the significance of this coefficient 0 timep .