erp.latency: calculate latency of several ERP data frames on a given time...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

This function calculates the peak latency on several ERP data frames. It returns the results in wide format (each electrode in a separate column) or in long format which is more suitable for standard statistical analysis in R (e.g. ANOVA). erp.latency applies the function mean to several ERP data frames with timepoints in rows and electrodes in columns. ERP data frames are expected to be named as a combination of strings specified in base and numbers.

Usage

1
2
3
erp.latency(base, numbers, win.ini, win.end, erplist = NULL, 
startmsec=NULL, endmsec=NULL, others=NULL, format="long", 
name.dep="Dep", name.newvar="electrode", peak.fun = "max", frac=1, ...)

Arguments

base

a string indicating the beginning of the name of the data.frame containing the ERP data.

numbers

the numbers of the subjects to be averaged by the function.

win.ini

the initial edge (in ms) of the window in which the peak latency has to be computed.

win.end

the final edge (in ms) of the window in which the peak latency has to be computed.

erplist

a list containing the ERP data frames specified in base and numbers.

startmsec

the start time (in ms) of the ERP data frames. It can be a negative value, indicating the baseline time frame.

endmsec

the end time (in ms) of the ERP data frames.

others

the names of other variables to be included in the returned data frame. Ignored if the format is "wide".

format

the output format. It may be "wide" or "long".

name.dep

the name of the dependent variable in the returned dataframe. Ignored if the format is "wide".

name.newvar

If the format is "long", the name of the new variable codifying the electrodes. Default is "electrode".

peak.fun

the function to calculate the peak. Available functions are max, min, localmax, localmin.

frac

To measure the "Fractional Peak Latency", this argument is number indicating the fraction of the peak maximum to be used to localize the peak. Default is 1, and the maximum (or minimum) peak is searched. If 0.5, the first peak before the maximum/mimimum, with 0.5 the size the maximum/minimum is searched.

...

arguments passed to the function specified in peak.fun.

Details

The function takes an ERP data frame with electrodes in separate columns as input. If the format is long, this function returns a data frame in long format ready for standard statistical analysis in R. The returned data frame has one column for the dependent variable and a new factor "electrode". The erpR functions localmax and localmin are written following Luck (2005).

Value

A ERP data frame with peak latency in long or wide format. Two more columns are added: the column Subject indicates the subject number; the column Subject_name reports the string retrieved from the comment of the data frame (see Details on import.erp).

Note

This function calls rearrange.

Author(s)

Giorgio Arcara

References

Luck, S., J. (2005). An Introduction to the Event-Related Potential Technique. Cambridge, Mass.: The MIT Press.

See Also

erp.mean, erp.peak, rearrange, max, min, localmax, localmin

Examples

1
2
3
4
5
6
data(erplistExample)

dat=erp.latency(base="Exp1_word_subj", numbers=1:20,
 win.ini=130, win.end=190, erplist=erplistExample,
others=c(condition="word", interval="130-190"), 
name.dep="Ampl", format="long", peak.fun=max)

erpR documentation built on June 7, 2019, 3 a.m.