reref | R Documentation |
Compute the average reference or a new common reference for data.
reref(
x,
fs = 1,
sensors = setdiff(colnames(x), "t"),
oldref = NULL,
newref = "robust",
saveref = FALSE,
interp = c("post-reference", "pre-reference", "none"),
estmean = c("median", "huber", "mean"),
sl = getLocationsfromLabels(colnames(x[, sensors])),
maxIter = 4
)
x |
input time series, specified as a numeric matrix or vector. In case
of a vector it represents a single signal; in case of a matrix each column
is a signal. Alternatively, an object of class |
fs |
sampling frequency of |
sensors |
vector of sensor names or numbers that are used for the calculations (hence they must contain EEG data). Default: all. |
oldref |
vector of sensor names or numbers that formed the original
reference. If specified, the old reference signal is reconstructed back
into the data object (added if it was not present in the data). Ignored if
|
newref |
signals that form the new reference, either specified as a
character vector of signal names ( |
saveref |
logical indication whether to save to new reference as a |
interp |
For |
estmean |
For |
sl |
For |
maxIter |
maximum number of iterations used for detecting noisy channels
and recomputing the reference. Default: 4. Only used in case |
The function reref
computes the mean of the new reference sensors and
subtracts that from the channels specified in sensors
. If the data
were originally referenced with respect to a sensor that is not present in
the data, then this sensor will be added, and it can be used in the new
reference.
Robust statistics can be used to compute the new reference (median or Huber
mean instead of arithmetic mean). In addition, reref
can use an
iterative procedure to remove bad channels before or after re-referencing,
which makes the re-referencing even more robust to outlier sensors. The
detection of noisy sensors is done using the noisysensors
function, using the default setup.
A list containing the following elements:
An object of the same class as the input, containing the
re-referenced data. Signals not included in sensors
are copied to
the output object. If saveref = TRUE
then the new reference is added
as a separate data channel (column). If the old reference was specified
through the oldref
parameters, and it was not also present in the
data, then it is also added.
the sampling frequency of y
the sensors that reref
operated on (on input)
the original reference sensor(s)
the new reference sensor(s)
logical indicating whether the new reference is saved
for robust referencing, the initial estimate of the mean
for robust referencing the instant of interpolating noisy sensors, either before or after re-referencing
for robust referencing, the number of iterations performed to detect noisy reference sensors
a list of sensors that were marked as bad by different
criteria (see noisysensors
)
Geert van Boxtel, G.J.M.vanBoxtel@gmail.com, based on Matlab code of the PREP pipeline by Nima Bigdely-Shamlo and colleagues.
Bigdely-Shamlo, N., Mullen, T.,, Kothe, C.,, Su, K.-M., and Robbins, K. A. (2015). The PREP pipeline: standardized preprocessing for large-scale EEG analysis. Frontiers in Neuroinformatics, 9, Article 16, https://www.frontiersin.org/article/10.3389/fninf.2015.00016.
Huber, P.J. (1981) Robust Statistics. Wiley.
noisysensors
, huber
avgref <- reref(EEGdata, sensors = 1:29, oldref = "M1",
newref = "average")
lmref <- reref(EEGdata, sensors = 1:29, oldref = "M1",
newref = "M1 M2")
## Not run:
rref <- reref(EEGdata, 1:29, "M1", "robust")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.