---
title: "How to start a `RAVE` dashboard"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{How to start a `RAVE` dashboard}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  eval = FALSE,
  comment = "#>"
)
```


## What's `RAVE` & `ravedash`

`RAVE` is an abbreviation for "R Analysis and Visualization of intracranial EEG", an integrated toolbox written in R for statistical rigorous and reproducible pipelines. The official wiki-page is at [rave wiki](https://openwetware.org/wiki/RAVE)

`ravedash` is the dashboard system for `RAVE` with the following goals:

* Easy to create and manage dashboard sessions
* Provides module templates and components to incorporate your own pipelines into the system

## Set up the templates

`ravedash` requires additional templates from [`RAVE` built-in pipelines](https://github.com/dipterix/rave-pipelines) (released under MIT license). You can always start with this template and expand from there.

To download the template, simply run the following one-time command:

```{r}
raveio::pipeline_install_github('dipterix/rave-pipelines')
```

## Manage the dashboard

To start a `ravedash` application, you need to create a session first.

```{r}
sess <- ravedash::new_session()
sess
```

To launch the session

```{r}
sess$launch_session()
```

A session is essentially a folder located on your hard drive. The folder contains a copy of all the modules that are currently installed as well as intermediate data, allowing you to always resume sessions from where it is left off (depends on the module implementation).

For example, it might take very long time to visually inspect hundreds of electrodes one-by-one. The `ravedash` session allows you to shutdown the application without losing the current configurations, and resume the analysis later on.

To resume the session, you can use `use_session` with the session ID, or simply list all the sessions using `list_session`.

```{r}
ravedash::list_session()
#> [[1]]
#> RAVE session <session-220619-155630-EDT-PB0P>
#>   Path: /Users/dipterix/rave_data/cache_dir/session-220619-155630-EDT-PB0P 
#>   Date created: 2022-06-19 15:56:30 EDT 
#> 
#> Please run `x$launch_session()` to launch the session.

sess <- ravedash::use_session("session-220619-155630-EDT-PB0P")
sess$launch_session()
```

## Develop your own modules

`RAVE` provides `RStudio` templates to extend modules. Please contact [help@rave.wiki](mailto:help@rave.wiki) and request for a demo. The official document is under development.

