From c6e81799a94ea0b8186476407334c787a4376d90 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Mon, 20 Nov 2023 17:00:25 +0000 Subject: [PATCH] build based on e47e957 --- dev/.documenter-siteinfo.json | 2 +- dev/api/index.html | 20 ++++++++++---------- dev/generated/reference/positions/index.html | 2 +- dev/generated/tutorials/circTopo/index.html | 2 +- dev/generated/tutorials/erp/index.html | 2 +- dev/helper/index.html | 4 ++-- dev/how_to/fix_pcp/index.html | 2 +- dev/how_to/hide_deco/index.html | 2 +- dev/how_to/mult_vis_in_fig/index.html | 2 +- dev/how_to/position2color/index.html | 2 +- dev/how_to/show_oob_labels/index.html | 2 +- dev/index.html | 2 +- dev/tutorials/butterfly/index.html | 2 +- dev/tutorials/designmatrix/index.html | 2 +- dev/tutorials/erpimage/index.html | 2 +- dev/tutorials/installation/index.html | 2 +- dev/tutorials/parallelcoordinates/index.html | 2 +- dev/tutorials/topoplot/index.html | 2 +- dev/tutorials/topoplotseries/index.html | 2 +- 19 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 67e5fd0e8..1aff295f4 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-11-20T16:51:23","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-11-20T17:00:21","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index bb88529b0..f1642bc2a 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/generated/reference/positions/index.html b/dev/generated/reference/positions/index.html index b573bd643..12b401c7d 100644 --- a/dev/generated/reference/positions/index.html +++ b/dev/generated/reference/positions/index.html @@ -39,4 +39,4 @@ f = Figure(resolution=(600,300)) scatter(f[1,1],pos3d[1:2,:]) scatter(f[1,2],pos2) -fExample block output

as one can see, the "naive" transform of just dropping the third dimension doesnt really work (left). We rather have to project the chanels to a sphere and unfold it (right)


This page was generated using Literate.jl.

+fExample block output

as one can see, the "naive" transform of just dropping the third dimension doesnt really work (left). We rather have to project the chanels to a sphere and unfold it (right)


This page was generated using Literate.jl.

diff --git a/dev/generated/tutorials/circTopo/index.html b/dev/generated/tutorials/circTopo/index.html index ed5173135..61ac94083 100644 --- a/dev/generated/tutorials/circTopo/index.html +++ b/dev/generated/tutorials/circTopo/index.html @@ -21,4 +21,4 @@ axis = (; label = "Time?!"), predictor = :time, predictor_bounds = [80, 320], -)Example block output

This page was generated using Literate.jl.

+)Example block output

This page was generated using Literate.jl.

diff --git a/dev/generated/tutorials/erp/index.html b/dev/generated/tutorials/erp/index.html index 0aeb43def..22ea6f9fc 100644 --- a/dev/generated/tutorials/erp/index.html +++ b/dev/generated/tutorials/erp/index.html @@ -30,4 +30,4 @@ # coefname=["(Intercept)", "condition: face"] # if coefname not specified, line should be black # )

plot_erp(results; :pvalue=>pvals)

stderror (boolean)

Indicating whether the plot should show a colored band showing lower and higher estimates based on the stderror. Default is false.

