-1

I have a time series and generate its spectrogram in Python with matplotlib.pyplot.specgram. After I make some analysis and changes I need to convert the spectrogram back into time series. Is there any function in matplotlib or in other library that I can use directly? Or if not, could you please elaborate on which direction I should work on?

Your warm help is appreciated.

Lina
  • 1
  • 1

2 Answers2

1

Matplotlib is a library for plotting data. Generally if you're trying to do any computation you'd use a library suited for that.

numpy is a very popular library for doing numerical computation in Python. It just so happens they have a fairly extensive set of fft and ifft methods.

I would check them out here and see if they can solve your problem.

jmkmay
  • 1,441
  • 11
  • 21
1

One thing commonly done (for example in the source separation community) is to use the phase data of the original signal (before transformation where applied to it) - the result is much better than null or random phase, and not so far from algorithms aiming at reconstructing the phase information from scratch.

A classic reconstruction algorithm is Griffin&Lim's, described in the paper "Signal estimation from modified short-time Fourier transform". This is an iterative algorithm, each iteration requires a full STFT / inverse STFT, which makes it quite costly.

This problem is indeed an active area of research, a search for STFT + reconstruction + magnitude will yield plenty of papers aiming at improving on Griffin&Lim in terms of signal quality and/or computational efficiency.

You can find detailed dicussion hereThread on DSP Stack Exchange

Salman Shaukat
  • 333
  • 3
  • 14