diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 9cf859ffc..8c8eac90f 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-11-20T17:04:03","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-11-20T17:04:49","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index 6a784a7c5..be66a627e 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -1,13 +1,13 @@ -API · UnfoldMakie.jl
UnfoldMakie.df_timebinMethod

function dftimebin(df, Δbin; coly=:erp, fun=mean, grouping=[]) Split or combine dataframe according to equally spaced time bins

  • df AbstractTable with columns :time and col_y (default :erp), and all columns in grouping;
  • Δbin bin size in :time units;
  • col_y default :erp, the column to combine over (with fun);
  • fun function to combine, default is mean;
  • grouping (vector of symbols/strings) default empty vector, columns to group the data by before aggregating. Values of nothing are ignored.
source
UnfoldMakie.eeg_topoplot_seriesMethod

function eegtopoplotseries(data::DataFrame, Δbin; y=:estimate, label=:label, col=:time, row=nothing, figure = NamedTuple(), combinefun=mean, rowlabels = false, collabels = false, topoplot_attributes... )

Plot a series of topoplots. The function automatically takes the combinefun=mean over the :time column of data in Δbin steps.

  • The data frame data needs the columns :time and y(=:erp), and label(=:label). If data is a matrix, it is automatically cast to a dataframe, time bins are in samples, labels are string.(1:size(data,1)).
  • Δbin in :time units, specifying the time steps. All other keyword arguments are passed to the EEG_TopoPlot recipe. In most cases, the user should specify the electrode positions with positions=pos.
  • The col and row arguments specify the field to be divided into columns and rows. The default is col=:time to split by the time field and row=nothing. Useful

to split by a condition, e.g. ...(..., col=:time, row=:condition) would result in multiple (as many as different values in df.condition) rows of topoplot series.

  • The figure option allows you to include information for plotting the figure. Alternatively, you can pass a fig object eeg_topoplot_series!(fig, data::DataFrame, Δbin; kwargs..).
  • row_labels and col_labels indicate whether there should be labels in the plots in the first column to indicate the row value and in the last row to indicate the time (typically timerange).

Examples

Desc

julia > df = DataFrame(:erp => repeat(1:63, 100), :time => repeat(1:20, 5 * 63), :label => repeat(1:63, 100)) # fake data
+API · UnfoldMakie.jl
UnfoldMakie.df_timebinMethod

function dftimebin(df, Δbin; coly=:erp, fun=mean, grouping=[]) Split or combine dataframe according to equally spaced time bins

  • df AbstractTable with columns :time and col_y (default :erp), and all columns in grouping;
  • Δbin bin size in :time units;
  • col_y default :erp, the column to combine over (with fun);
  • fun function to combine, default is mean;
  • grouping (vector of symbols/strings) default empty vector, columns to group the data by before aggregating. Values of nothing are ignored.
source
UnfoldMakie.eeg_topoplot_seriesMethod

function eegtopoplotseries(data::DataFrame, Δbin; y=:estimate, label=:label, col=:time, row=nothing, figure = NamedTuple(), combinefun=mean, rowlabels = false, collabels = false, topoplot_attributes... )

Plot a series of topoplots. The function automatically takes the combinefun=mean over the :time column of data in Δbin steps.

  • The data frame data needs the columns :time and y(=:erp), and label(=:label). If data is a matrix, it is automatically cast to a dataframe, time bins are in samples, labels are string.(1:size(data,1)).
  • Δbin in :time units, specifying the time steps. All other keyword arguments are passed to the EEG_TopoPlot recipe. In most cases, the user should specify the electrode positions with positions=pos.
  • The col and row arguments specify the field to be divided into columns and rows. The default is col=:time to split by the time field and row=nothing. Useful

to split by a condition, e.g. ...(..., col=:time, row=:condition) would result in multiple (as many as different values in df.condition) rows of topoplot series.

  • The figure option allows you to include information for plotting the figure. Alternatively, you can pass a fig object eeg_topoplot_series!(fig, data::DataFrame, Δbin; kwargs..).
  • row_labels and col_labels indicate whether there should be labels in the plots in the first column to indicate the row value and in the last row to indicate the time (typically timerange).

Examples

Desc

julia > df = DataFrame(:erp => repeat(1:63, 100), :time => repeat(1:20, 5 * 63), :label => repeat(1:63, 100)) # fake data
 julia > pos = [(1:63) ./ 63 .* (sin.(range(-2 * pi, 2 * pi, 63))) (1:63) ./ 63 .* cos.(range(-2 * pi, 2 * pi, 63))] .* 0.5 .+ 0.5 # fake electrode positions
 julia > pos = [Point2.(pos[k, 1], pos[k, 2]) for k in 1:size(pos, 1)]
-julia > eeg_topoplot_series(df, 5; positions=pos)
source
UnfoldMakie.plot_butterflyMethod

Plot a butterfly plot

kwargs (...; ...):

  • butterfly (bool, true): create a butterfly plot.
  • topolegend (bool, true): show an inlay topoplot with corresponding electrodes.
  • topomarkersize (Real, 10): change the size of the markers, topoplot-inlay electrodes.
  • topowidth (Real, 0.25): change the size of the inlay topoplot width.
  • topoheigth (Real, 0.25): change the size of the inlay topoplot height.
  • topopositions_to_color (function, ´x -> posToColorRomaO(x)´).

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (showlegend = false, legendposition = :right, xlabelFromMapping = :x, ylabelFromMapping = :y, use_colorbar = false, hidespines = (:r, :t))

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))

visual = (colormap = :roma,) - use kwargs... of $Makie.lines$

legend = (orientation = :vertical, tellwidth = true, tellheight = false, framevisible = false) - use kwargs... of Makie.Legend

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of AlgebraOfGraphics.colobar!

see also plot_erp

source
UnfoldMakie.plot_circulareegtopoplotMethod
plot_circulareegtopoplot(data::DataFrame; kwargs...)
-plot_circulareegtopoplot!(f, data::DataFrame; kwargs...)

Plot a circular EEG topoplot.

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure, GridLayout or GridPosition that the plot should be drawn into

  • data::DataFrame: DataFrame with keys for data (looks for :y, :yhat, :estimate), and :position (looks for :pos, :position, :positions),

  • predictor (optional; default: predictor): the circular predictor value, defines position of topoplot, is mapped around predictor_bounds

  • predictor_bounds (default: [0,360]): the bounds of the predictor. This is relevant for the axis labels.

  • positions (default: nothing): positions for the plot_topoplot

  • center_label (default: ""): the text in the center of the cricle

  • labels (default: nothing): labels for the plot_topoplot

  • kwargs...: additional styling behavior, see below.

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = (aspect = Makie.DataAspect(), label = "") - use kwargs... of Makie.Axis

layout = (showlegend = false, legendposition = :right, xlabelFromMapping = nothing, ylabelFromMapping = nothing, use_colorbar = true, hidespines = (), hidedecorations = ())

mapping = (x = (nothing,), y = (:estimate, :yhat, :y), positions = (:pos, :positions, :position, nothing), labels = (:labels, :label, :sensor, nothing))

visual = (colormap = Makie.Reverse{Symbol}(:RdBu), contours = (color = :white, linewidth = 2), labelscatter = true, labeltext = true, boundinggeometry = GeometryBasics.Circle) - *use kwargs... of [``Topoplot.eegtopoplot``](@ref)*

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

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

Return Value:

A figure containing the circular topoplot at given layout position

source
UnfoldMakie.plot_designmatrixMethod
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 or GridPosition (e.g. f[2, 3]) in which the plot will be placed into. A new axis is created.
  • data::Unfold.DesignMatrix: data for the plot visualization.

kwargs

  • standardize_data (bool,true): indicates whether the data is standardized by pointwise division of the data with its sampled standard deviation.
  • sort_data (bool, true): indicates whether the data is sorted; using sortslices() of Base Julia.
  • xticks (nothing): returns the number of labels on the x-axis. Behavior is set in the configuration:
    • xticks = 0: no labels are placed.
    • xticks = 1: first possible label is placed.
    • xticks = 2: first and last possible labels are placed.
    • 2 < xticks < number of labels: equally distribute the labels.
    • xticksnumber of labels: all labels are placed.

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = (xticklabelrotation = 0.39269908169872414,) - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = nothing, ylabelFromMapping = nothing, use_colorbar = true)

mapping = (x = (:time,), y = (:estimate, :yhat, :y))

visual = (colormap = :roma,) - use kwargs... of $Makie.heatmap$

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

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of Makie.Colorbar

Return Value:

A figure displaying the designmatrix.

source
UnfoldMakie.plot_erpMethod
plot_erp!(f::Union{GridPosition, GridLayout, Figure}, plot_data::DataFrame; kwargs...)
-plot_erp(plot_data::DataFrame; kwargs...)

