diff --git a/docs/src/general.md b/docs/src/general.md index 7703282..4529631 100644 --- a/docs/src/general.md +++ b/docs/src/general.md @@ -15,6 +15,7 @@ The recipe supports different interpolation methods, namely: ```@docs TopoPlots.ClaughTochter TopoPlots.SplineInterpolator +TopoPlots.NullInterpolator ``` One can define your own interpolation by subtyping: diff --git a/src/core-recipe.jl b/src/core-recipe.jl index 0f1b85a..66c7ff3 100644 --- a/src/core-recipe.jl +++ b/src/core-recipe.jl @@ -5,6 +5,7 @@ sensors = true, interpolation = ClaughTochter(), bounding_geometry = Circle, + markersize = 5, padding = 0.1, pad_value = 0.0, resolution = (512, 512), @@ -27,6 +28,7 @@ Creates an irregular interpolation for each `data[i]` point at `positions[i]`. * `labels::Vector{<:String}` = nothing: names for each data point * `interpolation::Interpolator = ClaughTochter()`: Applicable interpolators are $(join(subtypes(TopoPlots.Interpolator), ", ")) * `bounding_geometry = Circle`: the geometry added to the points, to create a smooth boundary. Can be `Rect` or `Circle`. +* `markersize = 5`: size of the points defined by positions * `padding = 0.1`: padding applied to `bounding_geometry` * `pad_value = 0.0`: data value filled in for each added position from `bounding_geometry` * `resolution = (512, 512)`: resolution of the interpolation @@ -124,7 +126,7 @@ function Makie.plot!(p::TopoPlot) contour!(p, xg, yg, data; attributes...) end label_scatter = to_value(p.label_scatter) - attributes = @plot_or_defaults label_scatter Attributes(markersize=5, color=p.data, colormap=p.colormap, colorrange=p.colorrange, strokecolor=:black, strokewidth=1) + attributes = @plot_or_defaults label_scatter Attributes(markersize=p.markersize, color=p.data, colormap=p.colormap, colorrange=p.colorrange, strokecolor=:black, strokewidth=1) if !isnothing(attributes) scatter!(p, p.positions; attributes...) end diff --git a/src/interpolators.jl b/src/interpolators.jl index 7c5b3b4..367100b 100644 --- a/src/interpolators.jl +++ b/src/interpolators.jl @@ -101,3 +101,20 @@ end # # the xg' * ones is a shorthand for np.meshgrid # return xg, yg, interp.set_locations( ones(length(xg))' .* yg, xg' .* ones(length(yg)))() # end + + +""" + NullInterpolator() + +Interpolator that returns "0", which is useful to display only the electrode locations + labels +""" +struct NullInterpolator <: TopoPlots.Interpolator + +end + +function (ni::NullInterpolator)( + xrange::LinRange, yrange::LinRange, + positions::AbstractVector{<: Point{2}}, data::AbstractVector{<:Number}) + + return zeros(length(xrange),length(yrange)) +end diff --git a/test/runtests.jl b/test/runtests.jl index 4447bb3..82050dd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,6 +24,11 @@ begin @test_figure("all-interpolations", f) end +begin # empty eeg topoplot + f, ax, pl = TopoPlots.eeg_topoplot(1:length(TopoPlots.CHANNELS_10_20),TopoPlots.CHANNELS_10_20; interpolation=TopoPlots.NullInterpolator(),) + @test_figure("nullInterpolator", f) +end + # begin # f = Figure(resolution=(1000, 1000)) # s = Slider(f[:, 1], range=1:size(data, 2), startvalue=351) @@ -72,3 +77,4 @@ begin f, ax, pl = eeg_topoplot(data[:, 340, 1]; positions=positions) @test_figure("eeg-topoplot3", f) end +