physioex.data.steps.JonesECGPreprocess#

class physioex.data.steps.JonesECGPreprocess(line_freq=60.0, remove_clips=True, find_noise=True, archetypes_path=None)[source]#

Bases: PreprocessingStep

Full Jones et al. (2024) ECG preprocessing in a single step.

Turn one raw single-lead ECG channel (whole night, any fs) into the network input of physioex.models.jones_ecg.JonesECGNet: 256 Hz, scaled by the per-night R-wave normalization factor and clipped to [-1, 1].

Order of operations (MATLAB stage 2 -> stage 3 -> stage 5 scaling):

  1. remove_large_clips — loose-lead clipping mask removal;

  2. zero-phase Chebyshev-II high-pass (0.5 / 0.25 Hz, 0.1 / 60 dB);

  3. line-noise notch at line_freq (with the aliasing rules) plus up to 10 iterative extra-noise notches (if find_noise);

  4. resample to 256 Hz with resample_poly (p/q from Fraction(256/fs).limit_denominator());

  5. R-wave detection (local variation + template; archetypes when available) and normalization factor = 2 x P90 of per-beat max |x|;

  6. divide by the factor, clip to [-1, 1].

Parameters#

line_freqfloat

Mains frequency to notch (60.0 in the authors’ US data, 50.0 in EU data).

remove_clipsbool

Apply the loose-lead clip-mask removal.

find_noisebool

Run the iterative extra-noise notch search.

archetypes_pathstr, optional

Path to archetypes.mat. None (default) downloads it from the authors’ repository on first use. Deliberately excluded from spec() — a path must not change the cache hash.

Degenerate inputs (all zeros, fully clipped, no beats found) return zeros of the correct length with a warning instead of raising.

__init__(line_freq=60.0, remove_clips=True, find_noise=True, archetypes_path=None)[source]#
Parameters:
  • line_freq (float)

  • remove_clips (bool)

  • find_noise (bool)

  • archetypes_path (str | None)

Methods

__init__([line_freq, remove_clips, ...])

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:
  • line_freq (float)

  • remove_clips (bool)

  • find_noise (bool)

  • archetypes_path (Optional[str])