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_breathsandpostprocess. Envelope options arewindow_secondsandmethod; they default to the envelope settings preprocessing used. Baseline options arewindow_seconds(7.5 s by default),step_seconds(0.2 s) andpercentile(33); other keys raise TypeError.ecg_detect_peaks.ecg_channelselects a reference ECG channel.ecg_removal.enabled=Falseskips gating; cardiac activity can then remain in the envelope and derived measurements. Supplyingecg_removal.ecg_peak_indicesgates known sample positions and skips peak detection. Supplied peaks and nonemptyecg_detect_peaksoptions are mutually exclusive.- Variables:
name (str) – Registered preset name,
"emg".
Methods
Process loaded EMG and store breath events and measurements.
Attributes
- 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:
- 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.