View source: R/interactive_waveforms.R
| interactive_waveforms | R Documentation |
Function for plotting time series of EEG signal colour-coded by epoch, channel or subject (depending on selected level) in an interactive plotly graph. When using the function for plotting the average, there is an option to add a confidence band using the CI argument. The output in plotly format enables to easily edit the image layout.
interactive_waveforms(
data,
amplitude = "signal",
subject = NULL,
channel = NULL,
FS = 250,
t0 = NULL,
col_palette,
level = "epoch",
avg = TRUE,
CI = FALSE,
use_latex = TRUE
)
data |
A data frame, tibble or a database table with input data containing a |
amplitude |
A character specifying the name of the column from input data with an EEG amplitude values. Default is |
subject |
A subject(s) chosen to plot. |
channel |
A channel(s) to plot. |
FS |
The sampling frequency. Default value is 250 Hz. |
t0 |
Index of the zero time point, i.e. point, where 0 ms should be marked (most often time of the stimulus or time of the response). |
col_palette |
Optionally, a colour palette for plotting lines. If missing, the rainbow palette is used. The expected length is the same (or higher) as the number of unique levels (e.g. number of epochs for |
level |
A character specifying the level of the time curves. The possible values are |
avg |
A logical value indicating, if the average black curve should be plotted. Default is |
CI |
A logical value indicating, if the confidence ribbon should be plotted. Default is |
use_latex |
A logical value indicating whether to use LaTeX formatting for the y-axis title. The default is |
The input data frame or database table must contain at least some of the following columns (according to the level parameter - for "sensor" level no epoch column is needed etc.):
subject - a column with subject IDs,
sensor - a column with sensor labels,
time - a column with time point numbers,
epoch - a column with epoch numbers,
signal (or other name specified in amplitude parameter) - a column with measured EEG signal values.
Note: The average signals must be pre-aggregated before plotting at higher grouping levels, for example sensor level assumes a mean sensor signal in the amplitude column (the input data for individual epochs together with sensor level setting will result in a mess output).
Plotting confidence ribbon:
To plot the confidence bands around the average lines (CI = TRUE), the input data must include the ci_up and ci_low columns (as in the output tibble from compute_mean function).
A plotly object showing an interactive time series of the signal according to the chosen level.
# 1) Plot epoch waveforms with average curve for subject 1 and electrode "E65"
# with 250 sampling frequency rate (default) and 10 as zero time point
interactive_waveforms(epochdata, amplitude = "signal", subject = 1, channel = "E65",
t0 = 10, level = "epoch")
# 2) Plot sensor level waveforms with confidence bands for subject 1 and electrodes "E65" and "E182"
# a) preparing data
sendata <- compute_mean(epochdata, amplitude = "signal", subject = 1, channel = c("E65", "E182"),
group = "time", level = "epoch")
# b) plot the waveforms without the average
interactive_waveforms(sendata, amplitude = "average", subject = 1, t0 = 10,
level = "sensor", avg = FALSE, CI = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.