You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+17-329
Original file line number
Diff line number
Diff line change
@@ -9,355 +9,43 @@ wfdb-python
9
9
Introduction
10
10
------------
11
11
12
-
Native python scripts for reading and writing WFDB signals and annotations. Package to be expanded with other useful functionalities.
12
+
The native Python waveform-database (WFDB) package. A library of tools for reading and writing WFDB signals and annotations, and general physiological signal processing.
13
13
14
+
Core components of this package are based on the original WFDB specifications:
15
+
16
+
|`WFDB Software Package`_
17
+
|`WFDB Applications Guide`_
18
+
|`WFDB Header Specifications`_
19
+
|`WFDB Signal Specifications`_
20
+
|`WFDB Annotation Specifications`_
14
21
15
22
Installation
16
23
------------
17
24
18
-
The distribution is hosted on pypi and directly installable via pip without needing clone or download this repository. Note that the pypi package does not contain the demo scripts or the example data. To install the package from pypi, run from your terminal:
25
+
The distribution is hosted on pypi at: https://pypi.python.org/pypi/wfdb/ and directly installable via pip without needing clone or download this repository. Note that the pypi package does not contain the demo scripts or the example data. To install the package from pypi, run from your terminal:
19
26
``pip install wfdb``
20
27
21
-
Download or clone this repository https://github.com/MIT-LCP/wfdb-python for the latest development version, the demo scripts, and the example data. To install the downloaded package, change directory into the base directory of the repository and run:
28
+
Download or clone this repository: https://github.com/MIT-LCP/wfdb-python for the latest development version, the demo scripts, and the example data. To install the downloaded package, navigate to the base directory of the repository and run:
22
29
``pip install .``
23
30
24
31
25
-
Usage
26
-
-----
27
-
28
-
See the **demo.ipynb** file for example cases.
29
-
30
-
31
-
32
-
Converting between Analog and Digital Values
33
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34
-
35
-
When reading signal sample values into ``record`` objects using ``rdsamp``, the samples are stored in either the ``p_signals`` or the ``d_signal`` field depending on the specified return type (``physical`` = ``True`` or ``False`` respectively).
36
-
37
-
One can also use existing objects to obtain physical values from digital values and vice versa, without having to re-read the wfdb file with a different set of options. The two following instance methods perform the conversions.
38
-
39
-
40
-
**adc** - Performs analogue to digital conversion of the physical signal stored in p_signals if expanded is False, or e_p_signals if expanded is True. The p_signals/e_p_signals, fmt, gain, and baseline fields must all be valid. If inplace is True, the adc will be performed inplace on the variable, the d_signal/e_d_signal attribute will be set, and the p_signals/e_p_signals field will be set to None.
41
-
42
-
::
43
-
44
-
record.adc(self, expanded=False, inplace=False)
45
-
46
-
Input arguments:
47
-
48
-
- ``expanded`` (default=False): Boolean specifying whether to transform the e_p_signals attribute (True) or the p_signals attribute (False).
49
-
- ``inplace`` (default=False): Boolean specifying whether to automatically set the object's corresponding digital signal attribute and set the physical signal attribute to None (True), or to return the converted signal as a separate variable without changing the original physical signal attribute (False).
50
-
51
-
Possible output argument:
52
-
53
-
- ``d_signal``: The digital conversion of the signal. Either a 2d numpy array or a list of 1d numpy arrays.
54
-
55
-
Example Usage:
56
-
57
-
::
58
-
59
-
import wfdb
60
-
record = wfdb.rdsamp('sampledata/100')
61
-
d_signal = record.adc()
62
-
record.adc(inplace=True)
63
-
record.dac(inplace=True)
64
-
65
-
66
-
**dac** - Performs digital to analogue conversion of the digital signal stored in d_signal if expanded is False, or e_d_signal if expanded is True. The d_signal/e_d_signal, fmt, gain, and baseline fields must all be valid. If inplace is True, the dac will be performed inplace on the variable, the p_signals/e_p_signals attribute will be set, and the d_signal/e_d_signal field will be set to None.
67
-
68
-
::
69
-
70
-
record.dac(self, expanded=False, inplace=False)
71
-
72
-
Input arguments:
73
-
74
-
- ``expanded`` (default=False): Boolean specifying whether to transform the e_d_signal attribute (True) or the d_signal attribute (False).
75
-
- ``inplace`` (default=False): Boolean specifying whether to automatically set the object's corresponding physical signal attribute and set the digital signal attribute to None (True), or to return the converted signal as a separate variable without changing the original digital signal attribute (False).
76
-
77
-
Possible output argument:
78
-
79
-
- ``p_signals``: The physical conversion of the signal. Either a 2d numpy array or a list of 1d numpy arrays.
80
-
81
-
Example Usage:
82
-
83
-
::
84
-
85
-
import wfdb
86
-
record = wfdb.rdsamp('sampledata/100', physical=False)
87
-
p_signal = record.dac()
88
-
record.dac(inplace=True)
89
-
record.adc(inplace=True)
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
Signal Processing
107
-
-----------------
108
-
109
-
Basic Functionalities
110
-
~~~~~~~~~~~~~~~~~~~~~
111
-
112
-
**resample_sig** - Resample a single-channel signal
**compute_hr** - Compute instantaneous heart rate from peak indices and signal frequency.
316
-
317
-
::
318
-
319
-
compute_hr(siglen, peak_indices, fs)
320
-
321
-
Input arguments:
322
-
323
-
- ``siglen`` (required): The length of the corresponding signal.
324
-
- ``peak_indices`` (required): The peak indices.
325
-
- ``fs`` (required): The corresponding signal's sampling frequency.
326
-
327
-
328
-
Output Arguments:
329
-
330
-
- ``hr``: A numpy array of the instantaneous heart rate, with the length of the corresponding signal. Contains numpy.nan where heart rate could not be computed.
331
-
332
-
333
-
Example Usage:
334
-
335
-
::
336
-
337
-
import wfdb
338
-
t0 = 10000
339
-
tf = 20000
340
-
record = wfdb.rdsamp("sampledata/100", sampfrom=t0, sampto=tf, channels=[0])
0 commit comments