Calling function from Makie Buttons and Menus

Hi everytone.
I am trying to build a GUI to call a bunch of my functions. It is based on Makie as it was suggested in this forum because the idea is to read a data file and them cut, filter, etc the data while displaying the changes. It is basically a couple of plots in GLmakie and a bunch of menus.

Here is an example of what I need with some simple matrix and data:


using GLMakie
fig = Figure(resolution = (1800, 1200))
xs = range(0, 2π, length=100)
ys = range(0, 2π, length=100)
zs = [sin(x*y) for x in xs, y in ys]

ax, hm = heatmap(fig[2:5,1:5],xs, ys, zs)
cb = Colorbar(fig[2:5, 6], hm)

x = range(0, 10, length=100)
y = sin.(x)
lines(fig[6,1:5], x, y)

## Menus
menu_File = Menu(fig, options = ["Read H5 file", "Read jld2 file", "Save to jld2", "Save to SAC", "Save to SEGY"])
menu_DAS_Processing = Menu(fig, options = ["Low Pass Filter","High Pass Filter","Bandpass Filter","Integrate","Derivate","Detrend","Remove Mean","Taper ends"])
menu_Channel_Processing = Menu(fig, options = ["Low Pass Filter","High Pass Filter","Bandpass Filter","Integrate","Derivate","Detrend","Remove Mean","Taper ends"])
menu_colormap = Menu(fig, options = ["bone_1","curl","inferno","grayC50","jet","magma","plasma","PRGn","PiYG","RdBu_11","RdGy_11","RdYlBu_11","Spectral_11","turbo","viridis"])
		
## Menus
#menu_File = Menu(fig, options = ["Read H5 file", "Read jld2 file", "Save to jld2", "Save to SAC", "Save to SEGY"],cell_color_hover=RGBf(0.90, 0.90, 0.90),cell_color_active=RGBf(0.80, 0.80, 0.80))
#menu_DAS_Processing = Menu(fig, options = ["Low Pass Filter","High Pass Filter","Bandpass Filter","Integrate","Derivate","Detrend","Remove Mean","Taper ends"], default = "Bandpass Filter",cell_color_hover=RGBf(0.90, 0.90, 0.90),cell_color_active=RGBf(0.80, 0.80, 0.80))
#menu_Channel_Processing = Menu(fig, options = ["Low Pass Filter","High Pass Filter","Bandpass Filter","Integrate","Derivate","Detrend","Remove Mean","Taper ends"], default = "Bandpass Filter",cell_color_hover=RGBf(0.90, 0.90, 0.90),cell_color_active=RGBf(0.80, 0.80, 0.80))
#menu_colormap = Menu(fig, options = ["bone_1","curl","inferno","grayC50","jet","magma","plasma","PRGn","PiYG","RdBu_11","RdGy_11","RdYlBu_11","Spectral_11","turbo","viridis"], default = "RdBu_11",cell_color_hover=RGBf(0.90, 0.90, 0.90),cell_color_active=RGBf(0.80, 0.80, 0.80))
    

## Plotting Menus
fig[1, 1] = vgrid!(   
    Label(fig, "File", width = nothing),
    menu_File;
    tellheight = false, width = 200)
    
fig[1, 2] = vgrid!(   
    Label(fig, "DAS Processing", width = nothing),
    menu_DAS_Processing;
    tellheight = false, width = 200)

fig[1, 3] = vgrid!(   
    Label(fig, "Channel Processing", width = nothing),
    menu_Channel_Processing;
    tellheight = false, width = 200)

fig[1, 4] = vgrid!(   
    Label(fig, "Others", width = nothing),
    menu_colormap;
    tellheight = false, width = 200)

notify(menu_colormap.selection)    
on(menu_colormap.selection) do s
    hm.colormap = s
end

fig

Now, in the first menu I need to call my own function which would look in a script like this:

strainrate, rtime, htime, offset, atrib = rdas("Data.h5");

This data file should be read and then update the plot to this data.

Then if the user needs to filter it with a butterworth filter 200 Hz to 1000 Hz and 4 poles (for example) he/she can calls:

filtstrainrate = bpdas(strainrate, rtime, offset, 200, 1000; poles=4);

Now, my question is how can I call this functions to the Makie window and request the user for the inputs required by each function.

Tips and recommendations are welcomed.
Thanks in advance!!!

M.

No one? :frowning:

you could maybe open a popup with:
display(GLMakie.Screen(float=true, focus=true), fig_for_choosing_params)?

Hi @sdanisch I just saw your post. I was on vacations. Any example for this?
Thanks!

I have never used menus or buttons, but for such filter tuning things I would use some sliders or interval sliders like that :

f = Figure()
ax = Axis(f[1,1])
sl = IntervalSlider(f[2,1], 
     range = LinRange(200, 1000, 1000), 
     startvalues = (200, 1000))

filtered_data = lift(sl.interval) do interval
    # do something with interval[1], interval[2] and the raw data
end

heatmap!(ax,filtered_data)
DataInspector() # can be very useful sometimes
f

(I don’t know if it would be very fluid, I guess if you work on DAS the data sets must be quite big)

I also work on fiber optic sensing data, and I really like FastRunningMedian if you ever want to do median filtering, it works great even with a lot of points

Hi @berjine Thanks for the referecnes to FastRunningMedia.
Maybe the sliders will work for something else, but my main problem now is calling my function to read the file name and request the input via the repl or via another text box. I am quire stuck here. Any help is welcomed :slight_smile:

PD: Nice to find someone else going crazy with fiber data here and not stucked in the pythonian bubble hehehe.