compute_psd: Compute power spectral density

Description Usage Arguments Details Value Methods (by class) Author(s) Examples

View source: R/frequency_analysis.R

Description

compute_psd returns the PSD calculated using Welch's method for every channel in the data. The output is in microvolts ^2 / Hz. If the object has multiple epochs, it will perform Welch's FFT separately for each epoch and then average them afterwards.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
compute_psd(data, ...)

## S3 method for class 'eeg_data'
compute_psd(data, seg_length = NULL,
  noverlap = NULL, n_fft = NULL, method = "Welch", ...)

## S3 method for class 'eeg_epochs'
compute_psd(data, seg_length = NULL,
  noverlap = NULL, n_fft = 256, method = "Welch",
  keep_trials = TRUE, ...)

## S3 method for class 'eeg_evoked'
compute_psd(data, seg_length = NULL,
  noverlap = NULL, n_fft = 256, method = "Welch", ...)

Arguments

data

Data to be plotted. Accepts objects of class eeg_data

...

any further parameters passed to specific methods

seg_length

Length of rolling data segments. Defaults to n_fft. Must be <= n_fft.

noverlap

Number of (sampling) points of overlap between segments. Must be <= seg_length.

n_fft

Length of FFT to be calculated in sampling points. See details.

method

Defaults to "Welch". No other method currently implemented.

keep_trials

Include FFT for every trial in output, or average over them if FALSE.

Details

Welch's FFT splits the data into multiple segments, calculates the FFT separately for each segment, and then averages over segments. Each segment is windowed with a Hanning window to counter spectral leakage. For epoched data, Welch's FFT is calculated separately for each trial.

The number of sampling points used for the FFT can be specified using n_fft. n_fft defaults to 256 sampling points for eeg_epochs data, or the minimum of 2048 or the length of the signal for continuous eeg_data.

seg_length defaults to be n_fft, and must be less than or equal to it.

noverlap specifies the amount of overlap between windows in sampling points. If not specified, it defaults to 50

Value

Currently, a data frame with the PSD for each channel separately.

Methods (by class)

Author(s)

Matt Craddock matt@mattcraddock.com

Examples

1
2
compute_psd(demo_epochs)
compute_psd(demo_epochs, n_fft = 256, seg_length = 128)

neuroconductor-devel-releases/eegUtils documentation built on May 5, 2020, 3:49 a.m.