rdrecord的使用:
import matplotlib.pyplot as plt
import wfdb
record = wfdb.rdrecord('sample-data/a103l')
plt.plot(record.p_signal[0: 500, 0])
plt.plot(record.p_signal[500: 1000, 1])
plt.plot(record.p_signal[49500: 50000, 2])
plt.show()
rdsamp的使用:
from IPython.display import display
import matplotlib.pyplot as plt
import numpy as np
import os
import shutil
import wfdb
# Demo 2 - Read certain channels and sections of the WFDB record using the simplified 'rdsamp' function
# which returns a numpy array and a dictionary. Show the data.
signals, fields = wfdb.rdsamp('sample-data/s0010_re', channels=[14, 0, 5, 10], sampfrom=100, sampto=15000)
display(signals)
display(fields)
运行结果如下:
[[ 0.0335 -0.167 -0.237 0.1165]
[ 0.0355 -0.1615 -0.2395 0.119 ]
[ 0.0385 -0.168 -0.2465 0.116 ]
...
[-0.0445 0.008 0.033 0.045 ]
[-0.044 0.0175 0.042 0.052 ]
[-0.044 0.0245 0.0365 0.05 ]]
{'comments': ['age: 81', 'sex: female', 'ECG date: 01/10/1990', 'Diagnose:', 'Reason for admission: Myocardial infarction', 'Acute infarction (localization): infero-latera', 'Former infarction (localization): no', 'Additional diagnoses: Diabetes mellitus', 'Smoker: no', 'Number of coronary vessels involved: 1', 'Infarction date (acute): 29-Sep-90', 'Previous infarction (1) date: n/a', 'Previous infarction (2) date: n/a', 'Hemodynamics:', 'Catheterization date: 16-Oct-90', 'Ventriculography: Akinesia inferior wall', 'Chest X-ray: Heart size upper limit of norm', 'Peripheral blood Pressure (syst/diast): 140/80 mmHg', 'Pulmonary artery pressure (at rest) (syst/diast): n/a', 'Pulmonary artery pressure (at rest) (mean): n/a', 'Pulmonary capillary wedge pressure (at rest): n/a', 'Cardiac output (at rest): n/a', 'Cardiac index (at rest): n/a', 'Stroke volume index (at rest): n/a', 'Pulmonary artery pressure (laod) (syst/diast): n/a', 'Pulmonary artery pressure (laod) (mean): n/a', 'Pulmonary capillary wedge pressure (load): n/a', 'Cardiac output (load): n/a', 'Cardiac index (load): n/a', 'Stroke volume index (load): n/a', 'Aorta (at rest) (syst/diast): 160/64 cmH2O', 'Aorta (at rest) mean: 106 cmH2O', 'Left ventricular enddiastoli