mtspec: Multitaper Spectrum

View source: R/mtspec.R

mtspecR Documentation

Multitaper Spectrum

Description

Compute the multitaper spectrum of a vector or matrix.

Usage

mtspec(
  x,
  fs = 1,
  detrend = c("short-linear", "short-mean", "long-linear", "long-mean", "none"),
  w = 4,
  overlap = 0,
  tbw = 2,
  k = round(tbw * w - 1)
)

mtchan(chan, fs, detrend, n, overlap, tapers)

mtfft(dat, fs, tapers)

Arguments

x

input time series, specified as a numeric or complex vector. In case of a vector it represents a single signal; in case of a matrix each column is a signal. Alternatively, an object of class ctd

fs

sampling frequency of x in Hz. Default: 1. Overruled if x is a ctd object, in which case the sampling frequency is fs(x)

detrend

character string specifying detrending option; one of:

long-mean

remove the mean from the data before splitting into segments (default)

short-mean

remove the mean value of each segment

long-linear

remove linear trend from the data before splitting into segments

short-linear

remove linear trend from each segment

none

no detrending

w

length of sliding window (segments) in seconds. Default: 4

overlap

proportion of overlap between the segments. Default: 0

tbw

taper bandwidth, specified as a positive numeric value. Default: 2 Hz

k

number of tapers to use, specified as a positive numeric value. Default: tbw * w - 1

chan

single channel

n

segment length (nearest power of 2 for w)

tapers

tapers from dpss

dat

data

Details

The multitaper method is a method for spectral density estimation, which overcomes some of the limitations of conventional Fourier analysis. It is a periodogram-based method that uses multiple tapers, or windows, to form independent estimates of the spectral density to reduce variance of the spectral density estimate. The method uses Slepian or discrete prolate spheroidal sequences as tapers since these vectors are mutually orthogonal and possess desirable spectral concentration properties. They average out noise in the spectrum and reduce information loss at the edges of the window.

The package multitaper contains a more complete version of multitaper spectral analysis (function spec.mtm), which computes confidence intervals, F-tests , and more.

The present implementation uses sliding windows, i.e., overlapping segments, tapering each segment, and then averaging over tapered segments. The tapers are computed by the function dpss, with parameters n = w * fs (number of samples in sliding window), k = tbw * w - 1 (number of tapers), and nw = tbw * w / 2 (time bandwidth of the tapers).

The function mtspec computes the multitaper spectrum for a vector or matrix. It calls the function mtchan, which computes the multitaper spectrum for a single channel (no parameter checking).

Value

An object of class frd, containing the spectra

Author(s)

Geert van Boxtel, G.J.M.vanBoxtel@gmail.com, based on Matlab code by Tim Mullen's (2011) adaptation of the Chronux 2 toolbox (http://chronux.org/) for the cleanline plugin in EEGlab.

References

https://en.wikipedia.org/wiki/Multitaper

See Also

spec.mtm, dpss, frd

Examples

data(EEGdata)
sp <- mtspec(EEGdata[, 1:28], fs = fs(EEGdata), detrend = "short-linear")
plot(sp, yscale = "dB", main = "EEGdata")


gjmvanboxtel/eegr documentation built on May 20, 2023, 4:26 a.m.