m3resp.EMGPreset#

class m3resp.EMGPreset[source]#

Preprocess loaded EMG, remove ECG, detect breaths and calculate features.

Runs preprocessing, ECG peak detection and gating, the envelope of the gated signal, a moving baseline, breath detection and postprocessing in that order.

Config groups keyword arguments under preprocess, ecg_detect_peaks, ecg_gating, envelope, baseline, detect_breaths and postprocess. Envelope options are window_seconds and method; they default to the envelope settings preprocessing used. Baseline options are window_seconds (7.5 s by default), step_seconds (0.2 s) and percentile (33); other keys raise TypeError. ecg_detect_peaks.ecg_channel selects a reference ECG channel.

ecg_removal.enabled=False skips gating; cardiac activity can then remain in the envelope and derived measurements. Supplying ecg_removal.ecg_peak_indices gates known sample positions and skips peak detection. Supplied peaks and nonempty ecg_detect_peaks options are mutually exclusive.

Variables:

name (str) – Registered preset name, "emg".

Methods

run

Process loaded EMG and store breath events and measurements.

Attributes

name: str = 'emg'#
run(session, *, config=None)[source]#

Process loaded EMG and store breath events and measurements.

Parameters:
  • session (M3Session) – Session with EMG data already loaded.

  • config (PresetConfig | None) – Settings grouped as described in EMGPreset. None uses the operation defaults, including ECG gating and moving-baseline estimation before breath detection.

Returns:

The supplied session with processed signals, detected

breaths, parameters, quality flags and provenance.

Return type:

M3Session

Raises:
  • MissingModalityDataError – If the required EMG recording is unavailable.

  • TypeError – If ECG-removal options are unsupported or supplied ECG peaks conflict with peak-detection options.