baselineCorr: Baseline correction

Description Usage Arguments Details Value See Also Examples

View source: R/erp_preprocess.R

Description

baselineCorr performs baseline correction, that is, it removes the average of the baseline amplitudes from the data.

Usage

1
2
3
4
5
6
7
baselineCorr(
  dat,
  pool_dim = "time",
  sep_dim = NULL,
  base_timerange = isPositive(negate. = TRUE),
  return_call = TRUE
)

Arguments

dat

numeric vector, matrix, or array containing the ERPs

pool_dim, sep_dim

numeric or character vector identifying the dimensions of dat whose dimension levels should be pooled or treated separately, respectively. Provide only pool_dim or sep_dim, but not both (the default is: pool_dim = "time"). See Details and Examples.

base_timerange

numeric or character vector, or a subsetting function from the is family of functions identifying time points which form the baseline. The default is isPositive(negate. = TRUE), which uses all time points up to zero. If NULL, all time points are included.

return_call

logical value whether the function call should be returned with additional informations (default: TRUE)

Details

Baseline correction is a standard step in ERP preprocessing. It means the subtraction of the average prestimulus voltage from the whole waveform. Usually baseline correction is done separately for each channel in each epoch, that is, each single ERP curve is corrected independently. baselineCorr allows to provide non-standard time windows and the pooling of dimensions (e.g., a common baseline is computed for all conditions).

Value

The function returns a numeric array with the same attributes as dat.

See Also

scaleArray for the function behind the scenes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# example dataset
data(erps)

# remove baseline activity - separately for each single time curve 
# (this is the default, but we explicitly include it for now) 
bc0 <- baselineCorr(erps, pool_dim = "time")

# remove baseline activity separately for each stimulus class, pairtype and 
# channel in each subject
bc1 <- baselineCorr(erps, sep_dim = c("stimclass", "pairtype", "chan", "id"))

# in the present case, the two calls give the same results, because
# the ERP dataset has these five dimensions
stopifnot(all.equal(bc0, bc1, check.attributes = FALSE)) 

# assume that the baseline is from -50 ms to 50 (silly example)
bc3 <- baselineCorr(erps, base_timerange = isBetween(-50, 50))

tdeenes/eegR documentation built on April 19, 2021, 4:17 p.m.