API Documentation

API reference for the FOOOF module.

Table of Contents

Model Objects

Objects that manage data and fit the model to parameterize neural power spectra.

FOOOF Object

The FOOOF object is the base object for the model, and can be used to fit individual power spectra.

FOOOF([peak_width_limits, max_n_peaks, ...])

Model a physiological power spectrum as a combination of aperiodic and periodic components.

FOOOFGroup Object

The FOOOFGroup object allows for parameterizing groups of power spectra.

FOOOFGroup(*args, **kwargs)

Model a group of power spectra as a combination of aperiodic and periodic components.

Object Utilities

Functions to manipulate, examine and analyze FOOOF objects, and related utilities.

compare_info(fooof_lst, aspect)

Compare a specified aspect of FOOOF objects across instances.

average_fg(fg, bands[, avg_method, regenerate])

Average across model fits in a FOOOFGroup object.

average_reconstructions(fg[, avg_method])

Average across model reconstructions for a group of power spectra.

combine_fooofs(fooofs)

Combine a group of FOOOF and/or FOOOFGroup objects into a single FOOOFGroup object.

fit_fooof_3d(fg, freqs, power_spectra[, ...])

Fit FOOOF models across a 3d array of power spectra.

Data Objects

Objects to manage frequency bands, model information, and simulation parameters.

Bands Object

An object to handle frequency band definitions.

Bands([input_bands])

Frequency band definitions.

Model Information

Objects to store settings, metadata and results for power spectrum models.

FOOOFSettings(peak_width_limits, ...)

User defined settings for the fitting algorithm.

FOOOFRunModes(debug, check_freqs, check_data)

Checks performed and errors raised by the model.

FOOOFMetaData(freq_range, freq_res)

Metadata information about a power spectrum.

FOOOFResults(aperiodic_params, peak_params, ...)

Model results from parameterizing a power spectrum.

Simulation Parameters

Object to store information about simulated data.

SimParams(aperiodic_params, periodic_params, nlv)

Parameters that define a simulated power spectrum.

Analyze Model Results

Functions to analyze power spectrum models and the results parameters / components.

Analyze Model Errors

Functions for analyzing the error of model fits.

Object Inputs

The following functions take in FOOOF objects directly, which is the recommended approach.

compute_pointwise_error_fm(fm[, ...])

Calculate the frequency by frequency error of a model fit from a FOOOF object.

compute_pointwise_error_fg(fg[, ...])

Calculate the frequency by frequency error of model fits from a FOOOFGroup object.

Array Inputs

The following functions operate on arrays of models and data, which may be useful for more custom work-flows.

compute_pointwise_error(model, data)

Calculate point-wise error between original data and a model fit of that data.

Analyze Periodic Components

Functions for analyzing the periodic components of model fits.

Object Inputs

The following functions take in FOOOF objects directly, which is the typical use case.

get_band_peak_fm(fm, band[, select_highest, ...])

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

get_band_peak_fg(fg, band[, threshold, ...])

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

Array Inputs

The following functions operate on arrays of peak parameters, which may be useful for more custom work-flows.

get_band_peak(peak_params, band[, ...])

Extract peaks within a given band of interest.

get_band_peak_group(peak_params, band, n_fits)

Extract peaks within a given band of interest, from peaks from a group fit.

get_highest_peak(peak_params)

Extract the highest power peak.

threshold_peaks(peak_params, threshold[, param])

Extract peaks that are above a given threshold value.

Simulation Code

Code & utilities for simulating power spectra.

Generate Power Spectra

Functions for simulating neural power spectra.

gen_freqs(freq_range, freq_res)

Generate a frequency vector.

gen_power_spectrum(freq_range, ...[, nlv, ...])

Generate a simulated power spectrum.

gen_group_power_spectra(n_spectra, ...[, ...])

Generate a group of simulated power spectra.

Manage Parameters

Functions and objects for managing parameters for simulated power spectra.

Stepper(start, stop, step)

Object for stepping across parameter values.

param_iter(params)

Create a generator to iterate across parameter ranges.

param_sampler(params[, probs])

Create a generator to sample randomly from possible parameters.

param_jitter(params, jitters)

Create a generator that adds jitter to parameter definitions.

update_sim_ap_params(sim_params, delta[, field])

