bandSpectra: Average Spectra within Frequency Bands

Description Usage Arguments Value Author(s) See Also Examples

Description

Given a matrix of spectra, where each row gives the power at each frequency, create banded spectra by averaging across columns within frequency bands.

Usage

1
bandSpectra(spectra, breaks = NULL, labels = NULL, ...)

Arguments

spectra

A matrix of spectra with numeric column names (as returned by readSpectra), or column names that can be coerced to numeric once any characters other than 0-9 and “.” are removed.

breaks

The break points between the frequency bands.

labels

Labels for the frequency bands.

...

Further arguments passed to cut.

Value

A matrix of banded spectra.

Author(s)

Heather Turner

See Also

gslcca

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## apply to arbitrary matrix to average over column groups
M <- matrix(1:12, 3, 4)
colnames(M) <- 1:4
## aggregate first two and last two columns
## (colnames <= 2, or colnames > 2)
bandSpectra(M, breaks = 2) 

## apply to clonidine experiment
data(clonidine)
colnames(clonidine$spectra)

banded <- bandSpectra(clonidine$spectra, breaks = c(4, 8, 10, 13, 15, 20, 28), 
             labels = c("delta", "theta", "alpha1", "alpha2", "not named",
                        "beta1", "beta2", "gamma"))
## run gslcca
result <- gslcca(banded, "Critical Exponential",
    time = Time, treatment = Treatment, subject = Rat, separate = FALSE,            
    subject.smooth = 4, data = clonidine)
                 
plot(result, "fitted")
plot(result, "signatures")

gslcca documentation built on May 2, 2019, 5:46 p.m.