gqrs detection


In [1]:
import wfdb
import numpy as np
import matplotlib.pyplot as plt

Max and Min Values


In [2]:
t0 = 10000
tf = 20000

Read the waveform info


In [3]:
folder = "p05/p050140"
waveform = "p050140-2188-07-26-05-51"
channel = [0]
record = wfdb.rdsamp(waveform,pbdir='mimic3wdb/matched/'+folder, sampfrom=t0, sampto=tf, channels=channel)

Check Record


In [4]:
plt.plot(np.array(record.p_signals[:,channel]))
plt.show()


Find the Peak indexes


In [5]:
d_signal = record.adc()[:,0]
peak_indices = wfdb.processing.gqrs_detect(x=d_signal, fs=record.fs, adcgain=record.adcgain[0], adczero=record.adczero[0], threshold=1.0)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-631258d701a6> in <module>()
----> 1 d_signal = record.adc()[:,0]
      2 peak_indices = wfdb.processing.gqrs_detect(x=d_signal, fs=record.fs, adcgain=record.adcgain[0], adczero=record.adczero[0], threshold=1.0)

/usr/local/lib/python3.4/dist-packages/wfdb/readwrite/_signals.py in adc(self, expanded)
    275                 d_signals[ch][chnanlocs] = dnans[ch]
    276         else:
--> 277             d_signals = self.p_signals * self.adcgain + self.baseline
    278 
    279             for ch in range(0, np.shape(self.p_signals)[1]):

TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

In [6]:
print(record.adcgain)


None

Fill empty params


In [7]:
record.adcgain = 1
record.adczero = 0
record.baseline = -1
d_signal = record.adc()[:,0]
peak_indices = wfdb.processing.gqrs_detect(x=d_signal, fs=record.fs, adcgain=record.adcgain[0], adczero=record.adczero[0], threshold=1.0)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-4fcac402ded2> in <module>()
      2 record.adczero = 0
      3 record.baseline = -1
----> 4 d_signal = record.adc()[:,0]
      5 peak_indices = wfdb.processing.gqrs_detect(x=d_signal, fs=record.fs, adcgain=record.adcgain[0], adczero=record.adczero[0], threshold=1.0)

/usr/local/lib/python3.4/dist-packages/wfdb/readwrite/_signals.py in adc(self, expanded)
    281                 nanlocs = np.isnan(self.p_signals[:,ch])
    282                 if nanlocs.any():
--> 283                     d_signals[nanlocs,ch] = dnans[ch]
    284 
    285             d_signals = d_signals.astype('int64')

TypeError: 'NoneType' object is not subscriptable