View source: R/frequency_analysis.R
compute_psd | R Documentation |
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.
compute_psd(data, ...) ## S3 method for class 'eeg_data' compute_psd( data, seg_length = NULL, noverlap = NULL, n_fft = NULL, method = "Welch", demean = TRUE, verbose = TRUE, ... ) ## S3 method for class 'eeg_epochs' compute_psd( data, seg_length = NULL, noverlap = NULL, n_fft = 256, method = "Welch", keep_trials = TRUE, demean = TRUE, verbose = TRUE, ... ) ## S3 method for class 'eeg_evoked' compute_psd( data, seg_length = NULL, noverlap = NULL, n_fft = 256, method = "Welch", demean = TRUE, verbose = TRUE, ... )
data |
Data to be plotted. Accepts objects of class |
... |
any further parameters passed to specific methods |
seg_length |
Length of rolling data segments. Defaults to |
noverlap |
Number of (sampling) points of overlap between segments. Must
be <= |
n_fft |
Length of FFT to be calculated in sampling points. See details. |
method |
Defaults to "Welch". No other method currently implemented. |
demean |
Remove channel/epoch means. TRUE by default. |
verbose |
Print informative messages. TRUE by default. |
keep_trials |
Include FFT for every trial in output, or average over them if FALSE. |
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 NULL, it defaults to 50\
Currently, a data frame with the PSD for each channel separately.
eeg_data
: Compute PSD for an eeg_data
object
eeg_epochs
: Compute PSD for an eeg_epochs
object
eeg_evoked
: Compute PSD for an eeg_evoked
object
Matt Craddock matt@mattcraddock.com
out <- compute_psd(demo_epochs) out <- compute_psd(demo_epochs, n_fft = 256, seg_length = 128)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.