UnfoldMakie.RelativeAxis
— Typeax = RelativeAxis(figlike, p::NTuple{4, Float64}; kwargs...)
Returns an axis whose position is relative to a GridLayout' element (via
BBox') 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]
UnfoldMakie.eeg_topoplot_series
— Functionfunction 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
andy(=:erp)
, andlabel(=:label)
. Ifdata
is a matrix, it is automatically cast to a dataframe, time bins are in samples, labels arestring.(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 withpositions=pos
. - The
col
androw
arguments specify the field to be divided into columns and rows. The default iscol=:time
to split by the time field androw=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 objecteeg_topoplot_series!(fig, data::DataFrame, Δbin; kwargs..)
. row_labels
andcol_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)
UnfoldMakie.eeg_topoplot_series!
— Functioneegtopoplotseries!(fig, data::DataFrame, Δbin; kwargs..) In place plotting of topoplot series see eegtopoplotseries(data, Δbin) for help
UnfoldMakie.config_kwargs!
— FunctionTakes a kwargs named tuple of Key => NamedTuple and merges the fields with the defaults
UnfoldMakie.eeg_matrix_to_dataframe
— FunctionHelper function converting a matrix (channel x times) to a tidy dataframe with columns :estimate, :time and :label
UnfoldMakie.rel_to_abs_bbox
— Functionrel_to_abs_bbox(org, rel)
Takes a rectangle org
and applies the relative transformation tuple rel
. Returns a Makie.BBox
.
UnfoldMakie.to_positions
— Functiontopositions(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
UnfoldMakie.df_timebin
— Functiondf_timebin(df, Δbin; col_y=:erp, fun=mean, grouping=[])
Split or combine dataframe
according to equally spaced time bins
df
AbstractTable with columns:time
andcol_y
(default:erp
), and all columns ingrouping
;Δbin
bin size in:time
units;col_y
default :erp, the column to combine over (withfun
);fun
function to combine, default ismean
;grouping
(vector of symbols/strings) default empty vector, columns to group the data by before aggregating. Values ofnothing
are ignored.
UnfoldMakie.cart3d_to_spherical
— Functionconvert x/y/z electrode montage positions to spherical coordinate representation. output is a matrix
UnfoldMakie.valType_to_symbol
— FunctionVal{:bu}() to => :bu