 So if you haven't checked the minecars.com please do so. There's lots of tools for you to play with and let me know what you think. Currently we're doing combining a fuzzy logic later potentially neural networks as well with the ECG game. And we can then apply it onto EEG as well. So that's the overall plan. So we are developing in the live stream. I'll share some code with you so you'll have an idea. The code is HTML code. At the bottom it has a description of what the application meant to do. But we're currently adding a machine learning fuzzy logic options to it. I'll be sharing more code. So I also have access to GitHub Copilot if it's better for you to generate prompts that I can use with Copilot to actually modify the code. The problem with that is that you wouldn't know how the code was modified. So if you prefer generating the code yourself that's perfectly fine. Can you keep responses as short as possible? Don't mind you trying to be funny at times. The following is the Waveforms.js. I'll be sharing the game logic JavaScript and the Python application script next. Instead of just selecting Waveforms randomly, you could use fuzzy logic to analyze the Waveforms' characteristics like amplitude, frequency, etc. and decide how likely they are to be abnormal. This can make the game more realistic. Dynamic difficulty adjustment. Use fuzzy logic to adjust the game's difficulty based on the player's performance. If they're doing well, the game will present more challenging, subtly abnormal. Okay, I didn't ask you to respond. I said keep responses as short as possible. Also do not use emojis as in ever. The general idea is that the front end will be generating the Waveforms. But the back end, which I'll share with you next, is used to do the fuzzy logic machine learning algorithm. So they should not know of each other. So essentially the machine learning fuzzy logic will be playing the ECG scoring game without knowing what the Waveforms are. So here is the game logic and here is the Python script back end flask application. Also again, just to be clear, the fuzzy logic meant to be playing the ECG scoring game independently from the game itself. So just getting the Waveform displayed on the screen, extracting features, which you can explain which features we are currently looking at based on the code I provided, and then making a decision as to the likelihood of abnormal ECG. If you want the fuzzy logic system in the back end to analyze the ECG Waveforms independently and assess their abnormality, let's dive into the features being extracted and analyzed based on your provided code. Dominant frequency, the primary frequency component of the ECG Waveform. It's calculated using Fast Fourier Transform, FFT, and normalized against the highest observed frequency so far. This feature can indicate the regularity or irregularity of heart rhythms, positive peaks, the count of peaks where the Waveform goes above a baseline. This reflects the number of upward spikes in the ECG Waveform, which can be indicative of certain cardiac events. Negative peaks, the count of peaks where the Waveform goes below the baseline. Similar to positive peaks, but for downward spikes, amplitude, the difference between the highest and lowest points of the Waveform. This can indicate the strength or intensity of the heart's electrical activity. The back end uses these features to assess the likelihood of abnormal ECG. Fuzzy sets and rules are defined for each feature, which helps in evaluating the overall abnormality. The system calculates a score that represents the likelihood of the Waveform being abnormal. The system works independently of the game's user interface. It receives a Waveform, processes the features, applies fuzzy logic, and returns an assessment. This assessment is the independent decision about the Waveform's abnormality. Integration with front end, ensure that the Waveform data is correctly sent from the front end to the back end for analysis. Improving feature extraction, you may refine how features are extracted or add new features for more accurate analysis. Tuning fuzzy logic rules, adjust the fuzzy sets and rules based on real ECG data or expert input to improve the accuracy of the abnormality assessment. The normalized amplitude is missing. Also, can we make sure the raw positive and negative peaks are correct? There is a potential issue with a DC offset of this signal. Can you check what the DC offset is? Pretty sure it's just sitting at 300 for whatever reason. From this line, does it mean the DC offset is 300? Should we just subtract 300 when doing the analysis? We're already doing it, that's fine. So for the normalized amplitude, can we use this as a prompt for co-pilot? It's taking 367 lines of code, giving me general examples why do we have a normalized function? This one, I like how this is working, because essentially things should be normalized differently in different places. I'm trying to restructure the whole thing. So essentially, we have a global amplitude. Well, it's not working correctly. Wait, maybe this. So when we have 349 as the raw amplitude of the signal, it's been normalized to 1. If it's 288, it's been normalized to about 0.6. Yeah, when it's 199, the normalized amplitude is not returning anything, which is not right. And code is a bit complicated too, complicated. Otherwise it looks correct. So if 349 turns into 1, there was a 300 as well turning into 0.8 or something. And we have the measure of abnormality, which is actually the opposite. It goes the higher the number, the number is the more normal, the ECG complex, maybe. Check, we already have that. So we do correct for the DC offset in the original waveform by subtracting 300. Now, get this couple of things. So from the back and we receive all the features and the settings, all the feature calculations and the settings of the fuzzy logic algorithm. Can you list them because we want to display them somehow on the front end? Can you keep responses short? Also, don't mind you to be funny at times, but definitely no emojis. Now the raw negative peak doesn't seem to be correct. Raw positive peak is fine, but the raw negative peak is displaying 2 instead of 1 most of the time. Can you look at the code? I said no emojis and quick responses. Why can't it work? Right, but it's fine. Over here, can we load X and O? Right, well that's wrong, isn't it? Okay, now I get it. Let's print screen this quickly. Check out the image. The negative peaks should not be negative peaks if the peak is at zero Y axis value. Let's see if it can correct the code. Right, I think this height should be 1 and minus 1 or something, so it doesn't detect zeros, is it? So that the peak should be 1 and minus 1. Right, so that one negative peak, that's wrong, should be at zero. Okay, how the height works again? The image should be zero. Is it originally suggested? No, so we have the positive peaks are working okay, there are three, the negative peaks are two. Okay, I think it means understood what I want. Right, because that's the inverted negative data, so it should be both one. This should work. Right, zero, yep. And three, that's correct. One negative peak, yes, that's right. One, that's correct. Two and one, that's right. Next one, three and one, one, two, three. And one negative peak, that's right. Just checking the, waiting for the zero. Let's just double check. Normally, I think they are 60, 40, I think it's the ratio of abnormal to normal. Right, so that one zero. Now the abnormality score is 0.6 and 0.8. That works really well with both heights being one, moving on. Can we double check that and confirm? I suspect the abnormality score is essentially reversed. So the higher the number is, the more normal the signal the ACG waveform is. Can we confirm that? Also, can we confirm? Yeah, so that's wrong. 0.5 for normal ACG. So that's not quite right. We need to fix that. A longer term on the front panel, we want to be able to display all the details about how the fuzzy logic algorithm is making the decision. That will include all the membership functions, the activation function and the rules. So all the fuzzy vacation and the fuzzy vacation process. Yep, let's see if it gets those last two words. Obviously the text to speech is not getting it. Let's go over the membership functions. So ideally we would have a graphical display for essentially designing a fuzzy logic system. Not sure how difficult that will be. So currently we have those fuzzy variables that we need to check. So we're looking at the frequency amplitude. Let's rearrange that. So we're looking at frequency, amplitude positive peaks, negative peaks, and the output is normality. It's using a centroid. I think they're all using centroid method. That's default. It's wrong. Yeah. Cooper doesn't really understand what's what. She's a bit of a shame. So we have the membership functions where positive peaks. We have a start-stop step. Okay, we have zero to five in steps of one. Can you explain the fuzzy logic analysis part of the code? Make it as specific to the code as possible. Keep it brief. You can make jokes if you like. But no emojis. Your fuzzy system is like a nightclub for data points. It's all about where they fit in, how they interact with the rules, and what score they leave with. Now, if the output is acting tipsy and saying normal when it's not, you might need to have a word with the bounces, membership functions, or check the club rules, fuzzy rules. When I said no emojis, I meant it like just don't use any emojis whatsoever. Okay, so for normal signal, normal ECG, I get the following analysis result. Can we get the most important feature is the number of peaks, number of positive and negative peaks. So we need to get those membership functions absolutely correct. Then the frequency and the amplitude. Okay, frequency doesn't seem to do much at all. It's really just changing between three and five. I'm thinking dropping or replacing that feature with kurtosis or what was the other option. Now the amplitude is important in a sense that for example, if we have three peaks, three positive peaks, then the second one should be much higher than the first and the third. Right, but then we could be missing the first or the third. So this might not help much. What do you think? So one thing I'm trying to understand if abnormality is meant to be between zero and one, steps of 0.1, that's fine. Normal ECG is 0.5. This one actually does go low, which is interesting. So it's essentially 0.5 is normal like this one. And then anything else is abnormal. Yes, we have the membership functions for abnormality, unlikely, possible, likely. Yes, so that's wrong. Right, so the rules. Let's go over the rules. We have too many rules. Well, in general, and in this code, too many rules. That's the problem. So positive peaks, we have too few, too many. When we have a line like this, what does it mean for the abnormality value? Because currently it's pretty, I'm pretty certain that 0.5 abnormality value is normal waveform and anything else is abnormal. And the abnormality peaks, that's the ID. Obviously should have it in the fuzzy logic showing data abnormality. We have abnormality mentioned 30 times. There's a return. We have two returns. By the way, I don't even know why. One in fuzzy logic analysis and another in process data. So in the JavaScript, it should have the bottom somewhere. We have analyzed waveform, post request, FH. Yeah, I'm not even sure how the thing works. But let's go back. What's important is those rules. That's in fuzzy. That's nice. The structure of the thing. I never realized it's actually there. That's how little I know. Well, in this case, Visual Studio Code. This will show you all the structure. Don't like those global variables. Make some of them. That's then also why they are defined twice. Okay. And frequency, by the way, is not, again, not giving me anything. So I might keep it and add kurtosis as an addition. We'll just keep it simple. Right. We were going over the rules in what they are as logic analysis. Yeah, these rules. So I have seven of them. This normality control shifts. So abnormality analysis compute. Computes the fuzzy system produces an output called abnormality. And she would go over the whole project quickly. Should we get the GPT-4 to do it? I mean, we could get the GitHub compiler to do it, but it's normally hopeless. Can we explain the abnormality analysis variable co-pilot? Explain these. Okay. The abnormality analysis is the name of the code referred to variable. That could. Why could? I'm asking for like specific stuff. Yeah, co-pilot. Hopeless. Can you explain this line in the Python code and generally the abnormality analysis variable and how it's being used? Don't mind you trying to be funny, but keep it short and no emojis. Yep. I think it's joking when I say no emojis. So this line here, I understand it's giving me the result of the fuzzy logic analysis. What I don't understand, for example, is why it's returning 0.5 when the ECG signal is normal. No, the centroid should be fine as the classification method. Can you explain these rules one by one? To understand one when it's normal, the abnormality is sitting at 0.5 considering. Yeah, we need to adjust some of those. So that's obviously abnormal. That frequency there goes to 5. So it's normally 3 at 0.6. So that's k. That's missing that bit. Right. So this is the normal ECG. This is an example of normal ECG as analysis result. So isn't it okay to have an abnormality score of 0.5 for a normal waveform? What do you think? So, should you accept a score of 0.5 for a normal ECG? If I were a DJ spinning tracks at the fuzzy club, I'd say we need to remix those rules and membership functions until the system is grooving to the beat of normalcy without missing a step. Okay, can you regenerate this function adjusting the membership functions? The frequency seemed to be 0.6 for normal. But can we change it so that the frequency membership function around 0.6 is considered normal and anything else is likely to be abnormal. For positive peaks, make sure that the number of 3 is normal below or above that should be considered abnormal. For the number of negative peaks, 1 is normal. Anything else is abnormal. If the number of negative peaks is 0, it is highly likely to be abnormal. And if the number of positive peaks is 1 or less than 1, it's also likely, highly likely to be abnormal. Here is what I currently have for the code. Just in case you don't already have it, can you suggest modifications or even better, regenerate the whole function? Yeah, I like that. Don't like the positive negative peaks, the number being increased, it's already high enough at 5 and 4. That should be fine. Don't expect the normality to have that line somewhere. Let's go over it one by one. That's okay, positive peaks. Positive peaks change it from 0 to 6. I don't expect it to be that high. Let's go with it. Then we have abnormality. So we have abnormality, then we have... Okay, let's do frequency next. Right, so as we said, around 0.6 is normal. So those names would be important. Then we have positive peaks, too few, normal, too many, 0 and 2. Positive peaks, too few. Yeah, that sounds legit. Yeah, that should be between 2 and 3 is normal. And 2 and 4, yeah, 4, 5, 5 is the end of the membership function. Okay, that makes sense. Then negative peaks, so too few, 0.5, 0.5 and 1.5. Should actually be 2, but should be 2. Yeah, 3, 4 is way too many, but 2 should be normal. Yeah, we have problem with amplitude. Now abnormality, unlikely, possible, likely. Now the rules might not have any rules for amplitude. Just to trick the system. I think that's what it removed, didn't it? Yeah, it is tempting to remove amplitude for now. Okay, positive peaks, too few, too many. A frequency normal, frequency low, high, abnormality possible. Should be likely. Those will be old rules, but we also need 1, 2, 3, 4, 5, 6, 7. Frequency, need the amplitude. Yeah, we need this as rule 7. If the frequency is high or the amplitude is low, as we have abnormality analysis, it's the same. Yeah, we're doing that scale check, we don't actually need to do it. Yeah, we don't have that problem anymore. Shift, yeah, we have an amplitude normalized. We have an amplitude printing the result. Okay, having an error at 500 error. Let's do the options. It's like the medium, not using medium. Okay, it's how we name things using medium instead of low, normal, high. Don't actually see medium. Is it frequency? Yeah, we're using low, normal, high. Okay, we have to fix it next time. And we'll be testing next time as well, probably tomorrow. So I'll see you. Let me know if there is any questions. Please pop them in the chat. Do go check out by AnyCase.com. You can provide feedback on any of the tools that are currently there. See you next time. Bye.