TABLE 2.
Features | Python code |
Time domain | |
Range | range = values.max() - values.min() |
Standard deviation | std = values.std() |
Root mean square | rms = numpy.sqrt(numpy.mean(values∗∗2)) |
Skewness | sk = scipy.stats.skew(values) |
Kurtosis | kt = scipy.stats.kurtosis(values) |
Linear prediction coefficients | lp_coefs = librosa.lpc(values, 3) |
Wavelet transform detail coefficients (cD) | _, cD = pywt.dwt(values, ’db3’) |
cD variance | variance = numpy.var(cD) |
cD entropy | def approximate_entropy(U, m = 2, r = 3): |
U = numpy.array(U) | |
N = U.shape[0] | |
def phi(m): | |
z = N - m + 1.0 | |
x = numpy.array([U[i:i + m] \ | |
for i in range(int(z))]) | |
x_ = numpy.repeat(x[:, \ | |
numpy.newaxis], 1, axis = 2) | |
C = numpy.sum(numpy.absolute(x - \ | |
x_).max(axis = 2) < = r, \ | |
axis = 0)/z | |
return numpy.log(C).sum()/z | |
entropy = abs(phi(m + 1) - phi(m)) | |
Third order cumulant | third_order_cum = scipy.stats.moment(values, moment = 3) |
Temporal frequency (tf) domain | |
Peak of energy | p_tf = frequency_values.max() |
Frequency at the peak energy | xf = numpy.linspace(0, af/2, |
frequency_values.size) | |
tf_p = xf[numpy.argmax(frequency_values)] | |
Skewness_tf | sk_tf = scipy.stats.skew(frequency_values) |
Kurtosis_tf | kt_tf = scipy.stats.kurtosis(frequency_values) |
Mean frequency | def mean_frequency(frequency_values): |
xf = numpy.linspace(0, af/2, | |
frequency_values.size) | |
xf = xf[xf > = 1] | |
total_area = numpy.trapz(frequency_values, xf) | |
for i, x in enumerate(xf): | |
partial_area = numpy.trapz(frequency_values[:i], | |
xf[:i]) | |
if partial_area > total_area/2: | |
mean_freq = xf[i-1] | |
Power ratio (1–6 Hz/6–12 Hz) | xf = numpy.linspace(0, af/2, |
frequency_values.size) | |
num = frequency_values[(xf > = 1) & | |
(xf < = 6)] | |
den = frequency_values[(xf > = 6) & | |
(xf < = 12)] | |
power_ratio = num.mean()/den.mean() |
values, inertial measures in the time domain vector; frequency_values, inertial measures in the temporal frequency domain vector; af, the acquisition frequency; and, xf, frequency values vector.