| Title: | Builtin Modules for 'RAVE' |
|---|---|
| Description: | This package provides builtin modules for 'RAVE'. It aims to analyze and visualize 'iEEG' data from different perspectives. |
| Authors: | John Magnotti [cre, aut], Zhengjia Wang [aut] |
| Maintainer: | John Magnotti <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.99.0 |
| Built: | 2026-10-15 18:14:26 UTC |
| Source: | https://github.com/beauchamplab/ravebuiltins |
Welch periodogram per conditionWelch periodogram per condition
by_condition_welch(results, ...)by_condition_welch(results, ...)
results |
results returned by module |
... |
other parameters passed to module output |
ERP dataBy Trial Plot for ERP data
by_trial_erp_map(results, ...)by_trial_erp_map(results, ...)
results |
results returned by module |
... |
other parameters passed to module output |
Draws an orange, dashed horizontal line at cut. Checks for not null and length > 0
draw_cut_point(cut = NULL)draw_cut_point(cut = NULL)
cut |
the location(s) of the lines |
the value of cut (invisibly)
Easy way to make a bunch of heatmaps with consistent look/feel and get a color bar. By default it is setup for time/freq, but by swapping labels and decorators you can do anything.
draw_many_heat_maps( hmaps, max_zlim = 0, percentile_range = FALSE, log_scale = FALSE, show_color_bar = TRUE, useRaster = TRUE, wide = FALSE, PANEL.FIRST = NULL, PANEL.LAST = NULL, PANEL.COLOR_BAR = NULL, axes = c(TRUE, TRUE), plot_time_range = NULL, special_case_first_plot = FALSE, max_columns = 2, decorate_all_plots = FALSE, center_multipanel_title = FALSE, ignore_time_range = NULL, marginal_text_fields = c("Subject ID", "Electrode", "Frequency"), extra_plot_parameters = NULL, do_layout = TRUE, ... )draw_many_heat_maps( hmaps, max_zlim = 0, percentile_range = FALSE, log_scale = FALSE, show_color_bar = TRUE, useRaster = TRUE, wide = FALSE, PANEL.FIRST = NULL, PANEL.LAST = NULL, PANEL.COLOR_BAR = NULL, axes = c(TRUE, TRUE), plot_time_range = NULL, special_case_first_plot = FALSE, max_columns = 2, decorate_all_plots = FALSE, center_multipanel_title = FALSE, ignore_time_range = NULL, marginal_text_fields = c("Subject ID", "Electrode", "Frequency"), extra_plot_parameters = NULL, do_layout = TRUE, ... )
hmaps |
data to draw heatmaps |
max_zlim |
|
percentile_range |
whether to draw in percentile |
log_scale |
draw y in log scale? |
show_color_bar |
show color legend to the right? Future: Will will check to see if this parameter is a function. If so, we can call it to allow arbitrary legends in the right-most (half) panel |
useRaster, ...
|
passed to image() |
wide |
boolean. should we use a wider margin on the left? defaults to false |
PANEL.FIRST |
a function that is called after each plot window has been created, but before any rendering is done. In truth, this is currently called AFTER the call to image(),
so if you draw within the plotting region it will overwrite the heatmap. To fix this requires editing |
PANEL.LAST |
a function that is called after the rendering of each heat map. It is not called after the rendering of the color bar. |
PANEL.COLOR_BAR |
a function to adjust color bar width |
axes |
vector of logicals, whether to draw axis |
plot_time_range |
x range, similar to |
special_case_first_plot |
logical, whether the first panel gets its own treatment (for example a wider left margin) instead of the shared layout |
max_columns |
maximum number of heatmap columns before wrapping onto additional rows (default 2) |
decorate_all_plots |
logical, whether |
center_multipanel_title |
logical, whether a multi-panel title is centered across the whole figure instead of over the first panel |
ignore_time_range |
optional time range to exclude from the drawn data |
marginal_text_fields |
character vector naming which fields are written into the plot margin (default Subject ID, Electrode, Frequency) |
extra_plot_parameters |
optional named list of additional graphical parameters forwarded to the individual heatmap panels |
do_layout |
logical, whether to call |
Called for its side effect of drawing the heatmaps; returns
NULL invisibly.
Voltage Time Series Plot
erp_over_time_plot(results, ...)erp_over_time_plot(results, ...)
results |
results returned by module |
... |
other parameters passed to module output |
Expands a short heatmap palette into a smooth color ramp of
ncolors entries, suitable for passing to image or to a
threeBrain viewer.
expand_heatmap(pal, results, ncolors = 101, space = "Lab", ...)expand_heatmap(pal, results, ncolors = 101, space = "Lab", ...)
pal |
a character vector of colors, or the name of one of the builtin
palettes returned by |
results |
optional RAVE results object; when supplied, |
ncolors |
number of colors in the returned ramp (default 101) |
space |
color space used for interpolation, passed to
|
... |
further arguments passed to |
A character vector of ncolors hex color strings.
expand_heatmap(get_heatmap_palette('BlueWhiteRed'), ncolors = 101)expand_heatmap(get_heatmap_palette('BlueWhiteRed'), ncolors = 101)
Returns one of the builtin diverging color palettes used for RAVE heatmaps. Most are adapted from https://colorbrewer2.org. Each palette has an odd number of colors so that the middle entry is the neutral midpoint.
get_heatmap_palette(pname, get_palettes = FALSE, get_palette_names = FALSE)get_heatmap_palette(pname, get_palettes = FALSE, get_palette_names = FALSE)
pname |
palette name, one of the values returned by this function with
|
get_palettes |
ignored, kept for backward compatibility |
get_palette_names |
whether to return the available palette names
instead of a palette; only used when |
A character vector of hex colors carrying a name attribute;
or, when pname is missing, the full named list of palettes, or a
character vector of palette names if get_palette_names = TRUE.
get_heatmap_palette(get_palette_names = TRUE) get_heatmap_palette('BlueWhiteRed')get_heatmap_palette(get_palette_names = TRUE) get_heatmap_palette('BlueWhiteRed')
Function to get builtin color palettes
get_palette(pname, get_palettes = FALSE, get_palette_names = FALSE)get_palette(pname, get_palettes = FALSE, get_palette_names = FALSE)
pname |
palette name |
get_palettes |
ignored |
get_palette_names |
whether to get palette names |
Collapses a vector of electrode labels to its unique values and
appends the number of electrodes carrying each label, as Label[n].
make_label_with_count(lbl)make_label_with_count(lbl)
lbl |
character vector of per-electrode labels, with repeats |
A character vector of the unique labels with counts appended. The
result carries a map attribute giving, for each element of
lbl, the index of its label in the returned vector.
make_label_with_count(c('G 1', 'G 1', 'S 2'))make_label_with_count(c('G 1', 'G 1', 'S 2'))
Time Series Plot
over_time_plot(results, ...)over_time_plot(results, ...)
results |
results returned by module |
... |
other parameters passed to module output |
This doesn't do any decoration, it's designed for use with
rutabaga::create_frames. Note that we're using barplot to set the
x- and y-range of the plot. Does not handle log axes correctly.
plot_grouped_data( mat, yvar, xvar, gvar = NULL, types = c("jitter points", "means", "ebar polygons"), layout = c("grouped", "overlay"), draw0 = TRUE, draw0.col = "black", ylim = NULL, col = NULL, ..., plot_options = NULL, jitter_seed )plot_grouped_data( mat, yvar, xvar, gvar = NULL, types = c("jitter points", "means", "ebar polygons"), layout = c("grouped", "overlay"), draw0 = TRUE, draw0.col = "black", ylim = NULL, col = NULL, ..., plot_options = NULL, jitter_seed )
mat |
a |
yvar |
name of the column holding the response values |
xvar |
name of the column defining positions along the x axis |
gvar |
name of the grouping column, or |
types |
character vector selecting which layers to draw; any of
|
layout |
whether groups are drawn side by side ( |
draw0 |
logical, whether to draw a reference line at zero |
draw0.col |
color of the zero reference line (default black) |
ylim |
y axis limits; computed from the data when |
col |
vector of colors, one per group; defaults to the active palette |
... |
extra options to pass to barplot during plot creation |
plot_options |
optional named list of graphical parameters such as
|
jitter_seed |
optional integer seed making the point jitter reproducible across redraws |
Called for its side effect of drawing the plot; returns NULL
invisibly.
Wraps graphics::title, defaulting the color to the
current foreground so titles stay legible when par('bg') is dark,
and shrinking the text when the plot is being written to a file.
rave_title(main, cex = rave_cex.main, col, font = 1, adj = 0.5, ...)rave_title(main, cex = rave_cex.main, col, font = 1, adj = 0.5, ...)
main |
the title text, passed to |
cex |
the character expansion for the title (default is
|
col |
title color; defaults to the current foreground color |
font |
the font type (default = 1, plain) |
adj |
horizontal justification, 0 left, 0.5 centered, 1 right |
... |
further arguments passed to |
Called for its side effect of drawing the title; returns the value
of graphics::title invisibly.
Removes the trailing [5] / [10] electrode count
that make_label_with_count appends to FreeSurfer labels.
remove_count_from_label(str)remove_count_from_label(str)
str |
character vector of labels |
The labels with any trailing bracketed count removed.
remove_count_from_label('G_temp_sup[5]')remove_count_from_label('G_temp_sup[5]')
Removes the leading GS , G and S
gyrus/sulcus markers from FreeSurfer anatomical labels.
remove_gyrus_sulcus_labels(str)remove_gyrus_sulcus_labels(str)
str |
character vector of labels |
The labels with gyrus/sulcus prefixes removed.
remove_gyrus_sulcus_labels('G temp_sup')remove_gyrus_sulcus_labels('G temp_sup')
Removes the leading L / R hemisphere markers so
that labels are compared consistently across hemispheres. Kept in one
place so every caller strips them the same way.
remove_hemisphere_labels(str)remove_hemisphere_labels(str)
str |
character vector of labels |
The labels with hemisphere prefixes removed.
remove_hemisphere_labels('L G_temp_sup')remove_hemisphere_labels('L G_temp_sup')