Circular Topoplots

Circular topoplot series is a plot type for visualizing EEG activity in relation to some continous variable arranged on a circluar line. It can fully represent channel and channel location dimensions using contour lines. It can also partially represent the varaible dimension. Variable could be for instance saccadic amplitude or degrees of visual angle. Basically, it is a series of Topoplots arranged on a circle.

Setup

Package loading

using UnfoldMakie
using CairoMakie
using TopoPlots # for example data
using Random
using DataFrames

Data generation Generate a Dataframe. We need to specify the Topoplot positions either via position, or via labels.

data, pos = TopoPlots.example_data();
dat = data[:, 240, 1]
df = DataFrame(
    :estimate => eachcol(Float64.(data[:, 100:40:300, 1])),
    :circular_variable => [0, 50, 80, 120, 180, 210],
    :time => 100:40:300,
)
df = flatten(df, :estimate);

Plot generations

Note how the plots are located at the angles of the circular_variable.

plot_circular_topoplots(
    df;
    positions = pos,
    center_label = "Relative angle [°]",
    predictor = :circular_variable,
)
Example block output

If the bounding variable is not between 0 and 360, since we are using time, we must specify it.

plot_circular_topoplots(
    df;
    positions = pos,
    center_label = "Time [s]",
    predictor = :time,
    predictor_bounds = [80, 320],
    colorbar = (; height = 350),
)
Example block output

Configurations of Circular Topoplots

UnfoldMakie.plot_circular_topoplotsFunction
plot_circular_topoplots!(f, data::DataFrame; kwargs...)
plot_circular_topoplots(data::DataFrame; kwargs...)

Plot a circular series of EEG topoplots.

Arguments

  • f::Union{GridPosition, GridLayout, Figure}
    Layout container in which to draw the plot.
  • data::DataFrame
    Data containing an amplitude column (:y, :yhat, or :estimate) and values for the circular predictor.

Keyword arguments (kwargs)

  • predictor::Symbol = :predictor
    Column containing the predictor values that determine the positions of the topoplots around the circle.
  • predictor_bounds::AbstractVector = [0, 360]
    Lower and upper bounds used to map predictor values onto the circular axis.
  • positions::Vector{Point{2, Float32}} = nothing
    Two-dimensional electrode positions used by plot_topoplot.
  • center_label::String = ""
    Text displayed at the centre of the circular axis.
  • plot_radius::Real = 0.8
    Relative radius of the circular arrangement, calculated as (minimum_layout_dimension * plot_radius) / 2.
  • labels::Vector{String} = nothing
    Electrode labels used to obtain positions when positions is not supplied.
  • topo_axis::NamedTuple = (;)
    Attributes passed to each topoplot axis. See ?Axis for available options.
    Defaults: (width = Relative(0.2f0), height = Relative(0.2f0), aspect = 1)
  • topo_attributes::NamedTuple = (;)
    Attributes controlling topoplot interpolation and appearance.
    Defaults: interp_resolution = (128, 128), interpolation = CloughTocher()
  • colorbar::NamedTuple = (;)
    Colorbar attributes. Set position to :right, :left, :top, or :bottom. Colorbars at the top or bottom are horizontal automatically.
  • return_objects::Bool = false
    Return a named tuple containing the created axis and colorbar.
    Helpful for colorbar tweaking. If false, returns the figure.

Shared plot configuration options

The shared plot options can be used as follows: type = (; key = value, ...)).
For example, plot_x(...; colorbar = (; vertical = true, label = "Test")).
Multiple defaults will be cycled until match.

Placing ; is important!

figure = NamedTuple() - use kwargs... of Makie.Figure

axis = (xlabel = "Time", aspect = 1) - use kwargs... of Makie.Axis

layout = (show_legend = false, use_colorbar = true, hidespines = (), hidedecorations = Dict{Symbol, Bool}(:label => 0)) - check this page

mapping = (x = nothing, y = (:estimate, :yhat, :y), positions = (:pos, :positions, :position, nothing), labels = (:labels, :label, :sensor, nothing)) - use any mapping from AlgebraOfGraphics

visual = (colormap = Makie.Reverse{Symbol}(:RdBu), contours = (color = :white, linewidth = 2), enlarge = 1, label_scatter = true, label_text = false, bounding_geometry = GeometryBasics.Circle) - use kwargs... of Topoplot.eeg_topoplot

legend = (orientation = :vertical, tellwidth = true, tellheight = false, halign = :right, valign = :center) - use kwargs... of Makie.Legend

colorbar = (vertical = true, tellwidth = true, tellheight = false, labelrotation = -1.5707963267948966, flipaxis = true, label = "Voltage [µV]", position = :right, colormap = Makie.Reverse{Symbol}(:RdBu)) - use kwargs... of Makie.Colorbar

Return Value: Figure.

source

This page was generated using Literate.jl.