2

I want to apply continuous wavelet transform for an array of 22 rows and 546304 columns (time series signal) to feed the scalograms to CNN. I got error 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 I don't know whether i use CWT in right way or not and whether my code is true or not.

Anyone who can provide some insight would be appreciated.

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
Eda
  • 565
  • 1
  • 7
  • 18

0 Answers0