| Title: | Dashboard for Reproducible Visualization of 'iEEG' |
|---|---|
| Description: | Dashboard system to display the analysis results produced by 'RAVE', Magnotti J.F., Wang Z., Beauchamp M.S. (2020), <doi:10.1016/j.neuroimage.2020.117341>; see <https://rave.wiki> for more documentations. Provides infrastructure to integrate customized analysis pipelines into dashboard modules, including file structures, front-end widgets, and event handlers; see <https://github.com/rave-ieeg/rave-pipelines> for implementation details. |
| Authors: | Zhengjia Wang [aut, cre, cph], Xiang Zhang [aut], John Magnotti [aut], Michael Beauchamp [aut], Trustees of the University of Pennsylvania [cph] (All files in this package unless explicitly stated in the file) |
| Maintainer: | Zhengjia Wang <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.3.48 |
| Built: | 2026-06-02 18:55:24 UTC |
| Source: | https://github.com/dipterix/ravedash |
Automatically generates href for input_card
and output_card
set_card_url_scheme(module_id, root, sep = "/") card_href(title, type = "input", module_id = NULL)set_card_url_scheme(module_id, root, sep = "/") card_href(title, type = "input", module_id = NULL)
module_id |
the module ID |
root |
'URL' default route |
sep |
separation |
title |
a title string that will be used to generate 'URL' |
type |
type of the card; choices are |
The hyper reference of suggested card 'URL'
set_card_url_scheme( module_id = "power_explorer", root = "https://openwetware.org/wiki/RAVE:ravebuiltins", sep = ":") card_href("Set Electrodes", type = "input", module_id = "power_explorer")set_card_url_scheme( module_id = "power_explorer", root = "https://openwetware.org/wiki/RAVE:ravebuiltins", sep = ":") card_href("Set Electrodes", type = "input", module_id = "power_explorer")
Create report wizard to be used within the interactive modules
create_report_wizard(pipeline, session = shiny::getDefaultReactiveDomain())create_report_wizard(pipeline, session = shiny::getDefaultReactiveDomain())
pipeline |
|
session |
shiny session |
A list of functions: launch with argument subject to
be called when users want to pop up a wizard allowing users to choose
reports; generate with arguments subject and
report_names to generate reports
Debug 'RAVE' modules interactively in local project folder
debug_modules( module_root = rstudioapi::getActiveProject(), host = "127.0.0.1", port = 17283, jupyter = FALSE, ... )debug_modules( module_root = rstudioapi::getActiveProject(), host = "127.0.0.1", port = 17283, jupyter = FALSE, ... )
module_root |
root of modules, usually the project folder created from
|
host, port
|
host and port of the application |
jupyter |
whether to launch |
... |
passed to |
'RStudio' job ID
Get current active module information, internally used
get_active_module_info(session = shiny::getDefaultReactiveDomain()) get_active_pipeline(session = shiny::getDefaultReactiveDomain())get_active_module_info(session = shiny::getDefaultReactiveDomain()) get_active_pipeline(session = shiny::getDefaultReactiveDomain())
session |
shiny reactive domain, default is current domain |
A named list, including module ID, module label, internal
'rave_id'.
Only works in template framework provided by 'shidashi'
package, see use_template
group_box(title, ..., class = NULL) flex_group_box(title, ..., class = NULL, wrap = "wrap", direction = "row")group_box(title, ..., class = NULL) flex_group_box(title, ..., class = NULL, wrap = "wrap", direction = "row")
title |
the box title |
... |
elements to be included or to be passed to other methods |
class |
additional class of the box |
wrap, direction
|
see |
A 'HTML' tag
library(shiny) library(shidashi) library(ravedash) group_box( title = "Analysis Group A", selectInput("a", "Condition", choices = c("A", "B")), sliderInput("b", "Time range", min = 0, max = 1, value = c(0,1)) ) flex_group_box( title = "Project and Subject", flex_item( "Some input 1" ), flex_item( "Some input 2" ), flex_break(), flex_item( "Some input in new line" ) )library(shiny) library(shidashi) library(ravedash) group_box( title = "Analysis Group A", selectInput("a", "Condition", choices = c("A", "B")), sliderInput("b", "Time range", min = 0, max = 1, value = c(0,1)) ) flex_group_box( title = "Project and Subject", flex_item( "Some input 1" ), flex_item( "Some input 2" ), flex_break(), flex_item( "Some input in new line" ) )
Common shiny server function to enable modules that requires data loader panel.
module_server_common( module_id, check_data_loaded, ..., session = shiny::getDefaultReactiveDomain(), parse_env = NULL )module_server_common( module_id, check_data_loaded, ..., session = shiny::getDefaultReactiveDomain(), parse_env = NULL )
module_id |
'RAVE' module ID |
check_data_loaded |
a function that takes zero to one argument and
must return either |
... |
ignored |
session |
shiny session; |
parse_env |
environment used to parse module |
A list of server utility functions; see 'Examples' below.
# 'RAVE' module server function server <- function(input, output, session, ...) { shidashi::init_app() pipeline_path <- "PATH to module pipeline" module_server_common( module_id = session$ns(NULL), check_data_loaded = function(first_time) { re <- tryCatch({ # Try to read data from pipeline results repo <- ravepipeline::pipeline_read( 'repository', pipe_dir = pipeline_path ) # Fire event to update footer message ravedash::fire_rave_event('loader_message', "Data loaded") # Return TRUE indicating data has been loaded TRUE }, error = function(e) { # Fire event to remove footer message ravedash::fire_rave_event('loader_message', NULL) # Return FALSE indicating no data has been found FALSE }) }, session = session ) }# 'RAVE' module server function server <- function(input, output, session, ...) { shidashi::init_app() pipeline_path <- "PATH to module pipeline" module_server_common( module_id = session$ns(NULL), check_data_loaded = function(first_time) { re <- tryCatch({ # Try to read data from pipeline results repo <- ravepipeline::pipeline_read( 'repository', pipe_dir = pipeline_path ) # Fire event to update footer message ravedash::fire_rave_event('loader_message', "Data loaded") # Return TRUE indicating data has been loaded TRUE }, error = function(e) { # Fire event to remove footer message ravedash::fire_rave_event('loader_message', NULL) # Return FALSE indicating no data has been found FALSE }) }, session = session ) }
Creates a container for preset components
new_rave_shiny_component_container( module_id, pipeline_name, pipeline_path = ravepipeline::pipeline_find(pipeline_name), settings_file = "settings.yaml" )new_rave_shiny_component_container( module_id, pipeline_name, pipeline_path = ravepipeline::pipeline_find(pipeline_name), settings_file = "settings.yaml" )
module_id |
'RAVE' module ID |
pipeline_name |
the name of pipeline to run |
pipeline_path |
path of the pipeline |
settings_file |
the settings file of the pipeline, usually stores the
pipeline input information; default is |
A 'RAVEShinyComponentContainer' instance
f <- tempfile() dir.create(f, showWarnings = FALSE, recursive = TRUE) file.create(file.path(f, "settings.yaml")) container <- new_rave_shiny_component_container( module_id = "module_power_phase_coherence", pipeline_name = "power_phase_coherence_pipeline", pipeline_path = f ) loader_project <- presets_loader_project() loader_subject <- presets_loader_subject() container$add_components( loader_project, loader_subject )f <- tempfile() dir.create(f, showWarnings = FALSE, recursive = TRUE) file.create(file.path(f, "settings.yaml")) container <- new_rave_shiny_component_container( module_id = "module_power_phase_coherence", pipeline_name = "power_phase_coherence_pipeline", pipeline_path = f ) loader_project <- presets_loader_project() loader_subject <- presets_loader_subject() container$add_components( loader_project, loader_subject )
Reserved for compatibility; do not use.
output_gadget_container(expr, ..., quoted = FALSE, env = parent.frame())output_gadget_container(expr, ..., quoted = FALSE, env = parent.frame())
expr |
expression to evaluate |
... |
ignored |
quoted |
whether |
env |
environment to evaluate |
Shiny plot output with minimum height and additional classes
plotOutput2( outputId, class = NULL, width = "100%", height = "100%", min_height = "400px", ... )plotOutput2( outputId, class = NULL, width = "100%", height = "100%", min_height = "400px", ... )
outputId, width, height, ...
|
passed to |
class |
additional 'HTML' class of the output wrapper |
min_height |
minimum height of the image; default is 400 pixels |
A plot output element that can be included in a panel.
plotOutput2("plot", class = "rounded overflow-hidden", min_height = 300)plotOutput2("plot", class = "rounded overflow-hidden", min_height = 300)
Randomly choose a text from a list of strings
be_patient_text(candidates) finished_text(candidates)be_patient_text(candidates) finished_text(candidates)
candidates |
character vectors, a list of candidates |
be_patient_text returns a text asking users to be patient;
finished_text returns the text indicating the task has finished.
be_patient_text() finished_text()be_patient_text() finished_text()
Input and output card (front-end element)
input_card( title, ..., class = "", class_header = "shidashi-anchor", class_body = "padding-10", class_foot = "padding-10", href = "auto", tools = NULL, footer = NULL, append_tools = TRUE, toggle_advanced = FALSE, module_id = get0("module_id", ifnotfound = NULL, envir = parent.frame()) ) output_card( title, ..., class = "", class_body = "padding-10", class_foot = "padding-10", href = "auto", tools = NULL, append_tools = TRUE, module_id = get0("module_id", ifnotfound = NULL, envir = parent.frame()) ) output_cardset( title, ..., class = "", class_body = "no-padding", class_foot = "padding-10", href = "auto", tools = NULL, append_tools = TRUE, module_id = get0("module_id", ifnotfound = NULL, envir = parent.frame()) )input_card( title, ..., class = "", class_header = "shidashi-anchor", class_body = "padding-10", class_foot = "padding-10", href = "auto", tools = NULL, footer = NULL, append_tools = TRUE, toggle_advanced = FALSE, module_id = get0("module_id", ifnotfound = NULL, envir = parent.frame()) ) output_card( title, ..., class = "", class_body = "padding-10", class_foot = "padding-10", href = "auto", tools = NULL, append_tools = TRUE, module_id = get0("module_id", ifnotfound = NULL, envir = parent.frame()) ) output_cardset( title, ..., class = "", class_body = "no-padding", class_foot = "padding-10", href = "auto", tools = NULL, append_tools = TRUE, module_id = get0("module_id", ifnotfound = NULL, envir = parent.frame()) )
title |
title of the card |
... |
additional elements to be included in the card, see
|
class |
the 'HTML' class for card |
class_header |
the 'HTML' class for card header; default is
|
class_body |
the 'HTML' class for card body; default is
|
class_foot |
the 'HTML' class for card footer; default is
|
href |
hyper reference link of the card |
tools |
a list of additional card tools, see
|
footer |
footer elements |
append_tools |
whether to append |
toggle_advanced |
whether to show links in the footer to toggle
elements with 'HTML' class |
module_id |
the 'RAVE' module ID |
'HTML' tags
input_card(title = "Condition selector", "Please select experimental conditions:", shiny::selectInput( inputId = "condition", label = "Condition", choices = c("Audio", "Visual") ))input_card(title = "Condition selector", "Please select experimental conditions:", shiny::selectInput( inputId = "condition", label = "Condition", choices = c("Audio", "Visual") ))
A set of preset behaviors used by 'RAVE' modules
register_rave_session( session = shiny::getDefaultReactiveDomain(), .rave_id = NULL ) get_default_handlers(session = shiny::getDefaultReactiveDomain()) fire_rave_event( key, value, global = FALSE, force = FALSE, session = shiny::getDefaultReactiveDomain(), .internal_ok = FALSE ) get_rave_event(key, session = shiny::getDefaultReactiveDomain()) open_loader(session = shiny::getDefaultReactiveDomain()) close_loader(session = shiny::getDefaultReactiveDomain()) watch_loader_opened(session = shiny::getDefaultReactiveDomain()) watch_data_loaded(session = shiny::getDefaultReactiveDomain()) current_shiny_theme(default, session = shiny::getDefaultReactiveDomain())register_rave_session( session = shiny::getDefaultReactiveDomain(), .rave_id = NULL ) get_default_handlers(session = shiny::getDefaultReactiveDomain()) fire_rave_event( key, value, global = FALSE, force = FALSE, session = shiny::getDefaultReactiveDomain(), .internal_ok = FALSE ) get_rave_event(key, session = shiny::getDefaultReactiveDomain()) open_loader(session = shiny::getDefaultReactiveDomain()) close_loader(session = shiny::getDefaultReactiveDomain()) watch_loader_opened(session = shiny::getDefaultReactiveDomain()) watch_data_loaded(session = shiny::getDefaultReactiveDomain()) current_shiny_theme(default, session = shiny::getDefaultReactiveDomain())
session |
shiny session, usually automatically determined |
key |
event key to fire or to monitor |
value |
event value |
global |
whether to notify other sessions (experimental and not recommended) |
force |
whether to force firing the event even the |
.internal_ok |
internally used |
default |
default value if not found |
rave_id, .rave_id
|
deprecated, no longer used |
These goal of these event functions is to simplify the dashboard
logic without understanding the details or passing global variables around.
Everything starts with shidashi::register_session. This function
registers session event handlers and theme observers.
If you have called module_server_common, then session
registration has already been done.
register_rave_sessionDeprecated. Use
shidashi::register_session() instead.
fire_rave_eventsend signals to make changes to a event; returns nothing
get_rave_eventwatch and get the event values; must run in shiny reactive context
open_loaderfire an event with a special key
'open_loader' to open the data-loading panel; returns nothing
close_loaderreset an event with a special key
'open_loader' to close the data-loading panel if possible;
returns nothing
watch_loader_openedwatch in shiny reactive context whether the loader is opened; returns a logical value, but raise errors when reactive context is missing
watch_data_loadedwatch a special event with key
'data_loaded'; returns a logical value of whether new data has been
loaded, or raise errors when reactive context is missing
current_shiny_themewatch and returns a list of theme parameters, for example, light or dark theme
See 'Details'
The following event keys are built-in. Please do not fire them using
fire_rave_event or the 'RAVE' application might will crash
'simplify_toggle'toggle visibility of 'HTML' elements with
class 'rave-option'
'run_analysis'notifies the module to run pipeline
'save_pipeline', 'load_pipeline'
notifies the module to save or load pipeline
'data_loaded'notifies the module that new data has been loaded
'open_loader', 'toggle_loader'
notifies the internal server code to show or hide the data loading panel
'active_module'internally populated by the action
dispatcher when the module first loads (and whenever a
type = "active_module" rave-action arrives). Returns a list with
elements type, id, parent_frame, and rave_id.
This key is reserved: external code must not call
fire_rave_event("active_module", ...) directly.
To obtain the currently active module, prefer
get_active_module_info(), which reads from the
shidashi module registry and is always up-to-date.
library(shiny) library(ravedash) ui <- fluidPage( actionButton("btn", "Fire event"), actionButton("btn2", "Toggle loader") ) server <- function(input, output, session) { # Create event registries shidashi::register_session() shiny::bindEvent( shiny::observe({ fire_rave_event("my_event_key", Sys.time()) }), input$btn, ignoreInit = TRUE, ignoreNULL = TRUE ) shiny::bindEvent( shiny::observe({ cat("An event fired with value:", get_rave_event("my_event_key"), "\n") }), get_rave_event("my_event_key"), ignoreNULL = TRUE ) shiny::bindEvent( shiny::observe({ if (watch_loader_opened()) { close_loader() } else { open_loader() } }), input$btn2, ignoreInit = TRUE, ignoreNULL = TRUE ) shiny::bindEvent( shiny::observe({ cat("Loader ", ifelse(watch_loader_opened(), "opened", "closed"), "\n") }), watch_loader_opened(), ignoreNULL = TRUE ) } if(interactive()) { shinyApp(ui, server) }library(shiny) library(ravedash) ui <- fluidPage( actionButton("btn", "Fire event"), actionButton("btn2", "Toggle loader") ) server <- function(input, output, session) { # Create event registries shidashi::register_session() shiny::bindEvent( shiny::observe({ fire_rave_event("my_event_key", Sys.time()) }), input$btn, ignoreInit = TRUE, ignoreNULL = TRUE ) shiny::bindEvent( shiny::observe({ cat("An event fired with value:", get_rave_event("my_event_key"), "\n") }), get_rave_event("my_event_key"), ignoreNULL = TRUE ) shiny::bindEvent( shiny::observe({ if (watch_loader_opened()) { close_loader() } else { open_loader() } }), input$btn2, ignoreInit = TRUE, ignoreNULL = TRUE ) shiny::bindEvent( shiny::observe({ cat("Loader ", ifelse(watch_loader_opened(), "opened", "closed"), "\n") }), watch_loader_opened(), ignoreNULL = TRUE ) } if(interactive()) { shinyApp(ui, server) }
Create, register, list, and remove 'RAVE' sessions
new_session(update = FALSE, app_root = NULL) use_session(x, ...) launch_session( x, host = "127.0.0.1", port = NULL, modules = NULL, dry_run = FALSE, options = list(jupyter = TRUE, jupyter_port = NULL, as_job = TRUE, launch_browser = TRUE, single_session = FALSE, page_title = NULL, sidebar_open = TRUE) ) session_getopt(keys, default = NA, namespace = "default") session_setopt(..., .list = NULL, namespace = "default") remove_session(x) remove_all_sessions() list_session(path = session_root(), order = c("none", "ascend", "descend")) start_session( session, new = NA, modules = NULL, page_title = NULL, sidebar_open = TRUE, host = "127.0.0.1", port = NULL, jupyter = NA, jupyter_port = NULL, as_job = TRUE, launch_browser = TRUE, single_session = FALSE, app_root = NULL, dry_run = FALSE ) shutdown_session( returnValue = invisible(NULL), jupyter = TRUE, session = shiny::getDefaultReactiveDomain() ) session_log(x, max_lines = 200, modules = NULL)new_session(update = FALSE, app_root = NULL) use_session(x, ...) launch_session( x, host = "127.0.0.1", port = NULL, modules = NULL, dry_run = FALSE, options = list(jupyter = TRUE, jupyter_port = NULL, as_job = TRUE, launch_browser = TRUE, single_session = FALSE, page_title = NULL, sidebar_open = TRUE) ) session_getopt(keys, default = NA, namespace = "default") session_setopt(..., .list = NULL, namespace = "default") remove_session(x) remove_all_sessions() list_session(path = session_root(), order = c("none", "ascend", "descend")) start_session( session, new = NA, modules = NULL, page_title = NULL, sidebar_open = TRUE, host = "127.0.0.1", port = NULL, jupyter = NA, jupyter_port = NULL, as_job = TRUE, launch_browser = TRUE, single_session = FALSE, app_root = NULL, dry_run = FALSE ) shutdown_session( returnValue = invisible(NULL), jupyter = TRUE, session = shiny::getDefaultReactiveDomain() ) session_log(x, max_lines = 200, modules = NULL)
update |
logical, whether to update to latest 'RAVE' template |
..., .list
|
named list of key-value pairs of session options. The keys must be characters, and values must be simple data types (such as numeric vectors, characters) |
host |
host 'IP' address, default is 'localhost' |
port |
port to listen |
modules |
selected module ID to launch; used to only show a subset of
modules; default is |
dry_run |
whether to dry-run (do not launch) the 'RAVE' session |
options |
additional options, including |
keys |
vector of characters, one or more keys of which the values should be obtained |
default |
default value if key is missing |
namespace |
namespace of the option; default is |
path, app_root
|
root path to store the sessions; default is the
|
order |
whether to order the session by date created; choices are
|
session, x
|
session identification string, or session object; use
|
new |
whether to create a new session instead of using the most recent one, default is false |
page_title |
session web page title and logo text; can have length of either one (page title and logo text are the same); or length of two, with page title be the first element and logo text be the second. |
sidebar_open |
whether to open the side-bar by default; default
|
jupyter |
logical, whether to launch 'jupyter' instances when starting 'RAVE' sessions, or to stop the 'jupyter' instances when shutting down. It requires additional setups to enable 'jupyter' lab; see 'Installation Guide Step 3' in the 'RAVE' wiki page. |
jupyter_port |
port used by 'jupyter' lab, can be set by
|
as_job |
whether to launch the application as 'RStudio' job, default is true if 'RStudio' is detected; when running without 'RStudio', this option is always false |
launch_browser |
whether to launch browser, default is true |
single_session |
whether to enable single-session mode. Under this mode, closing the main frame will terminate 'RAVE' run-time session, otherwise the 'RAVE' instance will still open in the background |
returnValue |
passed to |
max_lines |
maximum number of log entries to return; default is 200 |
new_sessionreturns a session object with character
'session_id' and a function 'launch_session' to launch the
application from this session
use_sessionreturns a session object, the same as
new_session under the condition that corresponding session exists,
or raise an error if the session is missing
list_sessionreturns a list of all existing session objects under the session root
remove_sessionreturns a logical whether the corresponding session has been found and removed
if (interactive()) { sess <- new_session() sess$launch_session() all_sessions <- list_session() print(all_sessions) # Use existing session session_id <- all_sessions[[1]]$session_id sess <- use_session(session_id) sess$launch_session() # Remove session remove_session(session_id) list_session() }if (interactive()) { sess <- new_session() sess$launch_session() all_sessions <- list_session() print(all_sessions) # Use existing session session_id <- all_sessions[[1]]$session_id sess <- use_session(session_id) sess$launch_session() # Remove session remove_session(session_id) list_session() }
For examples and use cases, please check
new_rave_shiny_component_container.
presets_analysis_electrode_selector2( id = "electrode_text", varname = "analysis_electrodes", label = "Select Electrodes", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", pipeline_repository = "repository", start_simple = FALSE, multiple = TRUE ) presets_analysis_ranges( id = "analysis_ranges", varname = "analysis_ranges", label = "Configure Analysis", pipeline_repository = "repository", max_components = 2 ) presets_baseline_choices( id = "baseline_choices", varname = "baseline", label = "Baseline Settings", pipeline_repository = "repository", baseline_choices = c("Decibel", "% Change Power", "% Change Amplitude", "z-score Decibel", "z-score Power", "z-score Amplitude"), baseline_along_choices = c("Per frequency, trial, and electrode", "Across electrode", "Across trial", "Across trial and electrode") ) presets_condition_groups( id = "condition_groups", varname = "condition_groups", label = "Create Condition Contrast", pipeline_repository = "repository" ) presets_import_export_subject_pipeline( id = "im_ex_pipeline", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", pipeline_repository = "repository", settings_entries = c("loaded_electrodes", "epoch_choice", "epoch_choice__trial_starts", "epoch_choice__trial_ends", "reference_name"), fork_mode = c("exclude", "include") ) presets_import_setup_blocks( id = "import_blocks", label = "Format & session blocks", import_setup_id = "import_setup", max_components = 5 ) presets_import_setup_native( id = "import_setup", label = "Select project & subject" ) presets_loader_3dviewer( id = "loader_3d_viewer", height = "600px", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", loader_reference_id = "loader_reference_name", loader_electrodes_id = "loader_electrode_text", ... ) presets_loader_3dviewer2( id = "loader_3d_viewer", height = "600px", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", loader_electrodes_id = "loader_electrode_text", ... ) presets_loader_electrodes( id = "loader_electrode_text", varname = "loaded_electrodes", label = "Electrodes", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code" ) presets_loader_epoch( id = "loader_epoch_name", varname = "epoch_choice", label = "Epoch and Trial Duration", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", allow_stitch = FALSE ) presets_loader_project( id = "loader_project_name", varname = "project_name", label = "Project" ) presets_loader_reference( id = "loader_reference_name", varname = "reference_name", label = "Reference name", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", mode = c("default", "create") ) presets_loader_subject( id = "loader_subject_code", varname = "subject_code", label = "Subject", loader_project_id = "loader_project_name", checks = c("notch", "wavelet"), allow_new = FALSE ) presets_loader_subject_only( id = "loader_subject_code", varname = "subject_code", label = "Subject", multiple = FALSE ) presets_loader_sync_project_subject( id = "loader_sync_project_subject", label = "Sync subject from most recently loaded", varname = "loader_sync_project_subject", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", from_module = NULL, project_varname = "project_name", subject_varname = "subject_code" )presets_analysis_electrode_selector2( id = "electrode_text", varname = "analysis_electrodes", label = "Select Electrodes", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", pipeline_repository = "repository", start_simple = FALSE, multiple = TRUE ) presets_analysis_ranges( id = "analysis_ranges", varname = "analysis_ranges", label = "Configure Analysis", pipeline_repository = "repository", max_components = 2 ) presets_baseline_choices( id = "baseline_choices", varname = "baseline", label = "Baseline Settings", pipeline_repository = "repository", baseline_choices = c("Decibel", "% Change Power", "% Change Amplitude", "z-score Decibel", "z-score Power", "z-score Amplitude"), baseline_along_choices = c("Per frequency, trial, and electrode", "Across electrode", "Across trial", "Across trial and electrode") ) presets_condition_groups( id = "condition_groups", varname = "condition_groups", label = "Create Condition Contrast", pipeline_repository = "repository" ) presets_import_export_subject_pipeline( id = "im_ex_pipeline", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", pipeline_repository = "repository", settings_entries = c("loaded_electrodes", "epoch_choice", "epoch_choice__trial_starts", "epoch_choice__trial_ends", "reference_name"), fork_mode = c("exclude", "include") ) presets_import_setup_blocks( id = "import_blocks", label = "Format & session blocks", import_setup_id = "import_setup", max_components = 5 ) presets_import_setup_native( id = "import_setup", label = "Select project & subject" ) presets_loader_3dviewer( id = "loader_3d_viewer", height = "600px", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", loader_reference_id = "loader_reference_name", loader_electrodes_id = "loader_electrode_text", ... ) presets_loader_3dviewer2( id = "loader_3d_viewer", height = "600px", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", loader_electrodes_id = "loader_electrode_text", ... ) presets_loader_electrodes( id = "loader_electrode_text", varname = "loaded_electrodes", label = "Electrodes", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code" ) presets_loader_epoch( id = "loader_epoch_name", varname = "epoch_choice", label = "Epoch and Trial Duration", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", allow_stitch = FALSE ) presets_loader_project( id = "loader_project_name", varname = "project_name", label = "Project" ) presets_loader_reference( id = "loader_reference_name", varname = "reference_name", label = "Reference name", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", mode = c("default", "create") ) presets_loader_subject( id = "loader_subject_code", varname = "subject_code", label = "Subject", loader_project_id = "loader_project_name", checks = c("notch", "wavelet"), allow_new = FALSE ) presets_loader_subject_only( id = "loader_subject_code", varname = "subject_code", label = "Subject", multiple = FALSE ) presets_loader_sync_project_subject( id = "loader_sync_project_subject", label = "Sync subject from most recently loaded", varname = "loader_sync_project_subject", loader_project_id = "loader_project_name", loader_subject_id = "loader_subject_code", from_module = NULL, project_varname = "project_name", subject_varname = "subject_code" )
id |
input or output ID of the element; this ID will be prepended with module namespace |
varname |
variable name(s) in the module's settings file |
label |
readable label(s) of the element |
loader_project_id |
the ID of |
loader_subject_id |
the ID of |
pipeline_repository |
the pipeline name that represents the 'RAVE'
repository from functions such as
|
start_simple |
whether to start in simple view and hide optional inputs |
multiple |
whether to allow multiple inputs |
max_components |
maximum number of components for compound inputs |
baseline_choices |
the possible approaches to calculate baseline |
baseline_along_choices |
the units of baseline |
settings_entries |
used when importing pipelines, pipeline variable
names to be included or excluded, depending on |
fork_mode |
|
import_setup_id |
the ID of |
height |
height of the element |
loader_reference_id |
the ID of |
loader_electrodes_id |
the ID of |
... |
ignored, typically reserved for obsolete arguments |
allow_stitch |
whether to allow stitching the events |
mode |
whether to create new reference, or simply to choose from existing references |
checks |
whether to check if subject has been applied with 'Notch' filters or 'Wavelet'; default is both. |
allow_new |
whether to allow new subject to be created; ignored when checks exist |
from_module |
which module to extract input settings |
project_varname, subject_varname
|
variable names that should be extracted from the settings file |
A 'RAVEShinyComponent' instance.
new_rave_shiny_component_container
A button that triggers 'run_analysis' event;
see also get_rave_event
run_analysis_button( label = "Run analysis (Ctrl+Enter)", icon = NULL, width = NULL, type = "primary", btn_type = c("button", "link"), class = "", style = "", ... )run_analysis_button( label = "Run analysis (Ctrl+Enter)", icon = NULL, width = NULL, type = "primary", btn_type = c("button", "link"), class = "", style = "", ... )
label |
label to display |
icon |
icon before the label |
width, class, style, ...
|
passed to 'HTML' tag |
type |
used to calculate |
btn_type |
button style, choices are |
A 'HTML' button tag
observe functionSafely wrap expression x such that shiny application does
no hang when when the expression raises error.
safe_observe( x, env = NULL, quoted = FALSE, priority = 0L, domain = NULL, ..., error_wrapper = c("none", "notification", "alert"), watch_data = getOption("ravedash.auto_watch_data", FALSE) )safe_observe( x, env = NULL, quoted = FALSE, priority = 0L, domain = NULL, ..., error_wrapper = c("none", "notification", "alert"), watch_data = getOption("ravedash.auto_watch_data", FALSE) )
x, env, quoted, priority, domain, ...
|
passed to |
error_wrapper |
handler when error is encountered, choices are
|
watch_data |
whether to invalidate only when
|
'shiny' observer instance
values <- shiny::reactiveValues(A=1) obsB <- safe_observe({ print(values$A + 1) })values <- shiny::reactiveValues(A=1) obsB <- safe_observe({ print(values$A + 1) })
Deprecated. This function is no longer used by RAVE modules.
Cache small objects such as inputs or configurations.
shiny_cache(namespace, session = shiny::getDefaultReactiveDomain())shiny_cache(namespace, session = shiny::getDefaultReactiveDomain())
namespace |
characters, usually the module ID |
session |
shiny interactive context domain |
A caching object. The caching object is identical within the same context and namespace.
Check shiny inputs and modify if validation fails
shiny_check_input( inputId, check = NULL, on_check_fails, ..., quoted = FALSE, env = parent.frame(), logger_level = c("trace", "none", "debug", "info", "warning", "error"), session = shiny::getDefaultReactiveDomain() )shiny_check_input( inputId, check = NULL, on_check_fails, ..., quoted = FALSE, env = parent.frame(), logger_level = c("trace", "none", "debug", "info", "warning", "error"), session = shiny::getDefaultReactiveDomain() )
inputId |
character, input ID |
check |
either a function that takes the input value or a character
of a |
on_check_fails |
value to substitute when check fails, and the input
value will be the result of |
... |
passed to |
quoted |
whether |
env |
environment to evaluate |
logger_level |
log level when validation fails |
session |
shiny session; default is current session |
A shiny observe instance
if(interactive()) { library(ravedash) shiny::shinyApp( ui = shiny::basicPage( shiny::textInput("id1", "Enter a text"), shiny::textOutput("id2") ), server = function(input, output, session) { # input$id1 must have at least 1 character # the check uses `checkmate::check_character` shiny_check_input( "id1", check = "character", min.chars = 1, on_check_fails = "altered text" ) output$id2 <- shiny::renderText({ print(input$id1) sprintf("The final value is: %s", input$id1) }) } ) }if(interactive()) { library(ravedash) shiny::shinyApp( ui = shiny::basicPage( shiny::textInput("id1", "Enter a text"), shiny::textOutput("id2") ), server = function(input, output, session) { # input$id1 must have at least 1 character # the check uses `checkmate::check_character` shiny_check_input( "id1", check = "character", min.chars = 1, on_check_fails = "altered text" ) output$id2 <- shiny::renderText({ print(input$id1) sprintf("The final value is: %s", input$id1) }) } ) }
Shiny icons
shiny_iconsshiny_icons
The goal of create this list is to keep 'shiny' icons (which are essentially 'font-awesome' icons) up-to-date.
Provides simple layout, with inputs on the left, and outputs on the right. Only useful in 'shidashi' framework.
simple_layout( input_ui, output_ui, input_width = 4L, container_fixed = FALSE, container_style = NULL, scroll = FALSE )simple_layout( input_ui, output_ui, input_width = 4L, container_fixed = FALSE, container_style = NULL, scroll = FALSE )
input_ui |
the 'HTML' tags for the inputs |
output_ui |
the 'HTML' tags for the outputs |
input_width |
width of inputs, must be an integer from 1 to 11 |
container_fixed |
whether the maximum width of the container should be fixed; default is no |
container_style |
additional 'CSS' style of the container |
scroll |
whether to stretch the container to full-heights and scroll the input and output separately. |
'HTML' tags
library(shiny) library(ravedash) simple_layout( input_ui = list( ravedash::input_card( title = "Data Selection", "Add inputs here" ) ), output_ui = list( ravedash::output_card( title = "Result A", "Add outputs here" ) ) )library(shiny) library(ravedash) simple_layout( input_ui = list( ravedash::input_card( title = "Data Selection", "Add inputs here" ) ), output_ui = list( ravedash::output_card( title = "Result A", "Add outputs here" ) ) )
Create a random temporary file path for current session
temp_file( pattern = "file", fileext = "", persist = c("process", "app-session", "package-cache") ) temp_dir(check = FALSE, persist = c("process", "app-session", "package-cache"))temp_file( pattern = "file", fileext = "", persist = c("process", "app-session", "package-cache") ) temp_dir(check = FALSE, persist = c("process", "app-session", "package-cache"))
pattern, fileext
|
see |
persist |
persist level, choices are |
check |
whether to create the temporary directory |
R default tempdir usually gets removed once the R
process ends. This behavior might not meet all the needs for 'RAVE' modules.
For example, some data are 'RAVE' session-based, like current or last visited
subject, project, or state data (like bookmarks, configurations). This
session-based information will be useful when launching the same 'RAVE'
instance next time, hence should not be removed when users close R.
Other data, such as subject-related, or package-related should last even
longer. These types of data may be cache of subject power,
package-generated color schemes, often irrelevant from R or 'RAVE' sessions,
and can be shared across different 'RAVE' instances.
The default scheme is persist='process'. Under this mode, this
function behaves the same as tempfile. To store data in 'RAVE'
session-based manner, please use persist='app-session'.
The actual path will be inside of 'RAVE' session folder, hence this option
is valid only if 'RAVE' instance is running. When
'RAVE' instance is not running, the result falls back to
persist='process'. When persist='process',
To cache larger and session-irrelevant data, use 'package-cache'.
The 'RAVE' session and package cache are not cleared even when R process
ends. Users need to clean the data by themselves. See
remove_session or remove_all_sessions about
removing session-based folders, or
clear_cached_files to remove package-based cache.
A file or a directory path to persist temporary data cache
temp_dir() temp_dir(persist = "package-cache")temp_dir() temp_dir(persist = "package-cache")
Keep track of messages printed by modules
error_notification( cond, title = "Error found!", type = "danger", class = "error_notif", delay = 30000, autohide = TRUE, collapse = "\n", prefix = paste("Found the following error", "(details have been printed in the console):"), session = shiny::getDefaultReactiveDomain() ) error_alert( cond, title = "Error found!", type = "error", danger_mode = TRUE, auto_close = FALSE, prefix = paste("Found the following error", "(details have been printed in the console):"), buttons = "Confirm", session = shiny::getDefaultReactiveDomain() ) with_error_notification(expr, envir = parent.frame(), quoted = FALSE, ...) with_error_alert(expr, envir = parent.frame(), quoted = FALSE, ...)error_notification( cond, title = "Error found!", type = "danger", class = "error_notif", delay = 30000, autohide = TRUE, collapse = "\n", prefix = paste("Found the following error", "(details have been printed in the console):"), session = shiny::getDefaultReactiveDomain() ) error_alert( cond, title = "Error found!", type = "error", danger_mode = TRUE, auto_close = FALSE, prefix = paste("Found the following error", "(details have been printed in the console):"), buttons = "Confirm", session = shiny::getDefaultReactiveDomain() ) with_error_notification(expr, envir = parent.frame(), quoted = FALSE, ...) with_error_alert(expr, envir = parent.frame(), quoted = FALSE, ...)
cond |
condition to log |
type |
which type of logging should be set; default is |
class, title, delay, autohide
|
passed to |
collapse, danger_mode, auto_close, buttons
|
will be passed to
|
prefix |
additional messages to display in the notification or alert |
session |
shiny session |
expr |
expression to evaluate |
envir |
environment to evaluate |
quoted |
whether |
... |
passed to other methods |
The condition cond if errored out, or the evaluated results
Evaluate script in the background and show the results from shiny modal dialogue
with_log_modal( expr, quoted = FALSE, callback = NULL, title = "Running...", size = "l", session = shiny::getDefaultReactiveDomain(), ... )with_log_modal( expr, quoted = FALSE, callback = NULL, title = "Running...", size = "l", session = shiny::getDefaultReactiveDomain(), ... )
expr |
R expression to evaluate The script must be standalone |
quoted |
whether the expression has been quoted |
callback |
callback function to run once the evaluate finishes; must take one argument. The passed variable will be the evaluation results or an error condition (if error occurs) |
title, size
|
modal title and size, see |
session |
shiny session object |
... |
ignored, reserved for future use |
A promise object
# Shiny server function server <- function(input, output, session) { shiny::bindEvent( shiny::observe({ with_log_modal( title = "Roll the dice", expr = { for(i in 1:10) { Sys.sleep(runif(1, min = 0.5, max = 2)) cat(sprintf("Rolling dice result: %.0f\n", sample(6, 1))) } } ) return() }), input$btn, ignoreNULL = TRUE, ignoreInit = TRUE ) } if(interactive()) { shiny::shinyApp( ui = shiny::basicPage( shiny::actionButton('btn', "Click me") ), server = server, options = list(launch.browser = TRUE) ) }# Shiny server function server <- function(input, output, session) { shiny::bindEvent( shiny::observe({ with_log_modal( title = "Roll the dice", expr = { for(i in 1:10) { Sys.sleep(runif(1, min = 0.5, max = 2)) cat(sprintf("Rolling dice result: %.0f\n", sample(6, 1))) } } ) return() }), input$btn, ignoreNULL = TRUE, ignoreInit = TRUE ) } if(interactive()) { shiny::shinyApp( ui = shiny::basicPage( shiny::actionButton('btn', "Click me") ), server = server, options = list(launch.browser = TRUE) ) }