meeg_utils.qc.HeartRate#

class meeg_utils.qc.HeartRate(*, min_bpm=None, max_bpm=None, max_irregular=0.1)[source]#

Heart rate from the ECG channel (or MEG magnetometers), a test of the ECG.

Heartbeats are detected with mne.preprocessing.find_ecg_events() (MNE defaults; without an ECG channel MNE builds a synthetic ECG from the MEG magnetometers).

Whether the detection worked is judged from the intervals between beats, not from the rate: missed or spurious beats make them irregular (a missed beat doubles an interval). Intervals more than 30 % away from the median interval are counted; normal beat-to-beat variability at rest stays well below that. When too many are irregular the rate is not reported (heart_rate_bpm is None, reliable is False). With an ECG channel this is a "warn" (check the ECG electrodes); with the synthetic ECG it is "info", since the magnetometers often pick up the heart too weakly and nothing is wrong with the recording.

The rate itself is reported without a verdict by default: the normal adult resting range is 60-100 bpm, but trained people are often below 60 and children above 100.

Parameters:
  • min_bpm (float | None) – Range of the heart rate outside which it is flagged; None (default) does not judge the rate.

  • max_bpm (float | None) – Range of the heart rate outside which it is flagged; None (default) does not judge the rate.

  • max_irregular (float) – Fraction of irregular intervals above which the detection is unreliable. There is no published limit; 0.1 is this library’s choice. (Synthetic ECG from CTF magnetometers in HAD-MEEG gave a plausible-looking 86 bpm with intervals varying by 340 ms.)

metrics_#

heart_rate_bpm (None when unreliable), reliable, n_beats, rr_sd_ms, irregular_fraction and channel ("synthetic" when derived from MEG).

Type:

dict

Notes

Figures: "heartbeats" (heart rate over time and the average beat).

__init__(*, min_bpm=None, max_bpm=None, max_irregular=0.1)[source]#

Methods

__init__(*[, min_bpm, max_bpm, max_irregular])

compute(raw)

Measure the recording.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

not_applicable(raw)

Return why the check cannot run on raw, or None if it can.

plot([kind, inst])

Draw quality-control figures.

set_params(**params)

Set the parameters of this estimator.

Attributes

level

The worst verdict of the findings ("ok" if there are none).

modalities

Data types the check needs at least one of ("meg", "eeg").

name

Key of the check in reports.

plot_kinds

kind -> whether it needs data (inst).

systems

Acquisition systems the check applies to; None means all.

name: ClassVar[str] = 'heart_rate'#

Key of the check in reports.

plot_kinds: ClassVar[dict[str, bool]] = {'heartbeats': False}#

kind -> whether it needs data (inst). Each kind is drawn by a _plot_<kind>(inst, **kwargs) method.

Type:

Figures the object can draw once fitted

not_applicable(raw)[source]#

Return why the check cannot run on raw, or None if it can.

Parameters:

raw (Raw) – The recording.

Returns:

The reason, or None.

Return type:

str | None