EP 65 · 44:57

Putting patients in the feedback loop

From What Happens When AI Gets a Lab?

Episode
7/16
Watch What Happens When AI Gets a Lab?
In this chapter

The chapter describes BrainChat, a research platform built at the University of Pennsylvania that connects epilepsy patients' EEG recordings to an agentic large language model, letting patients talk to their own brain data in natural language. A separate machine-learning model handles seizure detection from the EEG signal while the LLM manages the conversation, asking patients whether they consciously felt a seizure and turning their yes, no, or uncertain answers into training labels. The hosts describe this as shifting epilepsy monitoring from a one-way alarm system, prone to false positives like chewing artifacts, into a closed loop where patient feedback actively improves the detection model.

  1. 01

    The study recruited 13 adults in an epilepsy monitoring unit, 11 using scalp EEG and 2 using intracranial EEG.

  2. 02

    The system also models sleep stage and medication timing/decay as additional inputs feeding the ensemble of models that decide whether to trigger an alert.

  3. 03

    The architecture includes two safety gates, one moderating incoming patient messages and one moderating the AI's response before it reaches the patient.

  4. 04

    A message router decides whether a patient query is general chat or requires a SQL-style query into the patient's EEG database before the LLM responds.

  5. 05

    On-screen clarification notes the GPT-4o-mini model ran in Penn's HIPAA-compliant Azure OpenAI cloud environment, not locally as the hosts suggest.

Transcript

2,975 words · auto-generated from the episode video

44:57Now instead of open loop, we've got a closed loop kind of thing, right? The device knows when the she seizure is coming, but at the same time it's not closed in the sense that the patient is aware of what is going on, right? You can't you can't tell the patient maybe you need to sit down, maybe you need to pull the car over, >> alert, alert, >> like yeah, alert you're about to have a seizure, >> right? Which would be obviously great. >> That would be great. And that's where the breakthrough currently comes in handy. >> This is this the patient was never involved in any of the the the communication cycle of this. Obviously, we weren't there yet. >> Yeah. >> But because it required like a human

45:37being with a trained experience to understand all of these things. Now, with the advent of machine learning, you can put the patient in the loop >> of his or her own medical >> destiny. >> Yeah. >> It's pretty incredible. It's a this is a really big deal. Um because I think it also, you know, there's this whole been this whole era of like quantified self and you're going to get all this medical information from all these devices we have around us. It's going to help you improve your well-being. >> But part of and this is that's a different thing than medical and clinical treatments and solutions. I'm not saying they're the same thing, but there's been this big promise with the rise of technology as bringing us closer

46:18to understanding our own bodies >> in real time. M >> um and this is a perfect example of how that can have a hugely important impact for uh epilepsy patients. >> Yeah. And I think I think it's not only limited to epilepsy. This particular case >> is taking epilepsy as kind of like this microcosm because it's it's such a rich data set in terms of like you know you get >> in intraraanial stimulation. There's a lot of data that's going on. It requires a lot of expertise that perhaps a machine learning model can elucidate, but um it's it's absolutely an

46:59incredible paper. It's a team out of the University of Pennsylvania. And what they've done is fundamentally re-imagine the patient device relationship by bridging this EEG that comes with the the patients of epilepsy with agentic large language models. Right? That's the key. You're tying in the brain waves from inside the brain of these epileptic patients with now agentic models that use large language. >> This models this is the the promise that has been again large language models are not just a tool in the context of a chatbot. >> Yes. >> Is kind of the point here.

47:40>> Yeah. They've built a kind of interface that allows the patient to maybe interface with the chatbot, but the chatbot now has access to all of the data from within the patient's brain itself. It's incredible, dude. >> Now, now I actually like you know from a personal standpoint um my PhD had to do with electrophysiology, right? where you know you're taking electrodes, you're sticking it inside um the rodent brain while the rodent is freely behaving inside mazes inside you know behavioral tasks. One of the in one of the bane the bane

48:21of my existence during my PhD was deciphering between real neural signal and all of the artifacts that come with behavior. >> Because if the rodent is chewing, that's going to cause electrical signal, right? If the rodent is um going into like a micronap, that's going to cause electrical signal. >> This problem is real even for epilepsy patients, right? Because if you've got electrodes that are going into the brain, there's a giant signal to noise problem because brain waves are incredibly chaotic and highly variable. Here we're seeing brain waves where

49:03chewing artifacts come in. All of those all of those jagged things, that's when the person is chewing. >> That's crazy, >> right? If you have a really terrible machine learning classifier that just thinks you're having a seizure every time you chew. >> Yeah. Not great. >> That's not going to be great for two reasons. There's this thing called alarm fatigue, which is basically the boy who cried wolf, >> right? If if every time >> Yeah. If every time the thing just says, "Hey, you're going to have a seizure," and you're not having a seizure. There's so many false positives, well, then you're going to just disregard the thing. Right. Right. And two, if you're kind of someone who has seizures and has anxiety, that's

