physioex.data.PhysicalScale#

class physioex.data.PhysicalScale(mode)[source]#

Bases: PreprocessingStep

Scale a channel using its EDF header (physical dimension / range).

Modes#

"mV"

Convert a voltage channel to millivolts from its header unit: uV/µV -> * 1e-3, mV -> * 1, V -> * 1e3. An unknown or blank unit leaves the signal unchanged (with a logged warning), which matches the historical convention that unrecognised units are already in the expected unit.

"range"

Map the header physical range to [-1, 1]: y = (x - (pmax + pmin) / 2) / (|pmax - pmin| / 2). A zero range (pmax == pmin) leaves the signal unchanged.

The EDF header is reached through the pipeline’s optional header argument (a dict with at least one of physical_dimension, physical_min, physical_max – see physioex.data.base.BasePhysioDataset._channel_header()). Steps that do not need the header ignore it. If the header is missing or lacks the fields the mode requires, the step logs a warning and passes the signal through unchanged.

The header values are recording-specific but the step’s parameters (mode) are not, so spec() (and thus pipeline.hash()) covers the step’s identity while the actual scale is fixed per cache entry by the source channel (cache files are keyed by physical channel).

Parameters#

modestr

"mV" or "range".

__init__(mode)[source]#
Parameters:

mode (str)

Methods

__init__(mode)

compile(fs_in[, header])

Precompute any expensive state and return a callable specialized for fs_in.

spec()

Return canonical, hashable text repr.

Attributes

needs_header

Keys of the channel-header dict this step consumes.

compile(fs_in, header=None)[source]#

Precompute any expensive state and return a callable specialized for fs_in.

header is an optional per-channel metadata dict (physical dimension, physical min/max, …) forwarded to steps that declare they need it (needs_header attribute, e.g. PhysicalScale). Steps that ignore it simply do not read it; the signature default keeps every existing compile(fs) call site working.

Parameters:
Return type:

CompiledStep

needs_header = True#

Keys of the channel-header dict this step consumes.

spec()[source]#

Return canonical, hashable text repr.

Format: ClassName(key1=val1,key2=val2,…) with sorted keys, floats normalized via f’{float(v):.10g}’.

Return type:

str

Parameters:

mode (str)