Based on this paragraph of a paper about brain-computer-interface, I wanna extract time-frequency domain features using discrete wavelet transform and then calculate energy and entropy with the giving equation.
So I've chosen pywt in python, and now I have the below code for getting wavelet and entropy from each frequency band ( for example I'm using D2 ), and here is the link of data:
import numpy as np
data = np.loadtxt('data.txt')
import pywt
cA5, cD5, cD4, cD3, cD2, cD1 = pywt.wavedec(data,'db4',mode='symmetric',level= 5)
Ent = 0
for d in data:
E = d**2
p = cD2 * E
Ent -= np.sum( np.abs( p * np.log(p) ) )
print(Ent)
But I'm getting nan
for entropy for every frequency band. How can I solve getting nan value for the entropy of the wavelet?
data
defined? // Please post a SSCCE – KDeckerk
, and notD_j(k)
. – Karl Wilhelm