 So combining fuzzy logic with this ECG game, that's essentially a bot that will be playing the game for us or in addition. So we could like compete with the robot. That's now a noise option. And that's mainly to see how well the robot is doing when the noise is increased. So currently it's just generating all this false alarms. We will be fixing this before publishing the tool. And yes, you can still play yourself. So you should not click on that one, which was a normal ECG and this one missing a bit at the front. So we are not clicking on it, we're getting correct rejection. And when clicking on an abnormal ECG waveform, we get a hit. And that's what the bot does as well. We had a tuning of it before that just works 100% of the time, but it was relying on some magic numbers that we now removed. The system now performing much more. So it's essentially clicking on everything. It's making a decision that everything is abnormal. And we will be fixing that. We're looking at the, what's it for, parameters, positive peaks, the number of positive peaks, the number of negative peaks, amplitude, and the R peak sharpness. So obviously now it can win the bot, but we pretty sure can easily make it work much better to the point where human can sit back, relax and watch the robot in action. And so we have this four files, obviously this HTML that you see on the screen. So the waveforms are being generated using simple math equations. This is all happening in JavaScript. So front end and the fuzzy logic, which I'll get to in a sec, is working back end. So the fuzzy logic, the robot doesn't know what the current waveform label is. Oh, the robot is cheating somehow. No, it doesn't have the labels. Now we have this game logic, doesn't do much, or might as well get the co-pilot to work just by explaining the code quickly. And we'll try this one shot prompt, single shot, because it tends to work better to begin with and then performance drops with consecutive prompts. Here we do constants, waveform functions, variations. Yeah, we have a bunch of variations as you can see as you saw in the game itself. Generation and noise addition is also in JavaScript. And now the big reveal, the Python code. So this one has the, it's a flask application and it does the fuzzy logic business. Game logic does quite a bit, initialization, drawing, the game itself, so it does the scoring in the game, calculating the scores. Yeah, probably should break it up a bit, but it's, yeah, 200 lines of code, it's not too bad. It does the waveform analysis, noise level adjustment and starting the game. Now the Python code, this message is too long. Okay, so the Python code, yes, it's 400 lines of code. Yeah, the port currently as it is, it just keeps saying that everything is abnormal. You can still get some points out of it. Well, because the algorithm generation, I think is biased, I think it has something around there. The other thing with the core pilot, the core thing about it is we can use this workspace and actually ask how, what's the ratio between normal and abnormal ECG waveforms. So it will try and find the relevant bit supposedly in all the files that are currently open. Should tell you the reference as well. So it should tell you what it was looking at, but yeah, it's taking some time. So it looked at the waveforms.js and the HTML file and it didn't produce the result, which is unfortunate because I think it's 60, 40. Check, it was looking at the wrong file. I vaguely remember something about the 60, 40, but I can't confirm where is the generate waveform noise level. Yeah, this one, 0.6. Yeah, so it is 60, 40. Well, that's why by clicking on every waveform, you are able to overall over longer periods of time gain some points, but you won't be doing it very well because you're producing all these false alarms. So yes, there's the 52 to 38 ratio. So yeah, this is the kind of stuff core pilot is not being able to handle even though it's fairly simple. We are developing this Flask application that we would like to publish today, but I need your help. We need to update the fuzzy logic algorithm parameters as in the rules and the membership functions. We also got some examples of the ad output that I'm getting, can you look at the fuzzy logic analysis result and obviously we also having an issue with the number of peaks being calculated. I assume this is to do with the noise. Last time we were trying to add the basic filter but if we do do that, we'll have to show it to the human playing the game as well to keep things fair. Can you suggest the specific code changes or prompts for GitHub code? So if you could generate code with placeholders, that GitHub core pilot could fill out, that will be great. Please go over all of the code provided and the images uploaded. For the fuzzy logic part, you need a balance of specificity and sensitivity. You don't want to tag normal variations as abnormal, false positives, nor do you want to miss actual abnormalities, false negatives. Adjust your membership functions to reflect the degree of certainty you have about a segment's abnormality based on the input variables. GPT-4, yes, single, single shot prompt. I mean, it's everything seem legit. However, the code is not quite there. So it's suggesting, it suggests to rename the sharpness and that should be fine. We don't have to do it. Oh, it's actually changed it from triangular to trapezoidal with a triangle, triangle in the middle. Now, we already have this code. I'm not sure why it's generating it again. I don't think this will make much difference or a comment that out, but in a comment that that was a GPT-4 suggestion, and noticed that it's fine. It's doing the same for amplitude. And yes, using trapezoidal membership functions instead of triangular ones, which, yeah, I think it will make much difference. I used trapezoidal ones before to kind of make more sense, but the triangle ones should work just fine. Let me show what this side of it do, make these suggestions. If we can say co-pilot can do the right kind of thing. Right, now the rules. The rules is something we do have to go over. Now, yeah, when noise is removed, so that's actually what we are trying to show is that when there is no noise, the algorithm, the machine, and the fuzzy logic algorithm is doing much better. Let's say playing this as abnormal, which is correct. Yeah, it's now started moving much slower because we, the human went in negative score. Let's go, that's cause I wasn't paying attention. It's a normal issue, so I should get 10 points. Yeah, I'll need 12 correct responses to get back to zero. The machine is doing okay-ish. So that's after lowering the noise level all the way to zero. So the false alarms and misses are at 57 and 21. Ideal, it will just stay that way. Yeah, so if no noise, the fuzzy logic is doing pretty good. I think it might not be making any mistakes whatsoever. So for the demo, we might just add the low amount of noise where it does mistakes sometimes. No, it just didn't miss. So it was an abnormal waveform and it didn't click on it. So it's making mistakes even when there is no noise. There's some sort of basic adjustments that we need to make the positive peaks, three and one. There's some working okay. The amplitude, it doesn't look like row amplitude. The amplitude doesn't seem to be changing at all. So it was 0.83Y, now it changed to 0.5. Right, when you don't have the negative peak, the amplitude is changing. 0.58 seem to be the maximum amplitude, which is a bit odd, it should go to one or as close to one as possible. Yeah, so that the amplitude is probably not, oops, the false detection of a hand. Yeah, sometimes falsely detecting a hand on my ear or something like that, the music bit, I don't know if you call it music or not. I do, when the false alarm stayed at 57, the misses went from 21 to 28. So I think it's missing a very specific waveform. The thing about it is that we don't want to tune it up. We don't have any, we don't want any magic numbers that make the algorithm work better. We want it just to just give it the general instructions and for it to just do its thing. Let's go over those suggested rules. I need to explain each one because I forgot what they do. Don't fit the screen as well, which is not good. Yes, those are, again, GPT-4 suggestion. Don't think we will be testing this because that's not what the problem is. Write the peak detection. It's a suggestion to change the prominence value. And yes, we do have a prominence value. They currently, yeah, every time there's something funny on your face, it's a prompt for me to have a break and listen to some music. Hopefully this music is not copyrighted. Assuming if you create a musical instrument then the music is yours. I don't know, what do you think? Just a quick recap. We tried this single, what's called one-shot prompt of GPT-4 to try and fix some things with this phasologic algorithm that is playing this ECG scoring game. That's currently hallucinating a bit. I'm pretty sure one of the waveforms that never detects correctly is why they miss us. So one of the, it's always missing one abnormal ECG. And yes, I know which one it is. So this is kind of unfair for me to do this because I know exactly what the waveforms are. Later, at the later stage, we also try to add because this synthetic ECG, we can get add like an infinite number of different waveforms and see how the algorithm responds. So the rules should just be logical, nothing fancy. So we'll get the error in GPT-4 was an error generating a response. So obviously if I click regenerate, it will start again. It was a long prompt and a long response. What if I just refresh the page and I haven't finished when it's in this continue generating position that actually gives me an option to interact with it again, but don't have to continue. If I do continue, I suspect it will give me the same error again. Yes, that's right. So it's behaving in an odd way. I don't know, it's just for me. Is it because I'm on using the Chrome browser in Linux? I was thinking actually doing a tool where it's using an API and my Python just prompts the GPT-4, whichever model just continuously non-stop, obviously monitoring the cost. Maybe it will be even cheaper. I mean, you can always cap it at whatever, $20 a month that GPT-4 costs. Sorry for that, that's how drinking sounds like. This is the other hand. I like the other hand much better. I was saying I have to change the hands because I can do both at the same time. That was the idea, but essentially I'm playing two musical instruments at the same time. I wonder if there's any musicians in the crowd who would like to test this and provide the feedback. Okay, I don't know, GPT-4 just got stuck on me. Yeah, there's no point asking you anything about the working, the behind the scenes of how this terminal actually works is there. So I think we will just have to leave with it. So you generated pretty generic responses. I'm trying to get to the specifics of the code. Now it seems that the moment in the past we removed the frequency metric. We were looking at the frequency as a parameter and now the result of it is that we always get a miss for a certain type of wave forms, synthetic wave forms that have the R pick too close to the T wave. This must be because we removed the frequency component. How would you suggest fixing it? I would like a specific code. Yeah, I'm thinking should we bring the frequency back? The reason we removed frequency to begin with is because we are not looking at the continuous ECG wave form. We're looking at each QRS complex one at a time. So it kind of didn't make sense to look at frequency. But obviously now it seems like that might have been a mistake. Because if the R pick is moving around, coming too quickly or coming too late, we don't have a detection mechanism for that. We could of course look at distances between peaks but then we'll have to make an assumption. Assumptions as to which peak is which. And also if we have a missing peak that would not work as well. Any suggestions? Welcome. One of the peaks might be missing. So how do we deal with that? When calculating intervals, how would you make an assumption which peak is which and which one is missing? Suggesting to add these four intervals that yes, we have similar stuff obviously in the wave form generation. We have these two QRS variations. So one of them will have a gap between, so the R peak comes late. However, the phasological algorithm, the port, the machine that is playing the game should not know about how the wave forms were generated. So I'm suggesting adding three more parameters. I don't think this will work because again some of the wave forms might be missing some of the peaks. Not might. They are missing some of the peaks. So we're implementing a phasologic system to analyze some data. Yeah, it doesn't know what data we are looking at. Even though it could have looked at the names, likely related to ECG readings. Okay, it did do that. To actually read the whole thing, don't you? Phasologic is the form of many-valued logic in which the true values of variables may be any real number between 0 and 1. Yeah, so all the numbers have to be normalized, I don't think that's the case at the moment, especially not when we have noise, then the number of positive peaks just shoots up through the roof. Yeah, when we remove the noise, it just gives the correct number of positive and negative peaks. It might first sort out the no-noise situation that will kind of make sense. We have the frequency component, sorry, I keep repeating the same thing over and over again, but that's important. That's why our system is not working at the moment. Let's suggest that looking at calculating intervals. The thing is our Python code is already 400 lines of code, so I'm not sure if we should add extra parameters or not. I think it's suggesting three parameters. If we measure, if we are calculating the QRS detection, do we still need the R-peak sharpness to be calculated? Yeah, so the intervals are nice. Then we asked what happens if one of the peaks is missing. I was suggesting to calculate intervals with missing data and additional function. Obviously, every time you ask for something, it generates an additional function. So can I make sure I understand what you mean? If I have, do I still need, but by looking at the inputs of these functions, the answer would be yes, that I do still need them both. It just inflates my code. So after the suggested changes, how many parameters we will be looking at. So we're adding another function. Summing waveform is number array. Calculate the intervals between peaks. For example, intervals between R-peak and the ECG. No, we do not have intervals between R-peak because we're looking at individual PQRST. So that's no good. As the peak detection logic, do we have that function? Why do you stuff up the name? Yeah, we have peaks mentioned 174 times. Which is the variable, is it? Yeah, we just have them in processed data. Can we have it in a separate function? Yeah, it's a placeholder. This is not being co-piled to anything useful. I will just remind you all the tools we make are available on bionicaos.com. Go check them out and don't forget to leave your comments. Okay, a couple of things with the code that we currently have. We need to fix it and integrate it properly. Can you help with that? Ideally, just regenerate the whole code if it's too much regenerate functions. If that's too much, give instructions for GitHub co-pilot to do it. And we want to make sure that with noise level set to zero, the quasi-logical algorithm doesn't make any mistakes. I think for that, we need to sort out that frequency component or which... Sorry for that noise. So for which we have... I think instead of frequency, we now have the distance, the time between the different peaks, but it's not currently being fully integrated. We need to add the membership functions for it and the rules for the additional parameters. Can you do it yourself or provide prompts for GitHub co-pilot, whichever way you prefer? By the way, if you feel like being funny or something, go for it. But probably not too funny. It's something really wrong with the text window, with the window we insert the prompt. Yep. I would expect it to scroll automatically to the bottom or something, but it doesn't do that. Generating might take a while. We have been working on this tool for quite some time. Yeah, that's the one that's always being missed. So that's the one we always get the miss for currently. Yeah, we're not plotting anything in Python. So we can comment the mudplotlib, piplot out. Everything else is correct. Yes, we have this flash application. We have the analyze waveform. We have data processing. Quite safe. A copy of this quickly. Git is not properly working. I mean, eventually, I don't mind for the whole project to be on GitHub, but it's just going to be an absolute mess. So essentially what you see on the website is trying to deal with that mess. There's a lot of tools that are actually not being listed that are under development. You can go to them if you know the URL. Like the board currently, this one would not be working because we haven't added it as a flash application yet. So we don't do frequency anymore and processing the data we should calculate intervals as well after existing peak detection. Yeah, we have it for debugging at the moment, plotting stuff that I'm not... I think it will actually work at the moment. Or maybe it will have to bring the plot function back. Yeah, so this is how the current detection works. We just keep overlaying stuff. This is the type of waveforms that we have. Yeah, so this noise level is found at 35 positive peaks, which is obviously not correct. Okay, just keep popping up. Okay, so finding the A peaks and doing the absolute calculation, printing it out as well. We are not normalizing it because this is actually dividing by 600. We'll do the normalization. We are not returning processed data. Are we doing it for any other parameters? And no. Are you doing extra hours? Yeah, that's a plot. It's trying to plot still. That's okay now. Yes, we're running this application only locally at the moment. Yeah, we better not do this again because it's plotting stuff in the back end. It breaks the flow of the software. Yeah, it's good to bring the intervals. We need to add them in here. What does it get the frequency from? It should be intervals. Yeah, data is for whatever reason. Being generated at the DC level of 300. So we actually reduce it back to zero. That's instead of detrending. We could use a fancy detrending algorithm as well. Do we have frequency currently? Yeah, amplitude is not normal as any more can get rid of that. We don't have frequency. Abnormality is now called abnormality score and we also produce a decision. So it's a yes, no normal, abnormal decision. I wasn't sure about this auto generation of membership functions. I don't think we need this. Here's a process that we have the intervals. The intervals should be returned. Yes, intervals. That's right. Yeah, don't need that line. Let's do some music and recap. We have the calculate intervals function. Is it giving a different function every time? This is better. This is covering a case where there is no R peak, for example. Now we need to modify, get rid of that. Yeah, fuzzy logic analysis. That's the tricky business. We don't have our interval because it's not continuous waveform. Can we rewrite this function taking into account the newly added parameters to do with the time distance interval between the different peaks? Okay, getting confused here. Again, just to make sure we are clear, we are reviewing every individual PQRSD waveform at a time. So doing an RR interval would not make any sense. Instead, we would like to be able to detect if the R peak is too close to the P wave or the T wave within the one complex. Why the RT and PR intervals, antecedent variables do not go all the way to 1, but 0.21 instead? Also, if the rules, instead of adding four new rules, the way combining them all, considering the output for all of them, for the abnormality, is set to be likely. I shared both the current Python code that we have and the game logic JavaScript as well. Probably the JavaScript needs some adjustment, considering we added more parameters to the mix. Can you review the whole code and explain why potentially we're getting this error? Yeah, we're getting a bit confused now. Yeah, the more prompt we are doing, the less bang for the bug we are getting. There's something wrong now. We can actually get the GitHub co-pilot to do this instead. Might use the workspace function because we don't actually know where we need to make the change. Essentially, we added more parameters, more features to look at and process data. Sometimes it provides these links that are very helpful, so that we don't have to search for the code. So we're calculating the intervals here somewhere. Yes, and we were not doing this correctly. This is still not correct, but this is a bit... Yeah, get rid of the print statement. We're going to play it on the front page eventually, so we'll need to change the HTML code as well. I'll share it with you in a second. It should be just called NPData, and we don't need that. Can we just update? It's updating. It should be looking at the previous code for any changes we made. No, it's not doing that. Let's well get rid of it. Oops. Print interval. Sorry, PR interval. Yes, that's what we want then. RT interval. This is correct, and we're returning all that. So that's fine. We're going to calculate intervals. It's not a hypothetical function. It's an actual function. So we're adding them to the dictionary before passing on. Let's do the same thing again with a workspace function. Update the fuzzy logic analysis function to use these new intervals as inputs to the fuzzy system. Let's see if we can find the relevant code. We'll give GPT-4 a bit of a break just so we also don't hit the 40 messages per three hour limit. So it's still searching for stuff. We'll ask it eventually to give an overview for what we have so far. I think it's getting stuck. We get it to work twice. Request timeout. What? So we add the server error. Now this one is not doing anything in fuzzy logic analysis. That's where the function is. We can do that to select the whole code. No, we cannot. We're not doing the calculation in this function. We have this funny default rule that I thought we could read off. We're not actually, no, we are using it. So we have those six rules, a default rule and rule four, abnormal intervals. So essentially, if they're too short or too long, the abnormality of the signal is highly likely. Let's test this again. We're still getting error. Calculate intervals should take one position argument, but two were given. That's not good. I think this might be something for a copilot to sort out because we don't know where it is in the code, we just use the workspace function. So it tries to find it itself. I mean, yeah, GPT-4 is so much better with these things. Well, pretty much anything. Calculate intervals. We have the... It's not in Calculate intervals. I mean this one. No, this is just initializing an array. I want to do an interval type if it's okay. We're not using interval type. Okay, that should be fine. Now we actually need to use the interval type. Interval type is not being used. I think we need to rewrite the whole thing. Returning intervals. Yeah, now it's doing the interval between r and d wave and p and r wave instead of r, r, which we don't have because we're looking at each p, q, r, s, d complex individually. So this should be better. Still getting an error. I'd pop it into a GPT-4. If I select the whole code, it might tell me that the code is too long. No, it's dealt with 500 lines in analyzed waveform. Now it's not getting the links. It's pretty annoying. So I have the analyzed waveform. It actually did this for me. It's only taking one line of code. That's not good. I need to make sure that the p, r interval is in the JSON response. And it's not. Yeah, interval should be there. Actually, interval should be there. It responds data. This one's a bit odd. Yeah, now we're having another problem. Every time you fix something, you break something else, don't you? I'm not entirely sure how to prompt a co-pilot in terms of giving it the code. What code does it need? I'm comparing it into converting the something in the dictionary format. What's being written here? Yeah, I think it's a job for GPT. Okay, I'll be sharing the whole code that we currently have for the Python Flask application that does the fuzzy logic analysis. We also get this error of maybe you could quickly sort it for us. Hopefully, it's nothing to do with the JavaScript. No, it shouldn't be. So I'll give the entire code, and could you also provide a summary for the whole thing and the changes that we have made today? That should be, the previous code should be still commented out in the script. If you wish to be funny or something, make general comments, suggestions. They go for it. It might be thinking for a while. I'm not sure how much progress we made today. Currently, the application is not running properly. The robot is not generating any output. We're getting a silly error. Can we summarize the whole application so far? Give it a broader context. If you feel like being funny, go for it. But not too funny. Definitely do not use any emojis. No, every time I say this, it's actually picking up on the actual word and starts will start to actually generate emojis. Give a general context for the application how it might be useful or not. We already have the game published on our website, but this one will obviously provide extra features where you play against the machine. Imagine this, you've got a game, not just any game, but one where humans and machines face off in the grand arena of ECG Waveform analysis. Picture it as a, whose line is it anyway? But for ECG Waveforms, where the points do matter, players, likely healthcare professionals or enthusiasts, get to test their skills and identifying abnormalities in ECG Waveforms. It's like playing a medical version of, where's Waldo? But instead of Waldo, you're looking for sneaky little changes in those squiggly lines. This way your code steps in, flexing its fuzzy logic muscles. It's like having a robot judge in a talent show, but instead of judging singing, it's judging the peaks and valleys of heartbeats. The machine uses sophisticated algorithms to analyze these Waveforms, considering factors like peak sharpness, interval lengths, and amplitudes. Basically, it's looking for the heartbeats rhythm and style. Players are presented with a Waveform and have to decide whether it's normal or abnormal. Each decision is a gamble, like choosing door number one or two in a game show, but with more medical credibility at stake. Meanwhile, the machine, your Python backend, does its own analysis. It's like having Sherlock Holmes, but instead of solving crimes, he's deducing heart conditions. The machine's verdict is based on fuzzy logic, which is a fancy way of saying it makes decisions in a very human-like, somewhat uncertain way. It's not just about zeros and ones. It's about, maybe this peak is too sharp, or perhaps this interval is too long. Or application is not just a simple game. It's an educational tool, a training simulator, and a way to introduce people to the complexities of ECG interpretation. It's like combining a game of chess, a medical seminar, and a detective novel all into one. You've got peak detection, interval calculations, and amplitude analysis. It's like the machine is putting on its detective hat and magnifying glass to scrutinize every heartbeat. The integration of fuzzy logic adds a layer of sophistication, like adding a plot twist to a mystery novel. The JavaScript front-end makes it interactive and engaging, because what's the point of having a cool game if it's not fun to play? Dealing with errors and making sure the data passed around is in the right format. It's like making sure all the actors in a play know their lines and cues. Your application is a bridge between gaming and medical education, turning the daunting task of ECG analysis into an interactive learning experience. It's like if Grey's Anatomy met who wants to be a millionaire. Equal parts educational, thrilling, and potentially life-saving. So, while there might be some hiccups along the way, like our current era situation, remember, every great invention had its share of tuning. Once this is all ironed out, you're not just launching a game. You're launching a new way to learn, engage, and possibly save lives. No pressure, right? Winking Face