Title: | Builtin Modules for `RAVE` |
---|---|
Description: | This package provides builtin modules for `RAVE`. It aims at 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.0.5 |
Built: | 2024-11-03 04:53:15 UTC |
Source: | https://github.com/beauchamplab/ravebuiltins |
Welch periodogram per condition
by_condition_welch(results, ...)
by_condition_welch(results, ...)
results |
results returned by module |
... |
other parameters passed to module output |
By 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 |
Function to load all dev funtions and wrap them within an environment
dev_ravebuiltins(expose_functions = FALSE, reload = TRUE)
dev_ravebuiltins(expose_functions = FALSE, reload = TRUE)
expose_functions |
logical indicating whether to expose all dev functions to the global environment |
reload |
logical, do you want to fast-reload the package before load the functions? |
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 colorbar. 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 |
zlim that trims z value |
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 draw_img(...) to allow for a function to be called after creation but before rendering. Don't depend on this call order, use PANEL.LAST if you want to draw things on top of the heatmap |
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 colorbar width |
axes |
vector of logicals, whether to draw axis |
plot_time_range |
x range, similar to |
layout_heat_maps
draw_img
Provide easy ways to set plot layouts
easy_layout( K, nrows = 1, legend, legend_size = lcm(3), legend_side = 4, s_margin = par("mar"), b_margin = par("oma"), l_margin )
easy_layout( K, nrows = 1, legend, legend_size = lcm(3), legend_side = 4, s_margin = par("mar"), b_margin = par("oma"), l_margin )
K |
number of plots to be made |
nrows |
number of rows for the plot, default 1 |
legend |
expression for generating legend, see "?legend" |
legend_size |
legend width/height, default is lcm(3) |
legend_side |
1 - bottom, 2 - left, 3 - top, 4 - right. Default is 4 |
s_margin |
margins within each plots see "?par" for "mar" |
b_margin |
margins for the whole plot see "?par" for "oma" |
l_margin |
legend margin |
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 |
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 |
Basic Time Frequency Plot
heat_map_plot(results, ...)
heat_map_plot(results, ...)
results |
results returned by module |
... |
other parameters passed to module output |
## Not run: rave_prepare(...) fn = ravebuiltins:::get_module('power_explorer') res = fn() heat_map_plot(res$result) ## End(Not run)
## Not run: rave_prepare(...) fn = ravebuiltins:::get_module('power_explorer') res = fn() heat_map_plot(res$result) ## End(Not run)
Create a layout so that heatmaps look nice and you have enough space for the color bar
layout_heat_maps( k, max_col, ratio = 4, layout_color_bar = TRUE, colorbar_cm = 3.5 )
layout_heat_maps( k, max_col, ratio = 4, layout_color_bar = TRUE, colorbar_cm = 3.5 )
colorbar_cm |
The default width chosen (3.5) for the color bar relies on 'lcm'. If the function detects the user is writing to a file (@seealso plotting_to_file), the width is currently forced to 3.0 |
k: |
the number of heatmaps, excluding the color bar |
max_col: |
maximum number of columns before creating multiple rows |
ratio: |
heatmap to color bar width ratio (Default 4:1) |
layout_color_bar: |
whether space should be made for the color bar (Default TRUE) |
The idea here is to to separate the plotting of the heatmap from all the accoutrements that are done in the decorators. We are just plotting image(mat) Rather Than t(mat) as you might expect. The Rave_calculators know this so we can save a few transposes along the way.
make_image( mat, x, y, zlim, col = NULL, log = "", useRaster = TRUE, clip_to_zlim = TRUE, add = TRUE )
make_image( mat, x, y, zlim, col = NULL, log = "", useRaster = TRUE, clip_to_zlim = TRUE, add = TRUE )
mat |
z-matrix |
x , y
|
z and y axis |
zlim |
value to trim zmat |
col |
vector of colors, color palette |
log |
which axis will be in log scale |
useRaster |
passed to image() |
clip_to_zlim |
whether to clip mat |
add |
logical, whether to overlay current plot to an existing image |
Time Series Plot
over_time_plot(results, ...)
over_time_plot(results, ...)
results |
results returned by module |
... |
other parameters passed to module output |
Description 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. Note Does not handle log axes correctly param ... extra options to pass to barplot during plot creation
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 )
Function make a title for a plot, checks par('bg') to handle dark mode
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, ...)
cex |
the character expansion for the title (default is rave_cex.main) |
font |
the font type (default = 1, plain) |
title
By Trial Plot With Statistics
windowed_comparison_plot(results, ...)
windowed_comparison_plot(results, ...)
results |
results returned by module |
... |
other parameters passed to module output |