UCD4IDS / ContinuousWavelets.jl

wide array of continuous wavelet transforms using Julia
https://dsweber2.github.io/ContinuousWavelets.jl/dev/
Other
21 stars 7 forks source link

Discrepancy between CWT in ContinuousWavelets, Matlab and R #56

Open ManuelFossa opened 3 months ago

ManuelFossa commented 3 months ago

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

dsweber2 commented 3 months ago

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