In [1]:
import numpy as np
import plotly.graph_objects as go

from scipy import signal, fft

from ecg import ECG
from wfdb_db_reader import WfdbDbReader
In [2]:

wfdb_db_reader = WfdbDbReader(ECG_SIGNALS_DIR)
ecg_inst = wfdb_db_reader.get_ecg('100')
Getting list of record names from './'...

ECG signal visualization of filtered and non-filtered signal

In [3]:
fig = go.Figure()

max_sample = ecg_inst.samp_freq * 10 # ten seconds of the signal
x_coords_to_max = ecg_inst.time[:max_sample]

                         mode='lines', name='raw signal'))

                         mode='lines', name='filtered signal'))

r_peaks_locs = ecg_inst.r_peaks_locs[ecg_inst.r_peaks_locs < max_sample]
fig.add_trace(go.Scatter(x=[ecg_inst.time[r_peak_loc] for r_peak_loc in r_peaks_locs],
                         y=[ecg_inst.signal[r_peak_loc] for r_peak_loc in r_peaks_locs],
                         mode='markers', name='R Peaks'))

fig.update_xaxes(title_text='Time (s)')
fig.update_yaxes(title_text='Voltage (mV)')
Learning initial signal parameters...
Found 8 beats during learning. Initializing using learned parameters
Running QRS detection...
QRS detection complete.