find_frequency_peaks

find_frequency_peaks(spect, stimes, sfreqs, varargin)

PEAK PROMINENCE CALCULATION IN THE FREQUENCY DOMAIN

🔶

function used to calculate the peak prominence of the spectrum at each point in a spectrogram. Works by looking for activity in the designated frequency range. Normalizes the frequency values by dividing by a percentile of the the spectral values. The percentile can be calculated from a full night (artifact/wake-free sleep) or from a local segment with length of X minutes. By default, no normalization is applied since the prominence extraction implicitly takes care of the slow trend in the frequency domain.

Usage: [ fproms, ffreq, fwidth, x_fwidth, normalized_spectrogram ] = find_frequency_peaks(spectrogram,stimes,sfreqs,valid_time_inds,’<flag#1>’,<arg#1>…<flag#n>’,<arg#n>);

##### Declared Inputs: [[[NEEDS UPDATES!!!]]]

The following variables can be generated from the multitaper_spectrogram function:

  • scube: The spectrum at each time point. Format( Time X Frequency X Channels);

  • stimes: The time step vectors as defined by the mutlitaper

    spectrogram parameters.

  • sfreqs: The frequency step vector as defined by the mutlitaper

    spectrogram parameters.

Other Parameters:

  • stages: The sleep stages as a vector.

  • epochsize: The epochsize at which the stages were scored.

##### Optional Inputs:

  • ‘norm_method’: A string specifying what normalization

    method to use. Can be ‘percentile’ (default), ‘detrend’, or ‘none’ default: ‘percentile’

  • ‘peak_freq_range’: The range of frequencies to look for

    peak prominence values within. default: [9, 17]

  • ‘detrend_freq_range’: The range of frequencies to detrend

    the spectrum between. default: [6, 30]

  • ‘plot_on’: Whether to plot the spectrum for

    visulization. Note: will plot at every time step. default : false

  • ‘percent_num’: At which percentile to perform the

    normalization at. Will take the percentile at each frequency point. default : 3

  • ‘in_db’: Whether to employ findpeaks on spectrum

    at each time slice after converting to dB scale. default: false

  • ‘smooth_Hz’: Will complete a smoothing at each time

    slice of the spectrum before finding a peak in the spindle frequence range. Enter the number of Hz. default: 0

  • ‘local_norm_minutes’: Whether to perform the normalization of

    a spectrum basecd on the local spectral values versus the default which is the percentile calculated across the entire artifact/wake-free sleep recording. default: 0

  • ‘time_range’: Option to calculate only a portion of

    the night. default = [:] (full night)

##### Outputs:

In case of multiple channels, outputs will have multiple columns representing the multiple channel input.

  • fproms: The peak prominence values at each time

    point found in the designated frequency range.

  • ffreq: The frequency at which the peak was

    detected.

  • fwidth: The width of the peak that was detected in

    the spectrum. The width is in units Hz.

  • nscube: Normalized spectrogram in the specified

    detrend_freq_range.