我想对 22 行和 546304 列的数组(时间序列信号)应用连续小波变换,以将尺度图提供给 CNN。我收到错误Traceback (most recent call last): File "E:/physionet/wavelet.py", line 144, in create_cwt_image
sig = data[ii, :, jj] IndexError: too many indices for array
我不知道我是否以正确的方式使用 CWT 以及我的代码是否正确。
任何可以提供一些见解的人将不胜感激。
def create_cwt_image(data):
scales = range(1,128)
wavelet_name = 'morl'
#n_samples = data.shape[0]
#n_signals = data.shape[0]
scales = range(1,128)
data_cwt = np.ndarray(shape=(22,127,127, 9))
for ii in range(0,22):
if ii % 1000 == 0:
print(ii)
for jj in range(0,9):
sig = data[ii, :, jj]
coeffs, freqs = pywt.cwt(sig, scales, wavelet_name)
rescale_coeffs = resize(coeffs, (128, 128), mode = 'constant')
data_cwt[ii,:,:,jj] = rescale_coeffs
return data_cwt