This function generates spectrograms for Medtronic BrainSense time-domain signals across one or more data passes. Optionally, the user can select specific passes to plot, filter by frequency band, save the plots, and extract the underlying spectrogram data.
brain_sense_spectrogram(
dataset = NULL,
wl = 512,
ovlp = 75,
collevels = seq(-80, 0, by = 0.2),
save_as = NULL,
output_dir = getwd(),
passes = NULL,
band = NULL
)A list of data frames (invisible). Each data frame corresponds to one spectrogram and contains:
Time in seconds
Frequency in Hz
Spectral power in dB
Channel label
Pass index (i)
A JSON-like object (e.g., parsed with jsonlite::fromJSON()) containing Medtronic BrainSense data. If NULL, attempts to load the default dataset from the LeadSense package.
Integer. Window length for FFT. Default is 512.
Numeric. Overlap percentage between successive windows. Default is 75.
Numeric. A sequence of color levels for the spectrogram image (in dB). Default is seq(-80, 0, by = 0.2).
Character. File format to save plots ("png", "pdf", or "jpeg"). If NULL (default), plots are not saved.
Character. Path to the directory where plots will be saved. Default is current working directory.
Integer vector. Indices of passes to plot (e.g., c(1,3)). Default is NULL, which plots all available passes.
Character. One of "Delta", "Theta", "Alpha", "Beta", "Gamma". If provided, filters signal to this frequency band before generating the spectrogram.
WARNING: This function may be computationally intensive and take significant time to execute. Please wait until all plots are rendered.
brain_sense_spectrogram(dataset, passes = c(2), band = "Beta")
Run the code above in your browser using DataLab