brain_sense_spectrogram {LeadSense} | R Documentation |
Plot BrainSense Spectrograms and Return Data (with Optional Band Filtering)
Description
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.
Usage
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
)
Arguments
dataset |
A JSON-like object (e.g., parsed with |
wl |
Integer. Window length for FFT. Default is 512. |
ovlp |
Numeric. Overlap percentage between successive windows. Default is 75. |
collevels |
Numeric. A sequence of color levels for the spectrogram image (in dB). Default is |
save_as |
Character. File format to save plots ("png", "pdf", or "jpeg"). If NULL (default), plots are not saved. |
output_dir |
Character. Path to the directory where plots will be saved. Default is current working directory. |
passes |
Integer vector. Indices of passes to plot (e.g., |
band |
Character. One of "Delta", "Theta", "Alpha", "Beta", "Gamma". If provided, filters signal to this frequency band before generating the spectrogram. |
Details
WARNING: This function may be computationally intensive and take significant time to execute. Please wait until all plots are rendered.
Value
A list of data frames (invisible). Each data frame corresponds to one spectrogram and contains:
- time
Time in seconds
- frequency
Frequency in Hz
- magnitude
Spectral power in dB
- channel
Channel label
- pass
Pass index (i)
Examples
brain_sense_spectrogram(dataset, passes = c(2), band = "Beta")