コード例 #1
0
def feature_extraction(data, sfreq):
	#What features do I want???
	#Kurtosis
	#line-length
	#entropy

	#Perform feature extraction for 2 second segments
	kurt = np.zeros((data.shape[0],data.shape[1]//2//sfreq))
	s = np.zeros((data.shape[0],data.shape[1]//2//sfreq))
	H = np.zeros((data.shape[0],data.shape[1]//2//sfreq))


	segments = np.zeros((data.shape[0],data.shape[1]//2//sfreq,sfreq*2))
	for n in range(0,data.shape[1]//2//sfreq):
		cur_data = data[:,n*sfreq*2:(n+1)*sfreq*2]
		segments[:,n,:] = cur_data
		kurt[:,n] = univariate.compute_kurtosis(cur_data)
		s[:,n] = univariate.compute_line_length(cur_data)
		H[:,n] = univariate.compute_spect_entropy(sfreq, cur_data, psd_method='welch')

	#Average across channels
	kurt_avg = np.mean(kurt,axis=0)
	s_avg = np.mean(s,axis=0)*np.power(10,6)
	H_avg = np.mean(H,axis=0)

	return kurt_avg, s_avg, H_avg
コード例 #2
0
def test_kurtosis():
    expected = np.array([1141. / 361, 197. / 121])
    assert_almost_equal(compute_kurtosis(data1), expected)