eegpsd {eegkit}R Documentation

Plots Power Spectral Density of EEG Data

Description

Uses a fast discrete Fourier transform (eegfft) to estimate the power spectral density of EEG data, and plots the power esimate using the plot (single channel) or imagebar (multi-channel) function.

Usage

eegpsd(x, Fs, lower, upper, units = "dB", 
       xlab = NULL, ylab = NULL, zlab = NULL, ...)

Arguments

x

Vector or matrix (time by channel) of EEG data with n time points.

Fs

Sampling rate of x in Hz.

lower

Lower band in Hz. Smallest frequency to keep.

upper

Upper band in Hz. Largest frequency to keep.

units

Units for plot. Options include "dB" for decibals (default), "mV" for microvolts, and "mV^2" for squared microvolts. Note dB = 10*log10(mV^2).

xlab

x-axis label for the plot/image.

ylab

y-axis label for the plot/image.

zlab

z-axis label for the plot/image.

...

Optional inputs for the plot or imagebar function.

Value

Produces a plot (single channel) or image (multi-channel).

Author(s)

Nathaniel E. Helwig <helwig@umn.edu>

References

Cooley, James W., and Tukey, John W. (1965) An algorithm for the machine calculation of complex Fourier series, Math. Comput. 19(90), 297-301.

Singleton, R. C. (1979) Mixed Radix Fast Fourier Transforms, in Programs for Digital Signal Processing, IEEE Digital Signal Processing Committee eds. IEEE Press.

Examples


##########   EXAMPLE   ##########

# create data generating signals
n <- 1000                             # 1000 Hz signal
s <- 2                                # 2 seconds of data
t <- seq(0, s, length.out = s * n)    # time vector
s1 <- sin(2*pi*t)                     # 1 Hz sinusoid
s5 <- sin(2*pi*t*5)                   # 5 Hz sinusoid
s10 <- sin(2*pi*t*10)                 # 10 Hz sinusoid
s20 <- sin(2*pi*t*20)                 # 20 Hz sinusoid

# create data
set.seed(1)                           # set random seed
e <- rnorm(s * n, sd = 0.25)          # Gaussian error
mu <- s1 + s5 + s10 + s20             # 1 + 5 + 10 + 20 Hz mean
y <- mu + e                           # data = mean + error

# plot psd (single channel)
eegpsd(y, Fs = n, upper = 30, t = "b")

# plot psd (multi-channel)
ym <- cbind(s1, s5, s10, s20)
eegpsd(ym, Fs = n, upper = 30, units = "mV")


[Package eegkit version 1.0-4 Index]