Plot an ERP plot.

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure, GridLayout or GridPosition that the plot should be drawn into.
  • plot_data::DataFrame: Data for the line plot visualization.
  • kwargs...: Additional styling behavior. Often used: plot_erp(df; mapping=(; color=:coefname, col=:conditionA)).

kwargs (...; ...):

  • categorical_color (bool, true): in case of numeric :color column, treat :color as continuous or categorical variable.
  • categorical_group (bool, true): in case of numeric :group column, treat :group as categorical variable by default.
  • topolegend (bool, false): add an inlay topoplot with corresponding electrodes.
  • stderror (bool, false): add an error ribbon, with lower and upper limits based on the :stderror column.
  • pvalue (Array, []): show a pvalue.
    • example: DataFrame(from=[0.1, 0.3], to=[0.5, 0.7], coefname=["(Intercept)", "condition:face"]) - if coefname is not specified, the lines will be black

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = :x, ylabelFromMapping = :y, use_colorbar = false, hidespines = (:r, :t))

mapping = (x = (:time,), y = (:estimate, :yhat, :y), color = (:color, :coefname, nothing))

visual = (colormap = :roma,) - use kwargs... of $Makie.lines$

legend = (orientation = :vertical, tellwidth = true, tellheight = false, framevisible = false) - use kwargs... of Makie.Legend

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of AlgebraOfGraphics.colobar!

Return Value:

  • f - Figure() or the inputed f
source
UnfoldMakie.plot_newMethod
plot_new() -> String
-

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = :x, ylabelFromMapping = :y, use_colorbar = false, hidespines = (:r, :t))

mapping = (x = (:time,), y = (:estimate, :yhat, :y), color = (:color, :coefname, nothing))

visual = (colormap = :roma,) - use kwargs... of $Makie.lines$

legend = (orientation = :vertical, tellwidth = true, tellheight = false, framevisible = false) - use kwargs... of Makie.Legend

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of AlgebraOfGraphics.colobar!

source
UnfoldMakie.plot_parallelcoordinatesMethod
plot_parallelcoordinates!(f::Union{GridPosition, GridLayout, Figure}, 
-    data::DataFrame, config::PlotConfig; channels::Vector{Int64})

Plot a PCP (parallel coordinates plot).

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure or GridPosition that the plot should be drawn into.
  • data::DataFrame: data for the plot visualization.
  • config::PlotConfig: instance of PlotConfig being applied to the visualization.
  • channels::Vector{Int64}: vector with all the channels representing an axis used in the PCP in given order.

PCP has problems with size changes of the view window. By adapting the padding, aspect ratio and tick label size in px for a new use case, the PCP can even be added into a complex figures.

  • pc_aspect_ratio (default: 0.55) -
  • pc_right_padding (default: 15) -
  • pc_left_padding (default: 25) -
  • pc_top_padding (default: 26) -
  • pc_bottom_padding (default: 16) -
  • pc_tick_label_size (default: 14) -

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = :channel, ylabelFromMapping = :y, use_colorbar = false, hidespines = (), hidedecorations = (label = false,))

mapping = (x = (:time,), y = (:estimate, :yhat, :y), channel = :channel, category = :category, time = :time)

visual = (colormap = :roma,) - use kwargs... of $Makie.lines$

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

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of Makie.Colorbar

Return Value:

The input f

source
UnfoldMakie.plot_topoplotMethod
plot_topoplot!(f::Union{GridPosition, GridLayout, Figure}, data, ; positions=nothing, labels=nothing,kwargs...)
-plot_topoplot(data,; positions=nothing, labels=nothing, kwargs...)

Plot a topo plot.

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure or GridPosition (e.g. f[2, 3]) that the plot should be drawn into. New axis is created.
  • data::Union{DataFrame, Vector{Float32}}: data for the plot visualization.
  • positions::Vector{Point{2, Float32}}=nothing: positions used if data is not a DataFrame. If this is the case and positions=nothing then positions are generated from labels.
  • labels::Vector{String} = nothing: labels used if data is not a DataFrame.

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = (aspect = Makie.DataAspect(),) - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = nothing, ylabelFromMapping = nothing, use_colorbar = true, hidespines = (), hidedecorations = ())

mapping = (x = (nothing,), y = (:estimate, :yhat, :y), positions = (:pos, :positions, :position, nothing), labels = (:labels, :label, :sensor, nothing))

