Revision de un Dataset grande


In [1]:
import wfdb
import numpy as np

In [2]:
t0 = 1000
tf = 2000

In [21]:
carpeta = "p05/p050140"
onda = "p050140-2188-07-26-05-51"
sig, fields = wfdb.srdsamp(onda,pbdir='mimic3wdb/matched/'+carpeta, sampfrom=t0, sampto=tf)
channel = fields['signame'].index("II")
record = wfdb.rdsamp(onda,pbdir='mimic3wdb/matched/'+carpeta, sampfrom=t0, sampto=tf, channels = [channel])
record


Out[21]:
<wfdb.readwrite.records.Record at 0x7fbb605437b8>

In [22]:
fields


Out[22]:
{'comments': ['Location: micu'],
 'fs': 125,
 'signame': ['aVR', 'II', 'I', 'III', 'ABP', 'CVP', 'PLETH'],
 'units': ['mV', 'mV', 'mV', 'mV', 'mmHg', 'mmHg', 'NU']}

In [23]:
peaks_indexes = wfdb.processing.gqrs_detect(x=sig[:,0], frequency=fields['fs'], 
                                            adcgain= 0.8 #record.adcgain[0]
                                            , adczero= 0 #record.adczero[0] 
                                            ,threshold=1.0)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-23-75202f32520c> in <module>()
      2                                             adcgain= 0.8 #record.adcgain[0]
      3                                             , adczero= 0 #record.adczero[0]
----> 4                                             ,threshold=1.0)

/usr/local/lib/python3.4/dist-packages/wfdb/processing/gqrs.py in gqrs_detect(x, frequency, adcgain, adczero, threshold, hr, RRdelta, RRmin, RRmax, QS, QT, RTmin, RTmax, QRSa, QRSamin)
    485                 thresh=threshold)
    486     gqrs = GQRS()
--> 487     annotations = gqrs.detect(x=x, conf=conf, adczero=adczero)
    488     return [a.time for a in annotations]

/usr/local/lib/python3.4/dist-packages/wfdb/processing/gqrs.py in detect(self, x, conf, adczero)
    148         self.state = "RUNNING"
    149         self.t = t0 - self.c.dt4
--> 150         self.gqrs(t0, self.tf)
    151 
    152         return self.annotations

/usr/local/lib/python3.4/dist-packages/wfdb/processing/gqrs.py in gqrs(self, from_sample, to_sample)
    333             if self.countdown < 0:
    334                 if self.sample_valid:
--> 335                     self.qf()
    336                 else:
    337                     self.countdown = int(time_to_sample_number(1, self.c.freq))

/usr/local/lib/python3.4/dist-packages/wfdb/processing/gqrs.py in qf(self)
    220 
    221         # do this first, to ensure that all of the other smoothed values needed below are in the buffer
--> 222         dv2 = self.sm(self.t + self.c.dt4)
    223         dv2 -= self.smv_at(self.t - self.c.dt4)
    224         dv1 = int(self.smv_at(self.t + self.c.dt) - self.smv_at(self.t - self.c.dt))

/usr/local/lib/python3.4/dist-packages/wfdb/processing/gqrs.py in sm(self, at_t)
    206                 self.smv_put(smt, tmp)
    207             else:
--> 208                 v = int(self.at(smt))
    209                 for j in range(1, smdt):
    210                     smtpj = self.at(smt + j)

ValueError: cannot convert float NaN to integer

In [24]:
peaks_indexes


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-24-ece4f455a46a> in <module>()
----> 1 peaks_indexes

NameError: name 'peaks_indexes' is not defined

In [25]:
record.adc()


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-25-dbba364cb288> in <module>()
----> 1 record.adc()

/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 [ ]:
sigi = sig[:,fields['signame'].index("II")]
arrayNonNan = sigi[~np.isnan(sigi)]
arrayNonNan

In [ ]:
import matplotlib.pyplot as plt
XsavedArr = record.p_signals;
plt.plot(np.array(XsavedArr))
plt.show()

In [ ]: