Skip to content

Commit

Permalink
Merge branch 'main' into basemodel
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Aug 3, 2024
2 parents 4cea065 + f48b849 commit 3599dbc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
26 changes: 16 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@
Spectral Parameterization
=========================

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

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

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

.. |BuildStatus| image:: https://github.com/fooof-tools/fooof/actions/workflows/build.yml/badge.svg
.. _BuildStatus: https://github.com/fooof-tools/fooof/actions/workflows/build.yml
: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
.. _Coverage: https://codecov.io/gh/fooof-tools/fooof
:target: https://codecov.io/gh/fooof-tools/fooof
:alt: coverage

.. |License| image:: https://img.shields.io/pypi/l/fooof.svg
.. _License: https://opensource.org/licenses/Apache-2.0
:target: https://opensource.org/licenses/Apache-2.0
:alt: license

.. |PythonVersions| image:: https://img.shields.io/pypi/pyversions/fooof.svg
.. _PythonVersions: https://pypi.python.org/pypi/fooof/

.. |Paper| image:: https://img.shields.io/badge/paper-nn10.1038-informational.svg
.. _Paper: https://doi.org/10.1038/s41593-020-00744-x
:target: https://pypi.python.org/pypi/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.

Expand Down
15 changes: 11 additions & 4 deletions specparam/plts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def set_alpha(n_points):
return alpha


def add_shades(ax, shades, colors='r', add_center=False, logged=False):
def add_shades(ax, shades, colors='r', alpha=0.2,
add_center=False, center_alpha=0.6, logged=False):
"""Add shaded regions to a plot.
Parameters
Expand All @@ -76,8 +77,13 @@ def add_shades(ax, shades, colors='r', add_center=False, logged=False):
Shaded region(s) to add to plot, defined as [lower_bound, upper_bound].
colors : str or list of string
Color(s) to plot shades.
alpha : float or list of float, optional, default: 0.2
The alpha level to add the shade regions with.
If a list, can specify a separate alpha level per shade.
add_center : boolean, default: False
Whether to add a line at the center point of the shaded regions.
center_alpha : float, optional, default: 0.6
The alpha level for the center line, if added.
logged : boolean, default: False
Whether the shade values should be logged before applying to plot axes.
"""
Expand All @@ -87,16 +93,17 @@ def add_shades(ax, shades, colors='r', add_center=False, logged=False):
shades = [shades]

colors = repeat(colors) if not isinstance(colors, list) else colors
alphas = repeat(alpha) if not isinstance(alpha, list) else alpha

for shade, color in zip(shades, colors):
for shade, color, alpha in zip(shades, colors, alphas):

shade = np.log10(shade) if logged else shade

ax.axvspan(shade[0], shade[1], color=color, alpha=0.2, lw=0)
ax.axvspan(shade[0], shade[1], color=color, alpha=alpha, lw=0)

if add_center:
center = sum(shade) / 2
ax.axvspan(center, center, color='k', alpha=0.6)
ax.axvspan(center, center, color='k', alpha=center_alpha)


def recursive_plot(data, plot_function, ax, **kwargs):
Expand Down
4 changes: 4 additions & 0 deletions specparam/tests/plts/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def test_add_shades(skip_if_no_mpl):

add_shades(check_ax(None), [4, 8])

@plot_test
def test_add_shades_multi(skip_if_no_mpl):
add_shades(check_ax(None), [[4, 8], [8, 12], [12, 25]], colors=['b', 'c', 'y'], alpha=0.3)

@plot_test
def test_recursive_plot(skip_if_no_mpl):

Expand Down

0 comments on commit 3599dbc

Please sign in to comment.