Skip to content

Compare measurement channels

Question

Do two channels keep the same period and lag?

See every package-generated example · Read the complete analysis pipeline

When to use

Use this for exactly two simultaneously sampled measurements from one subject, such as activity and body temperature.

Example figure

Compare measurement channels output generated by Circadian Workbench

This deterministic example is calculated by the channel_comparison action and drawn by render_channel_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.channels(hours, {"PER2": per2, "temperature": temperature}).compare()

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("channel_comparison", recording, channels, config=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.
channels array yes - Exactly two measurement channel keys from this recording, e.g. ["activity", "body_temperature"]. Use inspect to list what a recording carries.
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.

Every nested config key, default, allowed value, and purpose is listed in the complete configuration reference.

How it works

Each channel is binned using its own aggregation rule and receives an independent period estimate. Their analytic phases are then compared by the same two-trace phase-locking calculation used for pairwise coupling.

$$ |P_1-P_2|\leq\frac{P^2}{T}\quad\text{is required before lag is called a phase angle} $$

Implementation: analysis.py::channel_comparison.

Outputs and interpretation

The result reports both channel identities, units, aggregation rules and periods, their agreement resolution, phase lag and interval, phase-locking value, drift, coverage, and interpretation guard.

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

This is exactly a two-channel comparison, not a network analysis. When periods differ beyond the record's resolution, the average lag is explicitly not interpreted as a stable phase angle.

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_channel-comparison.csv, a standalone plot_channel-comparison.py and source hashes; these companion files are not installed application files.

Methods text

The two selected channels were binned by their declared aggregation rules, estimated independently for period, and compared by Hilbert phase difference and phase-locking value on their shared time grid.

See also

Measure population synchrony · Map phase across space · Measure pairwise coupling · Analysis index · Gallery