Description Usage Arguments Value Examples
plotButterfly
creates a multi-channel (a.k.a butterfly) plot.
Additionally, significant time windows can be highlighted, and peak
topographies can be displayed above the ERP curves.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
dat |
the array of ERP curves which must have at least 'time' and/or 'chan' dimensions |
sig |
[optional] a corresponding array to |
topo_time |
[optional] an object which describes the time points at which the scalp topographies should be plotted. Can be a simple atomic vector or a data.frame if the time points are not identical across the faceting dimension(s). |
chan_pos |
a data.frame of channel positions. Obligatory if
|
subset |
a named list to subset the input arrays; see
|
pcrit |
the level of alpha to highlight significant effects |
aspect_ratio |
the ratio of |
scalp_ratio |
the ratio of the diameter of the scalp and the vertical range of the ERP curves on the figure |
ampl_range |
the range of amplitudes to plot. If |
caption |
logical flag indicating if caption should be also returned (default: TRUE) |
... |
additional arguments passed to |
plotButterfly
returns a ggplot object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # load example data
data(erps)
# extract channel positions
chan_pos <- attr(erps, "chan")
# collapse pairtypes and participants
tempdat <- avgDims(erps, c("pairtype", "id"))
# plot butterfly with topo-maps at specified time points
plotButterfly(tempdat, topo_time = seq(24, 476, by = 50),
chan_pos = chan_pos)
# plot butterfly with topo-maps at peaks which are selected
# automatically; let's look for local maxima on the GFP curves between
# 0 and 480 ms
# 1) add GFP to the dataset
tempdat2 <- compGfp(tempdat, keep_channels = TRUE)
# 2) provide the peak definition
peak_def <- isLocalMaximum(
subset. = list(time = isBetween(0, 480), chan = "GFP"),
options. = list(along_dim = "time", n = 15))
# 3) find the peaks
peak_data <- selectValues(tempdat2, peak_def)
# 4) create plot
plotButterfly(tempdat2, topo_time = peak_data, chan_pos = chan_pos)
# highlight time windows where the effect of the 'stimclass' factor is
# statistically significant according to TANOVA
# 1) run TANOVA
result_tanova <- tanova(
avgDims(erps, "pairtype"),
list(within = "stimclass", w_id = "id"),
parallel = .(ncores = 2),
perm = .(n = 499))
# 2) extract p-values and bind them to a single array
pvalues <- extract(result_tanova, c("p", "p_corr"))
pvalues <- bindArrays(pvalues, along_name = "measure")
# 3) plot
plotButterfly(tempdat2, sig = pvalues, topo_time = peak_data,
chan_pos = chan_pos)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.