 e.g. to music conversion. It works, but it sounds horrible as expected. So try to improve it by doing frequency shifting or some interpolation. Yes, this does look rhythmic. Current conversion it generates too many zero hertz, which is a bit odd when channel 10 I think gives some frequencies. Yeah, the mapping is incorrect. Getting dominant frequencies, already doing scaling, scaling e.g. to MIDI. So instead of a new function, we update the current one that we already have. Because most of the time the frequencies are just zero and now at the frequencies are very low, they end up being that lowest frequency note. The idea is to modify the function to handle zero frequencies as rests and a pie shift non-zero frequencies before scaling them to the MIDI range. Why am I having too many zero frequencies to begin with? This is updating scale, also shifting the values. Low variation, e.g. signals often have periods of low variation, especially in a relaxed or steady state, which result in a dominant frequency of zero. Yeah, so I do not expect zero frequencies. I can take f1 instead of f0. Window size, the size of the data segment, window, use for each FFT calculation significantly affects the result. If the window is too small, it may not capture enough data to accurately represent the frequency content. Conversely, if it's too large, it might have redoubt the variations over time. Yes, currently it's 300, 200 will be, it's a window size of half a second. Signal processing, if the signal is not properly processed before FFT, e.g. the trending, applying a window function, it can influence the outcome, potentially leading to a dominant frequency of zero. So we commented out the window function, probably should bring it back maybe with a different window type. Sampling rate, the sampling rate of your e.g. data determines the frequency resolution. A low sampling rate might not capture higher frequency details. Quantization error, if the e.g. data is digitized with low resolution, it might not capture subtle changes, leading to periods where the signal appears flat. It's actually not quantized down sampling or anything at this stage. If the e.g. signal has a low SNR, the actual brainwave signals might be masked by noise, resulting in an unclear frequency representation. We don't have noise in this, this should be a clear e.g. One thing though that I notice, you might need the, you might need to apply a window to detrend this. Yeah, because it has to remove the DC component from it. Can window function be used for detrending? Detrending. So we're using NumPy with defining a function. We need to do it manually since there's an existing function for this. Okay, so we need to fix the data, it's actually not called data, hitting a polynomial and subtracting the trend. We should be able to display this as well. Well, right, so this is the trending each segment independently. So that's not what I want to display on the graph. Yeah, let's do this. This looks legit. We don't need this because we already have it up top. Trend function. I don't know, dominant frequencies in the function itself for each segment. Second break. Have a detrend and then FFT result. Segmentation. Apply detrending to each segment of the EEG data if you're processing the data in chunks. Otherwise, apply it to the whole dataset. Window function. If you're also applying a window function, then after the trending and write before the FFT. Generate the whole getDominantFrequences function. Yes, this is replacing all this bit. I don't need to call that because we already have it. Trend dot, detrend dot. Then we're doing everything else on the detrended segment. Instead of segment, still running the thing, yes. Just clear the terminal. That's what the seizure sounds like. So the problem with those frequencies could be could be pretty random. So the sampling rate is 400. So if we have SHD, if 100 we'll have four nodes per second of EEG. Makes it also slower here. There would be much more improvements needed. So this is just a large number that loads the whole seizure. Yeah, this will keep the bounding 21s. 20 was better. There will be some sort of ideal water quickly. Same channel zero. This is a very large number to load the whole seizure, the whole data and might continue. Continue next time. Hopefully it will be more palatable the EEG music seizure song. I'll see you next time.