UnfoldMakie.RelativeAxisType

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

Returns an axis whose position is relative to a GridLayout' element (viaBBox') and not relative to the scene (default behavior is Axis(..., bbox=BBox()).

p::NTuple{4,Float64}: Specify the position relative to the GridPosition, left:right; bottom:top, typical numbers between 0 and 1, e.g. (0.25, 0.75, 0.25, 0.75) would center an Axis inside this GridPosition.

The kwargs... are inserted into the 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.rel_to_abs_bboxFunction
rel_to_abs_bbox(org, rel)

Takes a rectangle org and applies the relative transformation tuple rel. Returns a Makie.BBox.

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
df_timebin(df, Δbin; col_y=: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