![]() # Plot the data (using pandas here cause it's easy)ĭf = pd.DataFrame(columns=)ĭf = for band in eeg_bands]Īx = df.plot.bar(x='band', y='val', legend=False) # Take the mean of the fft amplitude for each EEG bandįreq_ix = np.where((fft_freq >= eeg_bands) &Įeg_band_fft = np.mean(fft_vals) # Get real amplitudes of FFT (only in postive frequencies)įft_vals = np.absolute(np.fft.rfft(data))įft_freq = np.fft.rfftfreq(len(data), 1.0/fs) Then whichever band has the max will tell you about the person's state. If you just want to know what EEG state the person is in, you could use np.max instead of np.mean. This is fine if you are going to compare one EEG set's gamma value to another (relative amp/power), but not if you're just looking at one set and want to compare gamma to say alpha. I think the reason you saw overly large values for Gamma, was that your gamma range is much larger than the others, and you're taking the sum of all the values in that range. I'm plotting the band amplitude below, but if you wanted power, it would just be the square of the values. In the below example, I have two seconds of random data between 0.0 and 100.0 sampled at 512 Hz. I believe there is a much simpler way to do this with and. The result for the first channel is:Ĭan anyone point out a better solution/ has any ideas about what is wrong/ can tell me what is wrong? Am I using the filter incorect? The problem is that I get a high value for gamma( which represents a high cognitive activity, which the person clearly didn't have). Than I compute the fft of the signal and store it in fft1, on which I use again the butterwort filter to extract the frequencies of each band and it looks like this: for i in np.arange(n):Īlpha1 = butter_bandpass_filter(fft1, 8.1, 12.0, 256)īeta1 = butter_bandpass_filter(fft1, 16.0, 36.0, 256) I used the filter with the low set on 0.1 and high on 80. ![]() I managed to do so by: firstly filtering the signal with a butterworth filter that looks like this: def butter_bandpass_filter(data, lowcut, highcut, fs, order=2):ī, a = butter(order,, btype='band') ![]() So I am trying to compute the EEG(25 channels, 512 sampling rate, 248832/channel) bands (alpha, beta, gamma, etc.) with Python. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |