diff --git a/previews/PR36/.documenter-siteinfo.json b/previews/PR36/.documenter-siteinfo.json index 23d3e6b..95fce7c 100644 --- a/previews/PR36/.documenter-siteinfo.json +++ b/previews/PR36/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-11-24T21:42:23","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-11-24T22:14:00","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/previews/PR36/eeg/81821054.png b/previews/PR36/eeg/81821054.png deleted file mode 100644 index a1d3868..0000000 Binary files a/previews/PR36/eeg/81821054.png and /dev/null differ diff --git a/previews/PR36/eeg/df7bcd64.png b/previews/PR36/eeg/df7bcd64.png new file mode 100644 index 0000000..68c380b Binary files /dev/null and b/previews/PR36/eeg/df7bcd64.png differ diff --git a/previews/PR36/eeg/index.html b/previews/PR36/eeg/index.html index 9e77350..62795f7 100644 --- a/previews/PR36/eeg/index.html +++ b/previews/PR36/eeg/index.html @@ -1,7 +1,7 @@ -EEG · TopoPlots.jl

EEG Topoplots

The eeg_topoplot recipe adds a bit of convenience for plotting Topoplots from EEG data, like drawing a head shape and automatically looking up default positions for known sensors. Otherwise, it supports the same attributes as topoplot.

TopoPlots.eeg_topoplotFunction
eeg_topoplot(data::Vector{<: Real}, labels::Vector{<: AbstractString})

Attributes:

  • positions::Vector{<: Point} = Makie.automatic: Can be calculated from label (channel) names. Currently, only 10/20 montage has default coordinates provided.

  • head = (color=:black, linewidth=3): draw the outline of the head. Set to nothing to not draw the head outline, otherwise set to a namedtuple that get passed down to the line! call that draws the shape.

Some attributes from topoplot are set to different defaults:

  • label_scatter = true
  • contours = true

Otherwise the recipe just uses the topoplot defaults and passes through the attributes.

source

So for the standard 10/20 montage, one can drop the positions attribute:

using TopoPlots, CairoMakie
+EEG · TopoPlots.jl

EEG Topoplots

The eeg_topoplot recipe adds a bit of convenience for plotting Topoplots from EEG data, like drawing a head shape and automatically looking up default positions for known sensors. Otherwise, it supports the same attributes as topoplot.

TopoPlots.eeg_topoplotFunction
eeg_topoplot(data::Vector{<: Real}, labels::Vector{<: AbstractString})

Attributes:

  • positions::Vector{<: Point} = Makie.automatic: Can be calculated from label (channel) names. Currently, only 10/20 montage has default coordinates provided.

  • head = (color=:black, linewidth=3): draw the outline of the head. Set to nothing to not draw the head outline, otherwise set to a namedtuple that get passed down to the line! call that draws the shape.

Some attributes from topoplot are set to different defaults:

  • label_scatter = true
  • contours = true

Otherwise the recipe just uses the topoplot defaults and passes through the attributes.

source

So for the standard 10/20 montage, one can drop the positions attribute:

using TopoPlots, CairoMakie
 
 labels = TopoPlots.CHANNELS_10_20
-TopoPlots.eeg_topoplot(rand(19), labels; axis=(aspect=DataAspect(),), label_text=true, label_scatter=(markersize=10, strokewidth=2,))
Example block output

If the channels aren't 10/20, one can still plot them, but then the positions need to be passed as well:

data, positions = TopoPlots.example_data()
+TopoPlots.eeg_topoplot(rand(19), labels; axis=(aspect=DataAspect(),), label_text=true, label_scatter=(markersize=10, strokewidth=2,))
Example block output

If the channels aren't 10/20, one can still plot them, but then the positions need to be passed as well:

data, positions = TopoPlots.example_data()
 labels = ["s$i" for i in 1:size(data, 1)]
-TopoPlots.eeg_topoplot(data[:, 340, 1], labels; positions=positions, axis=(aspect=DataAspect(),))
Example block output
+TopoPlots.eeg_topoplot(data[:, 340, 1], labels; positions=positions, axis=(aspect=DataAspect(),))
Example block output
diff --git a/previews/PR36/functions/index.html b/previews/PR36/functions/index.html index a1dbacf..c0f5746 100644 --- a/previews/PR36/functions/index.html +++ b/previews/PR36/functions/index.html @@ -1,2 +1,2 @@ -Function reference · TopoPlots.jl

Function Reference

TopoPlots.enclosing_geometryFunction
enclosing_geometry(G::Type{<: Geometry}, positions, enlarge=1.0)

Returns the Geometry of Type G, that best fits all positions. The Geometry can be enlarged by 1.x, so e.g. enclosing_geometry(Circle, positions, 0.1) will return a Circle that encloses all positions with a padding of 10%.

source
TopoPlots.labels2positionsFunction
labels2positions(labels)

Currently only supports 10/20 layout, by looking it up in TopoPlots.CHANNEL_TO_POSITION_10_20.

source
+Function reference · TopoPlots.jl

Function Reference

TopoPlots.enclosing_geometryFunction
enclosing_geometry(G::Type{<: Geometry}, positions, enlarge=1.0)

Returns the Geometry of Type G, that best fits all positions. The Geometry can be enlarged by 1.x, so e.g. enclosing_geometry(Circle, positions, 0.1) will return a Circle that encloses all positions with a padding of 10%.

source
TopoPlots.labels2positionsFunction
labels2positions(labels)

Currently only supports 10/20 layout, by looking it up in TopoPlots.CHANNEL_TO_POSITION_10_20.

source
diff --git a/previews/PR36/general/8307de79.png b/previews/PR36/general/8307de79.png deleted file mode 100644 index 11cd5d0..0000000 Binary files a/previews/PR36/general/8307de79.png and /dev/null differ diff --git a/previews/PR36/general/9522fa79.png b/previews/PR36/general/9e53b91c.png similarity index 67% rename from previews/PR36/general/9522fa79.png rename to previews/PR36/general/9e53b91c.png index 8d4df26..e6ade43 100644 Binary files a/previews/PR36/general/9522fa79.png and b/previews/PR36/general/9e53b91c.png differ diff --git a/previews/PR36/general/d16bde6b.png b/previews/PR36/general/d16bde6b.png new file mode 100644 index 0000000..dddcc81 Binary files /dev/null and b/previews/PR36/general/d16bde6b.png differ diff --git a/previews/PR36/general/index.html b/previews/PR36/general/index.html index a3b5677..b3dc543 100644 --- a/previews/PR36/general/index.html +++ b/previews/PR36/general/index.html @@ -1,10 +1,10 @@ General TopoPlots · TopoPlots.jl

Recipe for General TopoPlots

At the core of TopoPlots.jl is the topoplot recipe, which takes an array of measurements and an array of positions, which then creates a heatmap like plot which interpolates between the measurements from the positions.

TopoPlots.topoplotFunction
topoplot(data::Vector{<:Real}, positions::Vector{<: Point2})

Creates an irregular interpolation for each data[i] point at positions[i].