Update the aperiodic parameter definition in a SimParams object.

Transform Power Spectra

Functions for transforming power spectra.

translate_spectrum(power_spectrum, delta_offset)

Translate a spectrum, changing the offset value.

translate_sim_spectrum(power_spectrum, ...)

Translate a simulated spectrum, updating a SimParams object.

rotate_spectrum(freqs, power_spectrum, ...)

Rotate a power spectrum about a frequency point, changing the aperiodic exponent.

rotate_sim_spectrum(freqs, power_spectrum, ...)

Rotate a simulated power spectrum, updating a SimParams object.

compute_rotation_offset(delta_exponent, ...)

Calculate the change in offset from a given rotation.

compute_rotation_frequency(delta_exponent_b, ...)

Calculate the rotation frequency between two rotated power spectra.

Simulation Utilities

Utilities for simulating power spectra.

set_random_seed([seed_value])

Set the random seed value.

Plotting Functions

Visualizations.

Plot Power Spectra

Plots for visualizing power spectra.

plot_spectra(freqs, power_spectra[, ...])

Plot one or multiple power spectra.

Plots for plotting power spectra with shaded regions.

plot_spectra_shading(freqs, power_spectra, ...)

Plot one or multiple power spectra with a shaded frequency region (or regions).

plot_spectra_yshade(freqs, power_spectra[, ...])

Plot standard deviation or error as a shaded region around the mean spectrum.

Plot Model Properties & Parameters

Plots for visualizing periodic parameters and model components.

plot_peak_fits(peaks[, freq_range, colors, ...])

Plot reconstructions of model peak fits.

plot_peak_params(peaks[, freq_range, ...])

Plot peak parameters as dots representing center frequency, power and bandwidth.

Plots for visualizing aperiodic parameters and model components.

plot_aperiodic_fits(aps, freq_range[, ...])

Plot reconstructions of model aperiodic fits.

plot_aperiodic_params(aps[, colors, labels, ax])

Plot aperiodic parameters as dots representing offset and exponent value.

Plots for visualizing model error.

plot_spectral_error(freqs, error[, shade, ...])

Plot frequency by frequency error values.

Plot FOOOF Objects

Plots for visualizing models from FOOOF objects. Note that these are the same plotting functions that can be called from FOOOF objects directly.

plot_fm(fm[, plot_peaks, plot_aperiodic, ...])

Plot the power spectrum and model fit results from a FOOOF object.

plot_fg(fg[, save_fig, file_name, file_path])

Plot a figure with subplots visualizing the parameters from a FOOOFGroup object.

Annotated Plots

Annotated plots that describe the model and fitting process.

plot_annotated_model(fm[, plt_log, ...])

Plot a an annotated power spectrum and model, from a FOOOF object.

plot_annotated_peak_search(fm)

Plot a series of plots illustrating the peak search from a flattened spectrum.

Plot Utilities & Styling

Plot related utilies for styling and managing plots.

check_style_options()

Check the list of valid style arguments that can be passed into plot functions.

check_ax(ax[, figsize])

Check whether a figure axes object is defined, and define if not.

recursive_plot(data, plot_function, ax, **kwargs)

A utility to recursively plot sets of data.

save_figure(file_name[, file_path, close])

Save out a figure.

Utilities

Utility functions and objects.

Data Utilities

Utilities for working with data.

trim_spectrum(freqs, power_spectra, f_range)

Extract a frequency range from power spectra.

interpolate_spectrum(freqs, powers, interp_range)

Interpolate a frequency region in a power spectrum.

interpolate_spectra(freqs, powers, interp_range)

Interpolate a frequency region across a group of power spectra.

subsample_spectra(spectra, selection[, ...])

Subsample a group of power spectra.

Parameter Utilities

Utilities for working with parameters

compute_knee_frequency(knee, exponent)

Compute the frequency value of the knee given the aperiodic parameter values.

Input / Output (IO)

load_fooof(file_name[, file_path, regenerate])

Load a FOOOF file into a FOOOF object.

load_fooofgroup(file_name[, file_path])

Load data from file into a FOOOFGroup object.

Methods Reports

Utilities to creating methods reports.

methods_report_info([fooof_obj, concise])

Prints out a report of information required for methods reporting.

methods_report_text([fooof_obj])

Prints out a text template of methods reporting information.