visual = (colormap = Makie.Reverse{Symbol}(:RdBu), contours = (color = :white, linewidth = 2), labelscatter = true, labeltext = true, boundinggeometry = GeometryBasics.Circle) - *use kwargs... of [``Topoplot.eegtopoplot``](@ref)*

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

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of Makie.Colorbar

Return Value:

A figure displaying the topo plot.

source
UnfoldMakie.plot_topoplotseriesMethod
plot_topoplotseries!(f::Union{GridPosition, GridLayout, Figure}, data::DataFrame, Δbin::Real; kwargs...)
-plot_topoplotseries!(data::DataFrame, Δbin::Real; kwargs...)

Multiple miniature topoplots in regular distances

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure or GridPosition that the plot should be drawn into.
  • data::DataFrame: DataFrame with data, needs a time column.
  • Δbin::Real: A number for how large one time bin should be. Δbin is in units of the data.time column.
  • combinefun (default: mean) - can be used to specify how the samples within Δbin are combined.
  • rasterize_heatmaps (default: true) - enforce rasterization of the plot heatmap when saving in svg format. This has the benefit that all lines/points are vectors, except the interpolated heatmap. This is typically what you want, otherwise you get ~500x500 vectors per topoplot, which makes everything super slow.
  • col_labels, row_labels - shows column and row labels.
  • labels (default: nothing) - .
  • positions (default: nothing) - .

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = (aspect = Makie.DataAspect(),) - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = nothing, ylabelFromMapping = nothing, use_colorbar = true, hidespines = (), hidedecorations = ())

mapping = (x = (nothing,), y = (:estimate, :yhat, :y), positions = (:pos, :positions, :position, nothing), labels = (:labels, :label, :sensor, nothing), col = (:time,), row = (nothing,))

visual = (colormap = Makie.Reverse{Symbol}(:RdBu), contours = (color = :white, linewidth = 2), labelscatter = true, labeltext = false, boundinggeometry = GeometryBasics.Circle) - *use kwargs... of [``Topoplot.eegtopoplot``](@ref)*

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

colorbar = (vertical = true, tellwidth = true, tellheight = false, height = 300, flipaxis = true, labelrotation = 4.7, label = "Voltage [µV]") - use kwargs... of Makie.Colorbar

Return Value:

The input f

source
UnfoldMakie.to_positionsMethod

topositions(x,y,z;sphere=[0,0,0.]) topositions(pos::AbstractMatrix;sphere=[0,0,0.]) Projects 3D electrode positions to a 2D layout.

The matrix case, assumes size(pos) = (3,nChannels) Re-implementation of the MNE algorithm.

Tipp: You can directly get positions from an MNE object after loading PyMNE and thus activating the UnfoldMakie PyMNE extension

source

Internally, we use a PlotConfig struct to keep track of common plot options, in order to have a similar API to all functions

UnfoldMakie.PlotConfigType
PlotConfig(<plotname>)
-holds various different fields, that can modify various different plotting aspects.
source
+julia > eeg_topoplot_series(df, 5; positions=pos)
source
UnfoldMakie.plot_butterflyMethod

Plot a butterfly plot

kwargs (...; ...):

  • butterfly (bool, true): create a butterfly plot.
  • topolegend (bool, true): show an inlay topoplot with corresponding electrodes.
  • topomarkersize (Real, 10): change the size of the markers, topoplot-inlay electrodes.
  • topowidth (Real, 0.25): change the size of the inlay topoplot width.
  • topoheigth (Real, 0.25): change the size of the inlay topoplot height.
  • topopositions_to_color (function, ´x -> posToColorRomaO(x)´).

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (showlegend = false, legendposition = :right, xlabelFromMapping = :x, ylabelFromMapping = :y, use_colorbar = false, hidespines = (:r, :t))

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))

visual = (colormap = :roma,) - use kwargs... of $Makie.lines$

legend = (orientation = :vertical, tellwidth = true, tellheight = false, framevisible = false) - use kwargs... of Makie.Legend

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of AlgebraOfGraphics.colobar!

see also plot_erp

source
UnfoldMakie.plot_circulareegtopoplotMethod
plot_circulareegtopoplot(data::DataFrame; kwargs...)
+plot_circulareegtopoplot!(f, data::DataFrame; kwargs...)