previously we showed :stderror- but low/high is possible as well`

results.se_low = results.estimate .- 0.5
 results.se_high = results.estimate .+ 0.15
-plot_erp(select(results, Not(:stderror)); stderror = true)
Example block output
Note

as in the above code,:stderror has precedence over :se_low/:se_high


This page was generated using Literate.jl.

+plot_erp(select(results, Not(:stderror)); stderror = true)Example block output
Note

as in the above code,:stderror has precedence over :se_low/:se_high


This page was generated using Literate.jl.

diff --git a/dev/helper/index.html b/dev/helper/index.html index b0160bfdc..11f98b421 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
diff --git a/dev/how_to/fix_pcp/index.html b/dev/how_to/fix_pcp/index.html index f9a21362d..0094e0ab0 100644 --- a/dev/how_to/fix_pcp/index.html +++ b/dev/how_to/fix_pcp/index.html @@ -8,4 +8,4 @@ pc_bottom_padding = 27, ...

Furthermore, if the tick-number size becomes too big or small it can be changed with:

...
 pc_tick_label_size = 25,
-...

By setting these manually through trial and error we can fix the visualization issues

+...

By setting these manually through trial and error we can fix the visualization issues

diff --git a/dev/how_to/hide_deco/index.html b/dev/how_to/hide_deco/index.html index 0eeef7597..6ece15127 100644 --- a/dev/how_to/hide_deco/index.html +++ b/dev/how_to/hide_deco/index.html @@ -13,4 +13,4 @@ layout=(; hidespines = nothing, hidedecorations = nothing - ),)Example block output + ),)Example block output diff --git a/dev/how_to/mult_vis_in_fig/index.html b/dev/how_to/mult_vis_in_fig/index.html index d24525349..09f270eb1 100644 --- a/dev/how_to/mult_vis_in_fig/index.html +++ b/dev/how_to/mult_vis_in_fig/index.html @@ -56,4 +56,4 @@ plot_circulareegtopoplot!(f[3:4, 4:5], d_topo[in.(d_topo.time, Ref(-0.3:0.1:0.5)), :]; positions=positions, predictor=:time, predictor_bounds=[-0.3, 0.5]) -fExample block output +fExample block output diff --git a/dev/how_to/position2color/index.html b/dev/how_to/position2color/index.html index 2fcf81843..575536963 100644 --- a/dev/how_to/position2color/index.html +++ b/dev/how_to/position2color/index.html @@ -7,4 +7,4 @@ plot_butterfly(results; positions=positions)Example block output

We can switch the colorscale of the position-map, by giving a function that maps from a (x,y) tuple to a color. UnfoldMakie currently provides three different ones pos2colorRGB (same as MNE-Python), pos2colorHSV (HSV colorspace), pos2colorRomaO. Whereas RGB & HSV have the benefits of being 2D colormaps, Roma0 has the benefit of being perceptualy uniform.

Similar to MNE

plot_butterfly(results;
     positions=positions,
     topopositions_to_color = pos -> UnfoldMakie.posToColorRGB(pos)
-)
Example block output

HSV-Space

plot_butterfly(results; positions=positions, topopositions_to_color=UnfoldMakie.posToColorHSV)
Example block output

Uniform Color

To highlight the flexibility, we can also make all lines gray, or any other arbitrary color, or function of electrode-position.

plot_butterfly(results; positions=positions, topopositions_to_color = x -> Colors.RGB(0.5))
Example block output +)Example block output

HSV-Space

plot_butterfly(results; positions=positions, topopositions_to_color=UnfoldMakie.posToColorHSV)
Example block output

Uniform Color

To highlight the flexibility, we can also make all lines gray, or any other arbitrary color, or function of electrode-position.

plot_butterfly(results; positions=positions, topopositions_to_color = x -> Colors.RGB(0.5))
Example block output diff --git a/dev/how_to/show_oob_labels/index.html b/dev/how_to/show_oob_labels/index.html index d104f9310..b54503c84 100644 --- a/dev/how_to/show_oob_labels/index.html +++ b/dev/how_to/show_oob_labels/index.html @@ -2,4 +2,4 @@ Show out of Bounds Label · UnfoldMakie.jl

Show out of Bounds Label

When visualizing a design matrix, it can happen that the labels on the y-axis get cut off to the left (especially if they are quite long). In the following, we will discuss a possible quick solution to this problem.

We start with the "label-limited" time-expanded designmatrix from the corresponding Tutorial section, which describes in detail how to generate it.

plot_designmatrix(designmatrix!(ufCont,evts), cDesign; xTicks=10, sortData=false)

While the plot automatically sets its height according to the labels, the labels are cut off on the left side.

A quick fix would be to place an empty plot to the left of the designmatrix.

By creating your own figure with Makie.Figure and then giving the designmatrix only a certain grid position, we get white space next to the plot.

The plot! function inside the plot config instance can take any grid position, and the figure f will contain the plot and enough white space next to it.

The exact numbers in the grid position can be guessed from the overlap ratio, or just tried.

f = Figure()
 plot_design(f[1,2:6], designmatrix!(ufCont, evts), cDesign; setExtraValues=(xTicks=10, sortData=false))
 
-f
+f diff --git a/dev/index.html b/dev/index.html index b22af45b9..c444a3490 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -UnfoldMakie Documentation · UnfoldMakie.jl

UnfoldMakie Documentation

This is the documentation of the UnfoldMakie module for the Julia programming language.

About

UnfoldMakie aims to allow users to create different types of visualizations. These include line plots, butterfly plots, design matrices, parallel coordinate plots, ERP images, and topo plots. Building on the Unfold and Makie Modules, it also allows users to customize the plots through an input configuration.

As can be seen from the types of visualizations possible, these configuration options try to enable the user to create plots that are helpful in the field of computational EEG. One such example is the ability to use a topo plot as a legend for a line plot by allowing multiple visualizations within a figure.

Coordinated Multiple Views

+UnfoldMakie Documentation · UnfoldMakie.jl

UnfoldMakie Documentation

This is the documentation of the UnfoldMakie module for the Julia programming language.

About

UnfoldMakie aims to allow users to create different types of visualizations. These include line plots, butterfly plots, design matrices, parallel coordinate plots, ERP images, and topo plots. Building on the Unfold and Makie Modules, it also allows users to customize the plots through an input configuration.

As can be seen from the types of visualizations possible, these configuration options try to enable the user to create plots that are helpful in the field of computational EEG. One such example is the ability to use a topo plot as a legend for a line plot by allowing multiple visualizations within a figure.

Coordinated Multiple Views

diff --git a/dev/tutorials/butterfly/index.html b/dev/tutorials/butterfly/index.html index 532c8c5a8..c32e96790 100644 --- a/dev/tutorials/butterfly/index.html +++ b/dev/tutorials/butterfly/index.html @@ -4,4 +4,4 @@ using CairoMakie using DataFrames

Note that DataFramesMeta is also used here in order to be able to use @subset for testing (filtering).

Data

We filter the data to make it more clearly represented:

include("../../example_data.jl")
 df, pos = example_data("TopoPlots.jl")
-first(df, 3)
3×7 DataFrame
Rowestimatetimechannelcoefnametopo_positionssepval
Float64Float64Int64StringAnyFloat64Float64
10.020321-0.31A(0.493714, 0.544031)0.1228750.266091
20.017548-0.2981A(0.493714, 0.544031)0.1243450.29664
30.0150747-0.2961A(0.493714, 0.544031)0.1248280.323592

Plot Butterfly Plots

The following code will plot the default butterfly plot

plot_butterfly(df)
Example block output

or if you provide the channel positions:

plot_butterfly(df; positions=pos)
Example block output

Column Mappings for Butterfly Plots

Since butterfly plots use a DataFrame as input, the library needs to know the names of the columns used for plotting. You can set these mapping values by calling plot_butterfly(...; mapping=(; :x=:time)), that is, by specifying a NamedTuple (note the ; right after the opening parentheses).

While there are several default values that will be checked in that order if they exist in the DataFrame, a custom name may need to be chosen:

x

Default is (:x, :time).

y

Default is (:y, :estimate, :yhat).

labels

Default is (:labels, :label, :topoLabels, :sensor, :nothing)

Configurations for Butterfly Plots

Here we look into possible options for configuring the butterfly plot visualization using (...; <name>=<value>, ...).

key values

Since the configurations for ERP plots can be applied to butterfly plots as well. Here you can find the configurations for ERP plots.

+first(df, 3)
3×7 DataFrame
Rowestimatetimechannelcoefnametopo_positionssepval
Float64Float64Int64StringAnyFloat64Float64
10.020321-0.31A(0.493714, 0.544031)0.1228750.266091
20.017548-0.2981A(0.493714, 0.544031)0.1243450.29664
30.0150747-0.2961A(0.493714, 0.544031)0.1248280.323592

Plot Butterfly Plots

The following code will plot the default butterfly plot

plot_butterfly(df)
Example block output

or if you provide the channel positions:

plot_butterfly(df; positions=pos)
Example block output

Column Mappings for Butterfly Plots

Since butterfly plots use a DataFrame as input, the library needs to know the names of the columns used for plotting. You can set these mapping values by calling plot_butterfly(...; mapping=(; :x=:time)), that is, by specifying a NamedTuple (note the ; right after the opening parentheses).

While there are several default values that will be checked in that order if they exist in the DataFrame, a custom name may need to be chosen:

x

Default is (:x, :time).

y

Default is (:y, :estimate, :yhat).

labels

Default is (:labels, :label, :topoLabels, :sensor, :nothing)

Configurations for Butterfly Plots

Here we look into possible options for configuring the butterfly plot visualization using (...; <name>=<value>, ...).

key values

Since the configurations for ERP plots can be applied to butterfly plots as well. Here you can find the configurations for ERP plots.

diff --git a/dev/tutorials/designmatrix/index.html b/dev/tutorials/designmatrix/index.html index 490894ae9..33855d32f 100644 --- a/dev/tutorials/designmatrix/index.html +++ b/dev/tutorials/designmatrix/index.html @@ -16,4 +16,4 @@ coeftable(uf) (returns tidy result dataframe) -

Plot Designmatrices

The following code will result in the default configuration.

plot_designmatrix(designmatrix(uf))
Example block output

kwargs plot_designmatrix(...; ...).

To make the design matrix easier to read, you may want to sort it.

plot_designmatrix(designmatrix(uf); sortData=true)
+

Plot Designmatrices

The following code will result in the default configuration.

plot_designmatrix(designmatrix(uf))
Example block output

kwargs plot_designmatrix(...; ...).

To make the design matrix easier to read, you may want to sort it.

plot_designmatrix(designmatrix(uf); sortData=true)
diff --git a/dev/tutorials/erpimage/index.html b/dev/tutorials/erpimage/index.html index 2ee73746f..9d832f177 100644 --- a/dev/tutorials/erpimage/index.html +++ b/dev/tutorials/erpimage/index.html @@ -16,4 +16,4 @@ evts.Δlatency = diff(vcat(evts.latency, 0)) dat_e = dat_e[1,:,:] - plot_erpimage(times, dat_e; sortvalues=evts.Δlatency)Example block output + plot_erpimage(times, dat_e; sortvalues=evts.Δlatency)Example block output diff --git a/dev/tutorials/installation/index.html b/dev/tutorials/installation/index.html index 0117ede9d..73c79107d 100644 --- a/dev/tutorials/installation/index.html +++ b/dev/tutorials/installation/index.html @@ -3,4 +3,4 @@ using Pkg Pkg.activate("FOLDER_PATH") Pkg.resolve() -end

Use slash / for the folder path.

+end

Use slash / for the folder path.

diff --git a/dev/tutorials/parallelcoordinates/index.html b/dev/tutorials/parallelcoordinates/index.html index 444b07926..035c91763 100644 --- a/dev/tutorials/parallelcoordinates/index.html +++ b/dev/tutorials/parallelcoordinates/index.html @@ -24,4 +24,4 @@ 25599 │ 0.112385 0.496 64 A (0.719221, 0.888091) 0.262 25600 │ 0.109979 0.498 64 A (0.719221, 0.888091) 0.258 2 columns and 25585 rows omitted, Point{2, Float32}[[0.49371386, 0.5440313], [0.5630452, 0.50400287], [0.5630452, 0.4239459], [0.49371386, 0.38391745], [0.4243825, 0.4239459], [0.4243825, 0.50400287], [0.5378472, 0.6178857], [0.61455333, 0.56901854], [0.6522695, 0.4862579], [0.6388263, 0.39630732] … [0.93907887, 0.6439135], [0.9450873, 0.29968786], [0.8333667, 0.12432156], [0.61803544, 1.9428903f-16], [0.3693923, 2.7755576f-17], [0.15406103, 0.12432156], [0.029739477, 0.3396528], [0.04834886, 0.6439135], [0.26820713, 0.88809085], [0.7192206, 0.88809085]])

Plot PCPs

plot_parallelcoordinates(results_plot, [5,3,2]; # this selects channel 5,3 & 2
-    mapping = (color = :coefname, y = :estimate))
Example block output
Important

the following is still outdated...

Column Mappings for PCPs

Since PCPs use a DataFrame as an input, the library needs to know the names of the columns used for plotting.

While there are multiple default values that are checked in that order if they exist in the DataFrame, a custom name might need to be choosen for:

y

Default is (:y, :estimate, :yhat).

channel

Default is :channel.

color

XXX Default is :coef.

time

Default is :time.

+ mapping = (color = :coefname, y = :estimate))Example block output
Important

the following is still outdated...

Column Mappings for PCPs

Since PCPs use a DataFrame as an input, the library needs to know the names of the columns used for plotting.

While there are multiple default values that are checked in that order if they exist in the DataFrame, a custom name might need to be choosen for:

y

Default is (:y, :estimate, :yhat).

channel

Default is :channel.

color

XXX Default is :coef.

time

Default is :time.

diff --git a/dev/tutorials/topoplot/index.html b/dev/tutorials/topoplot/index.html index 45bab1e9b..82a22547a 100644 --- a/dev/tutorials/topoplot/index.html +++ b/dev/tutorials/topoplot/index.html @@ -7,4 +7,4 @@ df = DataFrame(:estimate => data[:,340,1]) plot_topoplot(df; positions = positions)Example block output

Giving the Positions

Since the topo plot needs the positions of the sensors they have to be put into the drawing function. But there are multiple options (In order of prioritization):

To get the positions from the labels we use a database.

Column Mappings for Topo Plots

When using topo plots with a DataFrame as an input, the library needs to know the names of the columns used for plotting. This is specified using the mapping=(;) kwargs.

While there are multiple default values, that are checked in that order if they exist in the DataFrame, a custom name might need to be choosen for:

Note that only one of positions or labels have to be set to draw a topo plot. If both are set, positions takes precedence, labels might be used for labelling electrodes in TopoPlots.jl

(...,mapping=(;))

:y plotting function looks in the default columns of mapping

cfgDefault = UnfoldMakie.PlotConfig()
 cfgDefault.mapping.y
(:estimate, :yhat, :y)

label_text (boolean)

Indicates whether label should drawn next to their position. Obviously the labels have to be provided: plot_topoplot(...; labels=[...])

plot_topoplot(...; visual=(; label_text=true))

label_scatter (boolean)

Indicates whether the dots should be drawn at the given positions.

plot_topoplot(...; visual=(; label_scatter=true))

data, positions = TopoPlots.example_data()
-plot_topoplot(data[1:4,340,1]; visual = (; label_scatter = false), labels=["O1", "F2", "F3", "P4"])
Example block output +plot_topoplot(data[1:4,340,1]; visual = (; label_scatter = false), labels=["O1", "F2", "F3", "P4"])Example block output diff --git a/dev/tutorials/topoplotseries/index.html b/dev/tutorials/topoplotseries/index.html index 027f8bb01..a85f0db1d 100644 --- a/dev/tutorials/topoplotseries/index.html +++ b/dev/tutorials/topoplotseries/index.html @@ -5,4 +5,4 @@ using CairoMakie using TopoPlots

Plot Topoplot Series

Example data

In case you do not already have data, you can get example data from the TopoPlots module. You can do it like this:

data, positions = TopoPlots.example_data()
 df = UnfoldMakie.eeg_matrix_to_dataframe(data[:,:,1], string.(1:length(positions)));
Δbin = 80
-plot_topoplotseries(df, Δbin; positions = positions)
Example block output

Arguments usage

Key arguments

Disabling colorbar:

plot_topoplotseries(df, Δbin; positions=positions, layout = (; use_colorbar=false))
Example block output

Positions

You can give either positions, or labels. If both are provided, positions have priority

plot_toposeries(...; mapping=(; key=value))

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

visual=(;)

label_text (boolean, false) Indicates whether label should drawn next to their position. The labels have to be given into the function seperately:

Important

currently bugged

label_scatter (boolean, true) - Indicates whether the dots should be drawn at the given positions.

+plot_topoplotseries(df, Δbin; positions = positions)Example block output

Arguments usage

Key arguments

Disabling colorbar:

plot_topoplotseries(df, Δbin; positions=positions, layout = (; use_colorbar=false))
Example block output

Positions

You can give either positions, or labels. If both are provided, positions have priority

plot_toposeries(...; mapping=(; key=value))

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

visual=(;)

label_text (boolean, false) Indicates whether label should drawn next to their position. The labels have to be given into the function seperately:

Important

currently bugged

label_scatter (boolean, true) - Indicates whether the dots should be drawn at the given positions.