Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 80 additions & 45 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,15 @@ Functions to manipulate, examine, and analyze model objects.
average_reconstructions
fit_models_3d

Component Objects
Model Sub-Objects
-----------------

The model object combines multiple sub-objects that define and store different
elements of the model definition, data, and results.

Here, the main sub-objects are listed, some of which can also be used independently.

Bands
~~~~~

An object for defining frequency band definitions.

.. currentmodule:: specparam

.. autosummary::
:toctree: generated/

Bands
elements of the model definition, data, and results. Here, the main sub-objects are listed.

Algorithm
~~~~~~~~~

An object for defining fit algorithms.

.. currentmodule:: specparam.algorithms.algorithm

.. autosummary::
Expand All @@ -102,77 +86,116 @@ An object for defining fit algorithms.
Modes
~~~~~

An object for defining fit modes.
.. currentmodule:: specparam.modes.modes

.. autosummary::
:toctree: generated/

Modes

.. currentmodule:: specparam.modes.mode
Data
~~~~

.. currentmodule:: specparam.data.data

.. autosummary::
:toctree: generated/

Mode
Data

Associated objects allow for defining mode parameters.
Results
~~~~~~~

.. currentmodule:: specparam.modes.params
.. currentmodule:: specparam.results.results

.. autosummary::
:toctree: generated/

ParamDefinition
Results

Utility to check for available fit modes.
Model Definitions
-----------------

.. currentmodule:: specparam.modes.definitions
Spectral models are defined by the defining fit Modes. This section

Mode
~~~~

The Mode object & related utilties, providing functionality for defining fit modes.

.. currentmodule:: specparam.modes

.. autosummary::
:toctree: generated/

Mode
ParamDefinition
check_modes

Metrics
~~~~~~~

An object for defining metrics.
Fit Functions (Aperiodic)
~~~~~~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: specparam.metrics.metric
.. currentmodule:: specparam.modes.funcs

.. autosummary::
:toctree: generated/

Metric
powerlaw_function
lorentzian_function
double_expo_function

Utility to check for available metrics.
Fit Functions (Peaks)
~~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: specparam.metrics.definitions
.. currentmodule:: specparam.modes.funcs

.. autosummary::
:toctree: generated/

check_metrics
gaussian_function
skewed_gaussian_function
cauchy_function
gamma_function
triangle_function

Data
~~~~
Metrics
-------

An object for managing data to be modeled.
The Metric object & related utilties, providing functionality for definining metrics to evaluate model fitting performance.

.. currentmodule:: specparam.data.data
Metric Object
~~~~~~~~~~~~~

.. currentmodule:: specparam.metrics

.. autosummary::
:toctree: generated/

Data
Metric

Results
~~~~~~~
Metric Functions (Error)
~~~~~~~~~~~~~~~~~~~~~~~~

An object for managing model results.
.. currentmodule:: specparam.metrics.error

.. currentmodule:: specparam.results.results
.. autosummary::
:toctree: generated/

compute_mean_abs_error
compute_mean_squared_error
compute_root_mean_squared_error
compute_median_abs_error

Metric Functions (GoF)
~~~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: specparam.metrics.gof

.. autosummary::
:toctree: generated/

Results
compute_r_squared
compute_adj_r_squared

Data Objects
------------
Expand Down Expand Up @@ -240,6 +263,18 @@ The following functions operate on arrays of peak parameters, which may be usefu
threshold_peaks
sort_peaks

Bands
~~~~~

An object for defining frequency band definitions.

.. currentmodule:: specparam

.. autosummary::
:toctree: generated/

Bands

Measures
--------

Expand Down
6 changes: 4 additions & 2 deletions examples/customize/plot_custom_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def expo_only_function(xs, *params):
xs : 1d array
X-axis values.
*params : float
Parameters that define the component fit.
Parameters that define the component fit: exponent.

Returns
-------
Expand Down Expand Up @@ -146,6 +146,7 @@ def expo_only_function(xs, *params):
name='custom_expo_only',
component='aperiodic',
description='Fit an exponent only.',
formula=r'A(F) = 1/f^x',
func=expo_only_function,
jacobian=None,
params=expo_only_params,
Expand Down Expand Up @@ -228,7 +229,7 @@ def rectangular_function(xs, *params):
xs : 1d array
X-axis values.
*params : float
Parameters that define the component fit.
Parameters that define the component fit: ctr, hgt, wid.

Returns
-------
Expand Down Expand Up @@ -270,6 +271,7 @@ def rectangular_function(xs, *params):
name='rectangular',
component='periodic',
description='Custom rectangular (boxcar) peak fit function.',
formula=None,
func=rectangular_function,
jacobian=None,
params=rectangular_params,
Expand Down
2 changes: 1 addition & 1 deletion examples/models/plot_model_component_relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from specparam.convert.params import compute_peak_height

# Import the default parameter conversions
from specparam.modes.convert import DEFAULT_CONVERTERS
from specparam.convert.definitions import DEFAULT_CONVERTERS

# sphinx_gallery_start_ignore
from specparam.plts.utils import check_ax
Expand Down
2 changes: 2 additions & 0 deletions specparam/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Metrics sub-module."""

from .metric import Metric
2 changes: 1 addition & 1 deletion specparam/metrics/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ def check_metrics():
print(' {:8s} {:12s} : {:s}'.format(metric.category, metric.measure, metric.description))


check_metric_definition = partial(check_selection, definition=Metric)
check_metric_definition = partial(check_selection, options=METRICS, definition=Metric)
4 changes: 2 additions & 2 deletions specparam/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from specparam.metrics.metric import Metric
from specparam.metrics.definitions import METRICS, check_metric_definition
from specparam.metrics.definitions import check_metric_definition
from specparam.reports.strings import gen_metrics_str

###################################################################################################
Expand Down Expand Up @@ -63,7 +63,7 @@ def add_metric(self, metric):
if isinstance(metric, dict):
metric = Metric(**metric)

metric = check_metric_definition(metric, METRICS)
metric = check_metric_definition(metric)

self.metrics.append(deepcopy(metric))

Expand Down
4 changes: 4 additions & 0 deletions specparam/modes/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
"""Functionality related to definining fit modes."""

from .mode import Mode
from .params import ParamDefinition
from .definitions import check_modes
Loading