Plot a circular EEG topoplot.

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure, GridLayout or GridPosition that the plot should be drawn into

  • data::DataFrame: DataFrame with keys for data (looks for :y, :yhat, :estimate), and :position (looks for :pos, :position, :positions),

  • predictor (optional; default: predictor): the circular predictor value, defines position of topoplot, is mapped around predictor_bounds

  • predictor_bounds (default: [0,360]): the bounds of the predictor. This is relevant for the axis labels.

  • positions (default: nothing): positions for the plot_topoplot

  • center_label (default: ""): the text in the center of the cricle

  • labels (default: nothing): labels for the plot_topoplot

  • kwargs...: additional styling behavior, see below.

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = (aspect = Makie.DataAspect(), label = "") - use kwargs... of Makie.Axis

layout = (showlegend = false, legendposition = :right, xlabelFromMapping = nothing, ylabelFromMapping = nothing, use_colorbar = true, hidespines = (), hidedecorations = ())

mapping = (x = (nothing,), y = (:estimate, :yhat, :y), positions = (:pos, :positions, :position, nothing), labels = (:labels, :label, :sensor, nothing))

visual = (colormap = Makie.Reverse{Symbol}(:RdBu), contours = (color = :white, linewidth = 2), labelscatter = true, labeltext = true, boundinggeometry = GeometryBasics.Circle) - *use kwargs... of [``Topoplot.eegtopoplot``](@ref)*

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

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

Return Value:

A figure containing the circular topoplot at given layout position

source
UnfoldMakie.plot_designmatrixMethod
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 or GridPosition (e.g. f[2, 3]) in which the plot will be placed into. A new axis is created.
  • data::Unfold.DesignMatrix: data for the plot visualization.

kwargs

  • standardize_data (bool,true): indicates whether the data is standardized by pointwise division of the data with its sampled standard deviation.
  • sort_data (bool, true): indicates whether the data is sorted; using sortslices() of Base Julia.
  • xticks (nothing): returns the number of labels on the x-axis. Behavior is set in the configuration:
    • xticks = 0: no labels are placed.
    • xticks = 1: first possible label is placed.
    • xticks = 2: first and last possible labels are placed.
    • 2 < xticks < number of labels: equally distribute the labels.
    • xticksnumber of labels: all labels are placed.

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = (xticklabelrotation = 0.39269908169872414,) - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = nothing, ylabelFromMapping = nothing, use_colorbar = true)

mapping = (x = (:time,), y = (:estimate, :yhat, :y))

visual = (colormap = :roma,) - use kwargs... of $Makie.heatmap$

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

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of Makie.Colorbar

Return Value:

A figure displaying the designmatrix.

source
UnfoldMakie.plot_erpMethod
plot_erp!(f::Union{GridPosition, GridLayout, Figure}, plot_data::DataFrame; kwargs...)
+plot_erp(plot_data::DataFrame; kwargs...)

Plot an ERP plot.

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure, GridLayout or GridPosition that the plot should be drawn into.
  • plot_data::DataFrame: Data for the line plot visualization.
  • kwargs...: Additional styling behavior. Often used: plot_erp(df; mapping=(; color=:coefname, col=:conditionA)).

kwargs (...; ...):

  • categorical_color (bool, true): in case of numeric :color column, treat :color as continuous or categorical variable.
  • categorical_group (bool, true): in case of numeric :group column, treat :group as categorical variable by default.
  • topolegend (bool, false): add an inlay topoplot with corresponding electrodes.
  • stderror (bool, false): add an error ribbon, with lower and upper limits based on the :stderror column.
  • pvalue (Array, []): show a pvalue.
    • example: DataFrame(from=[0.1, 0.3], to=[0.5, 0.7], coefname=["(Intercept)", "condition:face"]) - if coefname is not specified, the lines will be black

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = :x, ylabelFromMapping = :y, use_colorbar = false, hidespines = (:r, :t))

mapping = (x = (:time,), y = (:estimate, :yhat, :y), color = (:color, :coefname, nothing))

visual = (colormap = :roma,) - use kwargs... of $Makie.lines$

legend = (orientation = :vertical, tellwidth = true, tellheight = false, framevisible = false) - use kwargs... of Makie.Legend

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of AlgebraOfGraphics.colobar!

Return Value:

  • f - Figure() or the inputed f
source
UnfoldMakie.plot_newMethod
plot_new() -> String
+

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = :x, ylabelFromMapping = :y, use_colorbar = false, hidespines = (:r, :t))

mapping = (x = (:time,), y = (:estimate, :yhat, :y), color = (:color, :coefname, nothing))

