On Query: REPLACE INTO news_data (id, data, timestamp) VALUES ('%s', '%s', %i);MySQL Error Code: 1406
MySQL Error Msgs: Data too long for column 'data' at row 1
array(5) {
[0]=>
array(7) {
["file"]=>
string(25) "/app/sys/base/sql.inc.php"
["line"]=>
int(64)
["function"]=>
string(14) "ReportSqlError"
["class"]=>
string(3) "SQL"
["object"]=>
object(SQL)#1 (6) {
["CONNECTION":"SQL":private]=>
object(mysqli)#2 (18) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(14) "mysqlnd 8.4.27"
["client_version"]=>
int(80427)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(1406)
["error"]=>
string(40) "Data too long for column 'data' at row 1"
["error_list"]=>
array(1) {
[0]=>
array(3) {
["errno"]=>
int(1406)
["sqlstate"]=>
string(5) "22001"
["error"]=>
string(40) "Data too long for column 'data' at row 1"
}
}
["field_count"]=>
int(2)
["host_info"]=>
string(18) "db:3306 via TCP/IP"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(37) "11.2.2-MariaDB-1:11.2.2+maria~ubu2204"
["server_version"]=>
int(110202)
["sqlstate"]=>
string(5) "22001"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(390312)
["warning_count"]=>
int(0)
}
["URL":"SQL":private]=>
string(7) "db:3306"
["USER":"SQL":private]=>
string(8) "retrofox"
["PASS":"SQL":private]=>
string(16) "TreeakWqQPD9qnWR"
["DB":"SQL":private]=>
string(8) "retrofox"
["DROP_VALUES":"SQL":private]=>
array(1) {
[0]=>
string(0) ""
}
}
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(69) "REPLACE INTO news_data (id, data, timestamp) VALUES ('%s', '%s', %i);"
}
}
[1]=>
array(7) {
["file"]=>
string(25) "/app/sys/base/sql.inc.php"
["line"]=>
int(75)
["function"]=>
string(5) "Query"
["class"]=>
string(3) "SQL"
["object"]=>
object(SQL)#1 (6) {
["CONNECTION":"SQL":private]=>
object(mysqli)#2 (18) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(14) "mysqlnd 8.4.27"
["client_version"]=>
int(80427)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(1406)
["error"]=>
string(40) "Data too long for column 'data' at row 1"
["error_list"]=>
array(1) {
[0]=>
array(3) {
["errno"]=>
int(1406)
["sqlstate"]=>
string(5) "22001"
["error"]=>
string(40) "Data too long for column 'data' at row 1"
}
}
["field_count"]=>
int(2)
["host_info"]=>
string(18) "db:3306 via TCP/IP"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(37) "11.2.2-MariaDB-1:11.2.2+maria~ubu2204"
["server_version"]=>
int(110202)
["sqlstate"]=>
string(5) "22001"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(390312)
["warning_count"]=>
int(0)
}
["URL":"SQL":private]=>
string(7) "db:3306"
["USER":"SQL":private]=>
string(8) "retrofox"
["PASS":"SQL":private]=>
string(16) "TreeakWqQPD9qnWR"
["DB":"SQL":private]=>
string(8) "retrofox"
["DROP_VALUES":"SQL":private]=>
array(1) {
[0]=>
string(0) ""
}
}
["type"]=>
string(2) "->"
["args"]=>
array(4) {
[0]=>
string(69) "REPLACE INTO news_data (id, data, timestamp) VALUES ('%s', '%s', %i);"
[1]=>
string(86) "foxapi_article2_SNgSFz1UYwUgnAye8Iq6AwimFnBOT9jdyRE0kXeBSMWDBytDmFWIqUjBzXoAEIULeJjOhk"
[2]=>
string(82309) "{"id":"SNgSFz1UYwUgnAye8Iq6AwimFnBOT9jdyRE0kXeBSMWDBytDmFWIqUjBzXoAEIULeJjOhk","title":"Human\u2013artificial intelligence collaboration for comanaging epilepsy in real time","description":"One-third of the world\u2019s 70 million people with epilepsy have seizures uncontrolled by medication, and implantable devices are a promising treatment. These devices can detect impending seizures, missed medication and impaired cognition, but, like most medical devices, they cannot share this information with patients in real time. This is a missed opportunity for devices to learn from clinical events and teach patients how their behaviors affect their health. Here we present a device platform that converses with patients to help them manage their epilepsy. The inpatient prototype links scalp and intracranial electroencephalography (EEG) to a secure, large language model-based artificial intelligence (AI) that communicates bidirectionally through a smartphone app. The AI processes biomarkers of sleep, medication, cognition and seizure probability, notifies patients of clinical events and trends, records symptoms and responses, and uses their feedback to retrain its seizure detector, reducing false alarms. We validated this platform in 13 patients who are undergoing video-EEG monitoring for epilepsy (scalp, n\u2009=\u200911; intracranial, n\u2009=\u20092). In a pseudoprospective simulation, seizure detectors improved precision from patient feedback alone, without expert intervention. We propose this system as a scalable, safeguarded platform for medical devices that can rapidly adapt to patient and provider needs across epilepsy and other medical conditions. A small epilepsy monitoring study shows that a moderated, large language model-based chat interface lets patients converse with their electroencephalography monitoring in real time, using a smartphone, and patient feedback cut seizure-detector false alarms by about 80% without clinician input.","author":"Litt, Brian","source":"Nature","publish":"October 13, 2026, 10:23 am","canonical":"https:\/\/www.nature.com\/articles\/s41591-026-04680-4","text":["Main\r\nMore than one-third of the world\u2019s 70 million people with epilepsy continue to have seizures despite aggressive treatment with medications. Some are candidates for functional surgery (removing or laser-ablating seizure-generating brain regions), but only half will become seizure free after two years1. Implantable devices are an exciting, less invasive alternative that improve seizure control without surgery\u2019s most severe side effects, such as cognitive impairment or mood disorders.","However, seizure freedom is rare with devices.\r\n\r\nEven for the two-thirds of patients with medication-responsive epilepsy, living \u2018seizure free\u2019 but reliant on medication presents ongoing challenges. These individuals are at risk for seizure relapses triggered by common life events\u2014missed medications, sleep deprivation, pregnancy or taking commonly prescribed medications that increase seizure risk. There is a need for technologies that help people live with epilepsy, because clinical treatment often fails to provide complete seizure freedom.\r\n\r\nFDA approved only three devices to treat epilepsy.","Whether open loop (stimulating in fixed cycles agnostic to neural activity) or closed loop (stimulating in response to preprogrammed detection criteria), they reduce seizures gradually, plateauing at a median seizure reduction of up to 75% 9 years after deployment in the most positive studies2. Roughly 30% patients improve minimally or not at all. Although some devices can store and transmit small amounts of data asynchronously, none share it in real time. This is a missed opportunity to present useful information to patients that the device \u2018knows\u2019 but has no way to convey.","This could include changes in seizure risk, the presence of known seizure precipitants or detecting specific patient behaviors that may be either beneficial (for example, getting more sleep) or detrimental (for example, consuming alcohol or some medications) to controlling seizures.","Similarly, current devices prevent patients from configuring them to their needs and lifestyle; they lack mechanisms to richly annotate data and cannot efficiently retrain algorithms with minimal physician interaction.\r\n\r\nNew minimally invasive electroencephalography (EEG) devices are poised to dramatically change seizure management with their ability to continuously collect data from patients during normal daily life. These devices vary from small, battery-powered single-channel scalp motes to subgaleal implants and wearable devices3. Some devices can transmit continuous EEG data to smartphones and subsequently to the cloud4, where the data are processed and viewable by clinicians.","Wearable devices monitor movement, heart rate and other peripheral parameters to alert families to convulsive seizures. Yet none offer bidirectional interfaces that let patients communicate and interact with them in real time.\r\n\r\nTo our knowledge, no prior literature describes interactive epilepsy devices that communicate bidirectionally with patients or their specifications. Early work instead focuses on warning of impending seizures and forecasting seizure-free periods5,6.","Grounding our design in the published literature on the lived experience and stated priorities of people with epilepsy and their caregivers7,8,9,10,11, together with our group\u2019s clinical experience, we propose that an optimal interactive epilepsy device should (1) present sensor-derived information (here scalp or intracranial EEG (iEEG)) intelligibly; (2) answer patient queries with actionable text and figures matched to their level of function; (3) provide an intuitive, low-latency conversational interface for surveys and two-way voice or text; (4) use patient responses to annotate data and retrain adaptive algorithms; (5) govern the appropriateness, truthfulness, safety and security of its output; and (6) let experts efficiently review and annotate data for patient care and to improve performance.\r\n\r\nIn the following sections, we describe a platform that performs these functions and report results from prospective testing on 13 patients admitted to the Hospital of the University of Pennsylvania epilepsy monitoring unit (EMU) for continuous video and scalp (n\u2009=\u200911) or iEEG (n\u2009=\u20092) monitoring.\r\nResultsPatient recruitment\r\nWe conducted a prospective, single-center observational study to evaluate a real-time patient\u2013artificial intelligence (AI) interface for clinical utility and usability (see Methods for detailed study procedures).","Thirteen adult EMU inpatients undergoing continuous EEG monitoring to characterize seizures for presurgical evaluation were enrolled (scalp EEG, n\u2009=\u200911; iEEG, n\u2009=\u20092; Table 1 and Supplementary Fig. 1) without altering standard-of-care treatment.","Throughout their EMU stay, participants were encouraged to interact with the platform and provide feedback on their experience.\r\nTable 1 Patient demographics (n\u2009=\u200913)\r\nFull size table\r\nDevice platform\r\nThe platform comprises the following three systems: (1) software that extracts real-time EEG data and metadata from the hospital network; (2) a HIPAA-compliant cloud analytics environment that analyzes the data stream; and (3) a smartphone app with integrated conversational AI for bidirectional communication.","The system messaged patients to deliver clinical information, alerts and surveys, while patients used the app to query their physiological data, explore trends and annotate symptoms to provide labels for seizure-detection algorithms (Fig. 1).\r\nFig. 1: Platform overview.\r\na, Patient\u2013AI interface in the EMU. Left: patients undergoing continuous scalp or intracranial video-EEG monitoring connect to the platform through a smartphone application. EEG data streams from the EMU to a secure cloud environment for real-time processing. Right: representative screens showing bidirectional interaction modes, including system-initiated alerts (seizure alarms, surveys) and patient annotations.","The interface delivers neurophysiological visualizations, such as seizure heatmaps and sleep hypnograms, directly within the chat stream.","b, Cloud processing and AI system. Left: real-time neurophysiological biomarkers extracted from EEG data, including seizure probability, sleep staging, spike rates and brain synchrony, are compiled in a structured database. Right: the LLM-based AI system manages patient interactions and queries this database to synthesize responses.\r\n\r\nPatients received surveys thrice daily (morning, afternoon and evening; consisting of 10\u201315 questions about mood, anxiety, sleep, energy level and well-being; Supplementary Tables 4\u20137). Real-time EEG data streamed from the hospital network to the cloud infrastructure, where pretrained models extracted seizure probabilities (SPaRCNet12, WaveNet13 and ONCET (William K. S.","Ojemann, unpublished work)), interictal spikes (SpikeNet14 and a custom iEEG spike detector15) and sleep stages (YASA16; Supplementary Tables 2and 3). Additional features included phase synchrony (a biomarker for antiseizure medication (ASM) load17) and estimated ASM load derived from medical records. These measures capture seizures, clinical events, sleep architecture and medication-related changes that can alter seizure risk. In a post hoc linear mixed-effects analysis, phase synchrony rose as medication load fell (correlation coefficient\u2009=\u2009\u22120.315, 95% confidence interval (CI)\u2009=\u2009\u22120.337 to \u22120.293; Extended Data Fig.","1).\r\n\r\nTwo AI modes supported interaction\u2014\u2018general chat\u2019 for conversation and subjective logging, and a \u2018data agent\u2019 that retrieved and synthesized the above neurophysiological features from the study database to answer patient questions. HIPAA-compliant instances of GPT-4o-mini (OpenAI) power the AI system (Fig. 2; Methods).\r\nFig. 2: Platform technical architecture and AI framework.\r\na, Cloud infrastructure and real-time data streaming. The platform integrates on-premises clinical data acquisition with HIPAA-compliant cloud services. Continuous EEG signals are acquired through clinical workstations and relayed through a cloud-hosted virtual machine to Azure Event Hubs for ingestion.","Simultaneously, clinical metadata, including medication dosing and logs, are retrieved through the Sickbay platform. Data are processed within a Databricks environment using Delta Live Table pipelines for preprocessing, feature extraction and real-time clinical event detection. Automated analyses are performed by dedicated serving endpoints that host deep learning models and other algorithms. A HIPAA-compliant version of GPT-4o-mini is used in the AI system.","b, Directed state machine architecture of the AI system. All incoming patient messages and outgoing AI responses pass through moderation nodes that evaluate safety and clinical compliance. A message router classifies inputs as either \u2018general chat\u2019 for regular conversation or \u2018data query\u2019 for clinical information retrieval. Data queries are subsequently evaluated for scope and ambiguity. Valid queries are handled by a \u2018data agent\u2019 using a ReAct (reasoning and action) loop. This agent invokes SQL tools to inspect database schemas and execute secure queries against the Unity Catalog, where patient data are stored.","The agent maintains a persistent state, including conversation history and multimodal context (text and images) for context-aware interactions.\r\nPatient engagement\r\nWe analyzed the 1,307 messages exchanged between the 13 patients and the AI (Fig. 3a). Median patient participation, due to limited time in the EMU, was 4.87 days (interquartile range (IQR)\u2009=\u20093.85\u20136.11; Table 1). The system initiated 68.9% (n\u2009=\u2009900) interactions, consisting primarily of \u2018general chat\u2019 messages (43.1%), scheduled surveys (13.7%) and clinical event notifications (10.3%). Patients initiated the remaining 31.1% (n\u2009=\u2009407) interactions.","Patient activity was predominantly conversational\u201488.5% (n\u2009=\u2009360) patient-initiated messages were \u2018general chat\u2019, indicating comfort using the platform for everyday conversation and subjective logging. The remaining 11.5% were data queries about seizure events (5.9%, n\u2009=\u200924), sleep metrics (3.7%, n\u2009=\u200915) and interictal spike rates (1.9%, n\u2009=\u20098).\r\nFig. 3: Patient engagement and technical performance of the AI system.\r\na, Distribution of total messages (n\u2009=\u20091,307) exchanged between patients (n\u2009=\u200913) and the system, stratified by initiator (system versus patient) and interaction category.","b, Grouped bar plots illustrating the percentage of patient responses received across progressive time intervals for four categories\u2014general chat, surveys, seizure events and spike events.","c, Survey response rates and EEG event validation. Left: bar plots showing patient response rates for morning, afternoon and evening surveys (n\u2009=\u200948 each). Right: stacked bar plots for real-time seizure (n\u2009=\u200958) and interictal spike alerts (n\u2009=\u200933), showing both the response rate and patient-provided annotations (\u2018yes\u2019\/true positive, \u2018uncertain\u2019 or \u2018no\u2019\/false positive).","d, Response latency comparison between the \u2018general chat\u2019 and \u2018data agent\u2019 nodes. Box plots show median and IQR; whiskers extend to 1.5\u00d7 IQR. ***P value < 0.001.","e, AI agent performance. Left: message router accuracy (n\u2009=\u200978). Right: \u2018data agent\u2019 accuracy (n\u2009=\u200938).","f, SUS scores (n\u2009=\u20095), mean score (83\/100)\u2014\u2018excellent\u2019 usability range. An asterisk indicates that 200 automated (non-AI-generated) \u2018general chat\u2019 messages were excluded from the latency analysis. A dagger \u2018\u2020\u2019 indicates that seven patient \u2018general chat\u2019 messages erroneously routed to the \u2018data agent\u2019 were excluded from the \u2018data agent\u2019 accuracy analysis.\r\n\r\nResponse dynamics varied with urgency (Fig. 3b). Seizure queries elicited the fastest engagement, with 44.8% responses occurring within 10\u2009min and response rates reaching 60.3% within 30\u2009min. Conversely, notifications for spike events elicited the lowest engagement, plateauing at 27.3% within the first hour.","This likely reflects the lower patient prioritization of biomarkers that are often asymptomatic and imperceptible. Survey response rates reached 55.0% before their 3-h expiration. \u2018General chat\u2019 interactions accumulated steadily over the full 12\u201324-h window, consistent with patients treating these interactions as an asynchronous task compatible with the routine inpatient environment.\r\n\r\nPatient\u2013AI interaction enabled patient-in-the-loop validation of automated detections. Engagement with high-priority alerts was high\u2014patients responded to 67.2% real-time seizure detections (n\u2009=\u200958), annotating them as true seizures (15.5%, n\u2009=\u20099), false positives (37.9%, n\u2009=\u200922) or uncertain (13.8%, n\u2009=\u20098; Fig.","3c, Extended Data Table 1 and Extended Data Fig. 2). This provided a source of discriminatory labels for algorithm fine-tuning that is absent in passive monitoring. Survey adherence was highest for morning surveys (62.5%, n\u2009=\u200930), likely driven by the subsequent daily sleep report, versus afternoon (43.8%, n\u2009=\u200921) and evening (54.2%, n\u2009=\u200926).\r\n\r\nFor the two AI modes (\u2018general chat\u2019 and \u2018data agent\u2019), response latency differed significantly\u2014median difference of 6.75\u2009s (95% CI = 4.99\u20138.65; Mann\u2013Whitney U test, P<\u20090.001, rank-biserial r\u2009=\u20090.857; Fig. 3d).","\u2018General chat\u2019 was near real time (median latency\u2009=\u20091.95\u2009s; IQR\u2009=\u20091.57\u20134.11), whereas the \u2018data agent\u2019, which generates SQL and queries the database, was slower (median\u2009=\u20098.69\u2009s; IQR\u2009=\u20096.67\u201311.79). Despite the increased complexity of data retrieval tasks, \u2018data agent\u2019 reliability was nonetheless high\u2014executing retrieval tasks with 92.1% accuracy (n\u2009=\u200935\/38; Fig. 3e). The message router, which classified and directed patient messages to \u2018general chat\u2019 or \u2018data agent\u2019, achieved 89.7% accuracy (n\u2009=\u200970\/78; Fig. 3e). Misclassified messages are detailed in Supplementary Table 9. The moderation system flagged and blocked 1.47% (6\/407) patient messages and 0.0% (0\/900) AI-generated messages.","On review, all flags were benign (Supplementary Table 8 and Supplementary Results) and daily investigator audits confirmed no unsafe or clinically inappropriate messages (Methods).\r\n\r\nPatient feedback on usability was positive. The mean System Usability Scale (SUS)18 score was 83 of 100 (n\u2009=\u20095; individual scores\u2009=\u200972.5\u2013100; Fig.","3f), placing the system in the \u2018excellent\u2019 range and suggesting that it was accessible and intuitive for patients to use in an acute hospital setting.\r\nSeizure detection\r\nAccurate seizure detection is essential, yet current algorithms do not generalize well19. We collected real-time patient feedback on seizure detections as weak labels and simulated prospective rolling fine-tuning without clinician input (Fig. 4). As a baseline, validated models (SPaRCNet for scalp EEG and ONCET for iEEG) evaluated against technician-annotated and clinician-annotated events had a median event-level sensitivity of 0.83 (IQR\u2009=\u20090.35\u20131.00; n\u2009=\u200911) and a false alarm rate of 0.47 per hour (IQR\u2009=\u20090.35\u20130.77; n\u2009=\u200913; Extended Data Fig. 3).","We first used patient push-button seizure alarms, standard in the EMU and available for all patients (n\u2009=\u200913; Fig.","5b), as labels, treating the window from 1\u2009min before to 2\u2009min after each alarm as seizure (sensitivity\u2009=\u20090.66 (41\/62), precision\u2009=\u20090.60 (50\/84); Extended Data Fig. 2d). Models were updated every 3\u2009h when predefined criteria were met (Methods; Fig. 5a) and each iteration was evaluated on unseen data against baseline.\r\nFig. 4: Workflow for fine-tuning seizure-detection models.\r\nPretrained seizure-detection models produced seizure probability time series from preprocessed EEG windows; thresholds were then applied to generate binary predictions and identify discrete seizure events.","Upon detection of a seizure event, a push notification was sent to the patient for confirmation, allowing responses of \u2018yes\u2019, \u2018no\u2019 or \u2018uncertain\u2019. These responses were converted into labels for fine-tuning\u2014seizure annotations were labeled as 1, uncertain annotations as NaN and all other labels as 0. Models were fine-tuned every 3\u2009h, with only the last few layers trainable while all other layers remained frozen to prevent catastrophic forgetting. To further improve performance, a clinician-in-the-loop approach was implemented every 24\u2009h. Ten 90-s EEG segments with the least confident predictions were selected and reviewed by clinicians for fine-tuning.","conv, convolutional layer; FC, fully connected.\r\nFig. 5: Patient-in-the-loop and clinician-in-the-loop fine-tuning improves seizure detection.\r\na, Evaluation strategy for patient-in-the-loop fine-tuning. Left: the baseline model was fine-tuned sequentially every 3\u2009h when predefined criteria were met. Yellow squares indicate time blocks used for fine-tuning. Middle: performance change from baseline for each fine-tuned model on future unseen data (green squares) and the median across models. Right: performance comparison across the full EMU stay simulating prospective fine-tuning, where each model was deployed on future data (pink outline) until the next fine-tuned model became available, against baseline (blue outline).","Outlined squares indicate the time blocks during which the baseline or fine-tuned models were active.","b, Fine-tuning performance in offline validation using patient-initiated push-button alarms as labels (n\u2009=\u200913).","c, Fine-tuning performance using patient responses to seizure alerts through the phone app as labels (n\u2009=\u20096).","b, c, Middle: median change from baseline in seizure event sensitivity, F1 score and false alarms per hour after fine-tuning. Each dot represents one patient. Boxes indicate the IQR with the central line representing the median; whiskers extend to 1.5\u00d7 IQR. Right: paired baseline versus fine-tuned performance across the EMU stay.","d, Change in seizure-detection performance after clinician-in-the-loop fine-tuning (n\u2009=\u20095). Gray lines indicate individual patients, and the black line shows the median change across patients.","AUPRC, area under the precision-recall curve; FT, fine-tune.\r\n\r\nAcross patients, fine-tuning reduced false alarms per hour by a median of 77.8% (absolute difference\u2009=\u2009\u22120.306; 95% CI\u2009=\u2009\u22120.629 to \u22120.202; Wilcoxon signed-rank test, P\u2009=\u20090.007, r\u2009=\u2009\u22120.92; Fig. 5b) and increased F1 score by 115.4% (absolute difference\u2009=\u20090.017; 95% CI\u2009=\u20090.029 to 0.163; P\u2009=\u20090.023, r\u2009=\u20091.00; Fig. 5b).","Simulating prospective deployment across the EMU stay (most recent fine-tuned model immediately deployed), false alarms fell by 77.2%, from 0.469 (IQR\u2009=\u20090.349\u20130.774) to 0.097 (IQR\u2009=\u20090.081\u20130.168; median difference\u2009=\u2009\u20130.293; 95% CI\u2009=\u2009\u22120.615 to \u22120.211; P\u2009=\u20090.007, r\u2009=\u2009\u22120.91) and F1 score rose 66.2% from 0.063 (IQR\u2009=\u20090\u20130.194) to 0.160 (0\u20130.348; median difference\u2009=\u20090.109; 95% CI\u2009=\u20090.055 to 0.153; P\u2009=\u20090.008, r\u2009=\u20091.00), while preserving baseline sensitivity (median\u2009=\u20091.00, IQR\u2009=\u20090.43\u20131.00).\r\n\r\nWe then fine-tuned using prospective seizure annotations collected through the platform.","The annotation feature was unavailable for the first 2 participants; for the 11 remaining patients, clinicians confirmed 59 seizures. The system sent 58 alerts and six patients provided annotations that confirmed events (Supplementary Table 1). Raw seizure alerts had low sensitivity of 0.136 (8\/59) and precision of 0.138 (8\/58). Patient-confirmed annotations had relatively high accuracy, with a sensitivity of 1.0 (5\/5), precision of 0.71 (5\/7) and negative predictive value of 1.0 (19\/19). Overall sensitivity was 0.085 (5\/59; Extended Data Fig. 2).","Experts marked all uncertain events (n\u2009=\u20097) as nonseizure.\r\n\r\nFine-tuning with platform annotations reduced false alarms by 80.9% (absolute difference\u2009=\u2009\u22120.543; 95% CI\u2009=\u2009\u22120.825 to \u22120.17; P\u2009=\u20090.038, r\u2009=\u2009\u22120.91; Fig. 5c) and increased F1 score by 158.4% (median difference\u2009=\u20090.110; 95% CI\u2009=\u20090.056 to 0.389; P\u2009=\u20090.038, r\u2009=\u20091.00; Fig. 5c).","Across the EMU stay, false alarm rate decreased by 80.0%, from 0.736 (IQR\u2009=\u20090.201\u20131.090) to 0.104 (IQR\u2009=\u20090.060\u20130.187; median difference\u2009=\u2009\u22120.588; 95% CI\u2009=\u2009\u22120.942 to \u22120.166; P\u2009=\u20090.038, r\u2009=\u2009\u22120.91) and F1 score increased by 189.2%, from 0.021 (IQR\u2009=\u20090.004\u20130.071) to 0.143 (IQR\u2009=\u20090.073\u20130.300; median difference\u2009=\u20090.131; 95% CI\u2009=\u20090.065 to 0.229; P\u2009=\u20090.038, r\u2009=\u20091.00).","Fine-tuning with push-button alarms in matched patients (n\u2009=\u20096) produced a false alarm rate of 0.107 (IQR\u2009=\u20090.082\u20130.147; median difference\u2009=\u20090.02; 95% CI\u2009=\u2009\u22120.037 to 0.061) and an F1 score of 0.130 (IQR\u2009=\u20090.025\u20130.258; median difference\u2009=\u2009\u22120.041; 95% CI\u2009=\u2009\u22120.123 to \u22120.006), with no statistically meaningful difference between the two groups (false alarms\u2014P\u2009=\u20090.688, r\u2009=\u20090.238; F1 score\u2014P\u2009=\u20090.087, r\u2009=\u2009\u22120.867).\r\n\r\nWe also implemented a clinician-in-the-loop framework in which the system flags uncertain predictions for expert annotation (Fig.","4), adding a layer of verification against performance degradation during real-time fine-tuning. This was simulated by providing ground-truth labels for model-requested segments. Clinician-in-the-loop fine-tuning decreased false alarm rate by 82.6%, from 0.210 (IQR\u2009=\u20090.159\u20130.255) to 0.044 (IQR\u2009=\u20090.022\u20130.068; median difference\u2009=\u2009\u22120.188; 95% CI\u2009=\u2009\u22120.382 to \u22120.102; P\u2009=\u20090.038, r\u2009=\u2009\u22121.0) and increased F1 score by 271.5% (median difference\u2009=\u20090.193; 95% CI\u2009=\u20090.106 to 0.31; P\u2009=\u20090.038, r\u2009=\u20091.0; Fig.","5d).\r\nDiscussion\r\nIn this study, we demonstrate a new approach to medical devices\u2014a platform that analyzes physiological activity and behavior in real time and allows two-way, spontaneous communication between patients and their devices. Using inpatient EEG monitoring equipment, together with compute, storage and large language models (LLMs) in HIPAA-compliant cloud environments, patients conversed with their devices through a smartphone application\u2014initiating conversations, receiving alerts and querying their data. Despite the limited setting and short participation duration, patients found the platform useful for understanding their condition, with 5 of the 13 spontaneously requesting access to it as outpatients.","In a pseudoprospective simulation, the system retrained from imperfect patient annotations alone, markedly reducing false alarm rates while preserving baseline sensitivity, without clinician intervention\u2014although time-efficient expert annotation further improved performance. System latencies were acceptable to this small patient cohort (~2\u2009s for conversational interactions and ~9\u2009s for complex queries that synthesized plots and data).\r\n\r\nThe clinical and scientific impact of this work is multifold.\r\nA new approach to disease management\r\nSome of the most debilitating aspects of episodic conditions like epilepsy are the unpredictability of events and managing risk, even when patients are well.","EEG devices can detect biomarkers of increased seizure risk and timely alerts can prompt action, such as taking additional or rescue medication20. A prior implantable warning system reduced seizures, lowered medication burden and improved quality of life, but delivered only one-way feedback and required manual algorithm retraining at intervals typically months apart5,6. Our platform instead enables bidirectional feedback and automates model fine-tuning every 3\u2009h from patient annotations. Despite inaccuracies from missed or delayed responses, postictal amnesia or unrecognized subclinical seizures, these weak labels nonetheless proved effective, consistent with prior work21,22.","A complementary clinician-in-the-loop strategy lets experts efficiently validate and improve upon patients\u2019 labels23, which will be important for scaling to outpatient use, where a validated system may need only rare expert review.\r\nAn expanding platform\r\nThese innovations extend beyond epilepsy to domains where patient communication can enhance device efficacy. We are readying a trial applying the platform to program deep brain stimulation devices for Parkinson\u2019s disease, where two-way patient communication coupled to parameter-search algorithms could optimize therapy more efficiently than repeated in-office programming and expand access to a therapy currently limited by specialist availability24.","Other applications include cardiac devices, insulin pumps and, most notably, neuropsychiatric treatment, where patient-expressed symptoms may inform care better than external sensors or complement them. A critical enabler in this study, however, was the availability of well-validated, pretrained seizure detectors built on more than a decade of curated EEG data. Where such foundations are lacking, a platform like ours offers a route to accelerate building them by systematically capturing patient and clinician annotations during routine use.\r\nA way to find out what matters to patients\r\nAn exit survey (n\u2009=\u20095) offered a preliminary, qualitative view of patient experience.","Three of five patients reported increased awareness of connections between their behaviors, feelings and health, describing how it helped them track daily reports and explain their sleep data. Others were more equivocal, with one noting it largely \u2018reinforced what (they) already knew\u2019. Responses were more uniformly positive about anticipated everyday use. They valued regular status updates, warnings before major seizures and access to sleep data. Feature requests were practical, centering on more reliable survey notifications and easier access to data.","These priorities align with the lived-experience literature7,8,9,10,11 and with prior device studies that emphasized recognition of relative seizure-free periods and true seizure frequency6. We anticipate that sustained engagement will derive from delivering clear day-to-day value and from letting patients configure the AI\u2019s characteristics to their needs and preferences. Such personalization was deliberately constrained in this proof of concept and, for an adaptive assistive technology, is likely to develop over months of use rather than a brief inpatient stay.","A rigorous, prospective study of user experience and needs is a priority for our planned outpatient deployment.\r\nLimitations of our results\r\nOur study reports on 13 patients in the EMU, chosen for proximity to secure computing, high-quality neurophysiology and continuous supervision. The sample is small and may carry selection bias toward technology-interested individuals, and response rates, although good for survey studies, were below 100%. The EMU is an artificial, time-limited environment in which medications are reduced and seizures are provoked for diagnosis. The information the platform could surface therefore reflects feasibility rather than the day-to-day decision support most valuable in ambulatory life.","Our brief in-app surveys are designed for low-burden, high-frequency ecological momentary assessment; they are not validated epilepsy-specific patient-reported outcome measures (for example, QOLIE-31, NDDI-E, PROMIS), and we report them as engagement signals rather than clinical endpoints.\r\n\r\nContinuous video, electrocardiogram and other routine signals were recorded but not used in these first proof-of-principle experiments. For seizure detection, fine-tuning reduced false alarms and improved F1 while preserving sensitivity, but the false alarm rate after fine-tuning (2\u20134 per day) may still burden some patients, and would need to be reduced.","Sensitivity did not improve, likely reflecting the modest, homogeneous fine-tuning dataset and deliberately conservative hyperparameters. The lightweight detectors we used, selected for real-time deployment and reliable calibration, do not reflect the state of the art25,26,27. These constraints motivate our planned outpatient deployment and evaluation on long-term data from implanted systems for epilepsy, movement, sleep and other disorders.\r\nEthical considerations\r\nEthics were extensively reviewed during study design and institutional approval. To ensure that AI interactions did not interfere with clinical care, patients were reminded that their interactions were for research purposes only and were not monitored by their care team.","Patients were instructed to press the seizure alarm button for any suspected or impending event, and to interact with the AI only afterward. Consequently, all patients self-reported seizures through the clinical system while few did so through the platform. Patients in the EMU are frequently enrolled in other research studies, receive concurrent clinical care, recover in postictal states or attend to visiting family, all of which compete for their attention and limit interaction. This tension would be resolved in settings where the AI serves as the primary mode of patient\u2013device\u2013clinician communication, such as outpatient applications.","Protections instituted by the Institutional Review Board and a dedicated AI Governance Committee included daily human review of every patient\u2013AI interaction and performing all computation and LLM inference within Penn\u2019s HIPAA-compliant cloud infrastructure, so no protected health information was exposed to public, consumer or third-party services.\r\n\r\nBeyond these safeguards, long-term deployment surfaces broader human-factors considerations that warrant careful attention. Patients may over-rely on automated systems, and how an interface represents model uncertainty and the AI\u2019s limitations will shape whether patients weigh its outputs appropriately.","Questions of clinical responsibility also become more complex once medical decisions are based in part on AI-generated outputs. How that responsibility is allocated remains to be established as these systems move toward routine care. Underlying all of this are rapidly advancing AI models, raising the question of how to continually evaluate and ensure reliable performance in medical settings.\r\nNext steps and future vision\r\nThe true impact of this paradigm lies in applying this technology in the outpatient setting to improve everyday life.","Proof of real value will require demonstrating clear benefit to patients, caregivers, providers and payers\u2014ideally reduced seizure frequency or severity, fewer emergency visits, lower resource use and improved satisfaction\u2014for which the burden of evidence is high. It may also include the ability for patients to better make everyday decisions that affect their health. The same potential holds for other brain network disorders, heart disease, diabetes and other conditions. Informatics approaches comparing patients with these \u2018intelligent\u2019 devices to electronic health record controls may hasten demonstrating this value; otherwise, controlled clinical trials will be required.","The regulatory pathway will likely be stepwise and gradual, and, much as autonomous vehicles advanced incrementally, semi-autonomous medical devices may evolve from low-level advisory systems toward more capable clinical decision-support tools for diagnosing, managing and predicting disease.\r\nConclusion\r\nWe present a vision for medical devices that converse and interact with patients to help manage disease and improve quality of life. Given the current pace of innovation in computing, AI and neuroscience, such interactions may become increasingly common over time. The science fiction literature is full of worlds where humans and intelligent devices have united in intimate ways.","We believe that, because of the great promise of this path, it is important we push forward rapidly, but acknowledge that progress requires time and iterative improvement before these systems are worthy of our trust. It is vital to proceed deliberately and carefully, anticipating conflicts, failure modes and ethical challenges while embracing the enormous potential for improving the human condition.\r\nMethodsStudy design\r\nThis prospective, single-center observational study developed and evaluated a real-time patient\u2013data interface in a level 4 EMU at the Hospital of the University of Pennsylvania.","The study was approved by the University of Pennsylvania Institutional Review Board (protocol 849276) and written informed consent was obtained from all participants before any study procedure. We recruited patients admitted to the EMU for seizure characterization as part of clinical management or presurgical evaluation. Enrollment was reported during the clinical admission and coincided with the duration of continuous video-EEG monitoring, without altering standard-of-care monitoring or treatment.","Because this proof-of-concept platform was intended to demonstrate per-patient feasibility rather than a population-level effect, we prespecified a target of 10\u201315 EMU patients based on feasibility and patient availability during the study period, rather than by a formal power calculation. Participant sex, race and ethnicity were self-reported and are summarized in Table 1.","Sex and gender were not used as variables in the study design and the study was not powered for sex-based or gender-based analyses.\r\n\r\nThe implementation and clinical use of AI in this study were reviewed and approved by the Penn Medicine AI Governance Committee, an expert body established for this project that has since been institutionalized, the Penn Medicine Information Services Architecture Review Board and a Penn Medicine Security Risk Assessment.","Together, these bodies required that all model inference and computation should be performed within HIPAA-compliant infrastructure, that the LLM endpoint be contractually prohibited from training on or retaining any data, and that all patient\u2013AI interactions undergo daily human review. Committee composition, review scope and the multitrack governance process, which we share as an example for other institutions navigating the heterogeneous policies on cloud-based clinical AI, are described in the Supplementary Methods.\r\nProcedures\r\nExpert epileptologists screened incoming EMU admissions for eligibility.","Eligible patients were \u226518 years of age, with intact capacity to provide informed consent and interact with an app on a smartphone and English proficiency adequate for study procedures. We excluded patients with self-reported pregnancy or nursing, cognitive impairment or language barriers precluding meaningful engagement, or refusal or withdrawal of consent. On the day after admission, a research coordinator obtained informed consent and activated the NeuroWorks software development kit (SDK; Natus) on the patient\u2019s acquisition workstation to allow real-time EEG data streaming.","Each patient was provisioned a study account with a unique username and password, data-stream linkage identifier, medical record number for medication log integration and an EEG modality designation (scalp or intracranial) that configured model parameters. The coordinator installed the application as a progressive web app on the patient\u2019s smartphone, authenticated the patient, enabled push notifications and demonstrated key app features, including seizure and spike alerts, morning sleep reports and scheduled survey questionnaires.","Throughout their hospitalization, patients were encouraged to ask questions through the chat interface and respond to surveys and messages through the app, and the coordinator reviewed message histories at least daily. Patients were informed that this system is a research prototype in which false-positive seizure detections were anticipated, and that all clinical seizure concerns should be directed to their care team. Patients received $25 per day of participation. Accounts were deactivated on the day of discharge after completion of the exit survey (Supplementary Table 7) and clinical data were aggregated for research use under the approved protocol.","Figure 1 provides an overview of the study platform.\r\nPlatform implementationOverview\r\nThe platform comprised the following three interconnected systems (Fig. 2a): (1) an on-premises data acquisition and relay layer that exported real-time EEG data and metadata from EMU recording stations; (2) a HIPAA-compliant cloud analytics environment that ingested, preprocessed and analyzed streaming data and persisted features and events in databases; and (3) the patient-facing app with integrated conversational AI that delivered clinical event notifications and surveys and allowed patients to ask questions about their own physiological data.","A PostgreSQL database backed the application state and messaging history, and a LangGraph-based AI agent system orchestrated data queries against a Databricks Unity Catalog through a cloud-hosted, HIPAA-compliant LLM. We chose GPT-4o-mini (version 2024-08-01-preview) because it was, at the time of study initiation, the only model in Penn\u2019s HIPAA-compliant Azure OpenAI tenancy with sufficient instruction-following and tool-use reliability for our constrained, retrieval-oriented task, at substantially lower latency and cost for continuous usage than larger contemporary models.","Its smaller capacity makes it less suited to clinical reasoning, but the AI\u2019s role was deliberately scoped to information delivery and structured data retrieval rather than autonomous clinical judgment. The modular architecture allows the underlying model to be substituted as more capable HIPAA-compliant options become available. We did not specifically train or fine-tune the LLM, nor use rolling LLM-generated summarization. Each node in the AI system used a dedicated system prompt (Supplementary Table 10).\r\nReal-time EEG data acquisition and streaming\r\nContinuous scalp and iEEG signals were acquired using clinical Natus systems at 256 and 1,024\u2009Hz, respectively, and automatically downsampled to 512\u2009Hz during transmission.","The Natus NeuroWorks SDK provided real-time access, exposing ZeroMQ sockets for data, study information and event injection on the hospital network. A cloud-hosted virtual machine subscribed to the hospital-side publishers, retrieved sampling and channel metadata through the SDK and batched raw samples into 1-s windows. Batches were compressed (gzip), base64 encoded, annotated with channel names, timestamps and patient identifiers and forwarded to Azure Event Hubs using shared-access-signature authentication. Our configuration had four throughput units, each supporting up to 1\u2009MB of data or 1,000 events per second, with automatic scaling during periods of high input volume.","Given that a 1-s EEG packet is estimated to be 0.03\u20130.04\u2009MB for scalp EEG and 0.35\u2009MB for 250-channel stereoelectroencephalography (SEEG), the system can support at least 10 SEEG patients or 100 scalp EEG patients concurrently. Event Hubs fed a Databricks streaming pipeline that performed canonical EEG preprocessing, feature computation and model inference, writing outputs to Delta tables within a Unity Catalog.\r\nCloud data processing and feature extractionPreprocessing\r\nEEG signals were bandpass filtered (0.5\u2013100\u2009Hz for scalp EEG, 0.5\u2013250\u2009Hz for iEEG) and notch filtered at 60 and 120\u2009Hz to suppress powerline noise.","Bad channels were identified using a validated, custom artifact rejection algorithm (Supplementary Methods) and excluded before rereferencing to common average (CAR) or bipolar montages, as required by specific algorithms. Bipolar pairs rendered unavailable due to bad channels were retained but labeled as contaminated. Rereferenced signals were then prewhitened. Data from each stage were stored in dedicated Delta Live Tables on Databricks (Supplementary Tables 2 and 3).\r\nScalp EEG seizure detection\r\nFor scalp recordings, we used SPaRCNet12, a seizure-detection model trained on over 6,000 EEG recordings from 2,711 patients to distinguish among six types of ictal-interictal injury continuum patterns.","Per model design, inputs were 10-s windows of bipolar data with 2-s overlap. A segment was considered a seizure if the probability of the lateralized periodic discharges (LPD) class exceeded a data-adaptive threshold, defined as the mean seizure probability of +1.2 s.d. over a 400-s sliding window with a 100-s stride. We used the LPD class instead of the seizure class due to its empirically higher sensitivity, potentially reflecting misclassification of seizure segments as LPD.","We then used a cumulative sum strategy where a cumulative statistic was calculated as:\r\n\r\n$$S\\left(t\\right)=\\max \\left(0,S\\left(t-1\\right)+P\\left(t\\right)-k\\right)$$\r\n\r\n(1)\r\n\r\nwhere P(t) denotes the seizure probability at time t, and k represents the adaptive threshold. A seizure detection was declared when S(t) exceeded the decision threshold (h\u2009=\u20093). The parameters were empirically selected based on validation results from an independent EMU dataset. The detected samples were subsequently smoothed using binary opening and closing operations.","Consecutive detections separated by less than 2\u2009s were merged, and merged events shorter than 10\u2009s were discarded, as seizures typically last longer than 10\u2009s.\r\niEEG seizure detection\r\nFor intracranial data, we evaluated both WaveNet13 and ONCET (William K. S.","Ojemann, unpublished work) during inference and selected ONCET for fine-tuning based on its superior performance. WaveNet uses causal, dilating convolutional layers trained to discriminate between seizure and nonseizure neural activity. It accepts single-channel EEG data as input and adapts to variable channel counts in iEEG recordings. Following the inference pipeline described in the original publication, 1-s segments of bipolar, prewhitened data were downsampled to 128\u2009Hz and normalized using a robust scaler fitted on nonictal segments. Sensitivity analyses demonstrated minimal performance differences across scaler fitting durations from 1 to 20\u2009min, so we used the first 10\u2009min of available data.","ONCET is a seizure-annotation model trained on more than 1 million clips of single-channel iEEG recordings of interictal, seizure onset and seizure spread activity from 87 patients28. It uses dilating residual convolution blocks with expanding receptive fields, attention and feature compression to classify ictal activity, achieving an area under the receiver operating characteristic curve (AUROC) of 0.94 on the held-out test set and 0.95 on a gold-standard validation set29. ONCET inference follows similar preprocessing steps to WaveNet but operates on data downsampled to 256\u2009Hz by default. We obtained per-channel detections using a data-adaptive threshold of mean\u2009+\u20090.8 s.d. and a cumulative strategy with h\u2009=\u20093.","A sample was classified as seizure if more than 10% channels were predicted as seizure.\r\nAdditional features\r\nWe detected scalp EEG spikes using SpikeNet14 and iEEG spikes using a separate validated detector15. Sleep was staged with YASA16 or, when central channels were unavailable, alpha\u2013delta ratio was used as an alternative measure. Brain-wide phase synchronization was computed from Hilbert-transformed CAR data as a global synchrony index and total ASM plasma concentration was estimated from medication dosing records using a first-order pharmacokinetic model recently validated by our group30. Identified events were visualized as heatmaps, animated head topographic maps, hypnograms and line plots for presentation to patients (Fig. 1).","Window sizes, montages, thresholds, event definitions and visualization details for each feature are provided in Supplementary Tables 2 and 3 and Supplementary Methods.\r\nPatient-facing application\r\nThe application was a containerized Python Flask service served by Gunicorn and deployed to Azure App Service, providing authentication, a chat interface and push notifications (web push protocol with VAPID). A dedicated Azure Database for PostgreSQL stored patient authentication information, conversations, surveys, synchronized seizure and spike events, and cached images linked from Databricks volumes.","A background scheduler (APScheduler) polled Databricks tables at 30\u2009s intervals to synchronize new events and dispatch daily sleep reports once morning surveys were completed. To restrict patient interactions to high-confidence detections, the scheduler retrieved only scalp events with mean probability of \u22650.80 and maximum probability of \u22650.95, and iEEG events exceeding 1\u2009min in duration. Push notifications for clinical events were disabled overnight (21:00\u201308:00), but these events remained accessible to patients using data queries.","Images (for example, sleep staging hypnograms and seizure heatmaps) were retrieved from Databricks volumes through the Files API, cached under application-controlled storage and displayed in-line within the chat history.\r\n\r\nThe following three bidirectional data flows linked the patient application and the cloud analytics environment: (1) patient-initiated queries with secure structured query language (SQL) filtering returned personalized clinical event summaries (for example, historic seizure characterization) to the chat; (2) system-initiated alerts synchronized detection events to the application, triggering push notifications; and (3) patient-in-the-loop annotations captured patient responses to these events and persisted them in Databricks for iterative model retraining.\r\nConversational AI\r\nThe conversational AI (Fig.","2b) was implemented as a directed state machine using LangGraph, with nodes for message moderation, routing based on classified patient intent (\u2018general chat\u2019 versus \u2018data agent\u2019 query), conditional message evaluation and clarification, and a ReAct-style \u2018data agent\u2019 with an iterative tool loop31. The persistent state maintained conversation history, patient context (unique identifier, EEG type, sleep-monitoring status), routing flags, moderation results and SQL query metadata. All SQL queries ran through a custom tool that injected a patient-specific filter for data isolation and matched database table semantics.","To manage context and reduce token usage, chat history was truncated to a fixed sliding window of the most recent 200 messages, with images stripped to descriptive text placeholders before being passed to the moderation and \u2018data agent\u2019 nodes. The \u2018data agent\u2019 had a bounded iteration loop (up to 25 tool calls) and returned an automated message on recursion or validation failures.\r\n\r\nEach patient was provisioned a separate application account and conversation thread, with database access constrained server-side by that patient\u2019s unique identifier.","Conversation state, message routing flags and moderation results were likewise scoped to the individual patient, so no patient\u2019s conversation history or clinical data could enter another patient\u2019s session. Because the LLM is stateless across calls, each node\u2019s system prompt, defining its role, scope and constraints, was re-injected on every turn rather than relying on the model to retain it, keeping behavior consistent even as older messages left the 200-message window.","That window also bounded input size, preventing token-limit overflow that could otherwise truncate context unpredictably and degrade response quality over a prolonged conversation.\r\n\r\nTo mitigate hallucinations and unsafe content in a clinical setting, the AI system used the following multilayered safeguards: (1) an input moderation node evaluated every incoming patient message against an LLM-judged rubric (Supplementary Table 10) before it reached the conversational AI; (2) an output moderation node applied the same rubric to every LLM-generated response before patient delivery; (3) an LLM-based intent router classified whether a message was handled by \u2018general chat\u2019 or by the \u2018data agent\u2019, and only \u2018data agent\u2019 executed SQL queries against the Databricks Unity Catalog, logging each generated query and its result alongside the response so that every numerical claim about patient data could be audited against the underlying database; and (4) an investigator reviewed message histories at least daily for safety validation.\r\n\r\nPredeployment red-teaming was conducted iteratively as part of AI system development\u2014investigators attempted to elicit unsafe or off-protocol behavior, inspected the resulting traces to localize failures within the multinode tool-calling pipeline and refined system prompts, tool-calling logic and moderation criteria until adversarial probes no longer elicited inappropriate behavior.","Any message flagged by either moderation node was obfuscated from the patient (and, for input moderation, from the conversational AI) and routed for immediate human review. The patient-facing system reflects the converged endpoint of this iterative hardening, which is described in full in the Supplementary Methods.\r\nSurveys\r\nThe application administered three daily surveys\u2014morning (08:00\u201309:00), afternoon (14:00\u201315:00) and evening (20:00\u201321:00)\u2014as well as a one-time exit survey at study completion. Delivery times were randomized per patient within each window to reduce anticipatory bias.","Each survey contained ten questions (0\u2013100 visual analog scale with labeled endpoints), two for each of the five constructs\u2014depressed mood, anxiety, perceived cognitive function, stress level and fatigue\/energy level. These items are brief, author-constructed visual analog scale ratings designed for high-frequency in-app administration; they are not validated epilepsy-specific patient-reported outcome instruments and are reported here only as feasibility and engagement signals (response rates and directionality). The morning survey included five additional items from the Richards\u2013Campbell Sleep Questionnaire32 assessing sleep depth, latency, wakefulness, maintenance and overall quality.","The exit survey comprised the 10-item System Usability Scale18 (five-point Likert) and four free-text questions on system utility and patient feedback. Follow-up questions were generated under prespecified conditions\u2014one fixed, open-ended question after morning surveys about factors affecting sleep and up to three personalized questions after afternoon and evening surveys when responses showed notable day-to-day changes, monotonic trends or sustained extremes, with at most one follow-up per construct. Follow-up questions were LLM generated and expired after 1\u2009h; surveys themselves expired if not completed within 3\u2009h of being administered.","Full survey questionnaires are provided in Supplementary Tables 4\u20137.\r\nInteraction and engagement analysis\r\nTo quantify patient engagement and system performance, we calculated response latencies for both the AI system and patients. System response latency was the interval between a patient\u2019s message and the subsequent AI response. For survey follow-up questions generated by the LLM, it was measured from the survey completion to the delivery of the first follow-up question.","Patient response latency was categorized by interaction type\u2014for \u2018general chat\u2019, latency was measured from the delivery of an AI message to the first subsequent patient message; for surveys, latency was defined as the time from notification delivery to the patient initiating the survey; and, for seizure and spike events, latency was calculated from the time of notification delivery to the patient\u2019s annotation of the event. Automated (non-AI-generated) messages were excluded from the message logs before analysis. Message router accuracy (Fig.","3e, left) was evaluated by manual review of each patient message to determine whether it had been classified and routed to the appropriate downstream node (\u2018general chat\u2019 or \u2018data agent\u2019). \u2018Data agent\u2019 accuracy (Fig.","3e, right) was determined by inspecting the SQL query generated for each \u2018data agent\u2019 turn and verifying that the retrieved data and the synthesized response correctly answered the patient\u2019s question.\r\nModel fine-tuningPatient-in-the-loop fine-tuning\r\nWe implemented real-time model fine-tuning every 3\u2009h separately for each patient. Patient annotations were converted into binary labels time aligned with model predictions\u2014a window was labeled 1 if it overlapped with any patient-confirmed seizure event and 0 otherwise, while model-detected events without corresponding annotations were labeled \u2018Not a Number\u2019 and excluded.","Fine-tuning was skipped for any 3-h session with no detected events or when all detected events lacked valid annotations.\r\n\r\nSamples were split into training and validation sets with an 85-to-15 ratio. To preserve representation of rare positive cases, we adopted a stratified temporal split in which the first 85% seizure and nonseizure samples were assigned to the training set and the remaining 15% to the validation set. Fine-tuning was also skipped if the validation AUROC exceeded 0.98, indicating near-perfect performance, or was below 0.5, suggesting potentially incorrect patient annotations. For SPaRCNet, the Kullback\u2013Leibler divergence over the six-class output distribution was used as loss.","For ONCET, channel-level seizure probabilities were aggregated using a top-k pooling strategy, as only sample-level labels (without channel-wise annotations) were available. Given channel probabilities \\({{p}_{c}}_{c=1}^{C}\\), the aggregated probability:\r\n\r\n$$\\hat{y}=\\frac{1}{k}\\sum _{i=1}^{k}{p}_{\\left(i\\right)},$$\r\n\r\n(2)\r\n\r\nwhere p(1)\u2009\u2265\u2009p(2)\u2009\u2265 \u2026 \u2265\u2009p(C) denotes the sorted channel probabilities in descending order and k was set to 10% the total number of channels. A binary cross-entropy loss was then computed between the ground-truth label and \\(\\hat{y}\\).","Given the substantial class imbalance toward nonseizure samples, we incorporated model distillation to mitigate collapse to the negative class by introducing an additional supervision loss defined as the Kullback\u2013Leibler divergence between the original model\u2019s predictions and those of the fine-tuned model, weighted by a factor of 0.5.\r\n\r\nFine-tuning used an optimizer with a learning rate of 5\u2009\u00d7\u200910\u22126 and weight decay of 1\u2009\u00d7\u200910\u22123, class-balanced resampling, channel-flipping augmentation for SPaRCNet and partial layer freezing with a progressive unfreezing schedule. Training ran for up to 20 epochs with checkpointing and early stopping.","Full optimization settings and stopping criteria are provided in the Supplementary Methods.\r\nClinician-in-the-loop fine-tuning\r\nDeep active learning identified the most informative portions of each day\u2019s EEG recording for clinician annotation, enabling continuous refinement of the detection model with efficient expert input. At the end of each day, the model performed inference on the full day\u2019s recording, and a least-confidence sampling strategy selected ten 90-s segments for which the model showed the greatest uncertainty. Clinicians reviewed and labeled these segments and the annotations were used to fine-tune the model.","The model backbone was partially unfrozen using the same configuration as the patient fine-tune, and model distillation was applied with a weighting factor of 0.5. The updated model was then deployed for seizure detection on the subsequent days\u2019 recordings.\r\nPerformance evaluation\r\nWe evaluated fine-tuned models post hoc to determine whether fine-tuning improved seizure detection on subsequent data. We first validated the approach using patient-initiated push-button alarms in the EMU instead of patient responses through the system, treating the period from 1\u2009min before to 2\u2009min after each alarm as a seizure event and all remaining periods as nonictal.","This enabled evaluation in a larger cohort, including patients recruited before the interactive seizure-annotation feature was available. Seizures annotated by EMU clinicians were used for clinician-in-the-loop fine-tuning and served as the ground truth. All annotations were converted into binary labels time aligned with model predictions. The model was fine-tuned sequentially at multiple time points and its performance on subsequent data not used for fine-tuning was compared to the baseline (Fig. 5a). We also evaluated performance across the entire EMU stay by applying the fine-tuned models once they became available.","Performance metrics were computed using the SzCORE framework33, including event-level seizure sensitivity, false alarms per hour and event-wise F1 score, AUROC and area under the precision-recall curve. During evaluation, seizure events separated by less than 90\u2009s were merged and events longer than 5\u2009min were split into separate events. A seizure event was considered detected if any predicted event overlapped with it, with a 30-s preictal tolerance and a 60-s postictal tolerance.\r\n\r\nWe then evaluated prospective fine-tuning using patient-provided annotations collected through the system.","For safety, only the validated baseline model was deployed during actual patient sessions to avoid issuing inaccurate alarms that could affect the patient. To approximate real-time application, we performed a pseudoprospective analysis in which the model was sequentially fine-tuned, mirroring live deployment. Patient annotations were converted to labels as described above, and all other evaluation procedures followed the validation analyses.\r\nStatistical analysis\r\nTo assess the association between synchrony and ASM load, we applied a linear mixed-effects model using restricted maximum likelihood estimation, with total ASM load as the dependent variable, synchrony and \u03b1-to-\u03b4 ratio as fixed-effect predictors and patient as a random effect.","System response latencies between the \u2018general chat\u2019 and \u2018data agent\u2019 interaction modes were compared using a two-sided Mann\u2013Whitney U test. Seizure-detection performance was summarized using medians and IQRs. For each fine-tuned model, we computed the performance difference relative to the baseline model on future test data (Fig. 5a). The median performance difference across all fine-tuned models was aggregated within each patient and these medians were compared to zero using a one-sided Wilcoxon signed-rank test, with the alternative hypothesis set according to the expected direction of effect.","We also compared performance across the EMU stay between the baseline model and the simulated prospective fine-tuning approach, where the most recent fine-tuned model was deployed, using a one-sided paired Wilcoxon signed-rank test. To reduce multiple comparisons, statistical tests were limited to false alarm rate and F1 score. Rank-biserial effect sizes (r) and 95% CIs were reported for all Mann\u2013Whitney U and Wilcoxon tests. Multiple comparisons were corrected using the Benjamini\u2013Hochberg procedure, with adjusted P values <0.05 considered statistically significant.\r\n\r\nAnalyses were performed in Python (v3.10+). The interaction-mode response latency comparison was computed using SciPy (v1.16.3), NumPy (v2.3.3) and pandas (v2.3.3).","Seizure-detection performance was compared using one-sided Wilcoxon signed-rank tests (SciPy; v1.16.3), with Benjamini\u2013Hochberg correction applied using statsmodels (v0.14.4). Model fine-tuning used PyTorch (v2.6.0) and scikit-learn (v1.7.2). All study and analysis code with pinned dependency versions are available in the public repositories listed under Code availability.\r\nReporting summary\r\nFurther information on research design is available in the Nature Portfolio Reporting Summary linked to this article.\r\nData availability\r\nDe-identified derived data sufficient to replicate the findings of this study are available on Pennsieve Discover34.","De-identified clinical EEG recordings, seizure annotations and medication data are available within this Pennsieve dataset. The patient\u2013AI interaction data (chat logs and free-text survey responses) cannot be made publicly available because they contain unstructured protected health information. Requests for access from qualified academic researchers may be submitted to the corresponding authors and will be reviewed by the investigators and the University of Pennsylvania; the response time will be within approximately 5 business days.","Any data released will be de-identified and subject to a data use agreement prohibiting re-identification, onward redistribution and use beyond the approved research purpose.\r\nCode availability\r\nThe study comprises five software components, four of which are publicly available under the GNU General Public License (v3.0) as follows: (1) real-time data processing and feature computation pipelines (https:\/\/github.com\/penn-cnt\/Pioneer-Databricks-Release); (2) the patient-facing chat interface (https:\/\/github.com\/penn-cnt\/Pioneer-Chat-Release); (3) offline seizure-detection model fine-tuning and evaluation (https:\/\/github.com\/penn-cnt\/Pioneer-Finetune-Release); and (4) analysis and figure generation (https:\/\/github.com\/penn-cnt\/Pioneer-Analysis-Release).","The fifth component, edge-device EEG streaming to Azure Event Hubs, depends on the proprietary Natus NeuroWorks real-time streaming SDK, which is confidential and cannot be publicly released; this code can be shared under a usage agreement with Natus. Replication of the complete framework also requires secure Azure and Databricks cloud infrastructure and configuration, which are institution specific and are therefore not fully reproducible from the released source code alone.\r\nReferences\r\nJette, N.","& Wiebe, S. Update on the surgical treatment of epilepsy. Curr. Opin. Neurol.","26, 201\u2013207 (2013).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nNair, D. R. et al. Nine-year prospective efficacy and safety of brain-responsive neurostimulation for focal epilepsy. Neurology 95, e1244\u2013e1256 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRehman, M.,","Higdon, L. M. & Sperling, M. R. Long-term home EEG recording: wearable and implantable devices. J. Clin. Neurophysiol.","41, 200\u2013206 (2024).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nHalliday, A. J. et al. The UMPIRE study: a first-in-human multicenter trial of bilateral subscalp monitoring for epileptic seizure detection. Epilepsia 66, 3426\u20133439 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nSnyder, D.","E.,","Echauz, J.,","Grimes, D. B.","& Litt, B. The statistics of a practical seizure warning system. J. Neural. Eng.","5, 392\u2013401 (2008).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nCook, M. J. et al. Prediction of seizure likelihood with a long-term, implanted seizure advisory system in patients with drug-resistant epilepsy: a first-in-man study. Lancet Neurol.","12, 563\u2013571 (2013).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nMitchell, J.","W.,","Doherty, J.,","Batchelor, R.,","Noble, A.","& Marson, A.","What matters most to people living with epilepsy?","A rapid review of qualitative research relating to health outcomes. Epilepsia 66, 4122\u20134138 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nHill, C.","E., Vanderboll, K.,","Parent, J.","M.,","Skolarus, L. E. & Zahuranec, D. B. Health priorities and treatment preferences of adults with epilepsy: a narrative literature review with a systematic search. Epilepsy Behav.","166, 110359 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRapport, F.,","Clement, C.,","Doel, M. A. & Hutchings, H. A. Qualitative research and its methods in epilepsy: contributing to an understanding of patients\u2019 lived experiences of the disease. Epilepsy Behav.","45, 94\u2013100 (2015).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nCamarillo, I.","A.,","Misiewicz, S.,","Siegel, K.","& Ottman, R. The concept of \u2018control\u2019 in people with epilepsy: a qualitative study. Epilepsy Behav.","161, 110059 (2024).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nBoele, F. et al. Health-related quality of life and unmet needs of people with epilepsy and their family caregivers: a systematic scoping review. Epilepsy Behav.","171, 110601 (2025).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nJing, J. et al. Development of expert-level classification of seizures and rhythmic and periodic patterns during EEG interpretation. Neurology 100, e1750\u2013e1762 (2023).\r\n\r\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRevell, A. Y. et al. AI-driven mapping of seizure spread patterns. Ann. Neurol.","100, 59\u201373 (2026).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nJing, J. et al. Development of expert-level automated detection of epileptiform discharges during electroencephalogram interpretation. JAMA Neurol.","77, 103\u2013108 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nAguila, C. A. et al. Mesial-to-lateral gradients of epileptiform activity to localize mesial temporal lobe epilepsy. Epilepsia 66, 3491\u20133504 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nVallat, R.","& Walker, M. P. An open-source, high-performance tool for automated sleep staging.","eLife 10, e70092 (2021).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nMa, D. et al. Synchrony is a robust iEEG biomarker for antiseizure medication load in epileptic patients. Preprint at bioRxiv https:\/\/doi.org\/10.64898\/2026.01.09.698669 (2026).\r\n\r\nBrooke, J. SUS: a \u2018quick and dirty\u2019 usability scale. in Usability Evaluation in Industry (eds Jordan, P. W. et al.) 189\u2013194 (Taylor and Francis, 1996).\r\n\r\nBernini, A.,","Dan, J.","& Ryvlin, P. Ambulatory seizure detection. Curr. Opin. Neurol.","37, 99\u2013104 (2024).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nBeran, R. G. Use of interval therapy with benzodiazepines to prevent seizure recurrence in stressful situations. Brain Sci.","12, 512 (2022).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nSaab, K.,","Dunnmon, J.,","R\u00e9, C.,","Rubin, D. & Lee-Messer, C. Weak supervision as an efficient approach for automated seizure detection in electroencephalography. npj Digit. Med.","3, 59 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRoth, D. Incidental supervision: moving beyond supervised learning. Proc. 31st AAAI Conference on Artificial Intelligence Vol.","31, 4885\u20134890 (AAAI Press, 2017).\r\n\r\nXu, Z. et al. Annotating neurophysiologic data at scale with optimized human input. J. Neural. Eng.","22, 046003 (2025).\r\n\r\nArticle\n\nGoogle Scholar\r\n\r\nPearson, C. et al. Care access and utilization among medicare beneficiaries living with Parkinson\u2019s disease. npj Parkinsons Dis.","9, 108 (2023).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nWu, K.,","Zhao, Z.","& Yener, B. Large EEG-U-transformer for time-step level detection without pre-training. Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2504.00336 (2025).\r\n\r\nSverrisson, \u00de. & Gu\u00f0mundsson, S. LookAroundNet: extending temporal context with Transformers for clinically viable EEG seizure detection. Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2601.06016 (2026).\r\n\r\nYao, Y.,","Wang, H.,","Chen, L.,","Peng, Y.","& Luo, J. Foundation models for EEG decoding: current progress and prospective research. J. Neural. Eng.","22, 061002 (2025).\r\n\r\nArticle\n\nGoogle Scholar\r\n\r\nOjemann, W. K. S. et al. Unsupervised seizure annotation and detection with neural dynamic divergence. Preprint at medRxiv https:\/\/www.medrxiv.org\/content\/10.64898\/2026.02.15.26346325 (2026).\r\n\r\nOjemann, W. K. S. et al. Multi-expert consensus annotations of spontaneous and stimulation-induced seizures in stereotactic EEG. Preprint at medRxiv https:\/\/www.medrxiv.org\/content\/10.64898\/2026.01.15.26344025 (2026).\r\n\r\nGhosn, N. J. et al. A pharmacokinetic model of antiseizure medication load to guide care in the epilepsy monitoring unit. Epilepsia 64, 1236\u20131247 (2023).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nYao, S. et al. ReAct: synergizing reasoning and acting in language models.","Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2210.03629 (2023).\r\n\r\nRichards, K.","C., O\u2019Sullivan, P. S. & Phillips, R. L. Measurement of sleep in critically ill patients. J. Nurs. Meas.","8, 131\u2013144 (2000).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nDan, J. et al. SzCORE: seizure community open-source research evaluation framework for the validation of electroencephalography-based automated seizure detection algorithms. Epilepsia 66, 14\u201324 (2025).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nShi, H. et al. Data for human-AI collaboration for co-managing epilepsy in real time. Pennsieve Platform for Data Management https:\/\/doi.org\/10.26275\/ju7h-bo8u (2026).\r\n\r\nDownload references\r\nAcknowledgements\r\nThe authors are grateful to all patients and their families for their involvement in the research program. The authors thank L.","Faillace, L. Simmons and the staff, fellows and technicians of the Hospital of the University of Pennsylvania Epilepsy Monitoring Unit for their invaluable assistance and cooperation during the study. The authors also thank S. McCurdy (Penn Medicine, University of Pennsylvania Health System) and J. Dada (Natus Medical Incorporated) for their help in setting up the real-time EEG data streaming service and D.","Lydon-Staley (Annenberg School for Communication, University of Pennsylvania) for providing survey expertise.\r\nFunding\r\nThis work was supported by a National Institutes of Health (NIH) Pioneer Award (DP1-NS-122038), NIH\/NINDS (R01-NS-125137), NIH (T32NS091006) and foundation support from Jonathan and Bonnie Rothberg, Neil and Barbara Smit, and the Small Lake Foundation. K.A.D. received funding from NIH\/NINDS (awards R61-NS-125568 and R01-NS-116504). N.S. received funding from NIH\/NINDS (award K99NS138680) and the Department of Defense (grant W81XWH2210593). E.C.","received support from NIH\/NINDS (award K23 NS121401-01A1) and the Burroughs Wellcome Fund.\r\nAuthor information\r\nAuthor notes\r\n\r\nThese authors contributed equally: Zack Goldblum, Haoer Shi.\r\nAuthors and Affiliations\r\nCenter for Neuroengineering and Therapeutics, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum,\u00a0Haoer Shi,\u00a0Zhongchuan Xu,\u00a0William K. S.","Ojemann,\u00a0Carlos A.","Aguila,\u00a0Kevin Xie,\u00a0Kerry C.","Nix,\u00a0Katherine G.","Walsh,\u00a0Ellie Chang,\u00a0Sarah B.","Lavelle,\u00a0Brandon Bach,\u00a0Kathryn A.","Davis,\u00a0Nishant Sinha,\u00a0Lauren H.","Hammer,\u00a0Erin C. Conrad\u00a0&\u00a0Brian Litt\r\n\r\nDepartment of Bioengineering, School of Engineering and Applied Science, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum,\u00a0Haoer Shi,\u00a0Zhongchuan Xu,\u00a0William K. S.","Ojemann,\u00a0Carlos A.","Aguila,\u00a0Katherine G.","Walsh,\u00a0Ellie Chang,\u00a0Lauren H. Hammer\u00a0&\u00a0Brian Litt\r\n\r\nCenter for Health, Devices and Technology, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum\u00a0&\u00a0Brian Litt\r\n\r\nPenn Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Long\r\n\r\nCenter for Healthcare Transformation and Innovation, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Xie\r\n\r\nDepartment of Neurology, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Xie,\u00a0Kathryn A.","Davis,\u00a0Nishant Sinha,\u00a0Lauren H.","Hammer,\u00a0Erin C. Conrad\u00a0&\u00a0Brian Litt\r\n\r\nDepartment of Neuroscience, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKerry C. Nix\r\n\r\nDepartment of Biostatistics, Epidemiology and Informatics, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nNishant Sinha\r\nContributions\r\nB.L. conceptualized the study and supervised the project.","B.L., Z.G. and H.S. designed the overall study.","Z.G., H.S. and K.L. developed the platform and supporting cloud infrastructure. Z.G. enrolled patients. B.B. managed the project and the clinical data.","Z.G., H.S. and Z.X. performed the computational analyses, created the visualizations and drafted the paper. All authors contributed important intellectual content and approved the final manuscript.\r\nCorresponding authors\r\nCorrespondence to\nZack Goldblum or Brian Litt.\r\nEthics declarationsCompeting interests\r\nZ.G., H.S. and B.L. are named inventors on a U.S. provisional patent (application 63\/932,309; filed 5 December 2025; status: pending), filed by The Trustees of the University of Pennsylvania, entitled \u2018System and Method for Real-Time Biosignal Analysis, Behavioral Monitoring and Treatment Employing Conversational Artificial Intelligence\u2019.","It covers the real-time biosignal analysis, behavioral monitoring and conversational AI treatment system described in this article. The other authors declare no competing interests.\r\nPeer reviewPeer review information\r\nNature Medicine thanks Marcello Ienca, Samden Lhatoo, Alik Widge and the other, anonymous, reviewer(s) for their contribution to the peer review of this work. Primary Handling Editor: Jerome Staal, in collaboration with the Nature Medicine team.","Peer reviewer reports are available.\r\nAdditional information\r\nPublisher\u2019s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.\r\nExtended dataExtended Data Table 1 Patient information and interactions\r\nFull size table\r\nExtended Data Fig. 1 Synchrony as a biomarker for antiseizure medication load.\r\na, Time series of synchrony and normalized antiseizure medication (ASM) load across the entire epilepsy monitoring unit (EMU) stay for a representative patient.","b, Predicted response surface from a linear mixed model with normalized ASM load as the dependent variable, synchrony and alpha-delta ratio as fixed-effect predictors, and patient as a random effect.\r\nExtended Data Fig. 2 Per-patient, daily breakdown of platform engagement, response behavior and annotation performance.\r\na\u2013c, Cell shading encodes patient interactions (see colorbars); white cells indicate the feature was available but unused on that day; gray cells indicate the feature was unavailable or the patient had been discharged.","a, Heatmaps of patient-initiated messages per day across \u2018general chat\u2019 and \u2018data agent\u2019 categories: seizure queries, sleep queries and spike queries. Each row is one patient (P001\u2013P013); each column is a day of participation (D1\u2013D7). Numerical annotations report the exact message count.","b, Per-patient daily response rates to system-initiated seizure (n\u2009=\u200958) and interictal spike (n\u2009=\u200933) alerts. Proportion of alerts the patient responded to that day (responded\/sent) is shown as annotations.","c, Per-patient daily completion of the morning, afternoon and evening surveys (n\u2009=\u200948 each). Checkmarks indicate a completed survey.","d, Per-patient annotation accuracy against clinician-annotated ground truth, stratified by source. Cells display the raw count fraction, while shading encodes performance metrics. From left to right: patient self-reported push-button alarms, platform-issued alerts, patient annotations of those alerts through the app and the platform overall (combining alert generation with patient annotation). A summary row (\u2018sum\u2019) aggregates events across patients for each metric. Abbreviations: NPV: negative predictive value.\r\nExtended Data Fig. 3 Seizure detection performance at baseline (n\u2009=\u200913).\r\nEach dot represents one patient.","The box represents the interquartile range (IQR) with a central line indicating the median across patients; whiskers extend to 1.5\u00d7 IQR. Abbreviations: AUROC: area under the receiver operating characteristic curve; AUPRC: area under the precision-recall curve.\r\nRights and permissions\r\nOpen Access This article is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License, which permits any non-commercial use, sharing, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if you modified the licensed material.","You do not have permission under this licence to share adapted material derived from this article or parts of it. The images or other third party material in this article are included in the article\u2019s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article\u2019s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:\/\/creativecommons.org\/licenses\/by-nc-nd\/4.0\/.\r\n\r\nReprints and permissions\r\nAbout this article\r\n\r\nCite this article\r\nGoldblum, Z.,","Shi, H.,","Xu, Z. et al. Human\u2013artificial intelligence collaboration for comanaging epilepsy in real time.\nNat Med (2026). https:\/\/doi.org\/10.1038\/s41591-026-04680-4\r\n\r\nDownload citation\r\n\r\nReceived: 09 March 2026\r\n\r\nAccepted: 26 August 2026\r\n\r\nPublished: 13 October 2026\r\n\r\nVersion of record: 13 October 2026\r\n\r\nDOI: https:\/\/doi.org\/10.1038\/s41591-026-04680-4"],"images":[{"src":"\/news\/images\/TkbOmERl9AxXIxuBGmutuUwR6UsixSbO2KpXNdwPDxcvo9suZtrqd7ng772quSB6Jovyvn1cNGA4x3NOqTi8rktwPQDSeqZ2gNu0nN7gA9609cYx2kvYEUS1i8NjjJnATzGwEpWQMcr3cQpaWgTNu0inCp4ik.jpg","width":0,"height":0,"source":"featured","size":0}],"tickers":[]}"
[3]=>
int(1792744395)
}
}
[2]=>
array(7) {
["file"]=>
string(28) "/app/sys/data/newsdb.inc.php"
["line"]=>
int(14)
["function"]=>
string(6) "Insert"
["class"]=>
string(3) "SQL"
["object"]=>
object(SQL)#1 (6) {
["CONNECTION":"SQL":private]=>
object(mysqli)#2 (18) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(14) "mysqlnd 8.4.27"
["client_version"]=>
int(80427)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(1406)
["error"]=>
string(40) "Data too long for column 'data' at row 1"
["error_list"]=>
array(1) {
[0]=>
array(3) {
["errno"]=>
int(1406)
["sqlstate"]=>
string(5) "22001"
["error"]=>
string(40) "Data too long for column 'data' at row 1"
}
}
["field_count"]=>
int(2)
["host_info"]=>
string(18) "db:3306 via TCP/IP"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(37) "11.2.2-MariaDB-1:11.2.2+maria~ubu2204"
["server_version"]=>
int(110202)
["sqlstate"]=>
string(5) "22001"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(390312)
["warning_count"]=>
int(0)
}
["URL":"SQL":private]=>
string(7) "db:3306"
["USER":"SQL":private]=>
string(8) "retrofox"
["PASS":"SQL":private]=>
string(16) "TreeakWqQPD9qnWR"
["DB":"SQL":private]=>
string(8) "retrofox"
["DROP_VALUES":"SQL":private]=>
array(1) {
[0]=>
string(0) ""
}
}
["type"]=>
string(2) "->"
["args"]=>
array(4) {
[0]=>
string(69) "REPLACE INTO news_data (id, data, timestamp) VALUES ('%s', '%s', %i);"
[1]=>
string(86) "foxapi_article2_SNgSFz1UYwUgnAye8Iq6AwimFnBOT9jdyRE0kXeBSMWDBytDmFWIqUjBzXoAEIULeJjOhk"
[2]=>
string(82309) "{"id":"SNgSFz1UYwUgnAye8Iq6AwimFnBOT9jdyRE0kXeBSMWDBytDmFWIqUjBzXoAEIULeJjOhk","title":"Human\u2013artificial intelligence collaboration for comanaging epilepsy in real time","description":"One-third of the world\u2019s 70 million people with epilepsy have seizures uncontrolled by medication, and implantable devices are a promising treatment. These devices can detect impending seizures, missed medication and impaired cognition, but, like most medical devices, they cannot share this information with patients in real time. This is a missed opportunity for devices to learn from clinical events and teach patients how their behaviors affect their health. Here we present a device platform that converses with patients to help them manage their epilepsy. The inpatient prototype links scalp and intracranial electroencephalography (EEG) to a secure, large language model-based artificial intelligence (AI) that communicates bidirectionally through a smartphone app. The AI processes biomarkers of sleep, medication, cognition and seizure probability, notifies patients of clinical events and trends, records symptoms and responses, and uses their feedback to retrain its seizure detector, reducing false alarms. We validated this platform in 13 patients who are undergoing video-EEG monitoring for epilepsy (scalp, n\u2009=\u200911; intracranial, n\u2009=\u20092). In a pseudoprospective simulation, seizure detectors improved precision from patient feedback alone, without expert intervention. We propose this system as a scalable, safeguarded platform for medical devices that can rapidly adapt to patient and provider needs across epilepsy and other medical conditions. A small epilepsy monitoring study shows that a moderated, large language model-based chat interface lets patients converse with their electroencephalography monitoring in real time, using a smartphone, and patient feedback cut seizure-detector false alarms by about 80% without clinician input.","author":"Litt, Brian","source":"Nature","publish":"October 13, 2026, 10:23 am","canonical":"https:\/\/www.nature.com\/articles\/s41591-026-04680-4","text":["Main\r\nMore than one-third of the world\u2019s 70 million people with epilepsy continue to have seizures despite aggressive treatment with medications. Some are candidates for functional surgery (removing or laser-ablating seizure-generating brain regions), but only half will become seizure free after two years1. Implantable devices are an exciting, less invasive alternative that improve seizure control without surgery\u2019s most severe side effects, such as cognitive impairment or mood disorders.","However, seizure freedom is rare with devices.\r\n\r\nEven for the two-thirds of patients with medication-responsive epilepsy, living \u2018seizure free\u2019 but reliant on medication presents ongoing challenges. These individuals are at risk for seizure relapses triggered by common life events\u2014missed medications, sleep deprivation, pregnancy or taking commonly prescribed medications that increase seizure risk. There is a need for technologies that help people live with epilepsy, because clinical treatment often fails to provide complete seizure freedom.\r\n\r\nFDA approved only three devices to treat epilepsy.","Whether open loop (stimulating in fixed cycles agnostic to neural activity) or closed loop (stimulating in response to preprogrammed detection criteria), they reduce seizures gradually, plateauing at a median seizure reduction of up to 75% 9 years after deployment in the most positive studies2. Roughly 30% patients improve minimally or not at all. Although some devices can store and transmit small amounts of data asynchronously, none share it in real time. This is a missed opportunity to present useful information to patients that the device \u2018knows\u2019 but has no way to convey.","This could include changes in seizure risk, the presence of known seizure precipitants or detecting specific patient behaviors that may be either beneficial (for example, getting more sleep) or detrimental (for example, consuming alcohol or some medications) to controlling seizures.","Similarly, current devices prevent patients from configuring them to their needs and lifestyle; they lack mechanisms to richly annotate data and cannot efficiently retrain algorithms with minimal physician interaction.\r\n\r\nNew minimally invasive electroencephalography (EEG) devices are poised to dramatically change seizure management with their ability to continuously collect data from patients during normal daily life. These devices vary from small, battery-powered single-channel scalp motes to subgaleal implants and wearable devices3. Some devices can transmit continuous EEG data to smartphones and subsequently to the cloud4, where the data are processed and viewable by clinicians.","Wearable devices monitor movement, heart rate and other peripheral parameters to alert families to convulsive seizures. Yet none offer bidirectional interfaces that let patients communicate and interact with them in real time.\r\n\r\nTo our knowledge, no prior literature describes interactive epilepsy devices that communicate bidirectionally with patients or their specifications. Early work instead focuses on warning of impending seizures and forecasting seizure-free periods5,6.","Grounding our design in the published literature on the lived experience and stated priorities of people with epilepsy and their caregivers7,8,9,10,11, together with our group\u2019s clinical experience, we propose that an optimal interactive epilepsy device should (1) present sensor-derived information (here scalp or intracranial EEG (iEEG)) intelligibly; (2) answer patient queries with actionable text and figures matched to their level of function; (3) provide an intuitive, low-latency conversational interface for surveys and two-way voice or text; (4) use patient responses to annotate data and retrain adaptive algorithms; (5) govern the appropriateness, truthfulness, safety and security of its output; and (6) let experts efficiently review and annotate data for patient care and to improve performance.\r\n\r\nIn the following sections, we describe a platform that performs these functions and report results from prospective testing on 13 patients admitted to the Hospital of the University of Pennsylvania epilepsy monitoring unit (EMU) for continuous video and scalp (n\u2009=\u200911) or iEEG (n\u2009=\u20092) monitoring.\r\nResultsPatient recruitment\r\nWe conducted a prospective, single-center observational study to evaluate a real-time patient\u2013artificial intelligence (AI) interface for clinical utility and usability (see Methods for detailed study procedures).","Thirteen adult EMU inpatients undergoing continuous EEG monitoring to characterize seizures for presurgical evaluation were enrolled (scalp EEG, n\u2009=\u200911; iEEG, n\u2009=\u20092; Table 1 and Supplementary Fig. 1) without altering standard-of-care treatment.","Throughout their EMU stay, participants were encouraged to interact with the platform and provide feedback on their experience.\r\nTable 1 Patient demographics (n\u2009=\u200913)\r\nFull size table\r\nDevice platform\r\nThe platform comprises the following three systems: (1) software that extracts real-time EEG data and metadata from the hospital network; (2) a HIPAA-compliant cloud analytics environment that analyzes the data stream; and (3) a smartphone app with integrated conversational AI for bidirectional communication.","The system messaged patients to deliver clinical information, alerts and surveys, while patients used the app to query their physiological data, explore trends and annotate symptoms to provide labels for seizure-detection algorithms (Fig. 1).\r\nFig. 1: Platform overview.\r\na, Patient\u2013AI interface in the EMU. Left: patients undergoing continuous scalp or intracranial video-EEG monitoring connect to the platform through a smartphone application. EEG data streams from the EMU to a secure cloud environment for real-time processing. Right: representative screens showing bidirectional interaction modes, including system-initiated alerts (seizure alarms, surveys) and patient annotations.","The interface delivers neurophysiological visualizations, such as seizure heatmaps and sleep hypnograms, directly within the chat stream.","b, Cloud processing and AI system. Left: real-time neurophysiological biomarkers extracted from EEG data, including seizure probability, sleep staging, spike rates and brain synchrony, are compiled in a structured database. Right: the LLM-based AI system manages patient interactions and queries this database to synthesize responses.\r\n\r\nPatients received surveys thrice daily (morning, afternoon and evening; consisting of 10\u201315 questions about mood, anxiety, sleep, energy level and well-being; Supplementary Tables 4\u20137). Real-time EEG data streamed from the hospital network to the cloud infrastructure, where pretrained models extracted seizure probabilities (SPaRCNet12, WaveNet13 and ONCET (William K. S.","Ojemann, unpublished work)), interictal spikes (SpikeNet14 and a custom iEEG spike detector15) and sleep stages (YASA16; Supplementary Tables 2and 3). Additional features included phase synchrony (a biomarker for antiseizure medication (ASM) load17) and estimated ASM load derived from medical records. These measures capture seizures, clinical events, sleep architecture and medication-related changes that can alter seizure risk. In a post hoc linear mixed-effects analysis, phase synchrony rose as medication load fell (correlation coefficient\u2009=\u2009\u22120.315, 95% confidence interval (CI)\u2009=\u2009\u22120.337 to \u22120.293; Extended Data Fig.","1).\r\n\r\nTwo AI modes supported interaction\u2014\u2018general chat\u2019 for conversation and subjective logging, and a \u2018data agent\u2019 that retrieved and synthesized the above neurophysiological features from the study database to answer patient questions. HIPAA-compliant instances of GPT-4o-mini (OpenAI) power the AI system (Fig. 2; Methods).\r\nFig. 2: Platform technical architecture and AI framework.\r\na, Cloud infrastructure and real-time data streaming. The platform integrates on-premises clinical data acquisition with HIPAA-compliant cloud services. Continuous EEG signals are acquired through clinical workstations and relayed through a cloud-hosted virtual machine to Azure Event Hubs for ingestion.","Simultaneously, clinical metadata, including medication dosing and logs, are retrieved through the Sickbay platform. Data are processed within a Databricks environment using Delta Live Table pipelines for preprocessing, feature extraction and real-time clinical event detection. Automated analyses are performed by dedicated serving endpoints that host deep learning models and other algorithms. A HIPAA-compliant version of GPT-4o-mini is used in the AI system.","b, Directed state machine architecture of the AI system. All incoming patient messages and outgoing AI responses pass through moderation nodes that evaluate safety and clinical compliance. A message router classifies inputs as either \u2018general chat\u2019 for regular conversation or \u2018data query\u2019 for clinical information retrieval. Data queries are subsequently evaluated for scope and ambiguity. Valid queries are handled by a \u2018data agent\u2019 using a ReAct (reasoning and action) loop. This agent invokes SQL tools to inspect database schemas and execute secure queries against the Unity Catalog, where patient data are stored.","The agent maintains a persistent state, including conversation history and multimodal context (text and images) for context-aware interactions.\r\nPatient engagement\r\nWe analyzed the 1,307 messages exchanged between the 13 patients and the AI (Fig. 3a). Median patient participation, due to limited time in the EMU, was 4.87 days (interquartile range (IQR)\u2009=\u20093.85\u20136.11; Table 1). The system initiated 68.9% (n\u2009=\u2009900) interactions, consisting primarily of \u2018general chat\u2019 messages (43.1%), scheduled surveys (13.7%) and clinical event notifications (10.3%). Patients initiated the remaining 31.1% (n\u2009=\u2009407) interactions.","Patient activity was predominantly conversational\u201488.5% (n\u2009=\u2009360) patient-initiated messages were \u2018general chat\u2019, indicating comfort using the platform for everyday conversation and subjective logging. The remaining 11.5% were data queries about seizure events (5.9%, n\u2009=\u200924), sleep metrics (3.7%, n\u2009=\u200915) and interictal spike rates (1.9%, n\u2009=\u20098).\r\nFig. 3: Patient engagement and technical performance of the AI system.\r\na, Distribution of total messages (n\u2009=\u20091,307) exchanged between patients (n\u2009=\u200913) and the system, stratified by initiator (system versus patient) and interaction category.","b, Grouped bar plots illustrating the percentage of patient responses received across progressive time intervals for four categories\u2014general chat, surveys, seizure events and spike events.","c, Survey response rates and EEG event validation. Left: bar plots showing patient response rates for morning, afternoon and evening surveys (n\u2009=\u200948 each). Right: stacked bar plots for real-time seizure (n\u2009=\u200958) and interictal spike alerts (n\u2009=\u200933), showing both the response rate and patient-provided annotations (\u2018yes\u2019\/true positive, \u2018uncertain\u2019 or \u2018no\u2019\/false positive).","d, Response latency comparison between the \u2018general chat\u2019 and \u2018data agent\u2019 nodes. Box plots show median and IQR; whiskers extend to 1.5\u00d7 IQR. ***P value < 0.001.","e, AI agent performance. Left: message router accuracy (n\u2009=\u200978). Right: \u2018data agent\u2019 accuracy (n\u2009=\u200938).","f, SUS scores (n\u2009=\u20095), mean score (83\/100)\u2014\u2018excellent\u2019 usability range. An asterisk indicates that 200 automated (non-AI-generated) \u2018general chat\u2019 messages were excluded from the latency analysis. A dagger \u2018\u2020\u2019 indicates that seven patient \u2018general chat\u2019 messages erroneously routed to the \u2018data agent\u2019 were excluded from the \u2018data agent\u2019 accuracy analysis.\r\n\r\nResponse dynamics varied with urgency (Fig. 3b). Seizure queries elicited the fastest engagement, with 44.8% responses occurring within 10\u2009min and response rates reaching 60.3% within 30\u2009min. Conversely, notifications for spike events elicited the lowest engagement, plateauing at 27.3% within the first hour.","This likely reflects the lower patient prioritization of biomarkers that are often asymptomatic and imperceptible. Survey response rates reached 55.0% before their 3-h expiration. \u2018General chat\u2019 interactions accumulated steadily over the full 12\u201324-h window, consistent with patients treating these interactions as an asynchronous task compatible with the routine inpatient environment.\r\n\r\nPatient\u2013AI interaction enabled patient-in-the-loop validation of automated detections. Engagement with high-priority alerts was high\u2014patients responded to 67.2% real-time seizure detections (n\u2009=\u200958), annotating them as true seizures (15.5%, n\u2009=\u20099), false positives (37.9%, n\u2009=\u200922) or uncertain (13.8%, n\u2009=\u20098; Fig.","3c, Extended Data Table 1 and Extended Data Fig. 2). This provided a source of discriminatory labels for algorithm fine-tuning that is absent in passive monitoring. Survey adherence was highest for morning surveys (62.5%, n\u2009=\u200930), likely driven by the subsequent daily sleep report, versus afternoon (43.8%, n\u2009=\u200921) and evening (54.2%, n\u2009=\u200926).\r\n\r\nFor the two AI modes (\u2018general chat\u2019 and \u2018data agent\u2019), response latency differed significantly\u2014median difference of 6.75\u2009s (95% CI = 4.99\u20138.65; Mann\u2013Whitney U test, P<\u20090.001, rank-biserial r\u2009=\u20090.857; Fig. 3d).","\u2018General chat\u2019 was near real time (median latency\u2009=\u20091.95\u2009s; IQR\u2009=\u20091.57\u20134.11), whereas the \u2018data agent\u2019, which generates SQL and queries the database, was slower (median\u2009=\u20098.69\u2009s; IQR\u2009=\u20096.67\u201311.79). Despite the increased complexity of data retrieval tasks, \u2018data agent\u2019 reliability was nonetheless high\u2014executing retrieval tasks with 92.1% accuracy (n\u2009=\u200935\/38; Fig. 3e). The message router, which classified and directed patient messages to \u2018general chat\u2019 or \u2018data agent\u2019, achieved 89.7% accuracy (n\u2009=\u200970\/78; Fig. 3e). Misclassified messages are detailed in Supplementary Table 9. The moderation system flagged and blocked 1.47% (6\/407) patient messages and 0.0% (0\/900) AI-generated messages.","On review, all flags were benign (Supplementary Table 8 and Supplementary Results) and daily investigator audits confirmed no unsafe or clinically inappropriate messages (Methods).\r\n\r\nPatient feedback on usability was positive. The mean System Usability Scale (SUS)18 score was 83 of 100 (n\u2009=\u20095; individual scores\u2009=\u200972.5\u2013100; Fig.","3f), placing the system in the \u2018excellent\u2019 range and suggesting that it was accessible and intuitive for patients to use in an acute hospital setting.\r\nSeizure detection\r\nAccurate seizure detection is essential, yet current algorithms do not generalize well19. We collected real-time patient feedback on seizure detections as weak labels and simulated prospective rolling fine-tuning without clinician input (Fig. 4). As a baseline, validated models (SPaRCNet for scalp EEG and ONCET for iEEG) evaluated against technician-annotated and clinician-annotated events had a median event-level sensitivity of 0.83 (IQR\u2009=\u20090.35\u20131.00; n\u2009=\u200911) and a false alarm rate of 0.47 per hour (IQR\u2009=\u20090.35\u20130.77; n\u2009=\u200913; Extended Data Fig. 3).","We first used patient push-button seizure alarms, standard in the EMU and available for all patients (n\u2009=\u200913; Fig.","5b), as labels, treating the window from 1\u2009min before to 2\u2009min after each alarm as seizure (sensitivity\u2009=\u20090.66 (41\/62), precision\u2009=\u20090.60 (50\/84); Extended Data Fig. 2d). Models were updated every 3\u2009h when predefined criteria were met (Methods; Fig. 5a) and each iteration was evaluated on unseen data against baseline.\r\nFig. 4: Workflow for fine-tuning seizure-detection models.\r\nPretrained seizure-detection models produced seizure probability time series from preprocessed EEG windows; thresholds were then applied to generate binary predictions and identify discrete seizure events.","Upon detection of a seizure event, a push notification was sent to the patient for confirmation, allowing responses of \u2018yes\u2019, \u2018no\u2019 or \u2018uncertain\u2019. These responses were converted into labels for fine-tuning\u2014seizure annotations were labeled as 1, uncertain annotations as NaN and all other labels as 0. Models were fine-tuned every 3\u2009h, with only the last few layers trainable while all other layers remained frozen to prevent catastrophic forgetting. To further improve performance, a clinician-in-the-loop approach was implemented every 24\u2009h. Ten 90-s EEG segments with the least confident predictions were selected and reviewed by clinicians for fine-tuning.","conv, convolutional layer; FC, fully connected.\r\nFig. 5: Patient-in-the-loop and clinician-in-the-loop fine-tuning improves seizure detection.\r\na, Evaluation strategy for patient-in-the-loop fine-tuning. Left: the baseline model was fine-tuned sequentially every 3\u2009h when predefined criteria were met. Yellow squares indicate time blocks used for fine-tuning. Middle: performance change from baseline for each fine-tuned model on future unseen data (green squares) and the median across models. Right: performance comparison across the full EMU stay simulating prospective fine-tuning, where each model was deployed on future data (pink outline) until the next fine-tuned model became available, against baseline (blue outline).","Outlined squares indicate the time blocks during which the baseline or fine-tuned models were active.","b, Fine-tuning performance in offline validation using patient-initiated push-button alarms as labels (n\u2009=\u200913).","c, Fine-tuning performance using patient responses to seizure alerts through the phone app as labels (n\u2009=\u20096).","b, c, Middle: median change from baseline in seizure event sensitivity, F1 score and false alarms per hour after fine-tuning. Each dot represents one patient. Boxes indicate the IQR with the central line representing the median; whiskers extend to 1.5\u00d7 IQR. Right: paired baseline versus fine-tuned performance across the EMU stay.","d, Change in seizure-detection performance after clinician-in-the-loop fine-tuning (n\u2009=\u20095). Gray lines indicate individual patients, and the black line shows the median change across patients.","AUPRC, area under the precision-recall curve; FT, fine-tune.\r\n\r\nAcross patients, fine-tuning reduced false alarms per hour by a median of 77.8% (absolute difference\u2009=\u2009\u22120.306; 95% CI\u2009=\u2009\u22120.629 to \u22120.202; Wilcoxon signed-rank test, P\u2009=\u20090.007, r\u2009=\u2009\u22120.92; Fig. 5b) and increased F1 score by 115.4% (absolute difference\u2009=\u20090.017; 95% CI\u2009=\u20090.029 to 0.163; P\u2009=\u20090.023, r\u2009=\u20091.00; Fig. 5b).","Simulating prospective deployment across the EMU stay (most recent fine-tuned model immediately deployed), false alarms fell by 77.2%, from 0.469 (IQR\u2009=\u20090.349\u20130.774) to 0.097 (IQR\u2009=\u20090.081\u20130.168; median difference\u2009=\u2009\u20130.293; 95% CI\u2009=\u2009\u22120.615 to \u22120.211; P\u2009=\u20090.007, r\u2009=\u2009\u22120.91) and F1 score rose 66.2% from 0.063 (IQR\u2009=\u20090\u20130.194) to 0.160 (0\u20130.348; median difference\u2009=\u20090.109; 95% CI\u2009=\u20090.055 to 0.153; P\u2009=\u20090.008, r\u2009=\u20091.00), while preserving baseline sensitivity (median\u2009=\u20091.00, IQR\u2009=\u20090.43\u20131.00).\r\n\r\nWe then fine-tuned using prospective seizure annotations collected through the platform.","The annotation feature was unavailable for the first 2 participants; for the 11 remaining patients, clinicians confirmed 59 seizures. The system sent 58 alerts and six patients provided annotations that confirmed events (Supplementary Table 1). Raw seizure alerts had low sensitivity of 0.136 (8\/59) and precision of 0.138 (8\/58). Patient-confirmed annotations had relatively high accuracy, with a sensitivity of 1.0 (5\/5), precision of 0.71 (5\/7) and negative predictive value of 1.0 (19\/19). Overall sensitivity was 0.085 (5\/59; Extended Data Fig. 2).","Experts marked all uncertain events (n\u2009=\u20097) as nonseizure.\r\n\r\nFine-tuning with platform annotations reduced false alarms by 80.9% (absolute difference\u2009=\u2009\u22120.543; 95% CI\u2009=\u2009\u22120.825 to \u22120.17; P\u2009=\u20090.038, r\u2009=\u2009\u22120.91; Fig. 5c) and increased F1 score by 158.4% (median difference\u2009=\u20090.110; 95% CI\u2009=\u20090.056 to 0.389; P\u2009=\u20090.038, r\u2009=\u20091.00; Fig. 5c).","Across the EMU stay, false alarm rate decreased by 80.0%, from 0.736 (IQR\u2009=\u20090.201\u20131.090) to 0.104 (IQR\u2009=\u20090.060\u20130.187; median difference\u2009=\u2009\u22120.588; 95% CI\u2009=\u2009\u22120.942 to \u22120.166; P\u2009=\u20090.038, r\u2009=\u2009\u22120.91) and F1 score increased by 189.2%, from 0.021 (IQR\u2009=\u20090.004\u20130.071) to 0.143 (IQR\u2009=\u20090.073\u20130.300; median difference\u2009=\u20090.131; 95% CI\u2009=\u20090.065 to 0.229; P\u2009=\u20090.038, r\u2009=\u20091.00).","Fine-tuning with push-button alarms in matched patients (n\u2009=\u20096) produced a false alarm rate of 0.107 (IQR\u2009=\u20090.082\u20130.147; median difference\u2009=\u20090.02; 95% CI\u2009=\u2009\u22120.037 to 0.061) and an F1 score of 0.130 (IQR\u2009=\u20090.025\u20130.258; median difference\u2009=\u2009\u22120.041; 95% CI\u2009=\u2009\u22120.123 to \u22120.006), with no statistically meaningful difference between the two groups (false alarms\u2014P\u2009=\u20090.688, r\u2009=\u20090.238; F1 score\u2014P\u2009=\u20090.087, r\u2009=\u2009\u22120.867).\r\n\r\nWe also implemented a clinician-in-the-loop framework in which the system flags uncertain predictions for expert annotation (Fig.","4), adding a layer of verification against performance degradation during real-time fine-tuning. This was simulated by providing ground-truth labels for model-requested segments. Clinician-in-the-loop fine-tuning decreased false alarm rate by 82.6%, from 0.210 (IQR\u2009=\u20090.159\u20130.255) to 0.044 (IQR\u2009=\u20090.022\u20130.068; median difference\u2009=\u2009\u22120.188; 95% CI\u2009=\u2009\u22120.382 to \u22120.102; P\u2009=\u20090.038, r\u2009=\u2009\u22121.0) and increased F1 score by 271.5% (median difference\u2009=\u20090.193; 95% CI\u2009=\u20090.106 to 0.31; P\u2009=\u20090.038, r\u2009=\u20091.0; Fig.","5d).\r\nDiscussion\r\nIn this study, we demonstrate a new approach to medical devices\u2014a platform that analyzes physiological activity and behavior in real time and allows two-way, spontaneous communication between patients and their devices. Using inpatient EEG monitoring equipment, together with compute, storage and large language models (LLMs) in HIPAA-compliant cloud environments, patients conversed with their devices through a smartphone application\u2014initiating conversations, receiving alerts and querying their data. Despite the limited setting and short participation duration, patients found the platform useful for understanding their condition, with 5 of the 13 spontaneously requesting access to it as outpatients.","In a pseudoprospective simulation, the system retrained from imperfect patient annotations alone, markedly reducing false alarm rates while preserving baseline sensitivity, without clinician intervention\u2014although time-efficient expert annotation further improved performance. System latencies were acceptable to this small patient cohort (~2\u2009s for conversational interactions and ~9\u2009s for complex queries that synthesized plots and data).\r\n\r\nThe clinical and scientific impact of this work is multifold.\r\nA new approach to disease management\r\nSome of the most debilitating aspects of episodic conditions like epilepsy are the unpredictability of events and managing risk, even when patients are well.","EEG devices can detect biomarkers of increased seizure risk and timely alerts can prompt action, such as taking additional or rescue medication20. A prior implantable warning system reduced seizures, lowered medication burden and improved quality of life, but delivered only one-way feedback and required manual algorithm retraining at intervals typically months apart5,6. Our platform instead enables bidirectional feedback and automates model fine-tuning every 3\u2009h from patient annotations. Despite inaccuracies from missed or delayed responses, postictal amnesia or unrecognized subclinical seizures, these weak labels nonetheless proved effective, consistent with prior work21,22.","A complementary clinician-in-the-loop strategy lets experts efficiently validate and improve upon patients\u2019 labels23, which will be important for scaling to outpatient use, where a validated system may need only rare expert review.\r\nAn expanding platform\r\nThese innovations extend beyond epilepsy to domains where patient communication can enhance device efficacy. We are readying a trial applying the platform to program deep brain stimulation devices for Parkinson\u2019s disease, where two-way patient communication coupled to parameter-search algorithms could optimize therapy more efficiently than repeated in-office programming and expand access to a therapy currently limited by specialist availability24.","Other applications include cardiac devices, insulin pumps and, most notably, neuropsychiatric treatment, where patient-expressed symptoms may inform care better than external sensors or complement them. A critical enabler in this study, however, was the availability of well-validated, pretrained seizure detectors built on more than a decade of curated EEG data. Where such foundations are lacking, a platform like ours offers a route to accelerate building them by systematically capturing patient and clinician annotations during routine use.\r\nA way to find out what matters to patients\r\nAn exit survey (n\u2009=\u20095) offered a preliminary, qualitative view of patient experience.","Three of five patients reported increased awareness of connections between their behaviors, feelings and health, describing how it helped them track daily reports and explain their sleep data. Others were more equivocal, with one noting it largely \u2018reinforced what (they) already knew\u2019. Responses were more uniformly positive about anticipated everyday use. They valued regular status updates, warnings before major seizures and access to sleep data. Feature requests were practical, centering on more reliable survey notifications and easier access to data.","These priorities align with the lived-experience literature7,8,9,10,11 and with prior device studies that emphasized recognition of relative seizure-free periods and true seizure frequency6. We anticipate that sustained engagement will derive from delivering clear day-to-day value and from letting patients configure the AI\u2019s characteristics to their needs and preferences. Such personalization was deliberately constrained in this proof of concept and, for an adaptive assistive technology, is likely to develop over months of use rather than a brief inpatient stay.","A rigorous, prospective study of user experience and needs is a priority for our planned outpatient deployment.\r\nLimitations of our results\r\nOur study reports on 13 patients in the EMU, chosen for proximity to secure computing, high-quality neurophysiology and continuous supervision. The sample is small and may carry selection bias toward technology-interested individuals, and response rates, although good for survey studies, were below 100%. The EMU is an artificial, time-limited environment in which medications are reduced and seizures are provoked for diagnosis. The information the platform could surface therefore reflects feasibility rather than the day-to-day decision support most valuable in ambulatory life.","Our brief in-app surveys are designed for low-burden, high-frequency ecological momentary assessment; they are not validated epilepsy-specific patient-reported outcome measures (for example, QOLIE-31, NDDI-E, PROMIS), and we report them as engagement signals rather than clinical endpoints.\r\n\r\nContinuous video, electrocardiogram and other routine signals were recorded but not used in these first proof-of-principle experiments. For seizure detection, fine-tuning reduced false alarms and improved F1 while preserving sensitivity, but the false alarm rate after fine-tuning (2\u20134 per day) may still burden some patients, and would need to be reduced.","Sensitivity did not improve, likely reflecting the modest, homogeneous fine-tuning dataset and deliberately conservative hyperparameters. The lightweight detectors we used, selected for real-time deployment and reliable calibration, do not reflect the state of the art25,26,27. These constraints motivate our planned outpatient deployment and evaluation on long-term data from implanted systems for epilepsy, movement, sleep and other disorders.\r\nEthical considerations\r\nEthics were extensively reviewed during study design and institutional approval. To ensure that AI interactions did not interfere with clinical care, patients were reminded that their interactions were for research purposes only and were not monitored by their care team.","Patients were instructed to press the seizure alarm button for any suspected or impending event, and to interact with the AI only afterward. Consequently, all patients self-reported seizures through the clinical system while few did so through the platform. Patients in the EMU are frequently enrolled in other research studies, receive concurrent clinical care, recover in postictal states or attend to visiting family, all of which compete for their attention and limit interaction. This tension would be resolved in settings where the AI serves as the primary mode of patient\u2013device\u2013clinician communication, such as outpatient applications.","Protections instituted by the Institutional Review Board and a dedicated AI Governance Committee included daily human review of every patient\u2013AI interaction and performing all computation and LLM inference within Penn\u2019s HIPAA-compliant cloud infrastructure, so no protected health information was exposed to public, consumer or third-party services.\r\n\r\nBeyond these safeguards, long-term deployment surfaces broader human-factors considerations that warrant careful attention. Patients may over-rely on automated systems, and how an interface represents model uncertainty and the AI\u2019s limitations will shape whether patients weigh its outputs appropriately.","Questions of clinical responsibility also become more complex once medical decisions are based in part on AI-generated outputs. How that responsibility is allocated remains to be established as these systems move toward routine care. Underlying all of this are rapidly advancing AI models, raising the question of how to continually evaluate and ensure reliable performance in medical settings.\r\nNext steps and future vision\r\nThe true impact of this paradigm lies in applying this technology in the outpatient setting to improve everyday life.","Proof of real value will require demonstrating clear benefit to patients, caregivers, providers and payers\u2014ideally reduced seizure frequency or severity, fewer emergency visits, lower resource use and improved satisfaction\u2014for which the burden of evidence is high. It may also include the ability for patients to better make everyday decisions that affect their health. The same potential holds for other brain network disorders, heart disease, diabetes and other conditions. Informatics approaches comparing patients with these \u2018intelligent\u2019 devices to electronic health record controls may hasten demonstrating this value; otherwise, controlled clinical trials will be required.","The regulatory pathway will likely be stepwise and gradual, and, much as autonomous vehicles advanced incrementally, semi-autonomous medical devices may evolve from low-level advisory systems toward more capable clinical decision-support tools for diagnosing, managing and predicting disease.\r\nConclusion\r\nWe present a vision for medical devices that converse and interact with patients to help manage disease and improve quality of life. Given the current pace of innovation in computing, AI and neuroscience, such interactions may become increasingly common over time. The science fiction literature is full of worlds where humans and intelligent devices have united in intimate ways.","We believe that, because of the great promise of this path, it is important we push forward rapidly, but acknowledge that progress requires time and iterative improvement before these systems are worthy of our trust. It is vital to proceed deliberately and carefully, anticipating conflicts, failure modes and ethical challenges while embracing the enormous potential for improving the human condition.\r\nMethodsStudy design\r\nThis prospective, single-center observational study developed and evaluated a real-time patient\u2013data interface in a level 4 EMU at the Hospital of the University of Pennsylvania.","The study was approved by the University of Pennsylvania Institutional Review Board (protocol 849276) and written informed consent was obtained from all participants before any study procedure. We recruited patients admitted to the EMU for seizure characterization as part of clinical management or presurgical evaluation. Enrollment was reported during the clinical admission and coincided with the duration of continuous video-EEG monitoring, without altering standard-of-care monitoring or treatment.","Because this proof-of-concept platform was intended to demonstrate per-patient feasibility rather than a population-level effect, we prespecified a target of 10\u201315 EMU patients based on feasibility and patient availability during the study period, rather than by a formal power calculation. Participant sex, race and ethnicity were self-reported and are summarized in Table 1.","Sex and gender were not used as variables in the study design and the study was not powered for sex-based or gender-based analyses.\r\n\r\nThe implementation and clinical use of AI in this study were reviewed and approved by the Penn Medicine AI Governance Committee, an expert body established for this project that has since been institutionalized, the Penn Medicine Information Services Architecture Review Board and a Penn Medicine Security Risk Assessment.","Together, these bodies required that all model inference and computation should be performed within HIPAA-compliant infrastructure, that the LLM endpoint be contractually prohibited from training on or retaining any data, and that all patient\u2013AI interactions undergo daily human review. Committee composition, review scope and the multitrack governance process, which we share as an example for other institutions navigating the heterogeneous policies on cloud-based clinical AI, are described in the Supplementary Methods.\r\nProcedures\r\nExpert epileptologists screened incoming EMU admissions for eligibility.","Eligible patients were \u226518 years of age, with intact capacity to provide informed consent and interact with an app on a smartphone and English proficiency adequate for study procedures. We excluded patients with self-reported pregnancy or nursing, cognitive impairment or language barriers precluding meaningful engagement, or refusal or withdrawal of consent. On the day after admission, a research coordinator obtained informed consent and activated the NeuroWorks software development kit (SDK; Natus) on the patient\u2019s acquisition workstation to allow real-time EEG data streaming.","Each patient was provisioned a study account with a unique username and password, data-stream linkage identifier, medical record number for medication log integration and an EEG modality designation (scalp or intracranial) that configured model parameters. The coordinator installed the application as a progressive web app on the patient\u2019s smartphone, authenticated the patient, enabled push notifications and demonstrated key app features, including seizure and spike alerts, morning sleep reports and scheduled survey questionnaires.","Throughout their hospitalization, patients were encouraged to ask questions through the chat interface and respond to surveys and messages through the app, and the coordinator reviewed message histories at least daily. Patients were informed that this system is a research prototype in which false-positive seizure detections were anticipated, and that all clinical seizure concerns should be directed to their care team. Patients received $25 per day of participation. Accounts were deactivated on the day of discharge after completion of the exit survey (Supplementary Table 7) and clinical data were aggregated for research use under the approved protocol.","Figure 1 provides an overview of the study platform.\r\nPlatform implementationOverview\r\nThe platform comprised the following three interconnected systems (Fig. 2a): (1) an on-premises data acquisition and relay layer that exported real-time EEG data and metadata from EMU recording stations; (2) a HIPAA-compliant cloud analytics environment that ingested, preprocessed and analyzed streaming data and persisted features and events in databases; and (3) the patient-facing app with integrated conversational AI that delivered clinical event notifications and surveys and allowed patients to ask questions about their own physiological data.","A PostgreSQL database backed the application state and messaging history, and a LangGraph-based AI agent system orchestrated data queries against a Databricks Unity Catalog through a cloud-hosted, HIPAA-compliant LLM. We chose GPT-4o-mini (version 2024-08-01-preview) because it was, at the time of study initiation, the only model in Penn\u2019s HIPAA-compliant Azure OpenAI tenancy with sufficient instruction-following and tool-use reliability for our constrained, retrieval-oriented task, at substantially lower latency and cost for continuous usage than larger contemporary models.","Its smaller capacity makes it less suited to clinical reasoning, but the AI\u2019s role was deliberately scoped to information delivery and structured data retrieval rather than autonomous clinical judgment. The modular architecture allows the underlying model to be substituted as more capable HIPAA-compliant options become available. We did not specifically train or fine-tune the LLM, nor use rolling LLM-generated summarization. Each node in the AI system used a dedicated system prompt (Supplementary Table 10).\r\nReal-time EEG data acquisition and streaming\r\nContinuous scalp and iEEG signals were acquired using clinical Natus systems at 256 and 1,024\u2009Hz, respectively, and automatically downsampled to 512\u2009Hz during transmission.","The Natus NeuroWorks SDK provided real-time access, exposing ZeroMQ sockets for data, study information and event injection on the hospital network. A cloud-hosted virtual machine subscribed to the hospital-side publishers, retrieved sampling and channel metadata through the SDK and batched raw samples into 1-s windows. Batches were compressed (gzip), base64 encoded, annotated with channel names, timestamps and patient identifiers and forwarded to Azure Event Hubs using shared-access-signature authentication. Our configuration had four throughput units, each supporting up to 1\u2009MB of data or 1,000 events per second, with automatic scaling during periods of high input volume.","Given that a 1-s EEG packet is estimated to be 0.03\u20130.04\u2009MB for scalp EEG and 0.35\u2009MB for 250-channel stereoelectroencephalography (SEEG), the system can support at least 10 SEEG patients or 100 scalp EEG patients concurrently. Event Hubs fed a Databricks streaming pipeline that performed canonical EEG preprocessing, feature computation and model inference, writing outputs to Delta tables within a Unity Catalog.\r\nCloud data processing and feature extractionPreprocessing\r\nEEG signals were bandpass filtered (0.5\u2013100\u2009Hz for scalp EEG, 0.5\u2013250\u2009Hz for iEEG) and notch filtered at 60 and 120\u2009Hz to suppress powerline noise.","Bad channels were identified using a validated, custom artifact rejection algorithm (Supplementary Methods) and excluded before rereferencing to common average (CAR) or bipolar montages, as required by specific algorithms. Bipolar pairs rendered unavailable due to bad channels were retained but labeled as contaminated. Rereferenced signals were then prewhitened. Data from each stage were stored in dedicated Delta Live Tables on Databricks (Supplementary Tables 2 and 3).\r\nScalp EEG seizure detection\r\nFor scalp recordings, we used SPaRCNet12, a seizure-detection model trained on over 6,000 EEG recordings from 2,711 patients to distinguish among six types of ictal-interictal injury continuum patterns.","Per model design, inputs were 10-s windows of bipolar data with 2-s overlap. A segment was considered a seizure if the probability of the lateralized periodic discharges (LPD) class exceeded a data-adaptive threshold, defined as the mean seizure probability of +1.2 s.d. over a 400-s sliding window with a 100-s stride. We used the LPD class instead of the seizure class due to its empirically higher sensitivity, potentially reflecting misclassification of seizure segments as LPD.","We then used a cumulative sum strategy where a cumulative statistic was calculated as:\r\n\r\n$$S\\left(t\\right)=\\max \\left(0,S\\left(t-1\\right)+P\\left(t\\right)-k\\right)$$\r\n\r\n(1)\r\n\r\nwhere P(t) denotes the seizure probability at time t, and k represents the adaptive threshold. A seizure detection was declared when S(t) exceeded the decision threshold (h\u2009=\u20093). The parameters were empirically selected based on validation results from an independent EMU dataset. The detected samples were subsequently smoothed using binary opening and closing operations.","Consecutive detections separated by less than 2\u2009s were merged, and merged events shorter than 10\u2009s were discarded, as seizures typically last longer than 10\u2009s.\r\niEEG seizure detection\r\nFor intracranial data, we evaluated both WaveNet13 and ONCET (William K. S.","Ojemann, unpublished work) during inference and selected ONCET for fine-tuning based on its superior performance. WaveNet uses causal, dilating convolutional layers trained to discriminate between seizure and nonseizure neural activity. It accepts single-channel EEG data as input and adapts to variable channel counts in iEEG recordings. Following the inference pipeline described in the original publication, 1-s segments of bipolar, prewhitened data were downsampled to 128\u2009Hz and normalized using a robust scaler fitted on nonictal segments. Sensitivity analyses demonstrated minimal performance differences across scaler fitting durations from 1 to 20\u2009min, so we used the first 10\u2009min of available data.","ONCET is a seizure-annotation model trained on more than 1 million clips of single-channel iEEG recordings of interictal, seizure onset and seizure spread activity from 87 patients28. It uses dilating residual convolution blocks with expanding receptive fields, attention and feature compression to classify ictal activity, achieving an area under the receiver operating characteristic curve (AUROC) of 0.94 on the held-out test set and 0.95 on a gold-standard validation set29. ONCET inference follows similar preprocessing steps to WaveNet but operates on data downsampled to 256\u2009Hz by default. We obtained per-channel detections using a data-adaptive threshold of mean\u2009+\u20090.8 s.d. and a cumulative strategy with h\u2009=\u20093.","A sample was classified as seizure if more than 10% channels were predicted as seizure.\r\nAdditional features\r\nWe detected scalp EEG spikes using SpikeNet14 and iEEG spikes using a separate validated detector15. Sleep was staged with YASA16 or, when central channels were unavailable, alpha\u2013delta ratio was used as an alternative measure. Brain-wide phase synchronization was computed from Hilbert-transformed CAR data as a global synchrony index and total ASM plasma concentration was estimated from medication dosing records using a first-order pharmacokinetic model recently validated by our group30. Identified events were visualized as heatmaps, animated head topographic maps, hypnograms and line plots for presentation to patients (Fig. 1).","Window sizes, montages, thresholds, event definitions and visualization details for each feature are provided in Supplementary Tables 2 and 3 and Supplementary Methods.\r\nPatient-facing application\r\nThe application was a containerized Python Flask service served by Gunicorn and deployed to Azure App Service, providing authentication, a chat interface and push notifications (web push protocol with VAPID). A dedicated Azure Database for PostgreSQL stored patient authentication information, conversations, surveys, synchronized seizure and spike events, and cached images linked from Databricks volumes.","A background scheduler (APScheduler) polled Databricks tables at 30\u2009s intervals to synchronize new events and dispatch daily sleep reports once morning surveys were completed. To restrict patient interactions to high-confidence detections, the scheduler retrieved only scalp events with mean probability of \u22650.80 and maximum probability of \u22650.95, and iEEG events exceeding 1\u2009min in duration. Push notifications for clinical events were disabled overnight (21:00\u201308:00), but these events remained accessible to patients using data queries.","Images (for example, sleep staging hypnograms and seizure heatmaps) were retrieved from Databricks volumes through the Files API, cached under application-controlled storage and displayed in-line within the chat history.\r\n\r\nThe following three bidirectional data flows linked the patient application and the cloud analytics environment: (1) patient-initiated queries with secure structured query language (SQL) filtering returned personalized clinical event summaries (for example, historic seizure characterization) to the chat; (2) system-initiated alerts synchronized detection events to the application, triggering push notifications; and (3) patient-in-the-loop annotations captured patient responses to these events and persisted them in Databricks for iterative model retraining.\r\nConversational AI\r\nThe conversational AI (Fig.","2b) was implemented as a directed state machine using LangGraph, with nodes for message moderation, routing based on classified patient intent (\u2018general chat\u2019 versus \u2018data agent\u2019 query), conditional message evaluation and clarification, and a ReAct-style \u2018data agent\u2019 with an iterative tool loop31. The persistent state maintained conversation history, patient context (unique identifier, EEG type, sleep-monitoring status), routing flags, moderation results and SQL query metadata. All SQL queries ran through a custom tool that injected a patient-specific filter for data isolation and matched database table semantics.","To manage context and reduce token usage, chat history was truncated to a fixed sliding window of the most recent 200 messages, with images stripped to descriptive text placeholders before being passed to the moderation and \u2018data agent\u2019 nodes. The \u2018data agent\u2019 had a bounded iteration loop (up to 25 tool calls) and returned an automated message on recursion or validation failures.\r\n\r\nEach patient was provisioned a separate application account and conversation thread, with database access constrained server-side by that patient\u2019s unique identifier.","Conversation state, message routing flags and moderation results were likewise scoped to the individual patient, so no patient\u2019s conversation history or clinical data could enter another patient\u2019s session. Because the LLM is stateless across calls, each node\u2019s system prompt, defining its role, scope and constraints, was re-injected on every turn rather than relying on the model to retain it, keeping behavior consistent even as older messages left the 200-message window.","That window also bounded input size, preventing token-limit overflow that could otherwise truncate context unpredictably and degrade response quality over a prolonged conversation.\r\n\r\nTo mitigate hallucinations and unsafe content in a clinical setting, the AI system used the following multilayered safeguards: (1) an input moderation node evaluated every incoming patient message against an LLM-judged rubric (Supplementary Table 10) before it reached the conversational AI; (2) an output moderation node applied the same rubric to every LLM-generated response before patient delivery; (3) an LLM-based intent router classified whether a message was handled by \u2018general chat\u2019 or by the \u2018data agent\u2019, and only \u2018data agent\u2019 executed SQL queries against the Databricks Unity Catalog, logging each generated query and its result alongside the response so that every numerical claim about patient data could be audited against the underlying database; and (4) an investigator reviewed message histories at least daily for safety validation.\r\n\r\nPredeployment red-teaming was conducted iteratively as part of AI system development\u2014investigators attempted to elicit unsafe or off-protocol behavior, inspected the resulting traces to localize failures within the multinode tool-calling pipeline and refined system prompts, tool-calling logic and moderation criteria until adversarial probes no longer elicited inappropriate behavior.","Any message flagged by either moderation node was obfuscated from the patient (and, for input moderation, from the conversational AI) and routed for immediate human review. The patient-facing system reflects the converged endpoint of this iterative hardening, which is described in full in the Supplementary Methods.\r\nSurveys\r\nThe application administered three daily surveys\u2014morning (08:00\u201309:00), afternoon (14:00\u201315:00) and evening (20:00\u201321:00)\u2014as well as a one-time exit survey at study completion. Delivery times were randomized per patient within each window to reduce anticipatory bias.","Each survey contained ten questions (0\u2013100 visual analog scale with labeled endpoints), two for each of the five constructs\u2014depressed mood, anxiety, perceived cognitive function, stress level and fatigue\/energy level. These items are brief, author-constructed visual analog scale ratings designed for high-frequency in-app administration; they are not validated epilepsy-specific patient-reported outcome instruments and are reported here only as feasibility and engagement signals (response rates and directionality). The morning survey included five additional items from the Richards\u2013Campbell Sleep Questionnaire32 assessing sleep depth, latency, wakefulness, maintenance and overall quality.","The exit survey comprised the 10-item System Usability Scale18 (five-point Likert) and four free-text questions on system utility and patient feedback. Follow-up questions were generated under prespecified conditions\u2014one fixed, open-ended question after morning surveys about factors affecting sleep and up to three personalized questions after afternoon and evening surveys when responses showed notable day-to-day changes, monotonic trends or sustained extremes, with at most one follow-up per construct. Follow-up questions were LLM generated and expired after 1\u2009h; surveys themselves expired if not completed within 3\u2009h of being administered.","Full survey questionnaires are provided in Supplementary Tables 4\u20137.\r\nInteraction and engagement analysis\r\nTo quantify patient engagement and system performance, we calculated response latencies for both the AI system and patients. System response latency was the interval between a patient\u2019s message and the subsequent AI response. For survey follow-up questions generated by the LLM, it was measured from the survey completion to the delivery of the first follow-up question.","Patient response latency was categorized by interaction type\u2014for \u2018general chat\u2019, latency was measured from the delivery of an AI message to the first subsequent patient message; for surveys, latency was defined as the time from notification delivery to the patient initiating the survey; and, for seizure and spike events, latency was calculated from the time of notification delivery to the patient\u2019s annotation of the event. Automated (non-AI-generated) messages were excluded from the message logs before analysis. Message router accuracy (Fig.","3e, left) was evaluated by manual review of each patient message to determine whether it had been classified and routed to the appropriate downstream node (\u2018general chat\u2019 or \u2018data agent\u2019). \u2018Data agent\u2019 accuracy (Fig.","3e, right) was determined by inspecting the SQL query generated for each \u2018data agent\u2019 turn and verifying that the retrieved data and the synthesized response correctly answered the patient\u2019s question.\r\nModel fine-tuningPatient-in-the-loop fine-tuning\r\nWe implemented real-time model fine-tuning every 3\u2009h separately for each patient. Patient annotations were converted into binary labels time aligned with model predictions\u2014a window was labeled 1 if it overlapped with any patient-confirmed seizure event and 0 otherwise, while model-detected events without corresponding annotations were labeled \u2018Not a Number\u2019 and excluded.","Fine-tuning was skipped for any 3-h session with no detected events or when all detected events lacked valid annotations.\r\n\r\nSamples were split into training and validation sets with an 85-to-15 ratio. To preserve representation of rare positive cases, we adopted a stratified temporal split in which the first 85% seizure and nonseizure samples were assigned to the training set and the remaining 15% to the validation set. Fine-tuning was also skipped if the validation AUROC exceeded 0.98, indicating near-perfect performance, or was below 0.5, suggesting potentially incorrect patient annotations. For SPaRCNet, the Kullback\u2013Leibler divergence over the six-class output distribution was used as loss.","For ONCET, channel-level seizure probabilities were aggregated using a top-k pooling strategy, as only sample-level labels (without channel-wise annotations) were available. Given channel probabilities \\({{p}_{c}}_{c=1}^{C}\\), the aggregated probability:\r\n\r\n$$\\hat{y}=\\frac{1}{k}\\sum _{i=1}^{k}{p}_{\\left(i\\right)},$$\r\n\r\n(2)\r\n\r\nwhere p(1)\u2009\u2265\u2009p(2)\u2009\u2265 \u2026 \u2265\u2009p(C) denotes the sorted channel probabilities in descending order and k was set to 10% the total number of channels. A binary cross-entropy loss was then computed between the ground-truth label and \\(\\hat{y}\\).","Given the substantial class imbalance toward nonseizure samples, we incorporated model distillation to mitigate collapse to the negative class by introducing an additional supervision loss defined as the Kullback\u2013Leibler divergence between the original model\u2019s predictions and those of the fine-tuned model, weighted by a factor of 0.5.\r\n\r\nFine-tuning used an optimizer with a learning rate of 5\u2009\u00d7\u200910\u22126 and weight decay of 1\u2009\u00d7\u200910\u22123, class-balanced resampling, channel-flipping augmentation for SPaRCNet and partial layer freezing with a progressive unfreezing schedule. Training ran for up to 20 epochs with checkpointing and early stopping.","Full optimization settings and stopping criteria are provided in the Supplementary Methods.\r\nClinician-in-the-loop fine-tuning\r\nDeep active learning identified the most informative portions of each day\u2019s EEG recording for clinician annotation, enabling continuous refinement of the detection model with efficient expert input. At the end of each day, the model performed inference on the full day\u2019s recording, and a least-confidence sampling strategy selected ten 90-s segments for which the model showed the greatest uncertainty. Clinicians reviewed and labeled these segments and the annotations were used to fine-tune the model.","The model backbone was partially unfrozen using the same configuration as the patient fine-tune, and model distillation was applied with a weighting factor of 0.5. The updated model was then deployed for seizure detection on the subsequent days\u2019 recordings.\r\nPerformance evaluation\r\nWe evaluated fine-tuned models post hoc to determine whether fine-tuning improved seizure detection on subsequent data. We first validated the approach using patient-initiated push-button alarms in the EMU instead of patient responses through the system, treating the period from 1\u2009min before to 2\u2009min after each alarm as a seizure event and all remaining periods as nonictal.","This enabled evaluation in a larger cohort, including patients recruited before the interactive seizure-annotation feature was available. Seizures annotated by EMU clinicians were used for clinician-in-the-loop fine-tuning and served as the ground truth. All annotations were converted into binary labels time aligned with model predictions. The model was fine-tuned sequentially at multiple time points and its performance on subsequent data not used for fine-tuning was compared to the baseline (Fig. 5a). We also evaluated performance across the entire EMU stay by applying the fine-tuned models once they became available.","Performance metrics were computed using the SzCORE framework33, including event-level seizure sensitivity, false alarms per hour and event-wise F1 score, AUROC and area under the precision-recall curve. During evaluation, seizure events separated by less than 90\u2009s were merged and events longer than 5\u2009min were split into separate events. A seizure event was considered detected if any predicted event overlapped with it, with a 30-s preictal tolerance and a 60-s postictal tolerance.\r\n\r\nWe then evaluated prospective fine-tuning using patient-provided annotations collected through the system.","For safety, only the validated baseline model was deployed during actual patient sessions to avoid issuing inaccurate alarms that could affect the patient. To approximate real-time application, we performed a pseudoprospective analysis in which the model was sequentially fine-tuned, mirroring live deployment. Patient annotations were converted to labels as described above, and all other evaluation procedures followed the validation analyses.\r\nStatistical analysis\r\nTo assess the association between synchrony and ASM load, we applied a linear mixed-effects model using restricted maximum likelihood estimation, with total ASM load as the dependent variable, synchrony and \u03b1-to-\u03b4 ratio as fixed-effect predictors and patient as a random effect.","System response latencies between the \u2018general chat\u2019 and \u2018data agent\u2019 interaction modes were compared using a two-sided Mann\u2013Whitney U test. Seizure-detection performance was summarized using medians and IQRs. For each fine-tuned model, we computed the performance difference relative to the baseline model on future test data (Fig. 5a). The median performance difference across all fine-tuned models was aggregated within each patient and these medians were compared to zero using a one-sided Wilcoxon signed-rank test, with the alternative hypothesis set according to the expected direction of effect.","We also compared performance across the EMU stay between the baseline model and the simulated prospective fine-tuning approach, where the most recent fine-tuned model was deployed, using a one-sided paired Wilcoxon signed-rank test. To reduce multiple comparisons, statistical tests were limited to false alarm rate and F1 score. Rank-biserial effect sizes (r) and 95% CIs were reported for all Mann\u2013Whitney U and Wilcoxon tests. Multiple comparisons were corrected using the Benjamini\u2013Hochberg procedure, with adjusted P values <0.05 considered statistically significant.\r\n\r\nAnalyses were performed in Python (v3.10+). The interaction-mode response latency comparison was computed using SciPy (v1.16.3), NumPy (v2.3.3) and pandas (v2.3.3).","Seizure-detection performance was compared using one-sided Wilcoxon signed-rank tests (SciPy; v1.16.3), with Benjamini\u2013Hochberg correction applied using statsmodels (v0.14.4). Model fine-tuning used PyTorch (v2.6.0) and scikit-learn (v1.7.2). All study and analysis code with pinned dependency versions are available in the public repositories listed under Code availability.\r\nReporting summary\r\nFurther information on research design is available in the Nature Portfolio Reporting Summary linked to this article.\r\nData availability\r\nDe-identified derived data sufficient to replicate the findings of this study are available on Pennsieve Discover34.","De-identified clinical EEG recordings, seizure annotations and medication data are available within this Pennsieve dataset. The patient\u2013AI interaction data (chat logs and free-text survey responses) cannot be made publicly available because they contain unstructured protected health information. Requests for access from qualified academic researchers may be submitted to the corresponding authors and will be reviewed by the investigators and the University of Pennsylvania; the response time will be within approximately 5 business days.","Any data released will be de-identified and subject to a data use agreement prohibiting re-identification, onward redistribution and use beyond the approved research purpose.\r\nCode availability\r\nThe study comprises five software components, four of which are publicly available under the GNU General Public License (v3.0) as follows: (1) real-time data processing and feature computation pipelines (https:\/\/github.com\/penn-cnt\/Pioneer-Databricks-Release); (2) the patient-facing chat interface (https:\/\/github.com\/penn-cnt\/Pioneer-Chat-Release); (3) offline seizure-detection model fine-tuning and evaluation (https:\/\/github.com\/penn-cnt\/Pioneer-Finetune-Release); and (4) analysis and figure generation (https:\/\/github.com\/penn-cnt\/Pioneer-Analysis-Release).","The fifth component, edge-device EEG streaming to Azure Event Hubs, depends on the proprietary Natus NeuroWorks real-time streaming SDK, which is confidential and cannot be publicly released; this code can be shared under a usage agreement with Natus. Replication of the complete framework also requires secure Azure and Databricks cloud infrastructure and configuration, which are institution specific and are therefore not fully reproducible from the released source code alone.\r\nReferences\r\nJette, N.","& Wiebe, S. Update on the surgical treatment of epilepsy. Curr. Opin. Neurol.","26, 201\u2013207 (2013).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nNair, D. R. et al. Nine-year prospective efficacy and safety of brain-responsive neurostimulation for focal epilepsy. Neurology 95, e1244\u2013e1256 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRehman, M.,","Higdon, L. M. & Sperling, M. R. Long-term home EEG recording: wearable and implantable devices. J. Clin. Neurophysiol.","41, 200\u2013206 (2024).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nHalliday, A. J. et al. The UMPIRE study: a first-in-human multicenter trial of bilateral subscalp monitoring for epileptic seizure detection. Epilepsia 66, 3426\u20133439 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nSnyder, D.","E.,","Echauz, J.,","Grimes, D. B.","& Litt, B. The statistics of a practical seizure warning system. J. Neural. Eng.","5, 392\u2013401 (2008).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nCook, M. J. et al. Prediction of seizure likelihood with a long-term, implanted seizure advisory system in patients with drug-resistant epilepsy: a first-in-man study. Lancet Neurol.","12, 563\u2013571 (2013).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nMitchell, J.","W.,","Doherty, J.,","Batchelor, R.,","Noble, A.","& Marson, A.","What matters most to people living with epilepsy?","A rapid review of qualitative research relating to health outcomes. Epilepsia 66, 4122\u20134138 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nHill, C.","E., Vanderboll, K.,","Parent, J.","M.,","Skolarus, L. E. & Zahuranec, D. B. Health priorities and treatment preferences of adults with epilepsy: a narrative literature review with a systematic search. Epilepsy Behav.","166, 110359 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRapport, F.,","Clement, C.,","Doel, M. A. & Hutchings, H. A. Qualitative research and its methods in epilepsy: contributing to an understanding of patients\u2019 lived experiences of the disease. Epilepsy Behav.","45, 94\u2013100 (2015).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nCamarillo, I.","A.,","Misiewicz, S.,","Siegel, K.","& Ottman, R. The concept of \u2018control\u2019 in people with epilepsy: a qualitative study. Epilepsy Behav.","161, 110059 (2024).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nBoele, F. et al. Health-related quality of life and unmet needs of people with epilepsy and their family caregivers: a systematic scoping review. Epilepsy Behav.","171, 110601 (2025).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nJing, J. et al. Development of expert-level classification of seizures and rhythmic and periodic patterns during EEG interpretation. Neurology 100, e1750\u2013e1762 (2023).\r\n\r\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRevell, A. Y. et al. AI-driven mapping of seizure spread patterns. Ann. Neurol.","100, 59\u201373 (2026).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nJing, J. et al. Development of expert-level automated detection of epileptiform discharges during electroencephalogram interpretation. JAMA Neurol.","77, 103\u2013108 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nAguila, C. A. et al. Mesial-to-lateral gradients of epileptiform activity to localize mesial temporal lobe epilepsy. Epilepsia 66, 3491\u20133504 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nVallat, R.","& Walker, M. P. An open-source, high-performance tool for automated sleep staging.","eLife 10, e70092 (2021).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nMa, D. et al. Synchrony is a robust iEEG biomarker for antiseizure medication load in epileptic patients. Preprint at bioRxiv https:\/\/doi.org\/10.64898\/2026.01.09.698669 (2026).\r\n\r\nBrooke, J. SUS: a \u2018quick and dirty\u2019 usability scale. in Usability Evaluation in Industry (eds Jordan, P. W. et al.) 189\u2013194 (Taylor and Francis, 1996).\r\n\r\nBernini, A.,","Dan, J.","& Ryvlin, P. Ambulatory seizure detection. Curr. Opin. Neurol.","37, 99\u2013104 (2024).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nBeran, R. G. Use of interval therapy with benzodiazepines to prevent seizure recurrence in stressful situations. Brain Sci.","12, 512 (2022).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nSaab, K.,","Dunnmon, J.,","R\u00e9, C.,","Rubin, D. & Lee-Messer, C. Weak supervision as an efficient approach for automated seizure detection in electroencephalography. npj Digit. Med.","3, 59 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRoth, D. Incidental supervision: moving beyond supervised learning. Proc. 31st AAAI Conference on Artificial Intelligence Vol.","31, 4885\u20134890 (AAAI Press, 2017).\r\n\r\nXu, Z. et al. Annotating neurophysiologic data at scale with optimized human input. J. Neural. Eng.","22, 046003 (2025).\r\n\r\nArticle\n\nGoogle Scholar\r\n\r\nPearson, C. et al. Care access and utilization among medicare beneficiaries living with Parkinson\u2019s disease. npj Parkinsons Dis.","9, 108 (2023).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nWu, K.,","Zhao, Z.","& Yener, B. Large EEG-U-transformer for time-step level detection without pre-training. Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2504.00336 (2025).\r\n\r\nSverrisson, \u00de. & Gu\u00f0mundsson, S. LookAroundNet: extending temporal context with Transformers for clinically viable EEG seizure detection. Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2601.06016 (2026).\r\n\r\nYao, Y.,","Wang, H.,","Chen, L.,","Peng, Y.","& Luo, J. Foundation models for EEG decoding: current progress and prospective research. J. Neural. Eng.","22, 061002 (2025).\r\n\r\nArticle\n\nGoogle Scholar\r\n\r\nOjemann, W. K. S. et al. Unsupervised seizure annotation and detection with neural dynamic divergence. Preprint at medRxiv https:\/\/www.medrxiv.org\/content\/10.64898\/2026.02.15.26346325 (2026).\r\n\r\nOjemann, W. K. S. et al. Multi-expert consensus annotations of spontaneous and stimulation-induced seizures in stereotactic EEG. Preprint at medRxiv https:\/\/www.medrxiv.org\/content\/10.64898\/2026.01.15.26344025 (2026).\r\n\r\nGhosn, N. J. et al. A pharmacokinetic model of antiseizure medication load to guide care in the epilepsy monitoring unit. Epilepsia 64, 1236\u20131247 (2023).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nYao, S. et al. ReAct: synergizing reasoning and acting in language models.","Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2210.03629 (2023).\r\n\r\nRichards, K.","C., O\u2019Sullivan, P. S. & Phillips, R. L. Measurement of sleep in critically ill patients. J. Nurs. Meas.","8, 131\u2013144 (2000).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nDan, J. et al. SzCORE: seizure community open-source research evaluation framework for the validation of electroencephalography-based automated seizure detection algorithms. Epilepsia 66, 14\u201324 (2025).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nShi, H. et al. Data for human-AI collaboration for co-managing epilepsy in real time. Pennsieve Platform for Data Management https:\/\/doi.org\/10.26275\/ju7h-bo8u (2026).\r\n\r\nDownload references\r\nAcknowledgements\r\nThe authors are grateful to all patients and their families for their involvement in the research program. The authors thank L.","Faillace, L. Simmons and the staff, fellows and technicians of the Hospital of the University of Pennsylvania Epilepsy Monitoring Unit for their invaluable assistance and cooperation during the study. The authors also thank S. McCurdy (Penn Medicine, University of Pennsylvania Health System) and J. Dada (Natus Medical Incorporated) for their help in setting up the real-time EEG data streaming service and D.","Lydon-Staley (Annenberg School for Communication, University of Pennsylvania) for providing survey expertise.\r\nFunding\r\nThis work was supported by a National Institutes of Health (NIH) Pioneer Award (DP1-NS-122038), NIH\/NINDS (R01-NS-125137), NIH (T32NS091006) and foundation support from Jonathan and Bonnie Rothberg, Neil and Barbara Smit, and the Small Lake Foundation. K.A.D. received funding from NIH\/NINDS (awards R61-NS-125568 and R01-NS-116504). N.S. received funding from NIH\/NINDS (award K99NS138680) and the Department of Defense (grant W81XWH2210593). E.C.","received support from NIH\/NINDS (award K23 NS121401-01A1) and the Burroughs Wellcome Fund.\r\nAuthor information\r\nAuthor notes\r\n\r\nThese authors contributed equally: Zack Goldblum, Haoer Shi.\r\nAuthors and Affiliations\r\nCenter for Neuroengineering and Therapeutics, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum,\u00a0Haoer Shi,\u00a0Zhongchuan Xu,\u00a0William K. S.","Ojemann,\u00a0Carlos A.","Aguila,\u00a0Kevin Xie,\u00a0Kerry C.","Nix,\u00a0Katherine G.","Walsh,\u00a0Ellie Chang,\u00a0Sarah B.","Lavelle,\u00a0Brandon Bach,\u00a0Kathryn A.","Davis,\u00a0Nishant Sinha,\u00a0Lauren H.","Hammer,\u00a0Erin C. Conrad\u00a0&\u00a0Brian Litt\r\n\r\nDepartment of Bioengineering, School of Engineering and Applied Science, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum,\u00a0Haoer Shi,\u00a0Zhongchuan Xu,\u00a0William K. S.","Ojemann,\u00a0Carlos A.","Aguila,\u00a0Katherine G.","Walsh,\u00a0Ellie Chang,\u00a0Lauren H. Hammer\u00a0&\u00a0Brian Litt\r\n\r\nCenter for Health, Devices and Technology, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum\u00a0&\u00a0Brian Litt\r\n\r\nPenn Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Long\r\n\r\nCenter for Healthcare Transformation and Innovation, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Xie\r\n\r\nDepartment of Neurology, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Xie,\u00a0Kathryn A.","Davis,\u00a0Nishant Sinha,\u00a0Lauren H.","Hammer,\u00a0Erin C. Conrad\u00a0&\u00a0Brian Litt\r\n\r\nDepartment of Neuroscience, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKerry C. Nix\r\n\r\nDepartment of Biostatistics, Epidemiology and Informatics, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nNishant Sinha\r\nContributions\r\nB.L. conceptualized the study and supervised the project.","B.L., Z.G. and H.S. designed the overall study.","Z.G., H.S. and K.L. developed the platform and supporting cloud infrastructure. Z.G. enrolled patients. B.B. managed the project and the clinical data.","Z.G., H.S. and Z.X. performed the computational analyses, created the visualizations and drafted the paper. All authors contributed important intellectual content and approved the final manuscript.\r\nCorresponding authors\r\nCorrespondence to\nZack Goldblum or Brian Litt.\r\nEthics declarationsCompeting interests\r\nZ.G., H.S. and B.L. are named inventors on a U.S. provisional patent (application 63\/932,309; filed 5 December 2025; status: pending), filed by The Trustees of the University of Pennsylvania, entitled \u2018System and Method for Real-Time Biosignal Analysis, Behavioral Monitoring and Treatment Employing Conversational Artificial Intelligence\u2019.","It covers the real-time biosignal analysis, behavioral monitoring and conversational AI treatment system described in this article. The other authors declare no competing interests.\r\nPeer reviewPeer review information\r\nNature Medicine thanks Marcello Ienca, Samden Lhatoo, Alik Widge and the other, anonymous, reviewer(s) for their contribution to the peer review of this work. Primary Handling Editor: Jerome Staal, in collaboration with the Nature Medicine team.","Peer reviewer reports are available.\r\nAdditional information\r\nPublisher\u2019s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.\r\nExtended dataExtended Data Table 1 Patient information and interactions\r\nFull size table\r\nExtended Data Fig. 1 Synchrony as a biomarker for antiseizure medication load.\r\na, Time series of synchrony and normalized antiseizure medication (ASM) load across the entire epilepsy monitoring unit (EMU) stay for a representative patient.","b, Predicted response surface from a linear mixed model with normalized ASM load as the dependent variable, synchrony and alpha-delta ratio as fixed-effect predictors, and patient as a random effect.\r\nExtended Data Fig. 2 Per-patient, daily breakdown of platform engagement, response behavior and annotation performance.\r\na\u2013c, Cell shading encodes patient interactions (see colorbars); white cells indicate the feature was available but unused on that day; gray cells indicate the feature was unavailable or the patient had been discharged.","a, Heatmaps of patient-initiated messages per day across \u2018general chat\u2019 and \u2018data agent\u2019 categories: seizure queries, sleep queries and spike queries. Each row is one patient (P001\u2013P013); each column is a day of participation (D1\u2013D7). Numerical annotations report the exact message count.","b, Per-patient daily response rates to system-initiated seizure (n\u2009=\u200958) and interictal spike (n\u2009=\u200933) alerts. Proportion of alerts the patient responded to that day (responded\/sent) is shown as annotations.","c, Per-patient daily completion of the morning, afternoon and evening surveys (n\u2009=\u200948 each). Checkmarks indicate a completed survey.","d, Per-patient annotation accuracy against clinician-annotated ground truth, stratified by source. Cells display the raw count fraction, while shading encodes performance metrics. From left to right: patient self-reported push-button alarms, platform-issued alerts, patient annotations of those alerts through the app and the platform overall (combining alert generation with patient annotation). A summary row (\u2018sum\u2019) aggregates events across patients for each metric. Abbreviations: NPV: negative predictive value.\r\nExtended Data Fig. 3 Seizure detection performance at baseline (n\u2009=\u200913).\r\nEach dot represents one patient.","The box represents the interquartile range (IQR) with a central line indicating the median across patients; whiskers extend to 1.5\u00d7 IQR. Abbreviations: AUROC: area under the receiver operating characteristic curve; AUPRC: area under the precision-recall curve.\r\nRights and permissions\r\nOpen Access This article is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License, which permits any non-commercial use, sharing, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if you modified the licensed material.","You do not have permission under this licence to share adapted material derived from this article or parts of it. The images or other third party material in this article are included in the article\u2019s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article\u2019s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:\/\/creativecommons.org\/licenses\/by-nc-nd\/4.0\/.\r\n\r\nReprints and permissions\r\nAbout this article\r\n\r\nCite this article\r\nGoldblum, Z.,","Shi, H.,","Xu, Z. et al. Human\u2013artificial intelligence collaboration for comanaging epilepsy in real time.\nNat Med (2026). https:\/\/doi.org\/10.1038\/s41591-026-04680-4\r\n\r\nDownload citation\r\n\r\nReceived: 09 March 2026\r\n\r\nAccepted: 26 August 2026\r\n\r\nPublished: 13 October 2026\r\n\r\nVersion of record: 13 October 2026\r\n\r\nDOI: https:\/\/doi.org\/10.1038\/s41591-026-04680-4"],"images":[{"src":"\/news\/images\/TkbOmERl9AxXIxuBGmutuUwR6UsixSbO2KpXNdwPDxcvo9suZtrqd7ng772quSB6Jovyvn1cNGA4x3NOqTi8rktwPQDSeqZ2gNu0nN7gA9609cYx2kvYEUS1i8NjjJnATzGwEpWQMcr3cQpaWgTNu0inCp4ik.jpg","width":0,"height":0,"source":"featured","size":0}],"tickers":[]}"
[3]=>
int(1792744395)
}
}
[3]=>
array(7) {
["file"]=>
string(21) "/app/sys/news.inc.php"
["line"]=>
int(165)
["function"]=>
string(8) "saveData"
["class"]=>
string(6) "NewsDB"
["object"]=>
object(NewsDB)#4 (1) {
["db":"NewsDB":private]=>
object(SQL)#1 (6) {
["CONNECTION":"SQL":private]=>
object(mysqli)#2 (18) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(14) "mysqlnd 8.4.27"
["client_version"]=>
int(80427)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(1406)
["error"]=>
string(40) "Data too long for column 'data' at row 1"
["error_list"]=>
array(1) {
[0]=>
array(3) {
["errno"]=>
int(1406)
["sqlstate"]=>
string(5) "22001"
["error"]=>
string(40) "Data too long for column 'data' at row 1"
}
}
["field_count"]=>
int(2)
["host_info"]=>
string(18) "db:3306 via TCP/IP"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(37) "11.2.2-MariaDB-1:11.2.2+maria~ubu2204"
["server_version"]=>
int(110202)
["sqlstate"]=>
string(5) "22001"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(390312)
["warning_count"]=>
int(0)
}
["URL":"SQL":private]=>
string(7) "db:3306"
["USER":"SQL":private]=>
string(8) "retrofox"
["PASS":"SQL":private]=>
string(16) "TreeakWqQPD9qnWR"
["DB":"SQL":private]=>
string(8) "retrofox"
["DROP_VALUES":"SQL":private]=>
array(1) {
[0]=>
string(0) ""
}
}
}
["type"]=>
string(2) "->"
["args"]=>
array(2) {
[0]=>
string(86) "foxapi_article2_SNgSFz1UYwUgnAye8Iq6AwimFnBOT9jdyRE0kXeBSMWDBytDmFWIqUjBzXoAEIULeJjOhk"
[1]=>
string(82309) "{"id":"SNgSFz1UYwUgnAye8Iq6AwimFnBOT9jdyRE0kXeBSMWDBytDmFWIqUjBzXoAEIULeJjOhk","title":"Human\u2013artificial intelligence collaboration for comanaging epilepsy in real time","description":"One-third of the world\u2019s 70 million people with epilepsy have seizures uncontrolled by medication, and implantable devices are a promising treatment. These devices can detect impending seizures, missed medication and impaired cognition, but, like most medical devices, they cannot share this information with patients in real time. This is a missed opportunity for devices to learn from clinical events and teach patients how their behaviors affect their health. Here we present a device platform that converses with patients to help them manage their epilepsy. The inpatient prototype links scalp and intracranial electroencephalography (EEG) to a secure, large language model-based artificial intelligence (AI) that communicates bidirectionally through a smartphone app. The AI processes biomarkers of sleep, medication, cognition and seizure probability, notifies patients of clinical events and trends, records symptoms and responses, and uses their feedback to retrain its seizure detector, reducing false alarms. We validated this platform in 13 patients who are undergoing video-EEG monitoring for epilepsy (scalp, n\u2009=\u200911; intracranial, n\u2009=\u20092). In a pseudoprospective simulation, seizure detectors improved precision from patient feedback alone, without expert intervention. We propose this system as a scalable, safeguarded platform for medical devices that can rapidly adapt to patient and provider needs across epilepsy and other medical conditions. A small epilepsy monitoring study shows that a moderated, large language model-based chat interface lets patients converse with their electroencephalography monitoring in real time, using a smartphone, and patient feedback cut seizure-detector false alarms by about 80% without clinician input.","author":"Litt, Brian","source":"Nature","publish":"October 13, 2026, 10:23 am","canonical":"https:\/\/www.nature.com\/articles\/s41591-026-04680-4","text":["Main\r\nMore than one-third of the world\u2019s 70 million people with epilepsy continue to have seizures despite aggressive treatment with medications. Some are candidates for functional surgery (removing or laser-ablating seizure-generating brain regions), but only half will become seizure free after two years1. Implantable devices are an exciting, less invasive alternative that improve seizure control without surgery\u2019s most severe side effects, such as cognitive impairment or mood disorders.","However, seizure freedom is rare with devices.\r\n\r\nEven for the two-thirds of patients with medication-responsive epilepsy, living \u2018seizure free\u2019 but reliant on medication presents ongoing challenges. These individuals are at risk for seizure relapses triggered by common life events\u2014missed medications, sleep deprivation, pregnancy or taking commonly prescribed medications that increase seizure risk. There is a need for technologies that help people live with epilepsy, because clinical treatment often fails to provide complete seizure freedom.\r\n\r\nFDA approved only three devices to treat epilepsy.","Whether open loop (stimulating in fixed cycles agnostic to neural activity) or closed loop (stimulating in response to preprogrammed detection criteria), they reduce seizures gradually, plateauing at a median seizure reduction of up to 75% 9 years after deployment in the most positive studies2. Roughly 30% patients improve minimally or not at all. Although some devices can store and transmit small amounts of data asynchronously, none share it in real time. This is a missed opportunity to present useful information to patients that the device \u2018knows\u2019 but has no way to convey.","This could include changes in seizure risk, the presence of known seizure precipitants or detecting specific patient behaviors that may be either beneficial (for example, getting more sleep) or detrimental (for example, consuming alcohol or some medications) to controlling seizures.","Similarly, current devices prevent patients from configuring them to their needs and lifestyle; they lack mechanisms to richly annotate data and cannot efficiently retrain algorithms with minimal physician interaction.\r\n\r\nNew minimally invasive electroencephalography (EEG) devices are poised to dramatically change seizure management with their ability to continuously collect data from patients during normal daily life. These devices vary from small, battery-powered single-channel scalp motes to subgaleal implants and wearable devices3. Some devices can transmit continuous EEG data to smartphones and subsequently to the cloud4, where the data are processed and viewable by clinicians.","Wearable devices monitor movement, heart rate and other peripheral parameters to alert families to convulsive seizures. Yet none offer bidirectional interfaces that let patients communicate and interact with them in real time.\r\n\r\nTo our knowledge, no prior literature describes interactive epilepsy devices that communicate bidirectionally with patients or their specifications. Early work instead focuses on warning of impending seizures and forecasting seizure-free periods5,6.","Grounding our design in the published literature on the lived experience and stated priorities of people with epilepsy and their caregivers7,8,9,10,11, together with our group\u2019s clinical experience, we propose that an optimal interactive epilepsy device should (1) present sensor-derived information (here scalp or intracranial EEG (iEEG)) intelligibly; (2) answer patient queries with actionable text and figures matched to their level of function; (3) provide an intuitive, low-latency conversational interface for surveys and two-way voice or text; (4) use patient responses to annotate data and retrain adaptive algorithms; (5) govern the appropriateness, truthfulness, safety and security of its output; and (6) let experts efficiently review and annotate data for patient care and to improve performance.\r\n\r\nIn the following sections, we describe a platform that performs these functions and report results from prospective testing on 13 patients admitted to the Hospital of the University of Pennsylvania epilepsy monitoring unit (EMU) for continuous video and scalp (n\u2009=\u200911) or iEEG (n\u2009=\u20092) monitoring.\r\nResultsPatient recruitment\r\nWe conducted a prospective, single-center observational study to evaluate a real-time patient\u2013artificial intelligence (AI) interface for clinical utility and usability (see Methods for detailed study procedures).","Thirteen adult EMU inpatients undergoing continuous EEG monitoring to characterize seizures for presurgical evaluation were enrolled (scalp EEG, n\u2009=\u200911; iEEG, n\u2009=\u20092; Table 1 and Supplementary Fig. 1) without altering standard-of-care treatment.","Throughout their EMU stay, participants were encouraged to interact with the platform and provide feedback on their experience.\r\nTable 1 Patient demographics (n\u2009=\u200913)\r\nFull size table\r\nDevice platform\r\nThe platform comprises the following three systems: (1) software that extracts real-time EEG data and metadata from the hospital network; (2) a HIPAA-compliant cloud analytics environment that analyzes the data stream; and (3) a smartphone app with integrated conversational AI for bidirectional communication.","The system messaged patients to deliver clinical information, alerts and surveys, while patients used the app to query their physiological data, explore trends and annotate symptoms to provide labels for seizure-detection algorithms (Fig. 1).\r\nFig. 1: Platform overview.\r\na, Patient\u2013AI interface in the EMU. Left: patients undergoing continuous scalp or intracranial video-EEG monitoring connect to the platform through a smartphone application. EEG data streams from the EMU to a secure cloud environment for real-time processing. Right: representative screens showing bidirectional interaction modes, including system-initiated alerts (seizure alarms, surveys) and patient annotations.","The interface delivers neurophysiological visualizations, such as seizure heatmaps and sleep hypnograms, directly within the chat stream.","b, Cloud processing and AI system. Left: real-time neurophysiological biomarkers extracted from EEG data, including seizure probability, sleep staging, spike rates and brain synchrony, are compiled in a structured database. Right: the LLM-based AI system manages patient interactions and queries this database to synthesize responses.\r\n\r\nPatients received surveys thrice daily (morning, afternoon and evening; consisting of 10\u201315 questions about mood, anxiety, sleep, energy level and well-being; Supplementary Tables 4\u20137). Real-time EEG data streamed from the hospital network to the cloud infrastructure, where pretrained models extracted seizure probabilities (SPaRCNet12, WaveNet13 and ONCET (William K. S.","Ojemann, unpublished work)), interictal spikes (SpikeNet14 and a custom iEEG spike detector15) and sleep stages (YASA16; Supplementary Tables 2and 3). Additional features included phase synchrony (a biomarker for antiseizure medication (ASM) load17) and estimated ASM load derived from medical records. These measures capture seizures, clinical events, sleep architecture and medication-related changes that can alter seizure risk. In a post hoc linear mixed-effects analysis, phase synchrony rose as medication load fell (correlation coefficient\u2009=\u2009\u22120.315, 95% confidence interval (CI)\u2009=\u2009\u22120.337 to \u22120.293; Extended Data Fig.","1).\r\n\r\nTwo AI modes supported interaction\u2014\u2018general chat\u2019 for conversation and subjective logging, and a \u2018data agent\u2019 that retrieved and synthesized the above neurophysiological features from the study database to answer patient questions. HIPAA-compliant instances of GPT-4o-mini (OpenAI) power the AI system (Fig. 2; Methods).\r\nFig. 2: Platform technical architecture and AI framework.\r\na, Cloud infrastructure and real-time data streaming. The platform integrates on-premises clinical data acquisition with HIPAA-compliant cloud services. Continuous EEG signals are acquired through clinical workstations and relayed through a cloud-hosted virtual machine to Azure Event Hubs for ingestion.","Simultaneously, clinical metadata, including medication dosing and logs, are retrieved through the Sickbay platform. Data are processed within a Databricks environment using Delta Live Table pipelines for preprocessing, feature extraction and real-time clinical event detection. Automated analyses are performed by dedicated serving endpoints that host deep learning models and other algorithms. A HIPAA-compliant version of GPT-4o-mini is used in the AI system.","b, Directed state machine architecture of the AI system. All incoming patient messages and outgoing AI responses pass through moderation nodes that evaluate safety and clinical compliance. A message router classifies inputs as either \u2018general chat\u2019 for regular conversation or \u2018data query\u2019 for clinical information retrieval. Data queries are subsequently evaluated for scope and ambiguity. Valid queries are handled by a \u2018data agent\u2019 using a ReAct (reasoning and action) loop. This agent invokes SQL tools to inspect database schemas and execute secure queries against the Unity Catalog, where patient data are stored.","The agent maintains a persistent state, including conversation history and multimodal context (text and images) for context-aware interactions.\r\nPatient engagement\r\nWe analyzed the 1,307 messages exchanged between the 13 patients and the AI (Fig. 3a). Median patient participation, due to limited time in the EMU, was 4.87 days (interquartile range (IQR)\u2009=\u20093.85\u20136.11; Table 1). The system initiated 68.9% (n\u2009=\u2009900) interactions, consisting primarily of \u2018general chat\u2019 messages (43.1%), scheduled surveys (13.7%) and clinical event notifications (10.3%). Patients initiated the remaining 31.1% (n\u2009=\u2009407) interactions.","Patient activity was predominantly conversational\u201488.5% (n\u2009=\u2009360) patient-initiated messages were \u2018general chat\u2019, indicating comfort using the platform for everyday conversation and subjective logging. The remaining 11.5% were data queries about seizure events (5.9%, n\u2009=\u200924), sleep metrics (3.7%, n\u2009=\u200915) and interictal spike rates (1.9%, n\u2009=\u20098).\r\nFig. 3: Patient engagement and technical performance of the AI system.\r\na, Distribution of total messages (n\u2009=\u20091,307) exchanged between patients (n\u2009=\u200913) and the system, stratified by initiator (system versus patient) and interaction category.","b, Grouped bar plots illustrating the percentage of patient responses received across progressive time intervals for four categories\u2014general chat, surveys, seizure events and spike events.","c, Survey response rates and EEG event validation. Left: bar plots showing patient response rates for morning, afternoon and evening surveys (n\u2009=\u200948 each). Right: stacked bar plots for real-time seizure (n\u2009=\u200958) and interictal spike alerts (n\u2009=\u200933), showing both the response rate and patient-provided annotations (\u2018yes\u2019\/true positive, \u2018uncertain\u2019 or \u2018no\u2019\/false positive).","d, Response latency comparison between the \u2018general chat\u2019 and \u2018data agent\u2019 nodes. Box plots show median and IQR; whiskers extend to 1.5\u00d7 IQR. ***P value < 0.001.","e, AI agent performance. Left: message router accuracy (n\u2009=\u200978). Right: \u2018data agent\u2019 accuracy (n\u2009=\u200938).","f, SUS scores (n\u2009=\u20095), mean score (83\/100)\u2014\u2018excellent\u2019 usability range. An asterisk indicates that 200 automated (non-AI-generated) \u2018general chat\u2019 messages were excluded from the latency analysis. A dagger \u2018\u2020\u2019 indicates that seven patient \u2018general chat\u2019 messages erroneously routed to the \u2018data agent\u2019 were excluded from the \u2018data agent\u2019 accuracy analysis.\r\n\r\nResponse dynamics varied with urgency (Fig. 3b). Seizure queries elicited the fastest engagement, with 44.8% responses occurring within 10\u2009min and response rates reaching 60.3% within 30\u2009min. Conversely, notifications for spike events elicited the lowest engagement, plateauing at 27.3% within the first hour.","This likely reflects the lower patient prioritization of biomarkers that are often asymptomatic and imperceptible. Survey response rates reached 55.0% before their 3-h expiration. \u2018General chat\u2019 interactions accumulated steadily over the full 12\u201324-h window, consistent with patients treating these interactions as an asynchronous task compatible with the routine inpatient environment.\r\n\r\nPatient\u2013AI interaction enabled patient-in-the-loop validation of automated detections. Engagement with high-priority alerts was high\u2014patients responded to 67.2% real-time seizure detections (n\u2009=\u200958), annotating them as true seizures (15.5%, n\u2009=\u20099), false positives (37.9%, n\u2009=\u200922) or uncertain (13.8%, n\u2009=\u20098; Fig.","3c, Extended Data Table 1 and Extended Data Fig. 2). This provided a source of discriminatory labels for algorithm fine-tuning that is absent in passive monitoring. Survey adherence was highest for morning surveys (62.5%, n\u2009=\u200930), likely driven by the subsequent daily sleep report, versus afternoon (43.8%, n\u2009=\u200921) and evening (54.2%, n\u2009=\u200926).\r\n\r\nFor the two AI modes (\u2018general chat\u2019 and \u2018data agent\u2019), response latency differed significantly\u2014median difference of 6.75\u2009s (95% CI = 4.99\u20138.65; Mann\u2013Whitney U test, P<\u20090.001, rank-biserial r\u2009=\u20090.857; Fig. 3d).","\u2018General chat\u2019 was near real time (median latency\u2009=\u20091.95\u2009s; IQR\u2009=\u20091.57\u20134.11), whereas the \u2018data agent\u2019, which generates SQL and queries the database, was slower (median\u2009=\u20098.69\u2009s; IQR\u2009=\u20096.67\u201311.79). Despite the increased complexity of data retrieval tasks, \u2018data agent\u2019 reliability was nonetheless high\u2014executing retrieval tasks with 92.1% accuracy (n\u2009=\u200935\/38; Fig. 3e). The message router, which classified and directed patient messages to \u2018general chat\u2019 or \u2018data agent\u2019, achieved 89.7% accuracy (n\u2009=\u200970\/78; Fig. 3e). Misclassified messages are detailed in Supplementary Table 9. The moderation system flagged and blocked 1.47% (6\/407) patient messages and 0.0% (0\/900) AI-generated messages.","On review, all flags were benign (Supplementary Table 8 and Supplementary Results) and daily investigator audits confirmed no unsafe or clinically inappropriate messages (Methods).\r\n\r\nPatient feedback on usability was positive. The mean System Usability Scale (SUS)18 score was 83 of 100 (n\u2009=\u20095; individual scores\u2009=\u200972.5\u2013100; Fig.","3f), placing the system in the \u2018excellent\u2019 range and suggesting that it was accessible and intuitive for patients to use in an acute hospital setting.\r\nSeizure detection\r\nAccurate seizure detection is essential, yet current algorithms do not generalize well19. We collected real-time patient feedback on seizure detections as weak labels and simulated prospective rolling fine-tuning without clinician input (Fig. 4). As a baseline, validated models (SPaRCNet for scalp EEG and ONCET for iEEG) evaluated against technician-annotated and clinician-annotated events had a median event-level sensitivity of 0.83 (IQR\u2009=\u20090.35\u20131.00; n\u2009=\u200911) and a false alarm rate of 0.47 per hour (IQR\u2009=\u20090.35\u20130.77; n\u2009=\u200913; Extended Data Fig. 3).","We first used patient push-button seizure alarms, standard in the EMU and available for all patients (n\u2009=\u200913; Fig.","5b), as labels, treating the window from 1\u2009min before to 2\u2009min after each alarm as seizure (sensitivity\u2009=\u20090.66 (41\/62), precision\u2009=\u20090.60 (50\/84); Extended Data Fig. 2d). Models were updated every 3\u2009h when predefined criteria were met (Methods; Fig. 5a) and each iteration was evaluated on unseen data against baseline.\r\nFig. 4: Workflow for fine-tuning seizure-detection models.\r\nPretrained seizure-detection models produced seizure probability time series from preprocessed EEG windows; thresholds were then applied to generate binary predictions and identify discrete seizure events.","Upon detection of a seizure event, a push notification was sent to the patient for confirmation, allowing responses of \u2018yes\u2019, \u2018no\u2019 or \u2018uncertain\u2019. These responses were converted into labels for fine-tuning\u2014seizure annotations were labeled as 1, uncertain annotations as NaN and all other labels as 0. Models were fine-tuned every 3\u2009h, with only the last few layers trainable while all other layers remained frozen to prevent catastrophic forgetting. To further improve performance, a clinician-in-the-loop approach was implemented every 24\u2009h. Ten 90-s EEG segments with the least confident predictions were selected and reviewed by clinicians for fine-tuning.","conv, convolutional layer; FC, fully connected.\r\nFig. 5: Patient-in-the-loop and clinician-in-the-loop fine-tuning improves seizure detection.\r\na, Evaluation strategy for patient-in-the-loop fine-tuning. Left: the baseline model was fine-tuned sequentially every 3\u2009h when predefined criteria were met. Yellow squares indicate time blocks used for fine-tuning. Middle: performance change from baseline for each fine-tuned model on future unseen data (green squares) and the median across models. Right: performance comparison across the full EMU stay simulating prospective fine-tuning, where each model was deployed on future data (pink outline) until the next fine-tuned model became available, against baseline (blue outline).","Outlined squares indicate the time blocks during which the baseline or fine-tuned models were active.","b, Fine-tuning performance in offline validation using patient-initiated push-button alarms as labels (n\u2009=\u200913).","c, Fine-tuning performance using patient responses to seizure alerts through the phone app as labels (n\u2009=\u20096).","b, c, Middle: median change from baseline in seizure event sensitivity, F1 score and false alarms per hour after fine-tuning. Each dot represents one patient. Boxes indicate the IQR with the central line representing the median; whiskers extend to 1.5\u00d7 IQR. Right: paired baseline versus fine-tuned performance across the EMU stay.","d, Change in seizure-detection performance after clinician-in-the-loop fine-tuning (n\u2009=\u20095). Gray lines indicate individual patients, and the black line shows the median change across patients.","AUPRC, area under the precision-recall curve; FT, fine-tune.\r\n\r\nAcross patients, fine-tuning reduced false alarms per hour by a median of 77.8% (absolute difference\u2009=\u2009\u22120.306; 95% CI\u2009=\u2009\u22120.629 to \u22120.202; Wilcoxon signed-rank test, P\u2009=\u20090.007, r\u2009=\u2009\u22120.92; Fig. 5b) and increased F1 score by 115.4% (absolute difference\u2009=\u20090.017; 95% CI\u2009=\u20090.029 to 0.163; P\u2009=\u20090.023, r\u2009=\u20091.00; Fig. 5b).","Simulating prospective deployment across the EMU stay (most recent fine-tuned model immediately deployed), false alarms fell by 77.2%, from 0.469 (IQR\u2009=\u20090.349\u20130.774) to 0.097 (IQR\u2009=\u20090.081\u20130.168; median difference\u2009=\u2009\u20130.293; 95% CI\u2009=\u2009\u22120.615 to \u22120.211; P\u2009=\u20090.007, r\u2009=\u2009\u22120.91) and F1 score rose 66.2% from 0.063 (IQR\u2009=\u20090\u20130.194) to 0.160 (0\u20130.348; median difference\u2009=\u20090.109; 95% CI\u2009=\u20090.055 to 0.153; P\u2009=\u20090.008, r\u2009=\u20091.00), while preserving baseline sensitivity (median\u2009=\u20091.00, IQR\u2009=\u20090.43\u20131.00).\r\n\r\nWe then fine-tuned using prospective seizure annotations collected through the platform.","The annotation feature was unavailable for the first 2 participants; for the 11 remaining patients, clinicians confirmed 59 seizures. The system sent 58 alerts and six patients provided annotations that confirmed events (Supplementary Table 1). Raw seizure alerts had low sensitivity of 0.136 (8\/59) and precision of 0.138 (8\/58). Patient-confirmed annotations had relatively high accuracy, with a sensitivity of 1.0 (5\/5), precision of 0.71 (5\/7) and negative predictive value of 1.0 (19\/19). Overall sensitivity was 0.085 (5\/59; Extended Data Fig. 2).","Experts marked all uncertain events (n\u2009=\u20097) as nonseizure.\r\n\r\nFine-tuning with platform annotations reduced false alarms by 80.9% (absolute difference\u2009=\u2009\u22120.543; 95% CI\u2009=\u2009\u22120.825 to \u22120.17; P\u2009=\u20090.038, r\u2009=\u2009\u22120.91; Fig. 5c) and increased F1 score by 158.4% (median difference\u2009=\u20090.110; 95% CI\u2009=\u20090.056 to 0.389; P\u2009=\u20090.038, r\u2009=\u20091.00; Fig. 5c).","Across the EMU stay, false alarm rate decreased by 80.0%, from 0.736 (IQR\u2009=\u20090.201\u20131.090) to 0.104 (IQR\u2009=\u20090.060\u20130.187; median difference\u2009=\u2009\u22120.588; 95% CI\u2009=\u2009\u22120.942 to \u22120.166; P\u2009=\u20090.038, r\u2009=\u2009\u22120.91) and F1 score increased by 189.2%, from 0.021 (IQR\u2009=\u20090.004\u20130.071) to 0.143 (IQR\u2009=\u20090.073\u20130.300; median difference\u2009=\u20090.131; 95% CI\u2009=\u20090.065 to 0.229; P\u2009=\u20090.038, r\u2009=\u20091.00).","Fine-tuning with push-button alarms in matched patients (n\u2009=\u20096) produced a false alarm rate of 0.107 (IQR\u2009=\u20090.082\u20130.147; median difference\u2009=\u20090.02; 95% CI\u2009=\u2009\u22120.037 to 0.061) and an F1 score of 0.130 (IQR\u2009=\u20090.025\u20130.258; median difference\u2009=\u2009\u22120.041; 95% CI\u2009=\u2009\u22120.123 to \u22120.006), with no statistically meaningful difference between the two groups (false alarms\u2014P\u2009=\u20090.688, r\u2009=\u20090.238; F1 score\u2014P\u2009=\u20090.087, r\u2009=\u2009\u22120.867).\r\n\r\nWe also implemented a clinician-in-the-loop framework in which the system flags uncertain predictions for expert annotation (Fig.","4), adding a layer of verification against performance degradation during real-time fine-tuning. This was simulated by providing ground-truth labels for model-requested segments. Clinician-in-the-loop fine-tuning decreased false alarm rate by 82.6%, from 0.210 (IQR\u2009=\u20090.159\u20130.255) to 0.044 (IQR\u2009=\u20090.022\u20130.068; median difference\u2009=\u2009\u22120.188; 95% CI\u2009=\u2009\u22120.382 to \u22120.102; P\u2009=\u20090.038, r\u2009=\u2009\u22121.0) and increased F1 score by 271.5% (median difference\u2009=\u20090.193; 95% CI\u2009=\u20090.106 to 0.31; P\u2009=\u20090.038, r\u2009=\u20091.0; Fig.","5d).\r\nDiscussion\r\nIn this study, we demonstrate a new approach to medical devices\u2014a platform that analyzes physiological activity and behavior in real time and allows two-way, spontaneous communication between patients and their devices. Using inpatient EEG monitoring equipment, together with compute, storage and large language models (LLMs) in HIPAA-compliant cloud environments, patients conversed with their devices through a smartphone application\u2014initiating conversations, receiving alerts and querying their data. Despite the limited setting and short participation duration, patients found the platform useful for understanding their condition, with 5 of the 13 spontaneously requesting access to it as outpatients.","In a pseudoprospective simulation, the system retrained from imperfect patient annotations alone, markedly reducing false alarm rates while preserving baseline sensitivity, without clinician intervention\u2014although time-efficient expert annotation further improved performance. System latencies were acceptable to this small patient cohort (~2\u2009s for conversational interactions and ~9\u2009s for complex queries that synthesized plots and data).\r\n\r\nThe clinical and scientific impact of this work is multifold.\r\nA new approach to disease management\r\nSome of the most debilitating aspects of episodic conditions like epilepsy are the unpredictability of events and managing risk, even when patients are well.","EEG devices can detect biomarkers of increased seizure risk and timely alerts can prompt action, such as taking additional or rescue medication20. A prior implantable warning system reduced seizures, lowered medication burden and improved quality of life, but delivered only one-way feedback and required manual algorithm retraining at intervals typically months apart5,6. Our platform instead enables bidirectional feedback and automates model fine-tuning every 3\u2009h from patient annotations. Despite inaccuracies from missed or delayed responses, postictal amnesia or unrecognized subclinical seizures, these weak labels nonetheless proved effective, consistent with prior work21,22.","A complementary clinician-in-the-loop strategy lets experts efficiently validate and improve upon patients\u2019 labels23, which will be important for scaling to outpatient use, where a validated system may need only rare expert review.\r\nAn expanding platform\r\nThese innovations extend beyond epilepsy to domains where patient communication can enhance device efficacy. We are readying a trial applying the platform to program deep brain stimulation devices for Parkinson\u2019s disease, where two-way patient communication coupled to parameter-search algorithms could optimize therapy more efficiently than repeated in-office programming and expand access to a therapy currently limited by specialist availability24.","Other applications include cardiac devices, insulin pumps and, most notably, neuropsychiatric treatment, where patient-expressed symptoms may inform care better than external sensors or complement them. A critical enabler in this study, however, was the availability of well-validated, pretrained seizure detectors built on more than a decade of curated EEG data. Where such foundations are lacking, a platform like ours offers a route to accelerate building them by systematically capturing patient and clinician annotations during routine use.\r\nA way to find out what matters to patients\r\nAn exit survey (n\u2009=\u20095) offered a preliminary, qualitative view of patient experience.","Three of five patients reported increased awareness of connections between their behaviors, feelings and health, describing how it helped them track daily reports and explain their sleep data. Others were more equivocal, with one noting it largely \u2018reinforced what (they) already knew\u2019. Responses were more uniformly positive about anticipated everyday use. They valued regular status updates, warnings before major seizures and access to sleep data. Feature requests were practical, centering on more reliable survey notifications and easier access to data.","These priorities align with the lived-experience literature7,8,9,10,11 and with prior device studies that emphasized recognition of relative seizure-free periods and true seizure frequency6. We anticipate that sustained engagement will derive from delivering clear day-to-day value and from letting patients configure the AI\u2019s characteristics to their needs and preferences. Such personalization was deliberately constrained in this proof of concept and, for an adaptive assistive technology, is likely to develop over months of use rather than a brief inpatient stay.","A rigorous, prospective study of user experience and needs is a priority for our planned outpatient deployment.\r\nLimitations of our results\r\nOur study reports on 13 patients in the EMU, chosen for proximity to secure computing, high-quality neurophysiology and continuous supervision. The sample is small and may carry selection bias toward technology-interested individuals, and response rates, although good for survey studies, were below 100%. The EMU is an artificial, time-limited environment in which medications are reduced and seizures are provoked for diagnosis. The information the platform could surface therefore reflects feasibility rather than the day-to-day decision support most valuable in ambulatory life.","Our brief in-app surveys are designed for low-burden, high-frequency ecological momentary assessment; they are not validated epilepsy-specific patient-reported outcome measures (for example, QOLIE-31, NDDI-E, PROMIS), and we report them as engagement signals rather than clinical endpoints.\r\n\r\nContinuous video, electrocardiogram and other routine signals were recorded but not used in these first proof-of-principle experiments. For seizure detection, fine-tuning reduced false alarms and improved F1 while preserving sensitivity, but the false alarm rate after fine-tuning (2\u20134 per day) may still burden some patients, and would need to be reduced.","Sensitivity did not improve, likely reflecting the modest, homogeneous fine-tuning dataset and deliberately conservative hyperparameters. The lightweight detectors we used, selected for real-time deployment and reliable calibration, do not reflect the state of the art25,26,27. These constraints motivate our planned outpatient deployment and evaluation on long-term data from implanted systems for epilepsy, movement, sleep and other disorders.\r\nEthical considerations\r\nEthics were extensively reviewed during study design and institutional approval. To ensure that AI interactions did not interfere with clinical care, patients were reminded that their interactions were for research purposes only and were not monitored by their care team.","Patients were instructed to press the seizure alarm button for any suspected or impending event, and to interact with the AI only afterward. Consequently, all patients self-reported seizures through the clinical system while few did so through the platform. Patients in the EMU are frequently enrolled in other research studies, receive concurrent clinical care, recover in postictal states or attend to visiting family, all of which compete for their attention and limit interaction. This tension would be resolved in settings where the AI serves as the primary mode of patient\u2013device\u2013clinician communication, such as outpatient applications.","Protections instituted by the Institutional Review Board and a dedicated AI Governance Committee included daily human review of every patient\u2013AI interaction and performing all computation and LLM inference within Penn\u2019s HIPAA-compliant cloud infrastructure, so no protected health information was exposed to public, consumer or third-party services.\r\n\r\nBeyond these safeguards, long-term deployment surfaces broader human-factors considerations that warrant careful attention. Patients may over-rely on automated systems, and how an interface represents model uncertainty and the AI\u2019s limitations will shape whether patients weigh its outputs appropriately.","Questions of clinical responsibility also become more complex once medical decisions are based in part on AI-generated outputs. How that responsibility is allocated remains to be established as these systems move toward routine care. Underlying all of this are rapidly advancing AI models, raising the question of how to continually evaluate and ensure reliable performance in medical settings.\r\nNext steps and future vision\r\nThe true impact of this paradigm lies in applying this technology in the outpatient setting to improve everyday life.","Proof of real value will require demonstrating clear benefit to patients, caregivers, providers and payers\u2014ideally reduced seizure frequency or severity, fewer emergency visits, lower resource use and improved satisfaction\u2014for which the burden of evidence is high. It may also include the ability for patients to better make everyday decisions that affect their health. The same potential holds for other brain network disorders, heart disease, diabetes and other conditions. Informatics approaches comparing patients with these \u2018intelligent\u2019 devices to electronic health record controls may hasten demonstrating this value; otherwise, controlled clinical trials will be required.","The regulatory pathway will likely be stepwise and gradual, and, much as autonomous vehicles advanced incrementally, semi-autonomous medical devices may evolve from low-level advisory systems toward more capable clinical decision-support tools for diagnosing, managing and predicting disease.\r\nConclusion\r\nWe present a vision for medical devices that converse and interact with patients to help manage disease and improve quality of life. Given the current pace of innovation in computing, AI and neuroscience, such interactions may become increasingly common over time. The science fiction literature is full of worlds where humans and intelligent devices have united in intimate ways.","We believe that, because of the great promise of this path, it is important we push forward rapidly, but acknowledge that progress requires time and iterative improvement before these systems are worthy of our trust. It is vital to proceed deliberately and carefully, anticipating conflicts, failure modes and ethical challenges while embracing the enormous potential for improving the human condition.\r\nMethodsStudy design\r\nThis prospective, single-center observational study developed and evaluated a real-time patient\u2013data interface in a level 4 EMU at the Hospital of the University of Pennsylvania.","The study was approved by the University of Pennsylvania Institutional Review Board (protocol 849276) and written informed consent was obtained from all participants before any study procedure. We recruited patients admitted to the EMU for seizure characterization as part of clinical management or presurgical evaluation. Enrollment was reported during the clinical admission and coincided with the duration of continuous video-EEG monitoring, without altering standard-of-care monitoring or treatment.","Because this proof-of-concept platform was intended to demonstrate per-patient feasibility rather than a population-level effect, we prespecified a target of 10\u201315 EMU patients based on feasibility and patient availability during the study period, rather than by a formal power calculation. Participant sex, race and ethnicity were self-reported and are summarized in Table 1.","Sex and gender were not used as variables in the study design and the study was not powered for sex-based or gender-based analyses.\r\n\r\nThe implementation and clinical use of AI in this study were reviewed and approved by the Penn Medicine AI Governance Committee, an expert body established for this project that has since been institutionalized, the Penn Medicine Information Services Architecture Review Board and a Penn Medicine Security Risk Assessment.","Together, these bodies required that all model inference and computation should be performed within HIPAA-compliant infrastructure, that the LLM endpoint be contractually prohibited from training on or retaining any data, and that all patient\u2013AI interactions undergo daily human review. Committee composition, review scope and the multitrack governance process, which we share as an example for other institutions navigating the heterogeneous policies on cloud-based clinical AI, are described in the Supplementary Methods.\r\nProcedures\r\nExpert epileptologists screened incoming EMU admissions for eligibility.","Eligible patients were \u226518 years of age, with intact capacity to provide informed consent and interact with an app on a smartphone and English proficiency adequate for study procedures. We excluded patients with self-reported pregnancy or nursing, cognitive impairment or language barriers precluding meaningful engagement, or refusal or withdrawal of consent. On the day after admission, a research coordinator obtained informed consent and activated the NeuroWorks software development kit (SDK; Natus) on the patient\u2019s acquisition workstation to allow real-time EEG data streaming.","Each patient was provisioned a study account with a unique username and password, data-stream linkage identifier, medical record number for medication log integration and an EEG modality designation (scalp or intracranial) that configured model parameters. The coordinator installed the application as a progressive web app on the patient\u2019s smartphone, authenticated the patient, enabled push notifications and demonstrated key app features, including seizure and spike alerts, morning sleep reports and scheduled survey questionnaires.","Throughout their hospitalization, patients were encouraged to ask questions through the chat interface and respond to surveys and messages through the app, and the coordinator reviewed message histories at least daily. Patients were informed that this system is a research prototype in which false-positive seizure detections were anticipated, and that all clinical seizure concerns should be directed to their care team. Patients received $25 per day of participation. Accounts were deactivated on the day of discharge after completion of the exit survey (Supplementary Table 7) and clinical data were aggregated for research use under the approved protocol.","Figure 1 provides an overview of the study platform.\r\nPlatform implementationOverview\r\nThe platform comprised the following three interconnected systems (Fig. 2a): (1) an on-premises data acquisition and relay layer that exported real-time EEG data and metadata from EMU recording stations; (2) a HIPAA-compliant cloud analytics environment that ingested, preprocessed and analyzed streaming data and persisted features and events in databases; and (3) the patient-facing app with integrated conversational AI that delivered clinical event notifications and surveys and allowed patients to ask questions about their own physiological data.","A PostgreSQL database backed the application state and messaging history, and a LangGraph-based AI agent system orchestrated data queries against a Databricks Unity Catalog through a cloud-hosted, HIPAA-compliant LLM. We chose GPT-4o-mini (version 2024-08-01-preview) because it was, at the time of study initiation, the only model in Penn\u2019s HIPAA-compliant Azure OpenAI tenancy with sufficient instruction-following and tool-use reliability for our constrained, retrieval-oriented task, at substantially lower latency and cost for continuous usage than larger contemporary models.","Its smaller capacity makes it less suited to clinical reasoning, but the AI\u2019s role was deliberately scoped to information delivery and structured data retrieval rather than autonomous clinical judgment. The modular architecture allows the underlying model to be substituted as more capable HIPAA-compliant options become available. We did not specifically train or fine-tune the LLM, nor use rolling LLM-generated summarization. Each node in the AI system used a dedicated system prompt (Supplementary Table 10).\r\nReal-time EEG data acquisition and streaming\r\nContinuous scalp and iEEG signals were acquired using clinical Natus systems at 256 and 1,024\u2009Hz, respectively, and automatically downsampled to 512\u2009Hz during transmission.","The Natus NeuroWorks SDK provided real-time access, exposing ZeroMQ sockets for data, study information and event injection on the hospital network. A cloud-hosted virtual machine subscribed to the hospital-side publishers, retrieved sampling and channel metadata through the SDK and batched raw samples into 1-s windows. Batches were compressed (gzip), base64 encoded, annotated with channel names, timestamps and patient identifiers and forwarded to Azure Event Hubs using shared-access-signature authentication. Our configuration had four throughput units, each supporting up to 1\u2009MB of data or 1,000 events per second, with automatic scaling during periods of high input volume.","Given that a 1-s EEG packet is estimated to be 0.03\u20130.04\u2009MB for scalp EEG and 0.35\u2009MB for 250-channel stereoelectroencephalography (SEEG), the system can support at least 10 SEEG patients or 100 scalp EEG patients concurrently. Event Hubs fed a Databricks streaming pipeline that performed canonical EEG preprocessing, feature computation and model inference, writing outputs to Delta tables within a Unity Catalog.\r\nCloud data processing and feature extractionPreprocessing\r\nEEG signals were bandpass filtered (0.5\u2013100\u2009Hz for scalp EEG, 0.5\u2013250\u2009Hz for iEEG) and notch filtered at 60 and 120\u2009Hz to suppress powerline noise.","Bad channels were identified using a validated, custom artifact rejection algorithm (Supplementary Methods) and excluded before rereferencing to common average (CAR) or bipolar montages, as required by specific algorithms. Bipolar pairs rendered unavailable due to bad channels were retained but labeled as contaminated. Rereferenced signals were then prewhitened. Data from each stage were stored in dedicated Delta Live Tables on Databricks (Supplementary Tables 2 and 3).\r\nScalp EEG seizure detection\r\nFor scalp recordings, we used SPaRCNet12, a seizure-detection model trained on over 6,000 EEG recordings from 2,711 patients to distinguish among six types of ictal-interictal injury continuum patterns.","Per model design, inputs were 10-s windows of bipolar data with 2-s overlap. A segment was considered a seizure if the probability of the lateralized periodic discharges (LPD) class exceeded a data-adaptive threshold, defined as the mean seizure probability of +1.2 s.d. over a 400-s sliding window with a 100-s stride. We used the LPD class instead of the seizure class due to its empirically higher sensitivity, potentially reflecting misclassification of seizure segments as LPD.","We then used a cumulative sum strategy where a cumulative statistic was calculated as:\r\n\r\n$$S\\left(t\\right)=\\max \\left(0,S\\left(t-1\\right)+P\\left(t\\right)-k\\right)$$\r\n\r\n(1)\r\n\r\nwhere P(t) denotes the seizure probability at time t, and k represents the adaptive threshold. A seizure detection was declared when S(t) exceeded the decision threshold (h\u2009=\u20093). The parameters were empirically selected based on validation results from an independent EMU dataset. The detected samples were subsequently smoothed using binary opening and closing operations.","Consecutive detections separated by less than 2\u2009s were merged, and merged events shorter than 10\u2009s were discarded, as seizures typically last longer than 10\u2009s.\r\niEEG seizure detection\r\nFor intracranial data, we evaluated both WaveNet13 and ONCET (William K. S.","Ojemann, unpublished work) during inference and selected ONCET for fine-tuning based on its superior performance. WaveNet uses causal, dilating convolutional layers trained to discriminate between seizure and nonseizure neural activity. It accepts single-channel EEG data as input and adapts to variable channel counts in iEEG recordings. Following the inference pipeline described in the original publication, 1-s segments of bipolar, prewhitened data were downsampled to 128\u2009Hz and normalized using a robust scaler fitted on nonictal segments. Sensitivity analyses demonstrated minimal performance differences across scaler fitting durations from 1 to 20\u2009min, so we used the first 10\u2009min of available data.","ONCET is a seizure-annotation model trained on more than 1 million clips of single-channel iEEG recordings of interictal, seizure onset and seizure spread activity from 87 patients28. It uses dilating residual convolution blocks with expanding receptive fields, attention and feature compression to classify ictal activity, achieving an area under the receiver operating characteristic curve (AUROC) of 0.94 on the held-out test set and 0.95 on a gold-standard validation set29. ONCET inference follows similar preprocessing steps to WaveNet but operates on data downsampled to 256\u2009Hz by default. We obtained per-channel detections using a data-adaptive threshold of mean\u2009+\u20090.8 s.d. and a cumulative strategy with h\u2009=\u20093.","A sample was classified as seizure if more than 10% channels were predicted as seizure.\r\nAdditional features\r\nWe detected scalp EEG spikes using SpikeNet14 and iEEG spikes using a separate validated detector15. Sleep was staged with YASA16 or, when central channels were unavailable, alpha\u2013delta ratio was used as an alternative measure. Brain-wide phase synchronization was computed from Hilbert-transformed CAR data as a global synchrony index and total ASM plasma concentration was estimated from medication dosing records using a first-order pharmacokinetic model recently validated by our group30. Identified events were visualized as heatmaps, animated head topographic maps, hypnograms and line plots for presentation to patients (Fig. 1).","Window sizes, montages, thresholds, event definitions and visualization details for each feature are provided in Supplementary Tables 2 and 3 and Supplementary Methods.\r\nPatient-facing application\r\nThe application was a containerized Python Flask service served by Gunicorn and deployed to Azure App Service, providing authentication, a chat interface and push notifications (web push protocol with VAPID). A dedicated Azure Database for PostgreSQL stored patient authentication information, conversations, surveys, synchronized seizure and spike events, and cached images linked from Databricks volumes.","A background scheduler (APScheduler) polled Databricks tables at 30\u2009s intervals to synchronize new events and dispatch daily sleep reports once morning surveys were completed. To restrict patient interactions to high-confidence detections, the scheduler retrieved only scalp events with mean probability of \u22650.80 and maximum probability of \u22650.95, and iEEG events exceeding 1\u2009min in duration. Push notifications for clinical events were disabled overnight (21:00\u201308:00), but these events remained accessible to patients using data queries.","Images (for example, sleep staging hypnograms and seizure heatmaps) were retrieved from Databricks volumes through the Files API, cached under application-controlled storage and displayed in-line within the chat history.\r\n\r\nThe following three bidirectional data flows linked the patient application and the cloud analytics environment: (1) patient-initiated queries with secure structured query language (SQL) filtering returned personalized clinical event summaries (for example, historic seizure characterization) to the chat; (2) system-initiated alerts synchronized detection events to the application, triggering push notifications; and (3) patient-in-the-loop annotations captured patient responses to these events and persisted them in Databricks for iterative model retraining.\r\nConversational AI\r\nThe conversational AI (Fig.","2b) was implemented as a directed state machine using LangGraph, with nodes for message moderation, routing based on classified patient intent (\u2018general chat\u2019 versus \u2018data agent\u2019 query), conditional message evaluation and clarification, and a ReAct-style \u2018data agent\u2019 with an iterative tool loop31. The persistent state maintained conversation history, patient context (unique identifier, EEG type, sleep-monitoring status), routing flags, moderation results and SQL query metadata. All SQL queries ran through a custom tool that injected a patient-specific filter for data isolation and matched database table semantics.","To manage context and reduce token usage, chat history was truncated to a fixed sliding window of the most recent 200 messages, with images stripped to descriptive text placeholders before being passed to the moderation and \u2018data agent\u2019 nodes. The \u2018data agent\u2019 had a bounded iteration loop (up to 25 tool calls) and returned an automated message on recursion or validation failures.\r\n\r\nEach patient was provisioned a separate application account and conversation thread, with database access constrained server-side by that patient\u2019s unique identifier.","Conversation state, message routing flags and moderation results were likewise scoped to the individual patient, so no patient\u2019s conversation history or clinical data could enter another patient\u2019s session. Because the LLM is stateless across calls, each node\u2019s system prompt, defining its role, scope and constraints, was re-injected on every turn rather than relying on the model to retain it, keeping behavior consistent even as older messages left the 200-message window.","That window also bounded input size, preventing token-limit overflow that could otherwise truncate context unpredictably and degrade response quality over a prolonged conversation.\r\n\r\nTo mitigate hallucinations and unsafe content in a clinical setting, the AI system used the following multilayered safeguards: (1) an input moderation node evaluated every incoming patient message against an LLM-judged rubric (Supplementary Table 10) before it reached the conversational AI; (2) an output moderation node applied the same rubric to every LLM-generated response before patient delivery; (3) an LLM-based intent router classified whether a message was handled by \u2018general chat\u2019 or by the \u2018data agent\u2019, and only \u2018data agent\u2019 executed SQL queries against the Databricks Unity Catalog, logging each generated query and its result alongside the response so that every numerical claim about patient data could be audited against the underlying database; and (4) an investigator reviewed message histories at least daily for safety validation.\r\n\r\nPredeployment red-teaming was conducted iteratively as part of AI system development\u2014investigators attempted to elicit unsafe or off-protocol behavior, inspected the resulting traces to localize failures within the multinode tool-calling pipeline and refined system prompts, tool-calling logic and moderation criteria until adversarial probes no longer elicited inappropriate behavior.","Any message flagged by either moderation node was obfuscated from the patient (and, for input moderation, from the conversational AI) and routed for immediate human review. The patient-facing system reflects the converged endpoint of this iterative hardening, which is described in full in the Supplementary Methods.\r\nSurveys\r\nThe application administered three daily surveys\u2014morning (08:00\u201309:00), afternoon (14:00\u201315:00) and evening (20:00\u201321:00)\u2014as well as a one-time exit survey at study completion. Delivery times were randomized per patient within each window to reduce anticipatory bias.","Each survey contained ten questions (0\u2013100 visual analog scale with labeled endpoints), two for each of the five constructs\u2014depressed mood, anxiety, perceived cognitive function, stress level and fatigue\/energy level. These items are brief, author-constructed visual analog scale ratings designed for high-frequency in-app administration; they are not validated epilepsy-specific patient-reported outcome instruments and are reported here only as feasibility and engagement signals (response rates and directionality). The morning survey included five additional items from the Richards\u2013Campbell Sleep Questionnaire32 assessing sleep depth, latency, wakefulness, maintenance and overall quality.","The exit survey comprised the 10-item System Usability Scale18 (five-point Likert) and four free-text questions on system utility and patient feedback. Follow-up questions were generated under prespecified conditions\u2014one fixed, open-ended question after morning surveys about factors affecting sleep and up to three personalized questions after afternoon and evening surveys when responses showed notable day-to-day changes, monotonic trends or sustained extremes, with at most one follow-up per construct. Follow-up questions were LLM generated and expired after 1\u2009h; surveys themselves expired if not completed within 3\u2009h of being administered.","Full survey questionnaires are provided in Supplementary Tables 4\u20137.\r\nInteraction and engagement analysis\r\nTo quantify patient engagement and system performance, we calculated response latencies for both the AI system and patients. System response latency was the interval between a patient\u2019s message and the subsequent AI response. For survey follow-up questions generated by the LLM, it was measured from the survey completion to the delivery of the first follow-up question.","Patient response latency was categorized by interaction type\u2014for \u2018general chat\u2019, latency was measured from the delivery of an AI message to the first subsequent patient message; for surveys, latency was defined as the time from notification delivery to the patient initiating the survey; and, for seizure and spike events, latency was calculated from the time of notification delivery to the patient\u2019s annotation of the event. Automated (non-AI-generated) messages were excluded from the message logs before analysis. Message router accuracy (Fig.","3e, left) was evaluated by manual review of each patient message to determine whether it had been classified and routed to the appropriate downstream node (\u2018general chat\u2019 or \u2018data agent\u2019). \u2018Data agent\u2019 accuracy (Fig.","3e, right) was determined by inspecting the SQL query generated for each \u2018data agent\u2019 turn and verifying that the retrieved data and the synthesized response correctly answered the patient\u2019s question.\r\nModel fine-tuningPatient-in-the-loop fine-tuning\r\nWe implemented real-time model fine-tuning every 3\u2009h separately for each patient. Patient annotations were converted into binary labels time aligned with model predictions\u2014a window was labeled 1 if it overlapped with any patient-confirmed seizure event and 0 otherwise, while model-detected events without corresponding annotations were labeled \u2018Not a Number\u2019 and excluded.","Fine-tuning was skipped for any 3-h session with no detected events or when all detected events lacked valid annotations.\r\n\r\nSamples were split into training and validation sets with an 85-to-15 ratio. To preserve representation of rare positive cases, we adopted a stratified temporal split in which the first 85% seizure and nonseizure samples were assigned to the training set and the remaining 15% to the validation set. Fine-tuning was also skipped if the validation AUROC exceeded 0.98, indicating near-perfect performance, or was below 0.5, suggesting potentially incorrect patient annotations. For SPaRCNet, the Kullback\u2013Leibler divergence over the six-class output distribution was used as loss.","For ONCET, channel-level seizure probabilities were aggregated using a top-k pooling strategy, as only sample-level labels (without channel-wise annotations) were available. Given channel probabilities \\({{p}_{c}}_{c=1}^{C}\\), the aggregated probability:\r\n\r\n$$\\hat{y}=\\frac{1}{k}\\sum _{i=1}^{k}{p}_{\\left(i\\right)},$$\r\n\r\n(2)\r\n\r\nwhere p(1)\u2009\u2265\u2009p(2)\u2009\u2265 \u2026 \u2265\u2009p(C) denotes the sorted channel probabilities in descending order and k was set to 10% the total number of channels. A binary cross-entropy loss was then computed between the ground-truth label and \\(\\hat{y}\\).","Given the substantial class imbalance toward nonseizure samples, we incorporated model distillation to mitigate collapse to the negative class by introducing an additional supervision loss defined as the Kullback\u2013Leibler divergence between the original model\u2019s predictions and those of the fine-tuned model, weighted by a factor of 0.5.\r\n\r\nFine-tuning used an optimizer with a learning rate of 5\u2009\u00d7\u200910\u22126 and weight decay of 1\u2009\u00d7\u200910\u22123, class-balanced resampling, channel-flipping augmentation for SPaRCNet and partial layer freezing with a progressive unfreezing schedule. Training ran for up to 20 epochs with checkpointing and early stopping.","Full optimization settings and stopping criteria are provided in the Supplementary Methods.\r\nClinician-in-the-loop fine-tuning\r\nDeep active learning identified the most informative portions of each day\u2019s EEG recording for clinician annotation, enabling continuous refinement of the detection model with efficient expert input. At the end of each day, the model performed inference on the full day\u2019s recording, and a least-confidence sampling strategy selected ten 90-s segments for which the model showed the greatest uncertainty. Clinicians reviewed and labeled these segments and the annotations were used to fine-tune the model.","The model backbone was partially unfrozen using the same configuration as the patient fine-tune, and model distillation was applied with a weighting factor of 0.5. The updated model was then deployed for seizure detection on the subsequent days\u2019 recordings.\r\nPerformance evaluation\r\nWe evaluated fine-tuned models post hoc to determine whether fine-tuning improved seizure detection on subsequent data. We first validated the approach using patient-initiated push-button alarms in the EMU instead of patient responses through the system, treating the period from 1\u2009min before to 2\u2009min after each alarm as a seizure event and all remaining periods as nonictal.","This enabled evaluation in a larger cohort, including patients recruited before the interactive seizure-annotation feature was available. Seizures annotated by EMU clinicians were used for clinician-in-the-loop fine-tuning and served as the ground truth. All annotations were converted into binary labels time aligned with model predictions. The model was fine-tuned sequentially at multiple time points and its performance on subsequent data not used for fine-tuning was compared to the baseline (Fig. 5a). We also evaluated performance across the entire EMU stay by applying the fine-tuned models once they became available.","Performance metrics were computed using the SzCORE framework33, including event-level seizure sensitivity, false alarms per hour and event-wise F1 score, AUROC and area under the precision-recall curve. During evaluation, seizure events separated by less than 90\u2009s were merged and events longer than 5\u2009min were split into separate events. A seizure event was considered detected if any predicted event overlapped with it, with a 30-s preictal tolerance and a 60-s postictal tolerance.\r\n\r\nWe then evaluated prospective fine-tuning using patient-provided annotations collected through the system.","For safety, only the validated baseline model was deployed during actual patient sessions to avoid issuing inaccurate alarms that could affect the patient. To approximate real-time application, we performed a pseudoprospective analysis in which the model was sequentially fine-tuned, mirroring live deployment. Patient annotations were converted to labels as described above, and all other evaluation procedures followed the validation analyses.\r\nStatistical analysis\r\nTo assess the association between synchrony and ASM load, we applied a linear mixed-effects model using restricted maximum likelihood estimation, with total ASM load as the dependent variable, synchrony and \u03b1-to-\u03b4 ratio as fixed-effect predictors and patient as a random effect.","System response latencies between the \u2018general chat\u2019 and \u2018data agent\u2019 interaction modes were compared using a two-sided Mann\u2013Whitney U test. Seizure-detection performance was summarized using medians and IQRs. For each fine-tuned model, we computed the performance difference relative to the baseline model on future test data (Fig. 5a). The median performance difference across all fine-tuned models was aggregated within each patient and these medians were compared to zero using a one-sided Wilcoxon signed-rank test, with the alternative hypothesis set according to the expected direction of effect.","We also compared performance across the EMU stay between the baseline model and the simulated prospective fine-tuning approach, where the most recent fine-tuned model was deployed, using a one-sided paired Wilcoxon signed-rank test. To reduce multiple comparisons, statistical tests were limited to false alarm rate and F1 score. Rank-biserial effect sizes (r) and 95% CIs were reported for all Mann\u2013Whitney U and Wilcoxon tests. Multiple comparisons were corrected using the Benjamini\u2013Hochberg procedure, with adjusted P values <0.05 considered statistically significant.\r\n\r\nAnalyses were performed in Python (v3.10+). The interaction-mode response latency comparison was computed using SciPy (v1.16.3), NumPy (v2.3.3) and pandas (v2.3.3).","Seizure-detection performance was compared using one-sided Wilcoxon signed-rank tests (SciPy; v1.16.3), with Benjamini\u2013Hochberg correction applied using statsmodels (v0.14.4). Model fine-tuning used PyTorch (v2.6.0) and scikit-learn (v1.7.2). All study and analysis code with pinned dependency versions are available in the public repositories listed under Code availability.\r\nReporting summary\r\nFurther information on research design is available in the Nature Portfolio Reporting Summary linked to this article.\r\nData availability\r\nDe-identified derived data sufficient to replicate the findings of this study are available on Pennsieve Discover34.","De-identified clinical EEG recordings, seizure annotations and medication data are available within this Pennsieve dataset. The patient\u2013AI interaction data (chat logs and free-text survey responses) cannot be made publicly available because they contain unstructured protected health information. Requests for access from qualified academic researchers may be submitted to the corresponding authors and will be reviewed by the investigators and the University of Pennsylvania; the response time will be within approximately 5 business days.","Any data released will be de-identified and subject to a data use agreement prohibiting re-identification, onward redistribution and use beyond the approved research purpose.\r\nCode availability\r\nThe study comprises five software components, four of which are publicly available under the GNU General Public License (v3.0) as follows: (1) real-time data processing and feature computation pipelines (https:\/\/github.com\/penn-cnt\/Pioneer-Databricks-Release); (2) the patient-facing chat interface (https:\/\/github.com\/penn-cnt\/Pioneer-Chat-Release); (3) offline seizure-detection model fine-tuning and evaluation (https:\/\/github.com\/penn-cnt\/Pioneer-Finetune-Release); and (4) analysis and figure generation (https:\/\/github.com\/penn-cnt\/Pioneer-Analysis-Release).","The fifth component, edge-device EEG streaming to Azure Event Hubs, depends on the proprietary Natus NeuroWorks real-time streaming SDK, which is confidential and cannot be publicly released; this code can be shared under a usage agreement with Natus. Replication of the complete framework also requires secure Azure and Databricks cloud infrastructure and configuration, which are institution specific and are therefore not fully reproducible from the released source code alone.\r\nReferences\r\nJette, N.","& Wiebe, S. Update on the surgical treatment of epilepsy. Curr. Opin. Neurol.","26, 201\u2013207 (2013).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nNair, D. R. et al. Nine-year prospective efficacy and safety of brain-responsive neurostimulation for focal epilepsy. Neurology 95, e1244\u2013e1256 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRehman, M.,","Higdon, L. M. & Sperling, M. R. Long-term home EEG recording: wearable and implantable devices. J. Clin. Neurophysiol.","41, 200\u2013206 (2024).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nHalliday, A. J. et al. The UMPIRE study: a first-in-human multicenter trial of bilateral subscalp monitoring for epileptic seizure detection. Epilepsia 66, 3426\u20133439 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nSnyder, D.","E.,","Echauz, J.,","Grimes, D. B.","& Litt, B. The statistics of a practical seizure warning system. J. Neural. Eng.","5, 392\u2013401 (2008).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nCook, M. J. et al. Prediction of seizure likelihood with a long-term, implanted seizure advisory system in patients with drug-resistant epilepsy: a first-in-man study. Lancet Neurol.","12, 563\u2013571 (2013).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nMitchell, J.","W.,","Doherty, J.,","Batchelor, R.,","Noble, A.","& Marson, A.","What matters most to people living with epilepsy?","A rapid review of qualitative research relating to health outcomes. Epilepsia 66, 4122\u20134138 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nHill, C.","E., Vanderboll, K.,","Parent, J.","M.,","Skolarus, L. E. & Zahuranec, D. B. Health priorities and treatment preferences of adults with epilepsy: a narrative literature review with a systematic search. Epilepsy Behav.","166, 110359 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRapport, F.,","Clement, C.,","Doel, M. A. & Hutchings, H. A. Qualitative research and its methods in epilepsy: contributing to an understanding of patients\u2019 lived experiences of the disease. Epilepsy Behav.","45, 94\u2013100 (2015).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nCamarillo, I.","A.,","Misiewicz, S.,","Siegel, K.","& Ottman, R. The concept of \u2018control\u2019 in people with epilepsy: a qualitative study. Epilepsy Behav.","161, 110059 (2024).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nBoele, F. et al. Health-related quality of life and unmet needs of people with epilepsy and their family caregivers: a systematic scoping review. Epilepsy Behav.","171, 110601 (2025).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nJing, J. et al. Development of expert-level classification of seizures and rhythmic and periodic patterns during EEG interpretation. Neurology 100, e1750\u2013e1762 (2023).\r\n\r\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRevell, A. Y. et al. AI-driven mapping of seizure spread patterns. Ann. Neurol.","100, 59\u201373 (2026).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nJing, J. et al. Development of expert-level automated detection of epileptiform discharges during electroencephalogram interpretation. JAMA Neurol.","77, 103\u2013108 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nAguila, C. A. et al. Mesial-to-lateral gradients of epileptiform activity to localize mesial temporal lobe epilepsy. Epilepsia 66, 3491\u20133504 (2025).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nVallat, R.","& Walker, M. P. An open-source, high-performance tool for automated sleep staging.","eLife 10, e70092 (2021).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nMa, D. et al. Synchrony is a robust iEEG biomarker for antiseizure medication load in epileptic patients. Preprint at bioRxiv https:\/\/doi.org\/10.64898\/2026.01.09.698669 (2026).\r\n\r\nBrooke, J. SUS: a \u2018quick and dirty\u2019 usability scale. in Usability Evaluation in Industry (eds Jordan, P. W. et al.) 189\u2013194 (Taylor and Francis, 1996).\r\n\r\nBernini, A.,","Dan, J.","& Ryvlin, P. Ambulatory seizure detection. Curr. Opin. Neurol.","37, 99\u2013104 (2024).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nBeran, R. G. Use of interval therapy with benzodiazepines to prevent seizure recurrence in stressful situations. Brain Sci.","12, 512 (2022).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nSaab, K.,","Dunnmon, J.,","R\u00e9, C.,","Rubin, D. & Lee-Messer, C. Weak supervision as an efficient approach for automated seizure detection in electroencephalography. npj Digit. Med.","3, 59 (2020).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nRoth, D. Incidental supervision: moving beyond supervised learning. Proc. 31st AAAI Conference on Artificial Intelligence Vol.","31, 4885\u20134890 (AAAI Press, 2017).\r\n\r\nXu, Z. et al. Annotating neurophysiologic data at scale with optimized human input. J. Neural. Eng.","22, 046003 (2025).\r\n\r\nArticle\n\nGoogle Scholar\r\n\r\nPearson, C. et al. Care access and utilization among medicare beneficiaries living with Parkinson\u2019s disease. npj Parkinsons Dis.","9, 108 (2023).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nWu, K.,","Zhao, Z.","& Yener, B. Large EEG-U-transformer for time-step level detection without pre-training. Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2504.00336 (2025).\r\n\r\nSverrisson, \u00de. & Gu\u00f0mundsson, S. LookAroundNet: extending temporal context with Transformers for clinically viable EEG seizure detection. Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2601.06016 (2026).\r\n\r\nYao, Y.,","Wang, H.,","Chen, L.,","Peng, Y.","& Luo, J. Foundation models for EEG decoding: current progress and prospective research. J. Neural. Eng.","22, 061002 (2025).\r\n\r\nArticle\n\nGoogle Scholar\r\n\r\nOjemann, W. K. S. et al. Unsupervised seizure annotation and detection with neural dynamic divergence. Preprint at medRxiv https:\/\/www.medrxiv.org\/content\/10.64898\/2026.02.15.26346325 (2026).\r\n\r\nOjemann, W. K. S. et al. Multi-expert consensus annotations of spontaneous and stimulation-induced seizures in stereotactic EEG. Preprint at medRxiv https:\/\/www.medrxiv.org\/content\/10.64898\/2026.01.15.26344025 (2026).\r\n\r\nGhosn, N. J. et al. A pharmacokinetic model of antiseizure medication load to guide care in the epilepsy monitoring unit. Epilepsia 64, 1236\u20131247 (2023).\r\n\r\nArticle\nPubMed\nPubMed Central\n\nGoogle Scholar\r\n\r\nYao, S. et al. ReAct: synergizing reasoning and acting in language models.","Preprint at arXiv https:\/\/doi.org\/10.48550\/arXiv.2210.03629 (2023).\r\n\r\nRichards, K.","C., O\u2019Sullivan, P. S. & Phillips, R. L. Measurement of sleep in critically ill patients. J. Nurs. Meas.","8, 131\u2013144 (2000).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nDan, J. et al. SzCORE: seizure community open-source research evaluation framework for the validation of electroencephalography-based automated seizure detection algorithms. Epilepsia 66, 14\u201324 (2025).\r\n\r\nArticle\nPubMed\n\nGoogle Scholar\r\n\r\nShi, H. et al. Data for human-AI collaboration for co-managing epilepsy in real time. Pennsieve Platform for Data Management https:\/\/doi.org\/10.26275\/ju7h-bo8u (2026).\r\n\r\nDownload references\r\nAcknowledgements\r\nThe authors are grateful to all patients and their families for their involvement in the research program. The authors thank L.","Faillace, L. Simmons and the staff, fellows and technicians of the Hospital of the University of Pennsylvania Epilepsy Monitoring Unit for their invaluable assistance and cooperation during the study. The authors also thank S. McCurdy (Penn Medicine, University of Pennsylvania Health System) and J. Dada (Natus Medical Incorporated) for their help in setting up the real-time EEG data streaming service and D.","Lydon-Staley (Annenberg School for Communication, University of Pennsylvania) for providing survey expertise.\r\nFunding\r\nThis work was supported by a National Institutes of Health (NIH) Pioneer Award (DP1-NS-122038), NIH\/NINDS (R01-NS-125137), NIH (T32NS091006) and foundation support from Jonathan and Bonnie Rothberg, Neil and Barbara Smit, and the Small Lake Foundation. K.A.D. received funding from NIH\/NINDS (awards R61-NS-125568 and R01-NS-116504). N.S. received funding from NIH\/NINDS (award K99NS138680) and the Department of Defense (grant W81XWH2210593). E.C.","received support from NIH\/NINDS (award K23 NS121401-01A1) and the Burroughs Wellcome Fund.\r\nAuthor information\r\nAuthor notes\r\n\r\nThese authors contributed equally: Zack Goldblum, Haoer Shi.\r\nAuthors and Affiliations\r\nCenter for Neuroengineering and Therapeutics, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum,\u00a0Haoer Shi,\u00a0Zhongchuan Xu,\u00a0William K. S.","Ojemann,\u00a0Carlos A.","Aguila,\u00a0Kevin Xie,\u00a0Kerry C.","Nix,\u00a0Katherine G.","Walsh,\u00a0Ellie Chang,\u00a0Sarah B.","Lavelle,\u00a0Brandon Bach,\u00a0Kathryn A.","Davis,\u00a0Nishant Sinha,\u00a0Lauren H.","Hammer,\u00a0Erin C. Conrad\u00a0&\u00a0Brian Litt\r\n\r\nDepartment of Bioengineering, School of Engineering and Applied Science, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum,\u00a0Haoer Shi,\u00a0Zhongchuan Xu,\u00a0William K. S.","Ojemann,\u00a0Carlos A.","Aguila,\u00a0Katherine G.","Walsh,\u00a0Ellie Chang,\u00a0Lauren H. Hammer\u00a0&\u00a0Brian Litt\r\n\r\nCenter for Health, Devices and Technology, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nZack Goldblum\u00a0&\u00a0Brian Litt\r\n\r\nPenn Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Long\r\n\r\nCenter for Healthcare Transformation and Innovation, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Xie\r\n\r\nDepartment of Neurology, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKevin Xie,\u00a0Kathryn A.","Davis,\u00a0Nishant Sinha,\u00a0Lauren H.","Hammer,\u00a0Erin C. Conrad\u00a0&\u00a0Brian Litt\r\n\r\nDepartment of Neuroscience, Perelman School of Medicine, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nKerry C. Nix\r\n\r\nDepartment of Biostatistics, Epidemiology and Informatics, University of Pennsylvania, Philadelphia, PA, USA\r\n\r\nNishant Sinha\r\nContributions\r\nB.L. conceptualized the study and supervised the project.","B.L., Z.G. and H.S. designed the overall study.","Z.G., H.S. and K.L. developed the platform and supporting cloud infrastructure. Z.G. enrolled patients. B.B. managed the project and the clinical data.","Z.G., H.S. and Z.X. performed the computational analyses, created the visualizations and drafted the paper. All authors contributed important intellectual content and approved the final manuscript.\r\nCorresponding authors\r\nCorrespondence to\nZack Goldblum or Brian Litt.\r\nEthics declarationsCompeting interests\r\nZ.G., H.S. and B.L. are named inventors on a U.S. provisional patent (application 63\/932,309; filed 5 December 2025; status: pending), filed by The Trustees of the University of Pennsylvania, entitled \u2018System and Method for Real-Time Biosignal Analysis, Behavioral Monitoring and Treatment Employing Conversational Artificial Intelligence\u2019.","It covers the real-time biosignal analysis, behavioral monitoring and conversational AI treatment system described in this article. The other authors declare no competing interests.\r\nPeer reviewPeer review information\r\nNature Medicine thanks Marcello Ienca, Samden Lhatoo, Alik Widge and the other, anonymous, reviewer(s) for their contribution to the peer review of this work. Primary Handling Editor: Jerome Staal, in collaboration with the Nature Medicine team.","Peer reviewer reports are available.\r\nAdditional information\r\nPublisher\u2019s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.\r\nExtended dataExtended Data Table 1 Patient information and interactions\r\nFull size table\r\nExtended Data Fig. 1 Synchrony as a biomarker for antiseizure medication load.\r\na, Time series of synchrony and normalized antiseizure medication (ASM) load across the entire epilepsy monitoring unit (EMU) stay for a representative patient.","b, Predicted response surface from a linear mixed model with normalized ASM load as the dependent variable, synchrony and alpha-delta ratio as fixed-effect predictors, and patient as a random effect.\r\nExtended Data Fig. 2 Per-patient, daily breakdown of platform engagement, response behavior and annotation performance.\r\na\u2013c, Cell shading encodes patient interactions (see colorbars); white cells indicate the feature was available but unused on that day; gray cells indicate the feature was unavailable or the patient had been discharged.","a, Heatmaps of patient-initiated messages per day across \u2018general chat\u2019 and \u2018data agent\u2019 categories: seizure queries, sleep queries and spike queries. Each row is one patient (P001\u2013P013); each column is a day of participation (D1\u2013D7). Numerical annotations report the exact message count.","b, Per-patient daily response rates to system-initiated seizure (n\u2009=\u200958) and interictal spike (n\u2009=\u200933) alerts. Proportion of alerts the patient responded to that day (responded\/sent) is shown as annotations.","c, Per-patient daily completion of the morning, afternoon and evening surveys (n\u2009=\u200948 each). Checkmarks indicate a completed survey.","d, Per-patient annotation accuracy against clinician-annotated ground truth, stratified by source. Cells display the raw count fraction, while shading encodes performance metrics. From left to right: patient self-reported push-button alarms, platform-issued alerts, patient annotations of those alerts through the app and the platform overall (combining alert generation with patient annotation). A summary row (\u2018sum\u2019) aggregates events across patients for each metric. Abbreviations: NPV: negative predictive value.\r\nExtended Data Fig. 3 Seizure detection performance at baseline (n\u2009=\u200913).\r\nEach dot represents one patient.","The box represents the interquartile range (IQR) with a central line indicating the median across patients; whiskers extend to 1.5\u00d7 IQR. Abbreviations: AUROC: area under the receiver operating characteristic curve; AUPRC: area under the precision-recall curve.\r\nRights and permissions\r\nOpen Access This article is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License, which permits any non-commercial use, sharing, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if you modified the licensed material.","You do not have permission under this licence to share adapted material derived from this article or parts of it. The images or other third party material in this article are included in the article\u2019s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article\u2019s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:\/\/creativecommons.org\/licenses\/by-nc-nd\/4.0\/.\r\n\r\nReprints and permissions\r\nAbout this article\r\n\r\nCite this article\r\nGoldblum, Z.,","Shi, H.,","Xu, Z. et al. Human\u2013artificial intelligence collaboration for comanaging epilepsy in real time.\nNat Med (2026). https:\/\/doi.org\/10.1038\/s41591-026-04680-4\r\n\r\nDownload citation\r\n\r\nReceived: 09 March 2026\r\n\r\nAccepted: 26 August 2026\r\n\r\nPublished: 13 October 2026\r\n\r\nVersion of record: 13 October 2026\r\n\r\nDOI: https:\/\/doi.org\/10.1038\/s41591-026-04680-4"],"images":[{"src":"\/news\/images\/TkbOmERl9AxXIxuBGmutuUwR6UsixSbO2KpXNdwPDxcvo9suZtrqd7ng772quSB6Jovyvn1cNGA4x3NOqTi8rktwPQDSeqZ2gNu0nN7gA9609cYx2kvYEUS1i8NjjJnATzGwEpWQMcr3cQpaWgTNu0inCp4ik.jpg","width":0,"height":0,"source":"featured","size":0}],"tickers":[]}"
}
}
[4]=>
array(4) {
["file"]=>
string(22) "/app/news/article.html"
["line"]=>
int(11)
["function"]=>
string(18) "news_article_fetch"
["args"]=>
array(1) {
[0]=>
string(70) "SNgSFz1UYwUgnAye8Iq6AwimFnBOT9jdyRE0kXeBSMWDBytDmFWIqUjBzXoAEIULeJjOhk"
}
}
}