epfl-lts2/pygsp

inverse method not working for any filter

mfarazi1991 opened this issue · 4 comments

Hi,

I cannot use the inverse method of filterbanks. I did use the exact codes in the commented part of the inverse method in python files and still get the following error:

AttributeError: 'Abspline' object has no attribute 'inverse'

mdeff commented

Hi, thanks for your interest! You may be using an older version. Try to install the latest from github with pip install git+https://github.com/epfl-lts2/pygsp. (Discussion in #69.)

I'm on the latest version and also facing the same issue.

I'm also a little confused with the way the package works. If I understand correctly, given a wavelet filter g, g.filter(signal) should give the wavelet coefficients c, and g.inverse(c) should reconstruct the signal, right?

To inverse coefficient, you have to use the synthesize function. Synthesis is actually the inverse of analysis (analyze is actually the same as filter). The inverse function returns another filter, and does not inverse the coefficients.

Here is untested pseudo code:

signal = np.random.randn(G.N,1)
inverse_filter = g.inverse()
coefs = g.analyze(signal)
reconstructed_signal = inverse_filter.synthesize(coefs)
np.linalg.norm(reconstructed_signal-signal)

Good luck

Thanks for the pseudo-code and the explanation! The problem still remains in calculating in inverse filter though, since it gives the "object has no attribute 'inverse' " error. Is there a workaround for this?