0

我正在使用频带功率特征提取来提取 EEG 信号的功率特征。我用这段代码绘制了我的信号:

def plot_eeg(EEG, vspace=100, color='g'):
    bases = vspace * np.arange(1)
    EEG = EEG.T + bases

    samplerate = 128.
    time = np.arange(EEG.shape[0]) / samplerate
    plt.plot(time, EEG, color=color)
    plt.grid()

我有这张图片给你 在此处输入图像描述

现在,我正在尝试使用 bandpower 通过以下代码提取 theta、alpha、beta、gamma 功率特征:

def compute_feature(data,low,high,smplerate):
    win = 4 * samplerate
    freq_features = []
    freqs, psd = signal.welch(data, samplerate, nperseg=win)
    freq_res = freqs[1] - freqs[0]
    
    idx = np.logical_and(freqs >= low, freqs <= high)
    power = simps(psd[idx], dx=freq_res)
    freq_features.append(power)

return freq_features

from scipy import signal
from scipy.integrate import simps

power_features = []
samplerate = 128.
low_theta, high_theta = 4, 8
low_alpha, high_alpha = 9, 12
low_beta, high_beta = 13, 30
low_gamma, high_gamma = 31, 45

theta_features = compute_feature(data,low_theta,high_theta,128)
alpha_features = compute_feature(data,low_alpha,high_alpha,128)
beta_features = compute_feature(data,low_beta,high_beta,128)
gamma_features = compute_feature(data,low_gamma,high_gamma,128)

power_features.append(theta_features)
power_features.append(alpha_features)
power_features.append(beta_features)
power_features.append(gamma_features)

现在,我有一个 (4,1) 维度的 power_feature 数组。这是我的问题。如何在 DNN 模型中使用这些功能?如何绘制这些特征?

4

0 回答 0