physioex.data.InterpResample#
- class physioex.data.InterpResample(samples_per_epoch, epoch_sec=30.0)[source]#
Bases:
PreprocessingStepLinearly interpolate a signal onto a fixed time grid.
Output sample
k(k = 0 .. n_out - 1) is the input value at timet_k = (k + 1) * epoch_sec / samples_per_epoch(seconds), where input sampleisits at timei / 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 to0.0(no extrapolation).Output length is
n_out = floor(len(x) / fs * samples_per_epoch / epoch_sec)andfs_out = samples_per_epoch / epoch_sec. The output is float32.Parameters#
- samples_per_epochint
Number of output samples per
epoch_secwindow (e.g. 1024 for a 30 s epoch at the wav2sleep grid).- epoch_secfloat
Window length in seconds (default 30.0).
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.
headeris an optional per-channel metadata dict (physical dimension, physical min/max, …) forwarded to steps that declare they need it (needs_headerattribute, e.g.PhysicalScale). Steps that ignore it simply do not read it; the signature default keeps every existingcompile(fs)call site working.- Parameters:
- Return type: