{"id":209175,"date":"2026-10-17T14:44:18","date_gmt":"2026-10-17T14:44:18","guid":{"rendered":"https:\/\/www.europesays.com\/ai\/209175\/"},"modified":"2026-10-17T14:44:18","modified_gmt":"2026-10-17T14:44:18","slug":"human-artificial-intelligence-collaboration-for-comanaging-epilepsy-in-real-time","status":"publish","type":"post","link":"https:\/\/www.europesays.com\/ai\/209175\/","title":{"rendered":"Human\u2013artificial intelligence collaboration for comanaging epilepsy in real time"},"content":{"rendered":"<p>Study design<\/p>\n<p>This 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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"table anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Tab1\" rel=\"nofollow noopener\" target=\"_blank\">1<\/a>. 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.<\/p>\n<p>The 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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">Supplementary Methods<\/a>.<\/p>\n<p>Procedures<\/p>\n<p>Expert 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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">7<\/a>) and clinical data were aggregated for research use under the approved protocol. Figure <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"figure anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Fig1\" rel=\"nofollow noopener\" target=\"_blank\">1<\/a> provides an overview of the study platform.<\/p>\n<p>Platform implementationOverview<\/p>\n<p>The platform comprised the following three interconnected systems (Fig. <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"figure anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Fig2\" rel=\"nofollow noopener\" target=\"_blank\">2a<\/a>): (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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">10<\/a>).<\/p>\n<p>Real-time EEG data acquisition and streaming<\/p>\n<p>Continuous 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.<\/p>\n<p>Cloud data processing and feature extraction<br \/>\n                  Preprocessing<\/p>\n<p>EEG 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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">Methods<\/a>) 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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">2<\/a> and <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">3<\/a>).<\/p>\n<p>                  Scalp EEG seizure detection<\/p>\n<p>For scalp recordings, we used SPaRCNet<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 12\" title=\"Jing, J. et al. Development of expert-level classification of seizures and rhythmic and periodic patterns during EEG interpretation. Neurology 100, e1750&#x2013;e1762 (2023).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR12\" id=\"ref-link-section-d104467027e1976\" rel=\"nofollow noopener\" target=\"_blank\">12<\/a>, 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:<\/p>\n<p>$$S\\left(t\\right)=\\max \\left(0,S\\left(t-1\\right)+P\\left(t\\right)-k\\right)$$<\/p>\n<p>\n                    (1)\n                <\/p>\n<p>where 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.<\/p>\n<p>                  iEEG seizure detection<\/p>\n<p>For intracranial data, we evaluated both WaveNet<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 13\" title=\"Revell, A. Y. et al. AI-driven mapping of seizure spread patterns. Ann. Neurol. 100, 59&#x2013;73 (2026).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR13\" id=\"ref-link-section-d104467027e2074\" rel=\"nofollow noopener\" target=\"_blank\">13<\/a> 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 patients<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 28\" title=\"Ojemann, W. K. S. et al. Unsupervised seizure annotation and detection with neural dynamic divergence. Preprint at medRxiv &#010;                https:\/\/www.medrxiv.org\/content\/10.64898\/2026.02.15.26346325&#010;                &#010;               (2026).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR28\" id=\"ref-link-section-d104467027e2078\" rel=\"nofollow noopener\" target=\"_blank\">28<\/a>. 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 set<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 29\" title=\"Ojemann, W. K. S. et al. Multi-expert consensus annotations of spontaneous and stimulation-induced seizures in stereotactic EEG. Preprint at medRxiv &#010;                https:\/\/www.medrxiv.org\/content\/10.64898\/2026.01.15.26344025&#010;                &#010;               (2026).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR29\" id=\"ref-link-section-d104467027e2082\" rel=\"nofollow noopener\" target=\"_blank\">29<\/a>. 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.<\/p>\n<p>                  Additional features<\/p>\n<p>We detected scalp EEG spikes using SpikeNet<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 14\" title=\"Jing, J. et al. Development of expert-level automated detection of epileptiform discharges during electroencephalogram interpretation. JAMA Neurol. 77, 103&#x2013;108 (2020).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR14\" id=\"ref-link-section-d104467027e2097\" rel=\"nofollow noopener\" target=\"_blank\">14<\/a> and iEEG spikes using a separate validated detector<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 15\" title=\"Aguila, C. A. et al. Mesial-to-lateral gradients of epileptiform activity to localize mesial temporal lobe epilepsy. Epilepsia 66, 3491&#x2013;3504 (2025).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR15\" id=\"ref-link-section-d104467027e2101\" rel=\"nofollow noopener\" target=\"_blank\">15<\/a>. Sleep was staged with YASA<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 16\" title=\"Vallat, R. &amp; Walker, M. P. An open-source, high-performance tool for automated sleep staging. eLife 10, e70092 (2021).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR16\" id=\"ref-link-section-d104467027e2105\" rel=\"nofollow noopener\" target=\"_blank\">16<\/a> 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 group<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 30\" title=\"Ghosn, N. J. et al. A pharmacokinetic model of antiseizure medication load to guide care in the epilepsy monitoring unit. Epilepsia 64, 1236&#x2013;1247 (2023).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR30\" id=\"ref-link-section-d104467027e2109\" rel=\"nofollow noopener\" target=\"_blank\">30<\/a>. Identified events were visualized as heatmaps, animated head topographic maps, hypnograms and line plots for presentation to patients (Fig. <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"figure anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Fig1\" rel=\"nofollow noopener\" target=\"_blank\">1<\/a>). Window sizes, montages, thresholds, event definitions and visualization details for each feature are provided in Supplementary Tables <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">2<\/a> and <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">3<\/a> and Supplementary <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">Methods<\/a>.<\/p>\n<p>                Patient-facing application<\/p>\n<p>The 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.<\/p>\n<p>The 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.<\/p>\n<p>Conversational AI<\/p>\n<p>The conversational AI (Fig. <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"figure anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Fig2\" rel=\"nofollow noopener\" target=\"_blank\">2b<\/a>) 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 loop<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 31\" title=\"Yao, S. et al. ReAct: synergizing reasoning and acting in language models. Preprint at arXiv &#010;                https:\/\/doi.org\/10.48550\/arXiv.2210.03629&#010;                &#010;               (2023).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR31\" id=\"ref-link-section-d104467027e2150\" rel=\"nofollow noopener\" target=\"_blank\">31<\/a>. 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.<\/p>\n<p>Each 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.<\/p>\n<p>To 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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">10<\/a>) 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.<\/p>\n<p>Predeployment 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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">Methods<\/a>.<\/p>\n<p>Surveys<\/p>\n<p>The 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 Questionnaire<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 32\" title=\"Richards, K. C., O&#x2019;Sullivan, P. S. &amp; Phillips, R. L. Measurement of sleep in critically ill patients. J. Nurs. Meas. 8, 131&#x2013;144 (2000).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR32\" id=\"ref-link-section-d104467027e2177\" rel=\"nofollow noopener\" target=\"_blank\">32<\/a> assessing sleep depth, latency, wakefulness, maintenance and overall quality. The exit survey comprised the 10-item System Usability Scale<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 18\" title=\"Brooke, J. SUS: a &#x2018;quick and dirty&#x2019; usability scale. in Usability Evaluation in Industry (eds Jordan, P. W. et al.) 189&#x2013;194 (Taylor and Francis, 1996).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR18\" id=\"ref-link-section-d104467027e2181\" rel=\"nofollow noopener\" target=\"_blank\">18<\/a> (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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">4<\/a>\u2013<a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">7<\/a>.<\/p>\n<p>Interaction and engagement analysis<\/p>\n<p>To 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. <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"figure anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Fig3\" rel=\"nofollow noopener\" target=\"_blank\">3e<\/a>, 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. <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"figure anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Fig3\" rel=\"nofollow noopener\" target=\"_blank\">3e<\/a>, 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.<\/p>\n<p>Model fine-tuningPatient-in-the-loop fine-tuning<\/p>\n<p>We 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.<\/p>\n<p>Samples 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:<\/p>\n<p>$$\\hat{y}=\\frac{1}{k}\\sum _{i=1}^{k}{p}_{\\left(i\\right)},$$<\/p>\n<p>\n                    (2)\n                <\/p>\n<p>where 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.<\/p>\n<p>Fine-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 <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM1\" rel=\"nofollow noopener\" target=\"_blank\">Methods<\/a>.<\/p>\n<p>Clinician-in-the-loop fine-tuning<\/p>\n<p>Deep 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.<\/p>\n<p>Performance evaluation<\/p>\n<p>We 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. <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"figure anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Fig5\" rel=\"nofollow noopener\" target=\"_blank\">5a<\/a>). 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 framework<a data-track=\"click\" data-track-action=\"reference anchor\" data-track-label=\"link\" data-test=\"citation-ref\" aria-label=\"Reference 33\" title=\"Dan, J. et al. SzCORE: seizure community open-source research evaluation framework for the validation of electroencephalography-based automated seizure detection algorithms. Epilepsia 66, 14&#x2013;24 (2025).\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#ref-CR33\" id=\"ref-link-section-d104467027e2378\" rel=\"nofollow noopener\" target=\"_blank\">33<\/a>, 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.<\/p>\n<p>We 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.<\/p>\n<p>Statistical analysis<\/p>\n<p>To 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. <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"figure anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#Fig5\" rel=\"nofollow noopener\" target=\"_blank\">5a<\/a>). 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 &lt;0.05 considered statistically significant.<\/p>\n<p>Analyses 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.<\/p>\n<p>Reporting summary<\/p>\n<p>Further information on research design is available in the <a data-track=\"click\" data-track-label=\"link\" data-track-action=\"supplementary material anchor\" href=\"http:\/\/www.nature.com\/articles\/s41591-026-04680-4#MOESM2\" rel=\"nofollow noopener\" target=\"_blank\">Nature Portfolio Reporting Summary<\/a> linked to this article.<\/p>\n","protected":false},"excerpt":{"rendered":"Study design This prospective, single-center observational study developed and evaluated a real-time patient\u2013data interface in a level 4&hellip;\n","protected":false},"author":2,"featured_media":209176,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[24,25,49512,7040,7044,81045,617,2533,15020,7043,15021,4793],"class_list":["post-209175","post","type-post","status-publish","format-standard","has-post-thumbnail","category-ai","tag-ai","tag-artificial-intelligence","tag-biomedical-engineering","tag-biomedicine","tag-cancer-research","tag-epilepsy","tag-general","tag-infectious-diseases","tag-metabolic-diseases","tag-molecular-medicine","tag-neurosciences","tag-translational-research"],"_links":{"self":[{"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/posts\/209175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/comments?post=209175"}],"version-history":[{"count":0,"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/posts\/209175\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/media\/209176"}],"wp:attachment":[{"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/media?parent=209175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/categories?post=209175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.europesays.com\/ai\/wp-json\/wp\/v2\/tags?post=209175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}