opened
apatlpo
username_0
I'd like to use [generalized Morse wavelets](https://doi.org/10.1109/TSP.2012.2210890) for an analysis and am under the impression that it is not implemented in pywt. 
These wavelets are defined by in the frequency domain:
![image](https://user-images.githubusercontent.com/11750960/77447901-7e7e3380-6df0-11ea-9a4d-be2576957964.png)
where U(\omega) is the unit step function.

Do you believe we could add this to pywt ?
If yes, what would be the roadmap to do this?
generalized morse wavelets
issue
created
grlee77
username_1
We only have a handful of contributors working in their spare time, and I don't personally have a lot of experience with the continuous wavelet transform or these wavelets. I am happy to help with reviewing and getting things merged if you or others come up with an implementation. We can provide some guidance on how to get started if you are interested in working on it.

Sometimes it is possible to port an existing implementation from another open source software package. However, before going this route, please make sure the underlying code is based on a permissive license like MIT or BSD, otherwise we will not be able to include it.
comment
created
apatlpo
username_0
Do you think the spectral definition of the wavelet may be a problem?

I came across the following library otherwise [ninwavelets(https://github.com/uesseu/ninwavelets).
I have the feeling I could also try a scipy implementation.
comment
created
mattbit
username_2
Hi, I’m also interested in implementing Morse wavelets. The Generalized Morse Wavelets proposed in [1] were implemented by the authors in the [jLab Matlab toolbox](https://github.com/jonathanlilly/jLab) which can be used as a reference.
There's also a partial Python translation available [here](https://github.com/danrsc/analytic_wavelet).
I'm not familiar with PyWavelets internals, where shoud we start?
  
[1]: Lilly, Jonathan M., and Sofia C. Olhede. "[Generalized Morse wavelets as a superfamily of analytic wavelets.](https://arxiv.org/pdf/1203.3380.pdf)" IEEE Transactions on Signal Processing 60.11 (2012): 6036-6041.
comment
created
grlee77
username_1
Hi @username_2. 
In terms of implementation, the wavelets themselves are defined in C and Cython code. Specifically for the CWT, the files that would need to be modified are:
pywt/_extensions/c/_cwt.template.h
pywt/_extensions/c/_cwt.template.c
comment
created
grlee77
username_1
Also, I am not a licensing expert, but I don't know that it is okay to work from that jLab Matlab toolbox code unless you were to get specific permission from the authors. 
While open source, their license terms specifically forbid commercial applications, so it is a more restrictive license than the one used by PyWavelets.
comment
created
mattbit
username_2
Hi @username_1, thanks for your response.
I had a look at the PyWavelet code and I understand that the wavelet functions are defined in `pywt/_extensions/c/_cwt.templace.c`. The problem—as already pointed out by @username_0—is that Morse wavelets are naturally defined in the frequency space, so the calculation of the wave function would require an inverse FFT in the Cython/C code, if we want to keep consistency with the existing structure. I will have a look to understand how this can be implemented, but I’m open to suggestions.
Of course, the best thing would be to compute the CWT convolution directly in frequency space, but that would mean changing quite a lot of code (as far as I understand, the current implementation does not allow for wavelet defined in the frequency domain and the code in `pywt/_cwt` only deals with the time-domain case).
What's your opinion?

P.S: about the jLab code, I checked it and I think that it's not necessary, all what we need is described in the published that I article mentioned above. On the other hand, I guess that we can use Matlab to generate some test data and benchmark our implementation.
comment
created
apatlpo
username_0
my last thoughts on this was to first give a try at [scipy cwt implementation](https://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.signal.cwt.html) before considering an implementation in pywt.
The implementation in spectral space seemed easier there.
Did you try that @username_2 ?


>
comment
created
apatlpo
username_0
my last thoughts on this was to first give a try at [scipy cwt implementation](https://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.signal.cwt.html) before considering an implementation in pywt.
The implementation in spectral space seemed easier there.
Did you try that @username_2 ?
comment
created
mattbit
username_2
Not yet, I will have a look, thanks :)
comment
created
OverLordGoldDragon
username_3
p.s., I'll likely have it ported from jLab within a few weeks at [ssqueezepy](https://github.com/username_3/ssqueezepy).
comment