Description Usage Arguments Details See Also Examples
align
transforms the ERP curves by aligning them on the time
dimension.
1 | align(erp, w, time_dim = "time")
|
erp |
the numeric vector or array of ERPs |
w |
the numeric vector or array of the warping weights (see
|
time_dim |
either a numeric or a character index indicating the time dimension of the ERP array (default: "time") |
This function is useful if the warping weights are computed on a
specific subset of the ERP data, but the whole array should be aligned using
these pre-computed weights. So the standard analysis pipeline is to call
warp
on the subset of the ERPs, store the computed weights in
an array, and call align
on the original (non-subsetted) array of ERPs
and the stored warping weights.
In the simplest case, erp
and w
are vectors. They must be of
equal length. In the second case, erp
and w
are arrays of
equal dimensions. In the third case, erp
is an array with more
dimensions than w
. In this scenario erp
and w
must
have named dimensions, and all dimension identifiers in w
must be
present in erp
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # load example data
data(erps)
# collapse stimclass and pairtype dimensions + downsample
x <- avgDims(erps, c("stimclass", "pairtype"))
x <- avgBin(x, "time", bin_length = 3L)
str(x)
# let's assume we want to align the individual ERPs so that the individual
# variation in the peak latencies can be controlled for;
# we will use the Global Field Power instead of warping the ERPs for each
# channel separately
w <- warp(compGfp(x), align_dim = "id", verbose = TRUE) # takes some time
# now perform the alignment on the original data
x_aligned <- align(x, w)
# bind the original and the aligned arrays
x_all <- bindArrays(raw = x, aligned = x_aligned, along_name = "warp")
# plot the GFP of the raw and aligned curves
plotERParray(compGfp(x_all), sepdim = "id",
minus_up = FALSE, grid = c(2, 1))
# repeat the above analysis with lambda = 1 to demonstrate how
# the lambda parameter affects the results
w <- warp(compGfp(x), align_dim = "id", lambda = 1) # takes some time
# now perform the alignment on the original data
x_aligned <- align(x, w)
# bind the new results to the previous array
x_all <- bindArrays(x_all, aligned_lambda1 = x_aligned, along_name = "warp")
# plot the GFP of the raw, the default aligned, and the new aligned curves
plotERParray(compGfp(x_all), sepdim = "id",
minus_up = FALSE, grid = c(3, 1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.