plotwindows: Plot statistics calculated by windows

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

Description

This function was designed to do charts of EEG data. Basically, the data (for each channel, class and recording) is divided by windows and a statistical function (as the mean or variance) is applied for all signals in each window. Then, the sequence of values obtained for each window is plotted.

Usage

1
2
3
plotwindows(data, classes.Id, rec.Id, which.classes = "ALL", 
which.rec = "ALL", which.channels = "ALL", win = 10, stat = "sum", 
power = 2, abs = FALSE, log = FALSE, complete = FALSE, mintomax = FALSE)

Arguments

data

is the data frame containing the EEG signals. The data frame must be organized as follows: each column represents a different channel. Thus, the signals collected by each channel are represented in each row. To identify the class and recording represented by each line, the vectors classes.Id and rec.Id should be given and must have length equal to the number of rows in the data frame.

classes.Id

is a vector with length equal to the number of rows in data. Thus each value in the array identifies the class ID of each signal in each row of the database. For example, let classes.Id = c(rep(1,5),rep(2,5)), this means that the first 5 rows of data represents the class with ID 1 and the lines 6 to 10 represent the class with ID 2.

rec.Id

is a vector with length equal to the number of rows in data. Thus each value in the array identifies the recording ID of each signal in each row of the database. For example, let rec.Id <- c(rep(1,5),rep(2,5)), this means that the first 5 rows of data represents the recording with ID 1 of some class and the lines 6 to 10 represent the recording with ID 2 of some class. rec.Id must be numeric and numerated from 1 to the total number of recordings for each class.

which.classes

a vector representing which classes will be plotted. For example, if which.classes= c(1,3) then the classes with ID 1 and 3 will be plotted (indicated by the vector classes.Id). If which.classes= "ALL" then all classes will be plotted. Obs: if type = "T.pvalue" then only two classes are allowed.

which.rec

a list representing which recordings shall be plotted for each class. For example, if which.rec= list(c(1,3,4),c(1,2,4)) then the recordings with ID 1,3 and 4 will be plotted for the first class indicated in the vector which.classes and the recordings with ID 1,2 and 4 will be plotted for the second class indicated in the vector which.classes. If which.rec="ALL" then all recordings will be plotted.

which.channels

a vector representing which channels shall be plotted. For example, if which.channels =c(1,3) then the channels 1 and 3 (columns 1 and 3 of data) will be plotted. If which.channels ="ALL" then all channels will be plotted.

win

the window size.

stat

is the statistic applied on the signals of each window. If stat= "sum" then the sum is used. If stat="mean" then the mean is used. If stat="var" then the variance is used. If stat="sd" then the standard deviation is used. If stat="max" then the maximum value is used. If stat="min" then the minimum value is used. If stat="prod" then the product is used. If stat= "median" then the median is used. If stat="geometric" then the geometric mean is used. If stat="harmonic" then the harmonic mean is used.

power

a transformation of the data can be performed before using the chosen statistic. In this case the transformation will be data^power. OBS: watch out for negative values if power is not an integer!

abs

a transformation of the data can be used before using the chosen statistic, in this case, if abs=TRUE, then the transformation will be abs(data)^power.

log

a transformation of the data can be used before using the chosen statistic, in this case, if log=TRUE and abs=TRUE, then the transformation will be log(abs(data) ^power+1). OBS: watch out for negative values if abs= FALSE

complete

if complete=FALSE, then the windows will be completely separated. For example, if win=10 then the first window will consist of signals 1 to 10, the second window will consist of signals 11 to 20, and so on. If complete=TRUE, then some signals will overlap in consecutive windows. For example, if win=10 then the first window will consist of observations 1 to 10, the second window will consist of observations 2 to 11, the third will consist of observations 3 to 12, and so on.

mintomax

if mintomax=FALSE then the function will plot each obtained value for each window in order. If mintomax=TRUE then the function will sort the obtained values for each window and then plot these values from minimum to maximum, and thus, providing a quantile analysis.

Value

data

Is a data frame with all the statistics computed by the function for each window. Arranged in the same way as the input parameter data.

classes.Id

Is a vector with the same meaning as the input parameter classes.Id but related to the output parameter data.

rec.Id

Is a vector with the same meaning as the input parameter rec.Id but related to the output parameter data.

Author(s)

Murilo Coutinho Silva (coutinho.stat@gmail.com), George Freitas von Borries

References

Brockwell, P.J., Davis, R.A. (2002) Introduction to Time Series and Forecasting. 2nd ed. Colorado: Springer. Cap. 4.

See Also

plotEEG

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(eegAnalysis)


### Simulating a data set
sim<-randEEG()


### Plotting the sum of the signals in windows of size 10
plotwindows(sim$data, sim$classes.Id , sim$rec.Id , which.classes = "ALL", which.rec="ALL",
            which.channels=c(1), win=10, stat="sum", power = 2, abs=FALSE, 
            log=FALSE,complete = FALSE, mintomax=FALSE) 

### Plotting the sorted sum of the signals in windows of size 10
plotwindows(sim$data, sim$classes.Id , sim$rec.Id , which.classes = "ALL", which.rec="ALL",
            which.channels=c(1), win=10, stat="sum", power = 2, abs=FALSE, 
            log=FALSE,complete = FALSE, mintomax=TRUE) 

eegAnalysis documentation built on Jan. 15, 2017, 4:03 p.m.