UnfoldMakie._normalize_nticks — Method
_normalize_nticks(nticks)Normalize nticks to (x::Int, y::Int). Accepts:
Int→ same for both axes(Int, Int)→(x, y)(x=Int, y=Int)→ as-is
Errors on any other shape.
Return Value: NamedTuple{(:x, :y), Tuple{Int, Int}}.
UnfoldMakie.cart3d_to_spherical — Method
cart3d_to_spherical(x, y, z)Convert x, y, z electrode positions on a scalp to spherical coordinate representation.
Return Value: Matrix.
UnfoldMakie.config_kwargs! — Method
config_kwargs!(cfg::PlotConfig; kwargs...)Takes NamedTuple of Key => NamedTuple as kwargs and merges the fields with the defaults.
UnfoldMakie.data_binning — Method
data_binning(df; col_y = :erp, fun = mean, grouping = [])Group DataFrame according to topoplot coordinates and apply aggregation function.
Arguments:
df::AbstractTable
Requires columns:cont_cuts,col_y(default:erp), and all columns ingrouping(col_coord,row_coord,label);col_y = :erp
The column to combine over (withfun);fun = mean()
Function to combine.grouping = []
Vector of symbols or strings, columns to group by the data before aggregation. Values ofnothingare ignored.
Return Value: DataFrame.
UnfoldMakie.default_tick_positions — Method
default_tick_positions(values; nticks::Int=5)Compute nticks evenly spaced tick positions spanning values. If all values are equal, widens the range by a tiny epsilon.
Return Value: Vector{Float64} of tick positions.
UnfoldMakie.eeg_array_to_dataframe — Method
eeg_array_to_dataframe(data::AbstractMatrix, label_aliases::AbstractVector)
eeg_array_to_dataframe(data::AbstractVector, label_aliases::AbstractVector)
eeg_array_to_dataframe(data::Union{AbstractMatrix, AbstractVector{<:Number}})Helper function converting an array (Matrix or Vector) to a tidy DataFrame with columns :estimate, :time and :label (with aliases :color, :group, :channel).
Format of Arrays:
- times x condition for plot_erp.
- channels x time for plot_butterfly, plot_topoplotseries.
- channels for plot_topoplot.
Return Value: DataFrame.
UnfoldMakie.eeg_topoplot_series — Method
eeg_topoplot_series(data::DataFrame,
fig,
data_inp::Union{<:Observable,<:AbstractMatrix};
layout = nothing,
topoplot_xlabels = nothing,
labels = nothing,
rasterize_heatmaps = true,
interactive_scatter = nothing,
highlight_scatter = false,
topo_axis = (;),
topo_attributes = (;),
positions,
)
eeg_topoplot_series!(fig, data::DataFrame; kwargs..)Plot a series of topoplots. The function takes the combinefun = mean over the :time column of data.
fig
Figure object.data::Union{<:Observable,<:AbstractMatrix}
Matrix with size = (nchannel, ntopoplots).layout::Vector{Tuple{Int64, Int64}}
Vector of tuples with coordinates for each topoplot.topoplot_xlabels::Vector{String}
Vector of xlables for each topoplot.topo_axis::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot axis.
To see all options just type?Axisin REPL.
Defaults: (aspect = 1, title = "", xgridvisible = false, xminorgridvisible = false, xminorticksvisible = false, xticksvisible = false, xticklabelsvisible = false, xlabelvisible = true, ygridvisible = false, yminorgridvisible = false, yminorticksvisible = false, yticksvisible = false, yticklabelsvisible = false, leftspinevisible = false, rightspinevisible = false, topspinevisible = false, bottomspinevisible = false, xpanlock = true, ypanlock = true, xzoomlock = true, yzoomlock = true, xrectzoom = false, yrectzoom = false)topo_attributes::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot interoplation.
To see all options just type?Topoplot.topoplotin REPL.
Defaults: interp_resolution = (128, 128), interpolation = CloughTocher().positions::Vector{Point{2, Float32}}
Channel positions. The list of x and y positions for all unique electrodes.
Return Value: Tuple{Figure, Vector{Any}}.
UnfoldMakie.plot_butterfly — Method
plot_butterfly(plot_data::Union{DataFrame, AbstractMatrix}; kwargs...)
plot_butterfly(times::Vector, plot_data::Union{DataFrame, AbstractMatrix}; kwargs...)
plot_butterfly!(f::Union{GridPosition, GridLayout, Figure}, plot_data::Union{DataFrame, AbstractMatrix}; kwargs...)Plot a Butterfly plot.
Arguments
f::Union{GridPosition, GridLayout, Figure}
Figure,GridLayout, orGridPositionto draw the plot.data::Union{DataFrame, AbstractMatrix}
Data for the ERP plot visualization.kwargs...
Additional styling behavior.
Often used as:plot_butterfly(df; visual = (; colormap = :romaO)).
Keyword arguments (kwargs)
positions::Array = []
Adds a topoplot as an inset legend to the provided channel positions. Must be the same length asplot_data. To change the colors of the channel lines use thetopoposition_to_colorfunction.nticks::Union{Int,Tuple{Int,Int}, NamedTuple{(:x,:y),Tuple{Int,Int}}}= 5
Set the number of tick positions (x,y). Acepts 3 types fo arguments: 6 (=both axes are 6), (5,7), or (x=5, y=7). Controls positions only (use xtickformat/ytickformat for labels).topolegend::Bool = true
Show an inlay topoplot with corresponding electrodes. Requirespositions.topopositions_to_color::x -> pos_to_color_RomaO(x)
Change the line colors.topo_axis::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot axis.
To see all options just type?Axisin REPL.
Defaults: (width = Relative(0.35f0), height = Relative(0.35f0), halign = 0.05, valign = 0.95, aspect = 1)topo_attributes::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot interoplation.
To see all options just type?Topoplot.topoplotin REPL.
Defaults: (head = (color = :black, linewidth = 1), label_scatter = (markersize = 10, strokewidth = 0.5), interpolation = TopoPlots.NullInterpolator())mapping = (;)
For highlighting specific channels.
Example:mapping = (; color = :highlight)), where:highlightis variable with appopriate mapping.
Return Value: Figure displaying Butterfly plot.
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 [s]", ylabel = "Voltage [µV]", yticklabelsize = 14, xtickformat = UnfoldMakie.var"#PlotConfig##0#PlotConfig##1"(), ytickformat = UnfoldMakie.var"#PlotConfig##2#PlotConfig##3"(), xautolimitmargin = (0.01, 0.01)) - use kwargs... of Makie.Axis
layout = (show_legend = false, use_colorbar = true, use_legend = true, hidespines = (:r, :t), hidedecorations = Dict{Symbol, Bool}(:label => 0, :ticks => 0, :ticklabels => 0)) - check this page
mapping = (x = (:time,), y = (:estimate, :yhat, :y), color = (:channel, :channels, :trial, :trials), positions = (:pos, :positions, :position, :topo_positions, :x, nothing), labels = (:labels, :label, :topoLabels, :sensor, nothing), group = (:channel,)) - use any mapping from AlgebraOfGraphics
visual = (colormap = nothing, color = nothing) - use kwargs... of Makie.lines
legend = (orientation = :vertical, tellwidth = true, tellheight = false, halign = :right, valign = :center, framevisible = false, position = :right) - use kwargs... of Makie.Legend
colorbar = (vertical = true, tellwidth = true, tellheight = false, labelrotation = -1.5707963267948966, label = "", flipaxis = true) - use kwargs... of AlgebraOfGraphics.colorbar!
see also plot_erp
UnfoldMakie.plot_channelimage — Method
plot_channelimage!(f::Union{GridPosition, GridLayout, Figure}, data::Union{DataFrame,AbstractMatrix}, positions::Vector{Point{2,Float32}}, ch_names::Vector{String}; kwargs...)
plot_channelimage(data::Union{DataFrame, AbstractMatrix}, positions::Vector{Point{2,Float32}}, ch_names::Vector{String}; kwargs...)Plot a Channel image
Arguments
f::Union{GridPosition, GridLayout, Figure}
Figure,GridLayout, orGridPositionto draw the plot.data::Union{DataFrame, AbstractMatrix}
DataFrame or Matrix with data.
Data should has a format of 1 row - 1 channel.positions::Vector{Point{2,Float32}}
A vector with EEG layout coordinates.ch_names::Vector{String}
Vector with channel names.times::Vector = range(-0.3, 1.2, length = size(data, 2))
Time range on x-axis.sorting_variables::Vector = [:y, :x]
Method to sort channels on y-axis.
For instance, you can sort by channel positions on the scalp (x, y) or channel name.sorting_reverse::Vector = [:false, :false]
Should sorting variables be reversed or not?
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", ylabel = "Channels", yticklabelsize = 14) - use kwargs... of Makie.Axis
layout = (show_legend = true, use_colorbar = true) - check this page
mapping = (x = (:time,), y = (:estimate, :yhat, :y)) - use any mapping from AlgebraOfGraphics
visual = (colormap = Makie.Reverse{String}("RdBu"),) - use kwargs... of Makie.heatmap
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, label = "Voltage [µV]") - use kwargs... of Makie.Colorbar
Return Value: Figure displaying the Channel image.
UnfoldMakie.plot_circular_topoplots — Method
plot_circular_topoplots!(f, data::DataFrame; kwargs...)using ColorSchemes: topo using ColorSchemes: topo using ColorSchemes: topo plotcirculartopoplots(data::DataFrame; kwargs...)
Plot a circular EEG topoplot.
Arguments
f::Union{GridPosition, GridLayout, Figure}
Figure,GridLayout, orGridPositionto draw the plot.data::DataFrame
DataFrame with data keys (columns:y, :yhat, :estimate), and :position (columns:pos, :position, :positions).
Keyword arguments (kwargs)
predictor::Vector{Any} = :predictor
The circular predictor value, defines position of topoplot across the circle. Mapped aroundpredictor_bounds.predictor_bounds::Vector{Int64} = [0, 360]
The bounds of the predictor. Relevant for the axis labels.positions::Vector{Point{2, Float32}} = nothing
Positions of theplot_topoplot.center_label::String = ""
The text in the center of the cricle.plot_radius::String = 0.8
The radius of the circular topoplot series plot calucalted by formula:radius = (minwidth * plot_radius) / 2.labels::Vector{String} = nothing
Labels for theplot_topoplots.topo_axis::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot axis.
To see all options just type?Axisin REPL.
Defaults: (width = Relative(0.2f0), height = Relative(0.2f0), aspect = 1)topo_attributes::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot interoplation.
To see all options just type?Topoplot.topoplotin REPL.
Defaults: interp_resolution = (128, 128), interpolation = CloughTocher()
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]", colormap = Makie.Reverse{Symbol}(:RdBu)) - use kwargs... of Makie.Colorbar
Return Value: Figure displaying the Circular topoplot series.
UnfoldMakie.plot_designmatrix — Method
plot_designmatrix!(f::Union{GridPosition, GridLayout, Figure}, data::Unfold.DesignMatrix; kwargs...)
plot_designmatrix(data::Unfold.DesignMatrix; kwargs...)Plot a designmatrix.
Arguments
f::Union{GridPosition, GridLayout, Figure}
Figure,GridLayout, orGridPositionto draw the plot.data::Unfold.DesignMatrix
Data for the plot visualization.
Keyword arguments (kwargs)
standardize_data::Bool = false
Indicates whether the data is standardized by pointwise division of the data with its sampled standard deviation.sort_data::Bool = false
Indicates whether the data is sorted. It usessortslices()of Base Julia.xticks::Num = nothing
Specifies the number of labels displayed on the x-axis.xticks = 0: No labels are displayed.xticks = 1: Only the first label is displayed.xticks = 2: The first and last labels are displayed.2 < xticks < number of labels: The labels are evenly distributed across the axis.xticks ≥ number of labels: All labels are displayed.
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 = "Conditions", ylabel = "Trials", xticklabelrotation = 0.39) - use kwargs... of Makie.Axis
layout = (show_legend = true, use_colorbar = true) - check this page
mapping = (x = (:time,), y = (:estimate, :yhat, :y)) - use any mapping from AlgebraOfGraphics
visual = (colormap = :roma,) - use kwargs... of Makie.heatmap
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 = "") - use kwargs... of Makie.Colorbar
Return Value: Figure displaying the Design matrix.
UnfoldMakie.plot_erp — Method
plot_erp!(f::Union{GridPosition, GridLayout, Figure}, plot_data::Union{DataFrame, AbstractMatrix, AbstractVector{<:Number}}; kwargs...)
plot_erp(times, plot_data::Union{DataFrame, AbstractMatrix, AbstractVector{<:Number}}; kwargs...)Plot an ERP plot.
Arguments
f::Union{GridPosition, GridLayout, Figure}
Figure,GridLayout, orGridPositionto draw the plot.data::Union{Union{DataFrame, AbstractMatrix, AbstractVector{<:Number}, Vector{Float32}}
Data for the ERP plot visualization.kwargs...
Additional styling behavior.
Often used as:plot_erp(df; mapping = (; color = :coefname, col = :conditionA)).
Keyword arguments (kwargs)
nticks::Union{Int,Tuple{Int,Int}, NamedTuple{(:x,:y),Tuple{Int,Int}}}= 5
Set the number of tick positions (x,y). Acepts 3 types fo arguments: 6 (=both axes are 6), (5,7), or (x=5, y=7). Controls positions only (use xtickformat/ytickformat for labels).stderror::Bool = false
Add an error ribbon, with lower and upper limits based on the:stderrorcolumn.significance::DataFrame = nothing
Show significant time periods as horizontal bars.
Example:DataFrame(from = [0.1, 0.3], to = [0.5, 0.7], coefname = ["(Intercept)", "condition: face"]).
Ifcoefnameis not specified, the significance lines will be black.layout.use_colorbar = true
Enable or disable colorbar.layout.use_legend = true
Enable or disable legend.layout.show_legend = true
Enable or disable legend and colorbar.tick_formatter::Function = default_ticks
Function used to compute automatic tick positions and labels for both axes.
Example:tick_formatter = v -> default_ticks(v; nticks = 6).mapping = (;)
Specifycolor,col(column),linestyle,group.
F.e.mapping = (; col = :group)will make a column for each group.visual = (; color = Makie.wong_colors, colormap = :roma)
For categorical color usevisual.color, for continuous -visual.colormap.sigifnicance_visual::Symbol = :vspan
How to display significance intervals. Options:
*:vspan– draw vertical shaded spans (default);
*:lines– draw horizontal bands below ERP lines;
*:both– draw both.significance_lines::NamedTuple = (;)
Configure the appearance of significance lines:
*linewidth– thickness of each line (not working);
*gap– vertical space between stacked lines. Computed asstack_step = linewidth + gap;
*alpha– transparency of the lines.
Defaults: (alpha = 1, linewidth = 0.005, gap = 0.1)significance_vspan::NamedTuple = (;)
Control appearance of vertical significance spans:
*alpha– transparency of the shaded area.
Defaults: (alpha = 0.3,)
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 [s]", ylabel = "Voltage [µV]", yticklabelsize = 14, xtickformat = UnfoldMakie.var"#PlotConfig##4#PlotConfig##5"(), ytickformat = UnfoldMakie.var"#PlotConfig##6#PlotConfig##7"()) - use kwargs... of Makie.Axis
layout = (show_legend = true, use_colorbar = true, use_legend = true, hidespines = (:r, :t), hidedecorations = Dict{Symbol, Bool}(:grid => 1, :label => 0, :ticks => 0, :ticklabels => 0)) - check this page
mapping = (x = (:time,), y = (:estimate, :yhat, :y), color = (:color, :coefname, nothing)) - use any mapping from AlgebraOfGraphics
visual = (colormap = :roma, color = ColorTypes.RGBA{Float32}[RGBA(0.0, 0.44705883, 0.69803923, 1.0), RGBA(0.9019608, 0.62352943, 0.0, 1.0), RGBA(0.0, 0.61960787, 0.4509804, 1.0), RGBA(0.8, 0.4745098, 0.654902, 1.0), RGBA(0.3372549, 0.7058824, 0.9137255, 1.0), RGBA(0.8352941, 0.36862746, 0.0, 1.0), RGBA(0.9411765, 0.89411765, 0.25882354, 1.0)]) - use kwargs... of Makie.lines
legend = (orientation = :vertical, tellwidth = true, tellheight = false, halign = :right, valign = :center, framevisible = false, position = :right) - use kwargs... of Makie.Legend
colorbar = (vertical = true, tellwidth = true, tellheight = false, labelrotation = -1.5707963267948966, label = "", flipaxis = true) - use kwargs... of AlgebraOfGraphics.colorbar!
Return Value: Figure displaying the ERP plot.
UnfoldMakie.plot_erpgrid — Method
plot_erpgrid(data::Union{Matrix{<:Real}, DataFrame}, positions::Vector; kwargs...)
plot_erpgrid!(f::Union{GridPosition, GridLayout, Figure}, data::Union{Matrix{<:Real}, DataFrame}, positions::Vector, ch_names::Vector{String}; kwargs...)Plot an ERP image.
Arguments
f::Union{GridPosition, GridLayout, Figure}
Figure,GridLayout, orGridPositionto draw the plot.data::Union{Matrix{<:Real}, DataFrame}
Data for the plot visualization.
Data should has a format of 1 row - 1 channel.positions::Vector{Point{2,Float}}
Electrode positions.ch_names::Vector{String}
Vector with channel names.hlines_grid_axis::NamedTuple = (;)
Here you can flexibly change configurations of the hlines on all subaxes.
To see all options just type?hlinesin REPL.
Defaults: (color = :gray, linewidth = 0.5)vlines_grid_axis::NamedTuple = (;)
Here you can flexibly change configurations of the vlines on all subaxes.
To see all options just type?vlinesin REPL.
Defaults: (color = :gray, linewidth = 0.5, ymin = 0.2, ymax = 0.8)lines_grid_axis::NamedTuple = (;)
Here you can flexibly change configurations of the lines on all subaxes.
To see all options just type?linesin REPL.
Defaults: (color = :deepskyblue3,)labels_grid_axis::NamedTuple = (;)
Here you can flexibly change configurations of the labels on all subaxes.
To see all options just type?textin REPL.
Defaults: (color = :gray, fontsize = 12, align = (:left, :top), space = :relative)indicator_grid_axis::NamedTuple = (;)
Here you can change configurations of inidcator axis.
Defaults: (xlim = [-0.04, 1.0], ylim = [-0.04, 1.0], arrowsstart = Point{2, Float32}[[0.0, 0.0], [0.0, 0.0]], arrowsdir = Vec{2, Float32}[[0.0, 0.1], [0.1, 0.0]], arrowskwargs = (arrowsize = 10,), textxcoords = (0.02, 0), textxkwargs = (text = "Time [s]", align = (:left, :top), fontsize = 12), textycoords = (-0.008, 0.01), texty_kwargs = (text = "Voltage [µV]", align = (:left, :baseline), fontsize = 12, rotation = 1.5707963267948966))subaxes::NamedTuple = (;)
Here you can flexibly change configurations of all subaxes. F.e. make them wider or shorter
To see all options just type?Axisin REPL.
Defaults: (width = Relative(0.1f0), height = Relative(0.1f0))
Keyword arguments (kwargs)
drawlabels::Bool = false
Draw channels labels over each waveform.times::Vector = 1:size(data, 2)
Vector ofsize().
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 = (width = GridLayoutBase.Relative(1.05f0), height = GridLayoutBase.Relative(1.05f0)) - use kwargs... of Makie.Axis
layout = (show_legend = true, use_colorbar = true) - check this page
mapping = (x = (:time,), y = (:estimate, :yhat, :y)) - use any mapping from AlgebraOfGraphics
visual = (colormap = :roma,) - use kwargs... of Makie.lines
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) - use kwargs... of Makie.Colorbar
Return Value: Figure displaying ERP grid.
UnfoldMakie.plot_erpimage — Method
plot_erpimage!(f::Union{GridPosition, GridLayout, Figure}, data::AbstractMatrix{Float64}; kwargs...)
plot_erpimage!(f::Union{GridPosition, GridLayout, Figure}, data::Observable{<:AbstractMatrix}; kwargs...)
plot_erpimage!(f::Union{GridPosition, GridLayout, Figure}, times::Observable{<:AbstractVector}, data::Observable{<:AbstractMatrix{<:Real}}; kwargs...)
plot_erpimage(times::AbstractVector, data::Union{<:Observable{Matrix{<:Real}}, Matrix{<:Real}}; kwargs...)
plot_erpimage(data::Matrix{Float64}; kwargs...)Plot an ERP image.
Arguments:
f::Union{GridPosition, GridLayout, Figure}
Figure,GridLayout, orGridPositionto draw the plot.data::Union{DataFrame, Vector{Float32}}
Data for the plot visualization.
Keyword arguments (kwargs)
erpblur::Number = 10
Number indicating how much blur is applied to the image.
Gaussian blur of theImageFilteringmodule is used.
Non-Positive values deactivate the blur.sortvalues::Vector{Int64} = false
Parameter over which plot will be sorted. Usingsortperm()of Base Julia.
sortperm()computes a permutation of the array's indices that puts the array in sorted order.sortindex::Vector{Int64} = nothing
Sorting over index values.meanplot::bool = false
Add a line plot below the ERP image, showing the mean of the data.show_sortval::bool = false
Add a plot on the right from ERP image, showing the distribution of the sorting data.sortval_xlabel::String = "Sorting variable"
Ifshow_sortval = truecontrols xlabel.axis.ylabel::String = "Trials"
Ifsortvalues = truethe default text will change to "Sorted trials", but it could be changed to any values specified manually.meanplot_axis::NamedTuple = (;)
Here you can flexibly change configurations of meanplot.
To see all options just type?Axisin REPL.
Defaults: (height = 100, xlabel = "Time", xlabelpadding = 0, xautolimitmargin = (0, 0))sortplot_axis::NamedTuple = (;)
Here you can flexibly change configurations of meanplot.
To see all options just type?Axisin REPL.
Defaults: (ylabelvisible = true, yticklabelsvisible = false)
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", ylabel = "Trials") - use kwargs... of Makie.Axis
layout = (show_legend = true, use_colorbar = true) - check this page
mapping = (x = (:time,), y = (:estimate, :yhat, :y)) - use any mapping from AlgebraOfGraphics
visual = (colormap = Makie.Reverse{String}("RdBu"),) - use kwargs... of Makie.heatmap
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, label = "Voltage [µV]") - use kwargs... of Makie.Colorbar
Return Value: Figure displaying the ERP image.
UnfoldMakie.plot_parallelcoordinates — Method
plot_parallelcoordinates(data::Union{DataFrame, AbstractMatrix}; kwargs...)
plot_parallelcoordinates!(f::Union{GridPosition, GridLayout, Figure}, data::Union{DataFrame, AbstractMatrix}; kwargs)Plot a PCP (parallel coordinates plot).
Dimensions: conditions, channels, time, trials.
Arguments:
f::Union{GridPosition, GridLayout, Figure}Figure,GridLayout, orGridPositionto draw the plot.data::Union{DataFrame, AbstractMatrix}
Data for the plot visualization.
Keyword arguments (kwargs)
normalize::Symbol = nothing
If:minmax, normalize each axis to their respective min-max range.ax_labels::Vector{String} = nothing
Specify axis labels.
Should be a vector of labels with length equal to the number of uniquemapping.xvalues.
Example:ax_labels = ["Fz", "Cz", "O1", "O2"].ax_ticklabels::Symbol = :outmost
Specify tick labels on axis.:all- show all labels on all axes.:left- show all labels on the left axis, but only min and max on others.:outmost- show labels on min and max of all other axes.:none- remove all labels.
bend::Bool = false
Change straight lines between the axes to curved ("bent") lines using spline interpolation.
Note: While this makes the plot look cool, it is not generally recommended to bent the lines, as interpretation suffers, and the resulting visualizations can be potentially missleading.visual.alpha::Number = 0.5
Change of line transparency.
Defining the axes
mapping.x = :channel, mapping.y = :estimate.
Overwrite what should be on the x and the y axes.mapping.color = :colorcolumn
Split conditions by color. The default color is:black.
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 = "Channels", ylabel = "Voltage [µV]", title = "", xlabelpadding = 14, ylabelpadding = 26) - use kwargs... of Makie.Axis
layout = (show_legend = true, use_colorbar = true) - check this page
mapping = (x = :channel, y = (:estimate, :yhat, :y)) - use any mapping from AlgebraOfGraphics
visual = (colormap = ColorTypes.RGBA{Float32}[RGBA(0.0, 0.44705883, 0.69803923, 1.0), RGBA(0.9019608, 0.62352943, 0.0, 1.0), RGBA(0.0, 0.61960787, 0.4509804, 1.0), RGBA(0.8, 0.4745098, 0.654902, 1.0), RGBA(0.3372549, 0.7058824, 0.9137255, 1.0), RGBA(0.8352941, 0.36862746, 0.0, 1.0), RGBA(0.9411765, 0.89411765, 0.25882354, 1.0)], color = :black, alpha = 0.3) - use kwargs... of Makie.lines
legend = (orientation = :vertical, tellwidth = true, tellheight = false, halign = :right, valign = :center, title = "Conditions", merge = true, framevisible = false) - use kwargs... of Makie.Legend
colorbar = (vertical = true, tellwidth = true, tellheight = false, labelrotation = -1.5707963267948966) - use kwargs... of Makie.Colorbar
Return Value: Figure displaying the Parallel coordinates plot.
UnfoldMakie.plot_splines — Method
plot_splines(m::UnfoldModel; kwargs...)
plot_splines!(f::Union{GridPosition, GridLayout, Figure}, m::UnfoldModel; kwargs...)Visualization of spline terms in an UnfoldModel. Two subplots are generated for each spline term:
1) the basis function of the spline; 2) the density of the underlying covariate.
Multiple spline terms are arranged across columns.
Dashed lines indicate spline knots.
Arguments:
f::Union{GridPosition, GridLayout, Figure}Figure,GridLayout, orGridPositionto draw the plot.m::UnfoldModel
UnfoldModel with splines.spline_axis::NamedTuple = (;)
Here you can flexibly change configurations of spline subplots.
To see all options just type?Axisin REPL.
Defaults: (ylabel = "Spline value", xlabelvisible = false, xticklabelsvisible = false, ylabelvisible = true)density_axis::NamedTuple = (;)
Here you can flexibly change configurations of density subplots.
To see all options just type?Axisin REPL.
Defaults: (xautolimitmargin = (0, 0), ylabel = "Density value")superlabel_config::NamedTuple = (;)
Here you can flexibly change configurations of the Label on the top of the plot.
To see all options just type?Labelin REPL.
Defaults: (fontsize = 20, padding = (0, 0, 40, 0))
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 = NamedTuple() - use kwargs... of Makie.Axis
layout = (show_legend = true, use_colorbar = true) - check this page
mapping = (x = (:time,), y = (:estimate, :yhat, :y)) - use any mapping from AlgebraOfGraphics
visual = (colormap = :viridis,) - use kwargs... of Makie.series
legend = (orientation = :vertical, tellwidth = true, tellheight = false, halign = :right, valign = :center, title = "Splines", framevisible = false) - use kwargs... of Makie.Legend
colorbar = (vertical = true, tellwidth = true, tellheight = false, labelrotation = -1.5707963267948966) - use kwargs... of Makie.Colorbar
Return Value: Figure with splines and their density for basis functions.
UnfoldMakie.plot_topoplot — Method
plot_topoplot!(f::Union{GridPosition, GridLayout, Figure}, data::Union{<:Observable{<:DataFrame},<:AbstractDataFrame,<:AbstractVector}; positions::Vector, labels = nothing, kwargs...)
plot_topoplot(data::Union{<:Observable{<:DataFrame},<:AbstractDataFrame,<:AbstractVector}; position::Vector, labels = nothing, kwargs...)Plot a topoplot.
Arguments
f::Union{GridPosition, GridLayout, Figure}
Figure,GridLayout, orGridPositionto draw the plot.data::Union{<:Observable{<:DataFrame},<:AbstractDataFrame,<:AbstractVector}
Data for the plot visualization.positions::Vector{Point{2, Float32}}
Positions used ifdatais not aDataFrame. Positions are generated fromlabelsifpositions = nothing.labels::Vector{String} = nothing
Labels used ifdatais not a DataFrame.topo_axis::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot axis.
To see all options just type?Axisin REPL.
Defaults: (width = Relative(1.0f0), height = Relative(1.0f0), halign = 0.05, valign = 0.95, aspect = DataAspect())topo_attributes::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot interoplation.
To see all options just type?Topoplot.topoplotin REPL.
Defaults: interp_resolution = (128, 128), interpolation = CloughTocher()
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 = Makie.DataAspect()) - use kwargs... of Makie.Axis
layout = (show_legend = true, 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]") - use kwargs... of Makie.Colorbar
To highlight some electrodes, you can use topo_attributes = (; label_scatter = (; ...)) where ... are the attributes for scatter! function. For example, to change the marker size of all electrodes to 8, use topo_attributes = (; label_scatter = (; markersize = 15)). To set different sizes for each electrode, provide a vector of sizes with length equal to the number of electrodes.
Return Value: Figure displaying the Topoplot.
UnfoldMakie.plot_topoplotseries — Method
plot_topoplotseries(f::Union{GridPosition, GridLayout, Figure}, data::Union{<:Observable{<:DataFrame},DataFrame}; kwargs...)
plot_topoplotseries!(data::Union{<:Observable{<:DataFrame},DataFrame}; kwargs...)Multiple miniature topoplots in regular distances.
Arguments
f::Union{GridPosition, GridLayout, GridLayoutBase.GridSubposition, Figure}
Figure,GridLayout,GridPosition, orGridLayoutBase.GridSubpositionto draw the plot.data::Union{<:Observable{<:DataFrame},DataFrame}
DataFrame with data or Observable DataFrame.
Requires atimecolumn by default, but can be overridden by specifyingmapping=(; x=:my_column)with any continuous or categorical column.
Keyword arguments (kwargs)
bin_width::Real = nothing
Number specifing the width of bin of continuous x-value in its units.bin_num::Real = nothing
Number of topoplots.
Eitherbin_width, orbin_numshould be specified. Error if they are both specified
Ifmapping.colormapping.roware categoricalbin_widthandbin_numstay asnothing.combinefun::Function = mean
Specify how the samples withinbin_widthare summarised.
Example functions:mean,median,std.rasterize_heatmaps::Bool = true
Force rasterization of the plot heatmap when saving insvgformat.
Except for the interpolated heatmap, all lines/points are vectors.
This is typically what you want, otherwise you get ~128x128 vectors per topoplot, which makes everything very slow.col_labels::Bool,row_labels::Bool = true
Shows column and row labels in faceting mode. (not implemented)positions::Vector{Point{2, Float32}} = nothing
Specify channel positions. Requires the list of x and y positions for all unique electrodes.labels::Vector{String} = nothing
Show labels for each electrode.interactive_scatter = nothing
Enable interactive mode.
If you createobs_tuple = Observable((0, 0, 0))and pass it intointeractive_scatteryou can update the observable tuple with the indices of the clicked topoplot markers.
(0, 0, 0)corresponds to the (row of topoplot layout, column of topoplot layout, electrode).topo_axis::NamedTuple = (;)
Here you can flexibly change configurations of topoplots.
To see all options just type?Axisin REPL.mapping = (; col = :time, row = nothing, layout = nothing)
mapping.col- specify x-value, can be any continuous or categorical variable.
mapping.row- specify y-value, can be any continuous or categorical variable (not implemented yet).
mapping.layout- arranges topoplots by rows when equals:time.topo_attributes::NamedTuple = (;)
Here you can flexibly change configurations of the topoplot interoplation.
To see all options just type?Topoplot.topoplotin REPL.
Defaults: interp_resolution = (128, 128), interpolation = CloughTocher()topolabels_rounding = (; sigdigits = 3)
Rounding of the topo_axis labels.
sigdigits- number of significant digits.
digits- number of digits after the decimal point.
Only one ofsigdigitsordigitsshould be provided.
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 windows", aspect = Makie.DataAspect(), title = "", titlesize = 16, titlefont = :bold, ylabel = "", ylabelpadding = 25, xlabelpadding = 25, xpanlock = true, ypanlock = true, xzoomlock = true, yzoomlock = true, xrectzoom = false, yrectzoom = false) - use kwargs... of Makie.Axis
layout = (show_legend = true, 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), col = (:time,), row = (nothing,)) - use any mapping from AlgebraOfGraphics
visual = (colormap = Makie.Reverse{Symbol}(:RdBu), contours = (color = :white, linewidth = 2), enlarge = 1, label_scatter = false, label_text = false, bounding_geometry = GeometryBasics.Circle, levels = nothing) - 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]") - use kwargs... of Makie.Colorbar
Return Value: Figure displaying the Topoplot series.
UnfoldMakie.rel_to_abs_bbox — Method
rel_to_abs_bbox(org, rel)Takes a rectangle org consiting of coordinates of origins and applies the relative transformation tuple rel.
Return Value: Makie.BBox.
UnfoldMakie.supportive_defaults — Method
supportive_defaults(cfg_symb::Symbol)Default configurations for the supporting axis. Similar to PlotConfig, but these configurations are not shared by all plots.
Such supporting axes allow users to flexibly see defaults in docstrings and manipulate them using corresponding axes.
For developers: to make them updateable in the function, use update_axis. Return value: NamedTuple.
UnfoldMakie.to_positions — Method
to_positions(x, y, z; sphere = [0, 0, 0.])
to_positions(pos::AbstractMatrix; sphere = [0, 0, 0.])Projects 3D electrode positions to a 2D layout. Reimplementation of the MNE algorithm.
Assumes size(pos) = (3, nChannels) when input is AbstractMatrix.
Tip: You can get positions directly from an MNE object after loading PyMNE and enabling the UnfoldMakie PyMNE extension.
Return Value: Vector{Point2{Float64}}.
UnfoldMakie.update_axis — Method
update_axis(support_axis::NamedTuple; kwargs...)Update values of NamedTuple{key = value}.
Used for supportive axes to make users be able to flexibly change them.
Internally, we use a PlotConfig struct to keep track of common plotting options, so that all functions have a similar API.
UnfoldMakie.PlotConfig — Type
PlotConfig(<plotname>)Contains several different fields that can modify various aspects of the plot.
source