EEGPlot.jl: A package to plot Multivariate Time Series (interactively and statically)

EEGPlot was meant to be a package to plot interactively EEG data.

However, I’m just realizing it can be useful to plot other multivariate time series.

The example below plays and plots a chirp, allowing to interact like in this GIF:

Inspecting a sound wave

using Pkg
Pkg.add("EEGPlot")
Pkg.add("PortAudio")
Pkg.add("GLMakie")

using LinearAlgebra
using PortAudio
using EEGPlot
using GLMakie

function chirp(sr::Int, T::Float64 = 2.0)
    t = range(0, T, step = 1/sr)

    f0, f1 = 220.0, 440.0
    phase = 2π .* (f0 .* t .+ (f1 - f0) .* t.^2 ./ (2T))

    env = sinpi.(t ./ T).^2

    left  = env .* sin.(phase)
    right = env .* sin.(phase .+ 0.4)

    M = hcat(left, right)
    M ./= maximum(abs, M)
end


#######################################
sr = 44_100
X = chirp(sr, 2.0)   

# Play the sound
PortAudioStream(0, 2; samplerate = sr) do stream
    write(stream, X)
end

# Plot the waves
eegplot(X, sr, ["Left", "Right"];
        X_title = "Chirp",
        px_per_sec = 3000,
        X_title_font_size = 16,
        X_color = :firebrick,
        X_labels_font_size = 16,
        s_labels_font_size = 16)
1 Like