Skip to content

fixture

Build the fixture a conformance run needs from the configuration alone.

The recording is synthetic and satisfies what the configuration declares: the exact channels or the lowest acceptable number of each channel type, each at the lowest acceptable sample rate, slots filled in order. The manifest is the model the platform writes, with the configuration's parameter defaults, its cores, and the memory the platform would reserve for a recording of this length. An upstream events document and subject metadata are written when the configuration declares those inputs.

The recording also carries signals the configuration does not ask for, after the declared ones, as a polysomnogram does: ECG, oximetry, respiration, leg movements and the like. The manifest does not select them. An analysis that reads the whole file before keeping its channels then needs memory for all of them, which the peak a run reports makes visible.

With optional=False the fixture is the least a recording can offer: a channel type whose lower bound is 0 is left out, and every subject value is null, as it is for a study that records none.

:func:build_recording_fixture makes the same fixture from a real EDF recording cut or extended to a length, for measuring memory.

Fixture dataclass

What a run needs, on disk and in the container's terms.

output_file property

The host path of the document the container must write.

peak_file property

The host path where a measured run leaves its peak memory.

recording_file property

The host path of the recording.

PlannedChannel dataclass

One channel the fixture recording will carry.

label is what the file's header says; name is what the manifest says the user calls it. They differ on purpose: an analysis that attributes its output to header labels, or selects by them, then fails the check instead of passing by coincidence.

accepts_rate(config, rate_hz)

Whether every channel requirement of the configuration accepts a sample rate.

build_fixture(config, workdir, *, duration_seconds=300, seed=0, upstream_events=None, optional=True, channels=None, repeat_seconds=None)

Write the recording, the upstream inputs and the manifest under workdir.

Parameters:

Name Type Description Default
config AnalysisConfig

The analysis configuration the image is checked against.

required
workdir str | Path

An empty directory; alloc/ and local/ are created in it.

required
duration_seconds int

Length of the synthetic recording. Raised to the configuration's minimum_duration_seconds when that is longer.

300
seed int

Makes the recording reproducible.

0
upstream_events str | Path | None

An events document to give the container instead of a synthesised one, for a configuration that declares an events input.

None
optional bool

Include the optional channels and the subject values; False gives the least a recording can offer.

True
channels list[PlannedChannel] | None

The channels to write and select, instead of those :func:plan_channels chooses.

None
repeat_seconds int | None

Repeat the selected channels' samples after this many seconds, so that a recording of many hours is quick to write.

None

Returns:

Type Description
Fixture

The fixture, with host paths and the manifest that names them.

build_recording_fixture(config, workdir, *, source, seconds, most=False, upstream_events=None)

Write a fixture around a real recording cut or extended to seconds.

The copy carries every signal of the source; the manifest selects channels as :func:select_recording_channels chooses them and claims the memory the configuration projects for that selection and length.

Raises:

Type Description
ValueError

If the recording cannot satisfy the configuration, or the platform would refuse the selection.

has_optional(config)

Whether a recording may lack something the configuration reads.

plan_channels(config, *, optional=True, most=False, rate_hz=None)

Decide which channels the fixture recording carries.

Exact channels are written under their canonical names. A channel-type requirement contributes its lowest acceptable count, at least one, or one channel per declared slot when there are more slots than that, each at the lowest acceptable rate. With optional=False a type whose lower bound is 0 contributes nothing. A configuration without a recording input still gets one EEG channel, because the manifest always names a recording.

Parameters:

Name Type Description Default
config AnalysisConfig

The analysis configuration.

required
optional bool

Include the types whose lower bound is 0.

True
most bool

Each type contributes its highest acceptable count instead, or :data:MOST_PER_TYPE when the count has no upper bound.

False
rate_hz int | None

Every channel at this rate instead of its lowest acceptable one. The caller checks that the configuration accepts it.

None

select_recording_channels(config, header, *, most=False)

Choose channels of a real recording the way a user could select them.

An exact channel is the first signal that answers to its name or one of its alternatives. A channel type takes the first signals, in file order, whose label implies that type and whose rate the requirement accepts: its lowest count, or with most its highest (at most :data:MOST_PER_TYPE when unbounded, and at most what the file has). A type whose lower bound is 0 contributes nothing to the lowest selection.

Raises:

Type Description
ValueError

If the recording cannot satisfy the configuration.

undeclared_signals(channels, rate_hz)

List the signals a recording carries beside the planned channels.

Each is at rate_hz, and a label that one of the planned channels already uses, as its label or its name, is left out.