Compare period estimates¶
Question¶
Which period estimate should I trust?
See every package-generated example · Read the complete analysis pipeline
When to use¶
Use this when a recording contains enough cycles for period estimation and the choice of estimator could change a downstream fold, phase, or model.
Example figure¶
This deterministic example is calculated by the compare_periods action and drawn by render_period_comparison_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.open("mouse01.awd").compare_periods(["lomb", "chi_square", "f"])
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("compare_periods", recording, config=None, methods=None)
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. |
methods |
array of strings | no | null |
- | Which period methods to compare, as a list of registry keys. Omit to use the config's period_methods. BioDare2's advice is to pair any method that cannot test significance (MESA, mFourFit, FFT-NLLS) with one that can (lomb), and discard the rest if the Lomb-Scargle periodogram rejects the record. |
Every nested config key, default, allowed value, and purpose is listed in the complete configuration reference.
How it works¶
The same selected and binned trace is sent to only the requested estimators. Lomb-Scargle is the sole default; fast Fourier transform nonlinear least squares, maximum entropy spectral analysis, mFourFit, spectrum resampling, chi-square, F, JTK_CYCLE, and empirical JTK_CYCLE are opt-in comparisons with different output contracts.
$$ \delta P \approx \frac{P^2}{T} $$
Implementation: period_methods.py::estimate_periods.
Outputs and interpretation¶
One row per method reports the estimated period and, where that method can supply them, uncertainty, phase, amplitude, relative amplitude error, goodness of fit, significance, and a rhythmic verdict. Empty cells mean that the method does not produce that quantity.
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¶
A short record cannot resolve nearby periods, a peak at the search boundary is weak evidence, and methods without a significance test must not be used to establish rhythmicity.
Example¶
The figure above is a real package result from a seeded, redistributable synthetic dataset. Its editable SVG embeds the exact plotted data and provenance and is included with a rendered preview in the installed help. The separate authoring bundle retains figure_data_compare-period-estimates.csv, a standalone plot_compare-period-estimates.py and source hashes; these companion files are not installed application files.
Methods text¶
Period estimators were applied to the same selected, binned trace over the declared search interval; only the explicitly requested methods were run, with Lomb-Scargle used by default.
See also¶
Test rhythmicity · Detect two circadian components · Track phase and period · Analysis index · Gallery