spectrogram: Plot the spectrogram of signal.

View source: R/eeg.R

spectrogramR Documentation

Plot the spectrogram of signal.

Description

'spectrogram' resamples signal and use the 'specgram' function from the 'signal' library to compute the spectrogram. Results resolution can be then reduced to quickly plot large signals.

Usage

spectrogram(
  signal,
  sRate,
  maxFreq = 25,
  n = 1024,
  window = n,
  overlap = 0,
  cols = c(rep("#3B9AB2", 9), "#78B7C5", "#EBCC2A", "#E1AF00", rep("#F21A00", 6)),
  freq = 4,
  plot = TRUE,
  startTime = as.POSIXct("1970/01/01 00:00:00")
)

Arguments

signal

Numerical vector of the signal.

sRate

Signal sample rate in Hertz.

maxFreq

Maximal frequency to plot in Hertz. Signal will be resampled at maxFreq*2 sample rate.

n

The size of the Fourier transform window.

window

Shape of the fourier transform window, defaults to n.

overlap

Overlap with previous window, defaults to 0.

cols

Color scale used for the underlying plot function.

freq

Aggregate frequency used to lower spectrogram resolution. Defaults to 4.

plot

Boolean, plot or not the spectrogram.

startTime

Posixct of the signal start. Adjust the x axis labels accordingly.

Value

A spectrogram.

Examples

library(signal)
spectrogram(chirp(seq(-2, 15, by = 0.001), 400, 10, 100, 'quadratic'),20,n=1024)

rsleep documentation built on Nov. 6, 2023, 1:06 a.m.