grandaverage.bands: calculate value to plot the bands for an ERP plot.

Description Usage Arguments Value Author(s) See Also Examples

Description

This function can be used to calculate the values to plot error bands around an ERP. It calculates the bands fro the output of grandaverage.se, and of grandaverage.

Usage

1

Arguments

grandaverage

The object containing a grandaverage of ERPs (typically the output of grandaverage function of erpR)

grandaverage.se

The object containing the standard error of ERPs (typically the output of grandaverage.se function of erpR)

electrode

a character vector indicating the electrode on which calculate the band.

Value

A data frame with two columns: upper with the upper band, and lower with the lower band.

Author(s)

Giorgio Arcara

See Also

grandaverage,grandaverage.se

Examples

 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## Not run: 

######################################################
# LOAD AND PREPARE DATA FOR PLOTTING  ################
#####################################################
# load data
data(erplistExample)

# calculate grandaverage
word=grandaverage("Exp1_word_subj", 1:20, erplist=erplistExample)

# calcualte se
word.se = grandaverage.se ("Exp1_word_subj", 1:20, erplist=erplistExample)

# calculate bands on a given electrode
my_el = "FPZ"
myband = grandaverage.bands(word, word.se, my_el)


######################################################
# PLOT WITH ERP BANDS (ONLY ERPR FUNCTIONS AND BASE R)
#####################################################

# plot electrode
erp(word, my_el, smo=0, col="blue", startmsec=-200, endmsec=1500, ylim=c(-6,6))
# add band
polygon(x=c(1:length(word[,my_el]), length(word[, my_el]):1), 
  y = c(myband$lower, rev(myband$upper)), col=rgb(0.8, 0.8, 0.8,0.5))
# NOTE! I re-plot the electrode over.
erp.add(word, my_el, lwd=2) 

######################################################
# PLOT WITH ERP BANDS (WITH GGPLOT2)
#####################################################

require(ggplot2)


word=grandaverage("Exp1_word_subj", 1:20, erplist=erplistExample)
time = pointstomsec(1:dim(word)[[1]], startmsec=-500, 
  endmsec=1500, lengthsegment = dim(word)[[1]])

### WITH GGPLOT

ggplot(word, aes(time, FPZ))+
  geom_line(size=1)+
  #theme_bw()+
  geom_ribbon(data = myband, aes(ymin=lower,ymax=upper), alpha=0.3, col="darkgray") +
  theme(panel.grid.major=element_line(color="lightgray"), 
        panel.background = element_blank())


## End(Not run)

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