0

I am gonna apply Short Time Fourier Transform on this signal and plot the results using pcolormesh function. Then, I want to use Inverse Short Time Fourier Transform to reconstruct the signal. My question is how to use the output of the pcolormesh as input for signal.istft(Zxx) to get the signal back. In short this is what I want to do:

f, t, Zxx = signal.stft(sig, fs=250, nperseg=64)
mesh=plt.pcolormesh(t, f, np.abs(Zxx))
plt.axis('off')
plt.show()

which outputs this image. Then, apply the inverse Fourier Transform to reconstruct the signal:

_, xrec = signal.istft(mesh, fs=250)

Actually, I am not sure if the mesh input for the above function is the right way to do or not? And how I can get the correct input for the signal.istft(Zxx) instead of Zxx?

Thanks for your help.

Rahman
  • 23
  • 4
  • I don't think you can do what you want. The returned array from `stft` is an array of complex numbers. When you plot the array, you take the magnitude `np.abs()` of the complex numbers to turn them into real numbers. But you need the full complex info to apply the inverse `istft`. Maybe you can explain why you cannot use `Zxx` directly? – Diziet Asahi Mar 18 '19 at 13:02
  • Tnx @DizietAsahi for your comment. Actually, I am going to use these images as inputs for training a generative adversarial network and the output of the network will be images which I want to reconstruct the signal from them. – Rahman Mar 18 '19 at 13:12

0 Answers0