fooof.analysis.get_band_peak_fg

fooof.analysis.get_band_peak_fg(fg, band, threshold=None, thresh_param='PW', attribute='peak_params')[source]

Extract peaks from a band of interest from a FOOOFGroup object.

Parameters
fgFOOOFGroup

Object to extract peak data from.

bandtuple of (float, float)

Frequency range for the band of interest. Defined as: (lower_frequency_bound, upper_frequency_bound).

thresholdfloat

A minimum threshold value to apply.

thresh_param{‘PW’, ‘BW’}

Which parameter to threshold on. ‘PW’ is power and ‘BW’ is bandwidth.

attribute{‘peak_params’, ‘gaussian_params’}

Which attribute of peak data to extract data from.

Returns
2d array

Peak data. Each row is a peak, as [CF, PW, BW]. Each row represents an individual model from the input object.

Notes

The returned array keeps track of which model each extracted peak comes from, returning a [n_models, 3] array, with one peak returned per model.

  • To do so, this function necessarily extracts and returns one peak per model fit.

  • Each row reflects an individual model fit, in order, filled with nan if no peak was present.

If, instead, you wish to extract all peaks within a band, per model fit, you can do something like:

>>> peaks = np.empty((0, 3))
>>> for f_res in fg:  # doctest:+SKIP
...     peaks = np.vstack((peaks, get_band_peak(f_res.peak_params, band, select_highest=False)))

Examples

Extract alpha peaks from a FOOOFGroup object ‘fg’ that already has model results:

>>> alphas = get_band_peak_fg(fg, [7, 14])  # doctest:+SKIP

Extract peaks from a FOOOFGroup object ‘fg’, selecting those above a power threshold:

>>> betas = get_band_peak_fg(fg, [13, 30], threshold=0.1)  # doctest:+SKIP

Examples using fooof.analysis.get_band_peak_fg