2
$\begingroup$

so I have an eeg signal (edf format) that has 25 channels and 248832 entries, sampling frequency of 512Hz. I have to compute the frequency bands: – Delta: 0.1-4Hz – Theta: 4-8Hz – Alpha: 8-12Hz – Sigma: 12-16Hz – Beta: 16-36Hz – Gamma: >36Hz and plot them accordingly. I am using Python for this with scipy, numpy, etc. and I should get to something like this:

enter image description here

Does anyone have any point-outs/ideeas/tutorials that could help me compute the bands and then get such a plot(probably a histogram)? Thanks!

$\endgroup$
  • $\begingroup$ I would take a look at mne-python (martinos.org/mne/stable/index.html). Here is an example of frequency and time-frequency sensors analysis (for MEG sensors): martinos.org/mne/stable/auto_tutorials/… You can easily run it also on the EEG sensors. $\endgroup$ – Noam Peled Mar 30 '18 at 18:18
  • $\begingroup$ where is the dataset link address? $\endgroup$ – HasanShovon Apr 28 '18 at 18:37
  • $\begingroup$ @hasanshovon - can't post the data i used because of third party regulations! $\endgroup$ – user3640476 May 14 '18 at 9:48
1
$\begingroup$

Here is some code that may solve your problem:

from scipy.io import loadmat
import scipy
import numpy as np
from pylab import *
import matplotlib.pyplot as plt

eeg = loadmat("mydata.mat");
eeg1=eeg['eeg1'][0]    
fs = eeg['fs'][0][0]
fft1 = scipy.fft(eeg1)
f = np.linspace (0,fs,len(eeg1), endpoint=False)
plt.figure(1)
plt.plot (f, abs (fft1))
plt.title ('Magnitude spectrum of the signal')
plt.xlabel ('Frequency (Hz)')
show()

You can also check this other link:

http://forrestbao.blogspot.pt/2009/10/eeg-signal-processing-in-python-and.html

$\endgroup$
  • $\begingroup$ thanks for the answer! and for the link, I already saw it but I kinda got stuck.. I don't really get what you are doing with eeg1 and fs? should eeg1 be a copy of the eeg channels? and fs the sampling frequencies of the signals? :D I'm gonna edit the post and add the code if this works! $\endgroup$ – user3640476 Nov 17 '17 at 14:52
  • $\begingroup$ In the first part you can calculate the spectrum and observe it (I think this is not clear on the link). Then, on the link, you have the code to calculate the filters. The approach to design the bandpass filters is based on the "window method", the author calculates the impulse response (a sinc() function) for ideal filters (rectangular windows). $\endgroup$ – Filipe Pinto Nov 18 '17 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.