readSensorLocs: Read Sensor Locations

readSensorLocsR Documentation

Read Sensor Locations

Description

Read sensor locations from an external file or select locations from a data frame.

Usage

readSensorLocs(
  source = "EEGlocations",
  type = c("besa", "elp", "eeglab", "xyz", "custom"),
  format = "",
  select = "all",
  plot = FALSE
)

getLocationsfromLabels(labels, plot = FALSE)

Arguments

source

Character string. The source file or data frame containing the sensor location coordinates. source can also be a complete URL. (For the supported URL schemes, see the ‘URLs’ section of the help for url). Alternatively, source may be an object of class sensorlocs or a compatible data frame from which sensor locations may be selected.
Default: EEGlocations, the sensorlocs object that comes with eegr.

type

Character string, only used if source denotes a filename. type describes the type of file that the sensor locations are read from. Can be any of:

besa

BESA spherical coordinates (3,4, or columns)

elp

alias for besa

eeglab

Cartesian coordinates as used in the EEGLAB package

xyz

Cartesian Polhemus coordinates

custom

custom input type, see the format parameter

format

Character string. Format of data to read when using a custom source type. The format string should consist of keyword-expression combinations of the form keyword = (expr). The keyword-expression combinations recognized are:

vars = (var1, var2, ...)

The variables to read from the file. Variables can be either label, theta, phi, x, y, z, or dummy, separated by commas. The variables should at least contain either theta and phi, or x, y, and z. A label is not required, but recognized.

adjust = (expr, expr, ...)

used for adjusting vars. expr is either an expression applied to the value read (e.g., '*-1'), or NULL. There should be just as many expressions as there are vars.

skiplines = (x)

number of header lines to skip

For example: format='vars = (theta, phi, label),}\cr \code{adjust = (*90/72, NULL, NULL), skip = (2)'

select

Numeric or character vector, only used if source denotes a data frame. Specify 'all' (default) to select all sensors from the source data frame. Alternatively, a character vector indicating the labels of the sensors to be selected (a variable named label should then be present in the data frame), or a numeric vector specifying the rows from the data frame to be selected.

plot

logical, default: FALSE. If TRUE, make a 2D plot of all sensor locations (top view, nose pointing upward). Alternatively plot may be an array of character strings denoting the sensor labels to plot.

labels

Character vector indicating the labels of the sensors to be selected

Details

The function readSensorLocs reads sensor coordinates from a variety of input sources. Some well-known file types are supported, such as BESA spherical coordinates, and EEGLAB and Polhemus Cartesian coordinates. These coordinate systems are converted by this function to the coordinate system used by eegr (see sensorlocs).

Alternatively, a data.frame may be specified as the source. This may be useful if standard sensor locations are used, of which a particular experiment uses a selection (see the select parameter).

In addition, sensor locations may be read from an external file with a custom format. In this case (type = 'custom'), the function expects a format string that specifies the coordinates (see the format argument).

Value

A data frame of class sensorlocs containing x, y, z, x2d, y2d, theta, phi in the eegr internal format. Other variables in the input data frame or matrix are copied unchanged to the outpuut data frame.

Author(s)

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

Examples

## Not run: 
  readSensorLocs ('/path/to/filename', type = 'besa', plot = TRUE)
  readSensorLocs ('/path/to/filename', type = 'xyz', plot = c('Fz', 'Cz', 'Pz'))
  readSensorLocs (source = '/somestrangeformat.txt', type = 'custom',
               format='vars = (theta, phi, dummy), adjust=(*90/72, NULL, NULL), skip = (2)')

## End(Not run)


locs <- getLocationsfromLabels(c('Fz', 'Cz', 'Pz'), plot = TRUE)


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