cardioception.devices.beat_source.LSLBeatSource#

class cardioception.devices.beat_source.LSLBeatSource(recorder, detector=None)[source]#

R peaks found online in the ECG of an LSLRecorder.

Pulls the recorder’s inlet and feeds the samples of its channel to an OnlineRDetector. The anticipated period is the mean of the last 3 accepted RR intervals; an interval longer than MAX_RR is taken for a gap in the signal and starts the count again, and one outside RR_BAND times the median of the recent ones for a missed or extra beat, which is left out (see the module docstring).

While this source is in use it is the only reader of the inlet: do not call the recorder’s read, readInWaiting or waitBeat at the same time, they would take samples the detector never sees.

Parameters
recorder

A connected LSLRecorder (anything with inlet, channel and sfreq).

detector

An OnlineRDetector; one is made for the recorder’s rate if omitted.

__init__(recorder, detector=None)[source]#

Methods

__init__(recorder[, detector])

poll()

Beats committed since the last call.

start()

Drop what the inlet holds and start detecting from now.

stop()

Stop; the next start() begins afresh.

wait_next_beat(after[, timeout])

Block until a beat with r_time > after is found, or timeout s pass.

Attributes

period

virtual

This source follows a real heart.

n_rejected

RR intervals left out of the period as a missed or extra beat, since start().

n_samples

Samples fed to the detector since start().

last_sample_time

Clock time at which the last sample arrived.