mne.preprocessing.find_ecg_events¶
- mne.preprocessing.find_ecg_events(raw, event_id=999, ch_name=None, tstart=0.0, l_freq=5, h_freq=35, qrs_threshold='auto', filter_length='10s', return_ecg=False, reject_by_annotation=True, verbose=None)[source]¶
Find ECG events by localizing the R wave peaks.
- Parameters
- rawinstance of
Raw
The raw data.
- event_id
int
The index to assign to found ECG events.
- ch_name
None
|str
The name of the channel to use for ECG peak detection. If
None
(default), ECG channel is used if present. IfNone
and no ECG channel is present, a synthetic ECG channel is created from the cross-channel average. This synthetic channel can only be created from MEG channels.- tstart
float
Start ECG detection after
tstart
seconds. Useful when the beginning of the run is noisy.- l_freq
float
Low pass frequency to apply to the ECG channel while finding events.
- h_freq
float
High pass frequency to apply to the ECG channel while finding events.
- qrs_threshold
float
|str
Between 0 and 1. qrs detection threshold. Can also be “auto” to automatically choose the threshold that generates a reasonable number of heartbeats (40-160 beats / min).
- filter_length
str
|int
|None
Number of taps to use for filtering.
- return_ecgbool
Return the ECG data. This is especially useful if no ECG channel is present in the input data, so one will be synthesized. Defaults to
False
.- reject_by_annotationbool
Whether to omit bad segments from the data before fitting. If
True
(default), annotated segments whose description begins with'bad'
are omitted. IfFalse
, no rejection based on annotations is performed.New in version 0.18.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). If used, it should be passed as a keyword-argument only.
- rawinstance of
- Returns
- ecg_events
array
The events corresponding to the peaks of the R waves.
- ch_ecg
str
Name of channel used.
- average_pulse
float
The estimated average pulse. If no ECG events could be found, this will be zero.
- ecg
array
|None
The ECG data of the synthesized ECG channel, if any. This will only be returned if
return_ecg=True
was passed.
- ecg_events
See also