unfoldtoolbox / UnfoldMakie.jl

Plotting and visualization tools for EEG data, with additional Unfold.jl regression ERP methods. Based on the visualization libraries Makie.jl and AlgebraOfGraphics.jl
https://unfoldtoolbox.github.io/UnfoldMakie.jl/
MIT License
16 stars 7 forks source link

plot_topoplotseries - contour levels are overwritten #120

Closed behinger closed 3 months ago

behinger commented 11 months ago

there is a bug here: https://github.com/unfoldtoolbox/UnfoldMakie.jl/blob/3025598659ac4f405457502a20b6beae1968669c/src/eeg_series.jl#L120

if one specifies the contour manually, then it is overwritten by automatic contour-levels. E.g:

h = plot_topoplotseries(eff_mult, 0.15; positions = pos2d,
visual = (;enlarge=0.9,
label_scatter=false,    
contours=(linewidth=1, color=:black))) 

Reason is that this merge doesnt merge tuples within tuples. Thus a special merge needs to take place here, explicitly for contour

vladdez commented 3 months ago

i checked it and I don't see any problem here: contours are perfectly drawn. Seems like issue is outdated

behinger commented 3 months ago

have you tried specifying your own contour levels?

vladdez commented 3 months ago
@testset "contours" begin
    plot_topoplotseries(
        df;
        bin_width,
        positions = positions,
        visual = (; enlarge = 0.9,
        contours = (; linewidth = 1, color = :black)),
    )
end

@testset "contours" begin
    plot_topoplotseries(
        df;
        bin_width,
        positions = positions,
        visual = (; enlarge = 0.9,
        contours = (; linewidth = 5, color = :blue)),
    )
end

one was black, another blue, size was different

behinger commented 3 months ago

no, with custom levels included, levels mean where exactly the contours are in terms of voltage

edit: that is setting levels

vladdez commented 3 months ago
(q_min, q_max) = (-0.1, 0.9)
           plot_topoplotseries(
               df;
               bin_width,
               positions = positions,
               visual = (; enlarge = 0.9, contours = (; linewidth = 1, color = :black, 
               levels = range(q_min, q_max; length = 7))),
           )
┌ Debug: (linewidth = 1, color = :black, levels = -0.1:0.16666666666666666:0.9)

bug or feature? Should colorbar range also change?

behinger commented 3 months ago

I dont understand what youmean with bug or feature because I dont know the output can you manually input levels = [0,0.5] and do you then have only 2 contour lines visible? do they have linewidth 1 nd :black?

I expected levels to be part of visual.contours as in the code

vladdez commented 3 months ago

I meant is that expected or not.

Okay I understood that i didn't understand this parameter.

I looked in MNE: there is a parameter contour and it is Integer, default number is 6. If I put any integer in visual.contours.levels the number of lines will change. By default it is 6 too.

I dont understand why is it contours = (; levels = range(q_min, q_max; length = 7)) in eeg_series.jl (it is ignored anyway though) and why you want to put input levels = [0,0.5] (it will be one contour line btw).

vladdez commented 3 months ago

ah okay, it could be array too

so if I manually specify it, it will change, if not - it will be 6. I see the problem now

vladdez commented 3 months ago

But what was the goal? To overwrite levels manually? Then it works already To make them dependable on q_min, q_max? That is not working currently

behinger commented 3 months ago

No, to make the levels specifiallble via Array, but at the same time be able to change their appearance.

vladdez commented 3 months ago

in that case it work already

behinger commented 3 months ago

awesome! I dont really understand how it is possible but good then :-)

behinger commented 3 months ago

thanks for looking into it!