0

I'm wondering if I got some errors in my emg data + fft code

[I got 0Hz filtered emg data]

plt.figure(figsize=(20,10))
sns.lineplot(data = DF_newemg,  x = DF_newemg.index, y = 'emg[2]', label = 'DF_newemg')
sns.lineplot(data = DF_newemg_filtered, x = DF_newemg_filtered.index, y = 'emg[2]', label = 'DF_newemg_filtered')
plt.show()

(https://i.sstatic.net/gd5Bp3Iz.png)

And then, I got only positive frequencies and fft_values with fft thing.

fs = 1000

from scipy.fft import fft, fftfreq

N = len(DF_newemg_filtered['emg[0]'])  
freqs = fftfreq(N, d=1/fs)  
fft_values = fft(DF_newemg_filtered['emg[0]'].to_numpy())  


positive_freqs = freqs[:N // 2]
fft_values = abs(fft_values[:N//2]) 
plt.plot(positive_freqs, fft_values, label='Filtered Signal Spectrum', color='blue') 

(https://i.sstatic.net/oJ9chuSA.png)

But As you see, 0Hz and 0~100 Hz have high peaks, and I don't know how to solve this problems. (Even the emg device already had 50Hz notch filter) And wondering if the y-axis values are correct.

Can I get some answer please want some help :(

4
  • You need to tell us first what your sampling time interval is. Also what do you mean by 0Hz filtered EMG data. Do you mean with the mean subtracted or something else? It should be no surprise that with real input data you get a complex conjugate symmetric FFT. Anyway you are looking at the power spectrum in that graph. Can you provide a zoom view of 0-50 in frequency space? I'd be inclined to bet that the big peak is somehow related to local mains frequency. Commented Feb 12 at 11:37
  • The other thing to be aware of (assuming you are in the Northern hemisphere) is that at this time of year and under cold weather stress the nominal mains frequency during daytime can be as much as 0.05Hz low (more on very cold days). Unless your hardware notch filter is able to track the mains frequency it may not do a very good job. If you make the raw dataset available somewhere online we could take a look at it, but we do need to know the sampling rate for it to make sense. Commented Feb 13 at 9:33
  • I got 1000Hz frequency Data and to eliminate the DC offset (It meant the 0Hz filtered Data) I subtract the mean. I also thought the peaks caused by local mains frequency, but actually when I got zoom, the peak frequency is about 20Hz... If I give raw dataset, can you give me some help? Commented Feb 17 at 11:54
  • If you share the raw dataset somewhere public for a while then I or any other reader who comes along can take a look see at it. How big is it? 1ms sampling is 1000 samples a second. A representative sample of 2^N numbers would be convenient say 8192 or 16384 sample values should be enough to pick out any oddities. That way any old radix-2 FFT can handle it. Commented Feb 18 at 10:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.