ContinuousWavelets.jl icon indicating copy to clipboard operation
ContinuousWavelets.jl copied to clipboard

Discrepancy between CWT in ContinuousWavelets, Matlab and R

Open ManuelFossa opened this issue 1 year ago • 1 comments

Hi,

I ran a CWT using ContinuousWavelets, Matlab WTC package (Grinstead), and R's Biwavelet package, on the same signal. The result are consistent between R and matlab, but not at all with ContinuousWavelets. Can you help me?

signal = Matrix{Float64}(DataFrame(CSV.File("data.csv")))

       signal = Matrix{Float64}(DataFrame(CSV.File("data.csv")))

signal = vec(signal)



        c = ContinuousWavelets.CWT(Morlet());

        res = ContinuousWavelets.cwt(signal, c)

        Plots.heatmap(abs.(res)', xlabel= "time index",
        ylabel="frequency index",colorbar=false)

data.csv Screenshot from 2024-06-14 12-25-12

ManuelFossa avatar Jun 14 '24 10:06 ManuelFossa

At a guess, it looks like both of those packages have far more detailed defaults for even such a short signal (it looks to only have 46 entries?). You will need to increase the number of wavelets significantly to get a similar detail to those plots. s gives the # of wavelets per octave, and β gives the tail off towards 0 frequency. In general ContinuousWavelets is aimed at supporting significantly longer signals than this.

c = wavelet(morl, s=32, β = 1, averagingLength=-1)

res = ContinuousWavelets.cwt(signal, c)
heatmap(abs.(res)', xlabel= "time index", ylabel="frequency index",colorbar=false)

Here's something that more or less closer to the general plot that they have.

Here's the docs regarding wavelet spacing, and the genera docs

dsweber2 avatar Jun 22 '24 23:06 dsweber2