I'm slightly unsure how to handle this as it's a topic which is new to me so any guidance with my code would be greatly appreciated. I have a set of eeg recordings (18949 EEG records with a sampling rate of 500Hz, where the records are in nV). I'm trying to create a Frequency against Voltage graph from the data but I'm having no luck so far.
My code is as follows:
data = pd.read_csv('data.csv')
data = data['O1']
Fs = 500.0
Ts = 1.0/Fs
t = np.arange(len(data)) / Fs
n = len(data) # length of the signal
k = np.arange(n)
T = n/Fs
frq = k/T # two sides frequency range
frq = frq[range(int(n/2))]
Y = np.fft.fft(data)/n
Y = Y[range(int(n/2))]
fig, ax = plt.subplots(2, 1)
ax[0].plot(t,data)
ax[0].set_xlabel('Time')
ax[0].set_ylabel('Voltage')
ax[1].plot(frq,abs(Y),'r')
ax[1].set_xlabel('Freq (Hz)')
plt.draw()
plt.show()
fig.savefig("graph.png")
And my resulting graph looks like:
Could anyone provide some guidance as to where I may be going wrong with this?