Fit a damped rhythm¶
Question¶
Does a damped rhythm explain the changing signal?
See every package-generated example · Read the complete analysis pipeline
When to use¶
Use this when the rhythmic signal changes amplitude through the recording.
Example figure¶
This deterministic example is calculated by the damped_fit action and drawn by render_damped_fit_svg, the same renderer used for publication export. Empty or withheld elements are therefore visible exactly as they are in a real result.
import circadian_workbench as cw
cw.call("damped_fit", recording={"path": "mouse01.awd"})
Required inputs and controls¶
The public function is the registered action below. settings= is accepted as a friendlier alias for config= by cw.call; the calculation stores the complete normalized config in provenance.
Function reference¶
cw.call("damped_fit", recording, config=None, fit_baseline_degree='1', fit_max_degree=6, fit_model_selection='bic')
Arguments and parameters¶
| Name | Type | Required | Default | Units | Meaning |
|---|---|---|---|---|---|
recording |
recording spec | yes | — | - | The record to analyse: {'path': 'data/m01.awd'} (a bare path string also works), {'demo': true} for the built-in deterministic record, {'inline': {'filename': ..., 'text': ...}} for tabular text, {'trace': {'hours': [...], 'values': [...], 'name': ...}} for one elapsed-time trace, or {'channels': {'hours': [...], 'values': {'reporter_a': [...], 'reporter_b': [...]}}} for several measurements from one subject. A returned processed_trace spec retains transformed values, their original clock, source identity and explicit processing history. Versioned recording_snapshot specs are self-contained numeric inputs for replaying in-memory Recording objects; they do not invoke a raw-activity importer. |
config |
object | no | null |
- | Partial scientific settings. Omitted or None values use the shared installed defaults; invalid fresh values are rejected. Run describe_config for names, meanings, units, bounds and choices. Explicitly load old saved mappings with load_saved_settings to report compatibility conversions. |
fit_baseline_degree |
string | no | "1" |
- | Polynomial degree 0 through 6, or auto to compare degrees by the selected information criterion. |
fit_max_degree |
integer | no | 6 |
count | Highest polynomial degree considered when fit_baseline_degree is auto. |
fit_model_selection |
string | no | "bic" |
- | Information criterion for choosing a polynomial baseline: bic or aicc. |
Every nested config key, default, allowed value, and purpose is listed in the complete configuration reference.
How it works¶
A decaying cosine and a selected baseline are fitted to the time series.
$$ y(t)=b(t)+A e^{-kt}\cos(2\pi t/P+\phi) $$
Implementation: analysis.py::damped_fit.
Outputs and interpretation¶
The fit includes the fitted curve, baseline, oscillation and parameter estimates.
cw.call returns a Result: use .data for calculated values, .warnings for scientific qualifications, .provenance for version and input identity, .script for an equivalent replay script, and .files for saved outputs.
Limitations¶
Fit parameters can be poorly identified in short or irregular records; inspect convergence.
Example¶
The figure above is a real package result from a seeded, redistributable synthetic dataset. The flat gallery bundle retains figure_data_damped-rhythm.csv, a standalone plot_damped-rhythm.py, source hashes, an editable SVG, and a rendered preview.
Methods text¶
A damped cosine with a fitted baseline was evaluated against the selected trace.
See also¶
Compare period estimates · Test rhythmicity · Detect two circadian components · Analysis index · Gallery