Skip to content

channels

Channel related data types.

ChannelIdentitySource = Literal['label', 'user'] module-attribute

Where a channel's identity came from: read from its label, or set by a person.

ChannelLaterality = Literal['left', 'right'] module-attribute

Which body side a channel records; a slot may require one.

ChannelType

Bases: str, Enum

Represents the type of a single signal (EDF+ labels) + types such as MASTOID and UNKNOWN.

References

See https://www.edfplus.info/specs/edftexts.html

infer_from_signal_name(signal_name, exact_edf_label_only=True) classmethod

Infer the ChannelType from a signal name.

In strict (default) mode, only the leading EDF+ label token is inspected (e.g. "EEG Fpz-Cz" → EEG, "Fpz-Cz" → UNKNOWN). With exact_edf_label_only=False, a regex-based classifier inspects the full name and handles the realistic set of PSG signal labels: EEG (standard 10-20 electrodes, referenced or not), EOG, EMG, ECG/EKG, respiratory (RIP, pressure flow/snore, airflow, etc.), SpO2/SaO2, temperature, light, and mastoid references.

Referenced montages like "E1:M2" (EOG referenced to a mastoid) are classified by falling back to the electrode before the colon when the full-name match is ambiguous.

Parameters:

Name Type Description Default
signal_name str

The signal name to infer the ChannelType from.

required
exact_edf_label_only bool

If True, only match the leading EDF+ label token. If False, fall through to regex-based classification.

True

Returns:

Type Description
ChannelType

The inferred ChannelType.

Examples:

>>> ChannelType.infer_from_signal_name("EEG Fpz-Cz")
<ChannelType.EEG: 'EEG'>
>>> ChannelType.infer_from_signal_name("E1:M2", exact_edf_label_only=False)
<ChannelType.EOG: 'EOG'>
>>> ChannelType.infer_from_signal_name("SpO2", exact_edf_label_only=False)
<ChannelType.SAO2: 'SAO2'>

PhysicalDimension

Bases: str, Enum

Represents the physical dimension of a signal (EDF+ labels).

References

See https://www.edfplus.info/specs/edftexts.html

infer_from_string(dimension_str, exact_edf_label_only=True) classmethod

Infer the PhysicalDimension from a string.

If the string does not match any known PhysicalDimensions, return PhysicalDimension.UNKNOWN.

Parameters:

Name Type Description Default
dimension_str str

The string to infer the PhysicalDimension from.

required
exact_edf_label_only bool

If True, only use the EDF+ label to infer the PhysicalDimension. If False, uses a normalization map to infer the PhysicalDimension from the string.

True

Returns:

Type Description
PhysicalDimension

The inferred PhysicalDimension.

Examples:

>>> PhysicalDimension.infer_from_string("uV")
<PhysicalDimension.MICROVOLT: 'uV'>