Attributes

  • colormap = Reverse(:RdBu)

  • colorrange = automatic

  • labels::Vector{<:String} = nothing: names for each data point

  • interpolation::Interpolator = CloughTocher(): Applicable interpolators are TopoPlots.CloughTocher, TopoPlots.DelaunayMesh, TopoPlots.NullInterpolator, TopoPlots.ScatteredInterpolationMethod, TopoPlots.SplineInterpolator

  • extrapolation = GeomExtrapolation(): Extrapolation method for adding additional points to get less border artifacts

  • bounding_geometry = Circle: A geometry that defines what to mask and the x/y extend of the interpolation. E.g. Rect(0, 0, 100, 200), will create a heatmap(0..100, 0..200, ...). By default, a circle enclosing the positions points will be used.

  • enlarge = 1.2, enlarges the area that is being drawn. E.g., ifbounding_geometryisCircle`, a circle will be fitted to the points and the interpolation area that gets drawn will be 1.2x that bounding circle.

  • interp_resolution = (512, 512): resolution of the interpolation

  • label_text = false:

    • true: add text plot for each position from labels
    • NamedTuple: Attributes get passed to the Makie.text! call.
  • label_scatter = false:

    • true: add point for each position with default attributes
    • NamedTuple: Attributes get passed to the Makie.scatter! call.
  • markersize = 5: size of the points defined by positions, shortcut for label_scatter=(markersize=5,)

  • contours = false:

    • true: add scatter point for each position
    • NamedTuple: Attributes get passed to the Makie.contour! call.

Example

using TopoPlots, CairoMakie
-topoplot(rand(10), rand(Point2f, 10); contours=(color=:red, linewidth=2))
source

Interpolation

The recipe supports different interpolation methods, namely:

TopoPlots.DelaunayMeshType
DelaunayMesh()

Creates a delaunay triangulation of the points and linearly interpolates between the vertices of the triangle. Really fast interpolation that happens on the GPU (for GLMakie), so optimal for exploring larger timeseries.

Warning

DelaunayMesh won't allow you to add a contour plot to the topoplot.

source
TopoPlots.CloughTocherType
CloughTocher(fill_value=NaN, tol=1e-6, maxiter=400, rescale=false)

Piecewise cubic, C1 smooth, curvature-minimizing interpolant in 2D. Find more detailed docs in CloughTocher2DInterpolator.jl.

This is the default interpolator in MNE-Python

source

Interpolation

The recipe supports different interpolation methods, namely:

TopoPlots.DelaunayMeshType
DelaunayMesh()

Creates a delaunay triangulation of the points and linearly interpolates between the vertices of the triangle. Really fast interpolation that happens on the GPU (for GLMakie), so optimal for exploring larger timeseries.

Warning

DelaunayMesh won't allow you to add a contour plot to the topoplot.

source
TopoPlots.CloughTocherType
CloughTocher(fill_value=NaN, tol=1e-6, maxiter=400, rescale=false)

Piecewise cubic, C1 smooth, curvature-minimizing interpolant in 2D. Find more detailed docs in CloughTocher2DInterpolator.jl.

This is the default interpolator in MNE-Python

source
TopoPlots.ScatteredInterpolationMethodType
ScatteredInterpolationMethod(InterpolationMethod)
 
 Container to specify a `InterpolationMethod` from ScatteredInterpolation.
-E.g. ScatteredInterpolationMethod(Shepard(P=4))
source

One can define your own interpolation by subtyping:

TopoPlots.InterpolatorType

Interface for all types <: Interpolator:

interpolator = Interpolator(; kw_specific_to_interpolator)
-interpolator(xrange::LinRange, yrange::LinRange, positions::Vector{Point2}, data::Vector{<: Real})::Matrix{<: Real}
source

The different interpolation schemes look quite different:

using TopoPlots, CairoMakie, ScatteredInterpolation
+E.g. ScatteredInterpolationMethod(Shepard(P=4))
source
TopoPlots.NullInterpolatorType
NullInterpolator()

Interpolator that returns "0", which is useful to display only the electrode locations + labels

source

One can define your own interpolation by subtyping:

TopoPlots.InterpolatorType

Interface for all types <: Interpolator:

interpolator = Interpolator(; kw_specific_to_interpolator)
+interpolator(xrange::LinRange, yrange::LinRange, positions::Vector{Point2}, data::Vector{<: Real})::Matrix{<: Real}
source

The different interpolation schemes look quite different:

using TopoPlots, CairoMakie, ScatteredInterpolation
 
 data, positions = TopoPlots.example_data()
 
@@ -39,12 +39,12 @@
 
    ax.title = ("$(typeof(interpolation))() - $(round(t, digits=2))s")
 end
-f
Example block output

Extrapolation

There are currently just two extrapolations: None (NullExtrapolation()) and a geometry based one:

TopoPlots.GeomExtrapolationType
GeomExtrapolation(
+f
Example block output

Extrapolation

There are currently just two extrapolations: None (NullExtrapolation()) and a geometry based one:

TopoPlots.GeomExtrapolationType
GeomExtrapolation(
     method = Shepard(), # extrapolation method
     geometry = Rect, # the geometry to fit around the points
     enlarge = 3.0 # the amount to grow the bounding geometry for adding the extra points
 )

Takes positions and data, and returns points and additional datapoints on an enlarged bounding geometry:

extra = GeomExtrapolation()
-extra_positions, extra_data, bounding_geometry, bounding_geometry_enlarged = extra(positions, data)
source

The extrapolations in action:

data, positions = TopoPlots.example_data()
+extra_positions, extra_data, bounding_geometry, bounding_geometry_enlarged = extra(positions, data)
source

The extrapolations in action:

data, positions = TopoPlots.example_data()
 titles = ["No Extrapolation", "Rect", "Circle"]
 data_slice = data[:, 340, 1]
 f = Figure(resolution=(900, 300))
@@ -78,4 +78,4 @@
     colorrange=(-1, 1),
     bounding_geometry = Rect,
     label_scatter=(; strokewidth=2),
-    contours=(linewidth=2, color=:white))
Example block output
+ contours=(linewidth=2, color=:white))Example block output diff --git a/previews/PR36/index-5aeb0500.png b/previews/PR36/index-5aeb0500.png new file mode 100644 index 0000000..681499a Binary files /dev/null and b/previews/PR36/index-5aeb0500.png differ diff --git a/previews/PR36/index-e991d72a.png b/previews/PR36/index-e991d72a.png deleted file mode 100644 index 9fb5974..0000000 Binary files a/previews/PR36/index-e991d72a.png and /dev/null differ diff --git a/previews/PR36/index.html b/previews/PR36/index.html index 69ab53f..d746080 100644 --- a/previews/PR36/index.html +++ b/previews/PR36/index.html @@ -5,4 +5,4 @@ topoplot(f[1,2],rand(20), rand(Point2f, 20); contours=(color=:white, linewidth=2), label_scatter=true, bounding_geometry=Rect(0,0,1,1), colormap=:viridis) eeg_topoplot(f[1,3],rand(20),1:20;positions=rand(Point2f, 20), colormap=:Oranges) -fExample block output

Find more documentation for topoplot in Recipe for General TopoPlots.

It also contains some more convenience methods for EEG data, which is explained in EEG Topoplots.

+fExample block output

Find more documentation for topoplot in Recipe for General TopoPlots.

It also contains some more convenience methods for EEG data, which is explained in EEG Topoplots.