physioex.data.InterpResample#

class physioex.data.InterpResample(samples_per_epoch, epoch_sec=30.0)[source]#

Bases: PreprocessingStep

Linearly interpolate a signal onto a fixed time grid.

Output sample k (k = 0 .. n_out - 1) is the input value at time t_k = (k + 1) * epoch_sec / samples_per_epoch (seconds), where input sample i sits at time i / fs. The last output sample therefore lands exactly at the end of the covered window.

NaN input samples are dropped before interpolating; interior gaps are filled by linear interpolation between the surrounding valid samples (equivalent to pandas Series.interpolate(method="index", limit_area="inside")). Output times before the first or beyond the last valid input sample map to 0.0 (no extrapolation).

Output length is n_out = floor(len(x) / fs * samples_per_epoch / epoch_sec) and fs_out = samples_per_epoch / epoch_sec. The output is float32.

Parameters#

samples_per_epochint

Number of output samples per epoch_sec window (e.g. 1024 for a 30 s epoch at the wav2sleep grid).

epoch_secfloat

Window length in seconds (default 30.0).

__init__(samples_per_epoch, epoch_sec=30.0)[source]#
Parameters:
  • samples_per_epoch (int)

  • epoch_sec (float)

Methods

__init__(samples_per_epoch[, epoch_sec])

compile(fs_in[, header])

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

spec()

Return canonical, hashable text repr.

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

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:
  • samples_per_epoch (int)

  • epoch_sec (float)