49:44going to add to your anxiety and it's going to like be detrimental to your well-being at the end of the day. Like the whole point is to get better and like having these alerts is making it worse right? >> You're constantly put in this state of a heightened >> Exactly. >> You know, u defense mode anyway. >> Right. And and the the reason why this is so hard is because historically tuning these algorithms requires an expert neurologist to manually go through all of the data from your brain and be like, "Yep, that was you chewing. That was you not chewing. That was an actual seizure right there." Right? You got to have some MD be like, "That was an actual seizure. We got to tag that,

50:25not tag the other thing." Now, >> I can't believe it. >> You flip the script entirely, right? You're you're turning the patient into a collaborator for training the neural network, for training the machine learning model. >> This is so good. >> It's I dude I think I think it's so cool. I mean, there are things that are involved here that they were very careful about. You've got to be HIPPA compliant. And >> um these guys at UPUPEN, they made a system that features a HIPPA compliant instance of the GPT40 mini. >> So this is one of those mini models that OpenAI has, right? which means that you can like like put it on a local thing, >> right? It doesn't need to go to the cloud. >> It doesn't. Yeah. Yeah. So now patient

51:06data is not going to the cloud and like you know the the the Levant El Pog and Buckmaster >> uh nightmare where right where it's like they if if you guys don't know the Navier Stokes episode right Buckmaster was talking to OpenAI codeex about his solution for Navier Stokes and now behold >> lo and behold a week later >> yeah OpenAI came out with Navier Stokes right like I don't know I don't know how that happened Well, in this case, they've got a GPT40 mini that is local, right? So, there's no way that HIPPA that the data from the patient is going into the cloud. It's it's and it it's

51:47non-trivial to be able to execute something like this on on one of these smaller mini models. Like that's been part of the challenge generally is is you want the capability as you go to smaller parameter based smaller parameter models, you lose some of the capability you're looking for in an LLM. So, to be able to uh work within that constraint and still get the solution is I think an interesting part of the the the success here. Exactly. And one thing that I want to note here is the LLM is not actually doing the medical diagnosing. Okay. They've got a specific model, a neural network that they've trained for earlier purposes that is doing the medical diagnosis. Like there there's a

52:29separate model that is like taking in the brain waves and being like, "Hey, is this epilepsy? is this not blah blah blah. The LLM is being used to interface with the patient because that's the whole point of the language, right? It's like as a patient, I want to use natural language to interact with whatever data modality. >> Crazy, >> right? >> So, it's really agent-based. Like there's the agent that's the LLM, >> then there's the agent that's like has nothing to do with English, but just trying to classify brain waves. mate. Yeah. I I I think I think I think it's really cool. So So you can imagine, right? Like the deep learning model

53:09detects anomalous brain synchrony. The AI then texts the patient, "Hey, did you just experience a seizure?" >> This is so crazy. >> And and then the patient is like, "Uh, no, that was just me like jumping up and down." Or, "Actually, that felt weird. That might have been a seizure." And now it's again you're taking the the cycle of training goes from patient collects data over x period of time. It goes to the physician. The physic physician spends x period of time with some assistant or someone else that's tagging manually and then >> the physician doesn't even know the personal experience of the patient. So it's like experiencing the seizure. So they're just looking at it and based on

53:50our past things this is what normally and so it actually it has both the combination of bringing the patient into their own >> uh giving them a sense of control in their own experience but it also has a very functional benefit to improving the detection >> because the the part of the challenge is always patient translating their experience to the physician and then like that back and forth which there's it's a very uh noisy the signal to noise there is also not right right >> I mean it's absolutely incredible I think I think we're standing at a new dawn of medical technology right we're moving away from passive hardware that

54:30treats patients as biological substrates and towards semiautonomous conversational partners >> that help us navigate our own biology like imagine you have your you have like agency over your own kind of outcome in some sense And and I want to make a small note here. I there's a I know there's a lot of u people have a lot of feelings about specific providers of foundational models. >> Yeah. >> Uh I think part of the point here is >> this could be done on an open source mini model. It's not it's not open AI mini specific. It happens to be what they used in this case. >> The large language model is doing a very

55:11small amount. Right. Honestly, >> right. Right. And but I just wanted to make that distinction that you you know the >> now that we understand it can be done. >> This can be extrapolated to whatever provider you prefer. >> Yes, exactly. >> Um >> yeah. Um it's incredible. I want I want to take a brief note about how they actually did it because you know even though this is a rundown episode, I want to get into like some of the >> We got to hit two hours. You know how it is. >> Yeah. Yeah. Yeah. I'm sorry guys, but you know these pen researchers, they recruited 13 adults >> in the epilepsy monitoring unit. The setting here matters because it's an epilepsy monitoring unit which is one of these things where you go in high quality recording there's clinical

