SkillAgentSearch skills...

Fooof

Parameterizing neural power spectra into periodic & aperiodic components.

Install / Use

/learn @fooof-tools/Fooof

README

========================= Spectral Parameterization

|ProjectStatus| |Version| |BuildStatus| |Coverage| |License| |PythonVersions| |Publication|

.. |ProjectStatus| image:: https://www.repostatus.org/badges/latest/active.svg :target: https://www.repostatus.org/#active :alt: project status

.. |Version| image:: https://img.shields.io/pypi/v/fooof.svg :target: https://pypi.org/project/fooof/ :alt: version

.. |BuildStatus| image:: https://github.com/fooof-tools/fooof/actions/workflows/build.yml/badge.svg :target: https://github.com/fooof-tools/fooof/actions/workflows/build.yml :alt: build status

.. |Coverage| image:: https://codecov.io/gh/fooof-tools/fooof/branch/main/graph/badge.svg :target: https://codecov.io/gh/fooof-tools/fooof :alt: coverage

.. |License| image:: https://img.shields.io/pypi/l/fooof.svg :target: https://opensource.org/license/apache-2-0 :alt: license

.. |PythonVersions| image:: https://img.shields.io/pypi/pyversions/fooof.svg :target: https://pypi.org/project/fooof/ :alt: python versions

.. |Publication| image:: https://img.shields.io/badge/paper-nn10.1038-informational.svg :target: https://doi.org/10.1038/s41593-020-00744-x :alt: publication

Spectral parameterization (specparam, formerly fooof) is a fast, efficient, and physiologically-informed tool to parameterize neural power spectra.

WARNING: this Github repository has been updated to a major update / breaking change from previous releases, which were under the fooof name, and now contains major breaking update for the new specparam version of the code. The new version is not fully released, though a test version is available (see installation instructions below).

Overview

The power spectrum model conceives of a model of the power spectrum as a combination of two distinct functional processes:

  • An aperiodic component, reflecting 1/f like characteristics, with
  • A variable number of periodic components (putative oscillations), as peaks rising above the aperiodic component

This model driven approach can be used to measure periodic and aperiodic properties of electrophysiological data, including EEG, MEG, ECoG and LFP data.

The benefit of fitting a model in order to measure putative oscillations, is that peaks in the power spectrum are characterized in terms of their specific center frequency, power and bandwidth without requiring predefining specific bands of interest and controlling for the aperiodic component. The model also returns a measure of this aperiodic components of the signal, allowing for measuring and comparison of 1/f-like components of the signal within and between subjects.

specparam (upcoming version)


We are currently in the process of a major update to this tool, that includes a name changes (fooof -> specparam), and full rewrite of the code. This means that the new version will be incompatible with prior versions (in terms of the code having different names, and previous code no longer running as written), though note that the exact same procedures will be available (spectra can be fit in a way expected to give the same results), as well many new features.

The new version is called `specparam` (spectral parameterization). There is a release candidate available for testing (see installation instructions).

fooof (stable version)
~~~~~~~~~~~~~~~~~~~~~~

The fooof naming scheme, with most recent stable version 1.1 is the current main release, and is fully functional and stable, including everything that was introduced under the fooof name.

Which version should I use?
~~~~~~~~~~~~~~~~~~~~~~~~~~~

The previous release version, fooof, is fully functional, and projects that are already using it might as well stick with that, unless any of the new functionality in specparam is particularly important. For projects that are just starting, the new specparam version may be of interest if some of the new features are of interest (e.g. time-resolved estimations), though note that as release candidates, the release are not guaranteed to be stable (future updates may make breaking changes). Note that for the same model and settings, fooof and specparam should be exactly equivalent, so in terms of outputs there should be no difference in choosing one or the other.

Documentation
-------------

The `specparam` package includes a full set of code documentation.

specparam (upcoming version)

To see the documentation for the candidate 2.0 release, see here <https://specparam-tools.github.io/>_.

fooof (stable version)


Documentation is available on the
`documentation site <https://fooof-tools.github.io/>`_.

This documentation includes:

- `Motivations <https://fooof-tools.github.io/fooof/auto_motivations/index.html>`_:
  with motivating examples of why we recommend parameterizing neural power spectra
- `Tutorials <https://fooof-tools.github.io/fooof/auto_tutorials/index.html>`_:
  with a step-by-step guide through the model and how to apply it
- `Examples <https://fooof-tools.github.io/fooof/auto_examples/index.html>`_:
  demonstrating example analyses and use cases, and other functionality
- `API list <https://fooof-tools.github.io/fooof/api.html>`_:
  which lists and describes all the code and functionality available in the module