visual = (colormap = :roma,) - use kwargs... of $Makie.lines$

legend = (orientation = :vertical, tellwidth = true, tellheight = false, framevisible = false) - use kwargs... of Makie.Legend

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of AlgebraOfGraphics.colobar!

source
UnfoldMakie.plot_parallelcoordinatesMethod
plot_parallelcoordinates!(f::Union{GridPosition, GridLayout, Figure}, 
+    data::DataFrame, config::PlotConfig; channels::Vector{Int64})

Plot a PCP (parallel coordinates plot).

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure or GridPosition that the plot should be drawn into.
  • data::DataFrame: data for the plot visualization.
  • config::PlotConfig: instance of PlotConfig being applied to the visualization.
  • channels::Vector{Int64}: vector with all the channels representing an axis used in the PCP in given order.

PCP has problems with size changes of the view window. By adapting the padding, aspect ratio and tick label size in px for a new use case, the PCP can even be added into a complex figures.

  • pc_aspect_ratio (default: 0.55) -
  • pc_right_padding (default: 15) -
  • pc_left_padding (default: 25) -
  • pc_top_padding (default: 26) -
  • pc_bottom_padding (default: 16) -
  • pc_tick_label_size (default: 14) -

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = NamedTuple() - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = :channel, ylabelFromMapping = :y, use_colorbar = false, hidespines = (), hidedecorations = (label = false,))

mapping = (x = (:time,), y = (:estimate, :yhat, :y), channel = :channel, category = :category, time = :time)

visual = (colormap = :roma,) - use kwargs... of $Makie.lines$

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

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of Makie.Colorbar

Return Value:

The input f

source
UnfoldMakie.plot_topoplotMethod
plot_topoplot!(f::Union{GridPosition, GridLayout, Figure}, data, ; positions=nothing, labels=nothing,kwargs...)
+plot_topoplot(data,; positions=nothing, labels=nothing, kwargs...)

Plot a topo plot.

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure or GridPosition (e.g. f[2, 3]) that the plot should be drawn into. New axis is created.
  • data::Union{DataFrame, Vector{Float32}}: data for the plot visualization.
  • positions::Vector{Point{2, Float32}}=nothing: positions used if data is not a DataFrame. If this is the case and positions=nothing then positions are generated from labels.
  • labels::Vector{String} = nothing: labels used if data is not a DataFrame.

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = (aspect = Makie.DataAspect(),) - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = nothing, ylabelFromMapping = nothing, use_colorbar = true, hidespines = (), hidedecorations = ())

mapping = (x = (nothing,), y = (:estimate, :yhat, :y), positions = (:pos, :positions, :position, nothing), labels = (:labels, :label, :sensor, nothing))

visual = (colormap = Makie.Reverse{Symbol}(:RdBu), contours = (color = :white, linewidth = 2), labelscatter = true, labeltext = true, boundinggeometry = GeometryBasics.Circle) - *use kwargs... of [``Topoplot.eegtopoplot``](@ref)*

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

colorbar = (vertical = true, tellwidth = true, tellheight = false) - use kwargs... of Makie.Colorbar

Return Value:

A figure displaying the topo plot.

source
UnfoldMakie.plot_topoplotseriesMethod
plot_topoplotseries!(f::Union{GridPosition, GridLayout, Figure}, data::DataFrame, Δbin::Real; kwargs...)
+plot_topoplotseries!(data::DataFrame, Δbin::Real; kwargs...)

Multiple miniature topoplots in regular distances

Arguments:

  • f::Union{GridPosition, GridLayout, Figure}: Figure or GridPosition that the plot should be drawn into.
  • data::DataFrame: DataFrame with data, needs a time column.
  • Δbin::Real: A number for how large one time bin should be. Δbin is in units of the data.time column.
  • combinefun (default: mean) - can be used to specify how the samples within Δbin are combined.
  • rasterize_heatmaps (default: true) - enforce rasterization of the plot heatmap when saving in svg format. This has the benefit that all lines/points are vectors, except the interpolated heatmap. This is typically what you want, otherwise you get ~500x500 vectors per topoplot, which makes everything super slow.
  • col_labels, row_labels - shows column and row labels.
  • labels (default: nothing) - .
  • positions (default: nothing) - .

Shared plot configuration options

The shared plot options can be used as follows: type=(; key=value,...)) - for example plot_x(..., layout=(show_legend=true, legend_position=:right)). Multiple defaults will be cycled until match.

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