55:52supervision there's detailed event review and also sometimes they even take reduced medication to induce more and more epilepsy >> and more and more seizures to actually get more and more data. So that matters a little bit, right? Um the platform actually there's three parts. There's a stream of EEG and clinical information and then there's software that extracts whatever the useful measurements are and then that goes into a phone interface that then connects to the patients and the patients can be like just like in the epilepsy monitoring unit with their phone talking to this agent that is also talking to like the models that are interpreting data from his brain. This

56:34is so good, >> dude. It's It's absolutely incredible. >> It's clever, too. Yeah. It's so obvious. Like, it's so obvious in retrospect. >> Yeah. And And there's so many multiple modalities here. Like, there's a system that estimates sleep stages so that that is not confounding the algorithm. There's a system that med that estimates medication because there's medication information in the patient's notes, right? That'll tell you, okay, the patient took the medication at this time. And then there's a model that tells you how the medication is deteriorating with time. >> And that's going to inform this ensemble of machine learning

57:14models. >> We have all these inputs into the model that gets to decide, do I set the alarm on or off? And you also now have the feedback of the patient, which is arguably one of the most important inputs. Yeah. Into that >> uh let's call it detection system. Um, and to be able to have them all connected and streaming >> Mhm. >> real time. >> Yeah, it's absolutely very very cool. And the result is a structured collection of measurements, right? You can you can have these measurements be queried, plotted, and discussed. And the chatbot and the seizure detector are different models that are doing different jobs, but they're all coming together for this seamless sort of loop. The patient has a brain interface. It

57:57goes through all of the stuff, but the patient only only interacts with it using natural language, which means that, you know, it's kind of a democratized system. The patient doesn't have to understand what the machine learning nonsense is happening. Right. Right. >> The chatbot is going to go ahead and ask it questions and get the feedback. This is something we talked about at the end of our Navier Stokes episode, which is when we talk about these concepts of AI, we have to think about them as systems, not as individual component parts. Because this is a perfect example of why that framework of how to think about these things matters because they can be individual modules with discrete functions that can work in collaboration

58:38towards an end goal and they're also not just LLMs. There's a whole variety has a whole ecosystem of meaning and capability. Yeah. >> Uh and this is an example of combining two things in machine learning and the LLM. >> Exactly. >> Uh to for an outcome that has clinical relevance. >> Yeah. And and actually to piggyback back off of that, um you you can ask like what exactly is this m this there's a bunch of agents, right? What exactly is happening? Well, let's suppose a patient asks how much sleep they got last night and how good it was. Well, they've published kind of a flowchart of how things happen. Yeah. >> You've you received the patient message.

59:18Now, if the message is unsafe, then you don't do anything. you you maybe you know alert the physician who's in charge and things like that but if it's safe then you have a message router. >> Yes. >> And the router asks okay is this a general chat or do I need to actually do a data query? >> Yep. >> Right. If it's a data query >> then it actually instantiates a SQL query. Yeah, >> like there there's there's an agent that goes, "Okay, I'm going to go into the SQL database of all of the data on this patient and like instantiate get that bit of EEG or whatever brain wave and then now instantiate another thing that

59:59asks maybe a clarifying question that asks what are the tools that I need to understand this data and then you go back and send the AI message through the chatbot to the phone, >> right? it's it's able to actually look at the raw data, analyze the raw data, and kind of understand what to do next. >> And and from this flowchart, I'm seeing there's actually also two safety uh gates. One at the front end to moderate the patient me patient message if it's unsafe. And then once all of the processing is done, like you just mentioned, it also moderates the AI response. Yes. If it's unsafe prior to getting to the patient. So again there, you know, they've thought about both the

1:00:39front and back end from a a safety perspective. Um, and I, you know, the medical researchers, clinical researchers are some of the most uh anal retentive about details like this. >> Yeah. >> Uh, in ways that maybe uh people wish the Frontier Labs would be more conscientious. >> 100% dude. 100%. Um and I I one last thing that I want to talk about is the fact that the the system can ask questions back. So it's not just that the patient asks questions. Um for example, suppose it has detected a possible seizure. It sends the patient an alert asking hey did you consciously

1:01:21experience a seizure? Sometimes you have these kinds of mini seizures where you don't really experience anything and sometimes you do. Um, in any case, the the patient answers yes, no, or uncertain. And in machine learning, that means that you've established a label >> to the EEG. >> Yeah. >> That the the model had triggered as something that possibly could use a label. >> Now, usually you only want highquality labels, but actually even in the case of these lowquality weak labels, you can do a bit of learning. There's a technique in machine learning called distillation.

From the episode
  1. EP 65

    What Happens When AI Gets a Lab?

    AI enters the lab: scorpion-toxin binders, robotic experiments and patient-guided seizure detection. Plus, orangutan mothers and infant playdates.

    What Happens When AI Gets a Lab?

Animal BehaviorArtificial IntelligenceNeuroscienceProtein Engineering