- `FAQ <https://fooof-tools.github.io/fooof/faq.html>`_:
  answering frequency asked questions
- `Glossary <https://fooof-tools.github.io/fooof/glossary.html>`_:
  which defines all the key terms used in the module
- `Reference <https://fooof-tools.github.io/fooof/reference.html>`_:
  with information for how to reference and report on using the module

Dependencies
------------

`specparam` is written in Python, and requires Python >= 3.7 to run.

It has the following required dependencies:

- `numpy <https://github.com/numpy/numpy>`_
- `scipy <https://github.com/scipy/scipy>`_ >= 0.19

There are also optional dependencies, which are not required for model fitting itself, but offer extra functionality:

- `matplotlib <https://github.com/matplotlib/matplotlib>`_ is needed to visualize data and model fits
- `tqdm <https://github.com/tqdm/tqdm>`_ is needed to print progress bars when fitting many models
- `pandas <https://github.com/pandas-dev/pandas>`_ is needed for exporting model fit results to dataframes
- `pytest <https://github.com/pytest-dev/pytest>`_ is needed to run the test suite locally

Installation
------------

specparam / fooof can be installed using pip.

specparam (test version)

To install the current release candidate version for the new 2.0 version, you can do:

.. code-block:: shell

$ pip install specparam

The above will install the most recent release candidate.

NOTE: specparam is currently available as a 'release candidate', meaning it is not finalized and fully released yet. This means it may not yet have all features that the ultimate 2.0 version will include, and things are not strictly guaranteed to stay the same (there may be further breaking changes in the ultimate 2.0 release).

fooof (stable version)


The current major release is the 1.X.X series, which is a breaking change from the prior 0.X.X series.

Check the `changelog <https://fooof-tools.github.io/fooof/changelog.html>`_ for notes on updating to the new version.

**Stable Version**

To install the latest stable release, use pip:

.. code-block:: shell

    $ pip install fooof

The module can also be installed with conda, from the conda-forge channel:

.. code-block:: shell

    $ conda install -c conda-forge fooof

**Development Version**

To get the current development version, first clone this repository:

.. code-block:: shell

    $ git clone https://github.com/fooof-tools/fooof

To install this cloned copy, move into the directory you just cloned, and run:

.. code-block:: shell

    $ pip install .

**Editable Version**

To install an editable version, download the development version as above, and run:

.. code-block:: shell

    $ pip install -e .

Other Language Support
----------------------

The original implementation of `specparam`, available in this repository, is implemented in Python.

If you wish to run specparam from another language, there are a couple potential options:

- a `wrapper`, which allows for running the Python code from another language
- a `reimplementation`, which reflects a new implementation of the specparam algorithm in another language

Below are listed some examples of wrappers and/or re-implementations in other languages (non-exhaustive).

Matlab
~~~~~~

In Matlab, there is a reimplementation available in common toolboxes:
- The `Brainstorm <https://neuroimage.usc.edu/brainstorm/Introduction>`_ toolbox has a reimplementation of specparam (see the `Brainstorm fooof tutorial <https://neuroimage.usc.edu/brainstorm/Tutorials/Fooof>`_)
- The `Fieldtrip <https://www.fieldtriptoolbox.org/>`_ toolbox also uses the same reimplementation (see the `Fieldtrip fooof tutorial <https://www.fieldtriptoolbox.org/example/fooof/>`_)

There is also a Matlab wrapper in the `fooof_mat <https://github.com/fooof-tools/fooof_mat>`_ repository.

Note that another option is to use Python FOOOF within a Matlab pipeline, as explored in the
`mat_py_mat <https://github.com/fooof-tools/mat_py_mat>`_ repository.

Other Languages
~~~~~~~~~~~~~~~

Other languages with wrappers include:

- Julia, for which there is a `fooof wrapper <https://juliahub.com/ui/Packages/PyFOOOF/Ng8hN/0.1.0>`_
- R, in which fooof can be run using `reticulate <https://rstudio.github.io/reticulate/>`_, as `shown here <https://github.com/fooof-tools/DevelopmentalDemo/tree/main/R>`_

Reference
---------

If you use this code in your project, please cite::

    Donoghue T, Haller M, Peterson EJ, Varma P, Sebastian P, Gao R, Noto T, Lara AH, Wallis JD,
    Knight RT, Shestyuk A, & Voytek B (2020). Parameterizing neur
View on GitHub
GitHub Stars427
CategoryProduct
Updated6d ago
Forks112

Languages

Python

Security Score

100/100

Audited on Apr 1, 2026

No findings