axis = (aspect = Makie.DataAspect(),) - use kwargs... of Makie.Axis

layout = (showlegend = true, legendposition = :right, xlabelFromMapping = nothing, ylabelFromMapping = nothing, use_colorbar = true, hidespines = (), hidedecorations = ())

mapping = (x = (nothing,), y = (:estimate, :yhat, :y), positions = (:pos, :positions, :position, nothing), labels = (:labels, :label, :sensor, nothing), col = (:time,), row = (nothing,))

visual = (colormap = Makie.Reverse{Symbol}(:RdBu), contours = (color = :white, linewidth = 2), labelscatter = true, labeltext = false, boundinggeometry = GeometryBasics.Circle) - *use kwargs... of [``Topoplot.eegtopoplot``](@ref)*

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

colorbar = (vertical = true, tellwidth = true, tellheight = false, height = 300, flipaxis = true, labelrotation = 4.7, label = "Voltage [µV]") - use kwargs... of Makie.Colorbar

Return Value:

The input f

source
UnfoldMakie.to_positionsMethod

topositions(x,y,z;sphere=[0,0,0.]) topositions(pos::AbstractMatrix;sphere=[0,0,0.]) Projects 3D electrode positions to a 2D layout.

The matrix case, assumes size(pos) = (3,nChannels) Re-implementation of the MNE algorithm.

Tipp: You can directly get positions from an MNE object after loading PyMNE and thus activating the UnfoldMakie PyMNE extension

source

Internally, we use a PlotConfig struct to keep track of common plot options, in order to have a similar API to all functions

UnfoldMakie.PlotConfigType
PlotConfig(<plotname>)
+holds various different fields, that can modify various different plotting aspects.
source
diff --git a/dev/helper/index.html b/dev/helper/index.html index 82935458d..b38b05240 100644 --- a/dev/helper/index.html +++ b/dev/helper/index.html @@ -1,5 +1,5 @@ -Utilities · UnfoldMakie.jl
UnfoldMakie.RelativeAxisType

ax = RelativeAxis(figlike, p::NTuple{4, Float64}; kwargs...)

Returns an axis which's position is relative to a GridLayout Element (via BBox) and not relative to the Scene (default Axis(..., bbox=BBox()) behavior)

p::NTuple{4,Float64}: Give the relative position to the GridPosition, left:right; bottom:up, typical numbers betwen 0 and 1. E.g. (0.25, 0.75, 0.25, 0.75) would center an Axis inside that GridPosition

kwargs... are pasted into Axis

f = Figure() ax = RelativeAxis(f[1,2], (0.25, 0.75, 0.25, 0.75)) # returns Axis centered within f[1,2]

source
UnfoldMakie.eeg_topoplot_seriesFunction

function eegtopoplotseries(data::DataFrame, Δbin; y=:estimate, label=:label, col=:time, row=nothing, figure = NamedTuple(), combinefun=mean, rowlabels = false, collabels = false, topoplot_attributes... )

Plot a series of topoplots. The function automatically takes the combinefun=mean over the :time column of data in Δbin steps.

  • The data frame data needs the columns :time and y(=:erp), and label(=:label). If data is a matrix, it is automatically cast to a dataframe, time bins are in samples, labels are string.(1:size(data,1)).
  • Δbin in :time units, specifying the time steps. All other keyword arguments are passed to the EEG_TopoPlot recipe. In most cases, the user should specify the electrode positions with positions=pos.
  • The col and row arguments specify the field to be divided into columns and rows. The default is col=:time to split by the time field and row=nothing. Useful

to split by a condition, e.g. ...(..., col=:time, row=:condition) would result in multiple (as many as different values in df.condition) rows of topoplot series.

  • The figure option allows you to include information for plotting the figure. Alternatively, you can pass a fig object eeg_topoplot_series!(fig, data::DataFrame, Δbin; kwargs..).
  • row_labels and col_labels indicate whether there should be labels in the plots in the first column to indicate the row value and in the last row to indicate the time (typically timerange).

Examples

Desc

julia > df = DataFrame(:erp => repeat(1:63, 100), :time => repeat(1:20, 5 * 63), :label => repeat(1:63, 100)) # fake data
+Utilities · UnfoldMakie.jl
UnfoldMakie.RelativeAxisType

ax = RelativeAxis(figlike, p::NTuple{4, Float64}; kwargs...)

Returns an axis which's position is relative to a GridLayout Element (via BBox) and not relative to the Scene (default Axis(..., bbox=BBox()) behavior)

p::NTuple{4,Float64}: Give the relative position to the GridPosition, left:right; bottom:up, typical numbers betwen 0 and 1. E.g. (0.25, 0.75, 0.25, 0.75) would center an Axis inside that GridPosition

kwargs... are pasted into Axis

f = Figure() ax = RelativeAxis(f[1,2], (0.25, 0.75, 0.25, 0.75)) # returns Axis centered within f[1,2]

source
UnfoldMakie.eeg_topoplot_seriesFunction

function eegtopoplotseries(data::DataFrame, Δbin; y=:estimate, label=:label, col=:time, row=nothing, figure = NamedTuple(), combinefun=mean, rowlabels = false, collabels = false, topoplot_attributes... )

Plot a series of topoplots. The function automatically takes the combinefun=mean over the :time column of data in Δbin steps.

  • The data frame data needs the columns :time and y(=:erp), and label(=:label). If data is a matrix, it is automatically cast to a dataframe, time bins are in samples, labels are string.(1:size(data,1)).
  • Δbin in :time units, specifying the time steps. All other keyword arguments are passed to the EEG_TopoPlot recipe. In most cases, the user should specify the electrode positions with positions=pos.
  • The col and row arguments specify the field to be divided into columns and rows. The default is col=:time to split by the time field and row=nothing. Useful

to split by a condition, e.g. ...(..., col=:time, row=:condition) would result in multiple (as many as different values in df.condition) rows of topoplot series.

  • The figure option allows you to include information for plotting the figure. Alternatively, you can pass a fig object eeg_topoplot_series!(fig, data::DataFrame, Δbin; kwargs..).
  • row_labels and col_labels indicate whether there should be labels in the plots in the first column to indicate the row value and in the last row to indicate the time (typically timerange).

Examples

Desc

julia > df = DataFrame(:erp => repeat(1:63, 100), :time => repeat(1:20, 5 * 63), :label => repeat(1:63, 100)) # fake data
 julia > pos = [(1:63) ./ 63 .* (sin.(range(-2 * pi, 2 * pi, 63))) (1:63) ./ 63 .* cos.(range(-2 * pi, 2 * pi, 63))] .* 0.5 .+ 0.5 # fake electrode positions
 julia > pos = [Point2.(pos[k, 1], pos[k, 2]) for k in 1:size(pos, 1)]
-julia > eeg_topoplot_series(df, 5; positions=pos)
source
UnfoldMakie.to_positionsFunction

topositions(x,y,z;sphere=[0,0,0.]) topositions(pos::AbstractMatrix;sphere=[0,0,0.]) Projects 3D electrode positions to a 2D layout.

The matrix case, assumes size(pos) = (3,nChannels) Re-implementation of the MNE algorithm.

Tipp: You can directly get positions from an MNE object after loading PyMNE and thus activating the UnfoldMakie PyMNE extension

source
UnfoldMakie.df_timebinFunction

function dftimebin(df, Δbin; coly=:erp, fun=mean, grouping=[]) Split or combine dataframe according to equally spaced time bins

  • df AbstractTable with columns :time and col_y (default :erp), and all columns in grouping;
  • Δbin bin size in :time units;
  • col_y default :erp, the column to combine over (with fun);
  • fun function to combine, default is mean;
  • grouping (vector of symbols/strings) default empty vector, columns to group the data by before aggregating. Values of nothing are ignored.
source
+julia > eeg_topoplot_series(df, 5; positions=pos)
source
UnfoldMakie.to_positionsFunction

topositions(x,y,z;sphere=[0,0,0.]) topositions(pos::AbstractMatrix;sphere=[0,0,0.]) Projects 3D electrode positions to a 2D layout.

The matrix case, assumes size(pos) = (3,nChannels) Re-implementation of the MNE algorithm.

Tipp: You can directly get positions from an MNE object after loading PyMNE and thus activating the UnfoldMakie PyMNE extension

source
UnfoldMakie.df_timebinFunction

function dftimebin(df, Δbin; coly=:erp, fun=mean, grouping=[]) Split or combine dataframe according to equally spaced time bins

  • df AbstractTable with columns :time and col_y (default :erp), and all columns in grouping;
  • Δbin bin size in :time units;
  • col_y default :erp, the column to combine over (with fun);
  • fun function to combine, default is mean;
  • grouping (vector of symbols/strings) default empty vector, columns to group the data by before aggregating. Values of nothing are ignored.
source