topoplot: Topographic Plot

topoplotR Documentation

Topographic Plot

Description

Draw a topographical plot of EEG data using spherical spline interpolation.

Usage

topoplot(
  x,
  sl,
  res = 200,
  scale = "auto",
  plot = c("sensorlocs", "legend"),
  col = (grDevices::colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F",
    "yellow", "#FF7F00", "red", "#7F0000")))(100),
  fmt = "%+f",
  xlab = "",
  ylab = "",
  main = "",
  ...
)

Arguments

x

Numeric array (coerced). The data to be interpolated and plotted. The number of data points should equal the number of sensors in the sl parameter.

sl

sensorlocs object, or data frame with sensor coordinates. Should at least contain the variables 'label', 'x2d' and 'y2d'.

res

Numeric. Resolution of the output grid, Default 200.

scale

Plot using this scale. Use "auto" (default) for automatic scaling; otherwise pass a pair of c(min, max), e.g., c(-40,40).

plot

Character. Specifies how the plot will look like. Levels are always plotted, "sensorlocs" plots sensor locations as dots, "legend" plots a legend at the right side of the plot, "contour" specifies contour lines with values in the plot, "labels" plots sensor labels, and "all" plots all of the above. Default: c("sensorlocs", "Legend").

col

color palette used for the map. Default: jet colors (as in Matlab), interpolated using colorRampPalette using 100 levels.

fmt

format statement, specified as a character value, passed to sprint to format the labels of the legend. See link{sprintf} for further detail. Default: "%+f".

xlab, ylab, main

labels passed too plotting function. Default: "".

...

Additional parameters passed to the plotting function.

Details

The function topoplot draws a topographical map of EEG data x recorded at sensors sens. Values in between sensor locations are interpolated using spherical splines. The plot may optionally include contour lines, sensor positions, sensor labels, and a legend. Scaling can be manual or automatic.

The function assumes the internal sensor coordinate system, which originates in the middle of the head (0,0,0). See sensorlocs

Multiple topoplots can also be combined on a single page or display, using appropriate par(mfrow = c()), par(mfcol = c()), or split.screen() commands. In such cases, you may want to draw a single legend for all graphs. To do so, do not specify plotting a legend in the constituent plots, but add the legends after plotting, as in the example below.

Value

A list with 4 components, returned invisibly:

x, y

vectors of x- and y- coordinates of the output grid, each 'res' values ranging from -200 to + 200.

z

matrix of fitted z-values, dimensions 400 x 400. The fitted value at an sensor location with coordinates x2d and y2d can be found at z[x2d, y2d].

zlim

range of z-values used in the interpolation

Author(s)

Geert van Boxtel, G.J.M.vanBoxtel@gmail.com

See Also

colorRampPalette

Examples

data("EEGdata")
ncoi <- 28
coi <- colnames(EEGdata)[1:ncoi]
sensors <- getLocationsfromLabels(labels = coi)

## scalp distributuon of two time points, Matlab-style 'jet' colors
col <- grDevices::colorRampPalette(c("#00007F", "blue",
                                     "#007FFF", "cyan",
                                     "#7FFF7F", "yellow",
                                     "#FF7F00", "red",
                                     "#7F0000"))(100)
op <- par(mfrow = c(1, 2))
topoplot (EEGdata[400, coi], sensors, scale = c(-10, 10), main="Sample #400",
          col = col, plot = "sensorlocs")
topoplot (EEGdata[450, coi], sensors, scale = c(-10, 10), main="Sample #450",
          col = col, plot = "sensorlocs")
par(op)
title("Example displaying two scalp maps")
usr <- graphics::par("usr")
plotrix::color.legend(xl = usr[2] + 0.15, yb = usr[3] + 0.35,
      xr = usr[2] + 0.35, yt = usr[4] - 0.35,
      rect.col = col, gradient="y", align="rb",
      legend = sprintf("%+2.0f", seq(-10, 10, length = 5)))

## this color scheme might be more appropriate for scalp plots
topoplot(EEGdata[400, coi], sensors, scale = c(-20, 20),
         col = grDevices::colorRampPalette(c("blue", "white", "red"))(50))


gjmvanboxtel/eegr documentation built on May 20, 2023, 4:26 a.m.