physioex.data.XSleepNetSpectrogram#

class physioex.data.XSleepNetSpectrogram(nperseg=200, noverlap=100, nfft=256, window='hamming', log_scale=True, clip_db=None)[source]#

Bases: PreprocessingStep

STFT spectrogram with power-dB scaling, matching Huy Phan’s SeqSleepNet / XSleepNet / SleepTransformer preprocessing.

Pipeline:

signal -> STFT (Hamming, 2 s window, 50% overlap, 256-pt FFT)
        -> |X|^2       (power spectrum)
        -> 10*log10    (dB, power-scale)
        -> clip_db     (optional noise-floor removal, e.g. -25 dB)

Output shape: (..., T, F) where T = time bins, F = nfft//2 + 1. fs_out is set to 0 because the output is in the time-frequency domain (not a resampled time series).

Parameters#

npersegint

STFT window length in samples (default 200 = 2 s at 100 Hz).

noverlapint

STFT overlap in samples (default 100 = 1 s, 50%).

nfftint

FFT size (default 256).

windowstr

Window function name (default "hamming").

log_scalebool

If True (default), apply power-dB scaling: 10 * log10(|X|^2 + eps).

clip_dbfloat or None

If not None, clip the dB spectrogram at this floor value. Recommended -25 to suppress low-power noise introduced by filter stop-band leakage and zero-padding artifacts.

__init__(nperseg=200, noverlap=100, nfft=256, window='hamming', log_scale=True, clip_db=None)[source]#
Parameters:

Methods

__init__([nperseg, noverlap, nfft, window, ...])

compile(fs_in)

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

spec()

Return canonical, hashable text repr.

compile(fs_in)[source]#

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

Parameters:

fs_in (float)

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: