Skip to contents

Creates an interactive 3D mesh surface plot of EEG amplitude in one time point using plotly. The dense point mesh forms the 2D base, while the interpolated signal amplitude determines the 3D elevation and surface color.

Usage

interactive_surfaceplot(
  data,
  amplitude,
  mesh,
  coords = NULL,
  template = NULL,
  col_range = NULL,
  col_scale = NULL,
  show_sensors = TRUE
)

Arguments

data

A data frame, tibble, or a database table with input data to plot. It must contain at least two columns: sensor with sensor labels, and the column with the EEG amplitude specified in the argument amplitude.

amplitude

A character string specifying the name of the column from the input data containing EEG amplitude values.

mesh

A "mesh" object (or a named list with the same structure) containing at least a D2 element with x and y coordinates of a point mesh used for computing the IM model, and a template element specifying the sensor montage. If not defined, the point mesh with default settings from point_mesh function is used.

coords

Sensor coordinates as a tibble or data frame with named x, y and sensor columns. The sensor labels must match the labels in sensor column in data. If not defined, the template specified in mesh$template (or the default "HCGSN256") is used.

template

The kind of sensor template montage used. Available options are "HCGSN256", "biosemi128", "biosemi256", and "system1005". Default setting is "HCGSN256".

col_range

A vector with minimum and maximum value of the amplitude used in the colour palette for plotting. If not defined, the range of interpolated signal is used.

col_scale

Optionally, a colour scale to be utilised for plotting. If not defined, it is computed from col_range.

show_sensors

Logical. Indicates whether original sensor locations should be visualized as black scatter points on the 3D surface. Default is TRUE.

Value

A plotly widget object containing the interactive 3D surface plot.

Additionally, the returned object carries a "diegr_metadata" attribute with metadata such as details about the data and plot.

Examples

# \donttest{
# Prepare a data structure:
edata <- pick_data(epochdata, subject_rg = 2, epoch_rg = 1:13, time_rg = 1:10)
data_base <- baseline_correction(edata, baseline_range = 1:9)
data_mean <- compute_mean(data_base, amplitude = "signal_base", type = "point", domain = "space")

# Create an interactive 3D surface plot of average signal in time point 10:
data_mean |>
dplyr::filter(time == 10) |>
interactive_surfaceplot(amplitude = "average", col_range = c(-10, 10))
# }