Skip to content

Commit 3907097

Browse files
author
Chen Xie
committed
doc
1 parent e8bfb10 commit 3907097

File tree

2 files changed

+49
-59
lines changed

2 files changed

+49
-59
lines changed

README.md

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
[![Build Status](https://travis-ci.org/MIT-LCP/wfdb-python.svg?branch=master)](https://travis-ci.org/MIT-LCP/wfdb-python)
44

5-
<p align="center" >
6-
<img src="https://raw.githubusercontent.com/MIT-LCP/wfdb-python/master/demoimg1.png" alt="wfdbsignals" title="wfdbsignals"/>
7-
</p>
5+
![wfdb signals](https://raw.githubusercontent.com/MIT-LCP/wfdb-python/master/demoimg1.png)
6+
87

98
## Introduction
10-
<p>Native python scripts for reading and writing WFDB signals and annotations.
9+
Native python scripts for reading and writing WFDB signals and annotations.
1110

1211
## Usage
1312

14-
See the <strong>wfdbdemo.ipynb</strong> file for example scripts on how to call the functions.
13+
See the **wfdbdemo.ipynb** file for example scripts on how to call the functions.
1514

1615
### Reading Signals
1716

18-
<strong>rdsamp</strong> - Read a WFDB file and return the signal as a numpy array and the metadata as a dictionary.
17+
**rdsamp** - Read a WFDB file and return the signal as a numpy array and the metadata as a dictionary.
1918

2019
```
2120
sig, fields = rdsamp(recordname, sampfrom=0, sampto=[], channels=[], physical=1, stacksegments=1, pbdl=0, dldir=os.cwd(), keepfiles=0)
@@ -28,33 +27,30 @@ sig, fields = wfdb.rdsamp('mitdb/100', sampto=2000, pbdl=1)
2827
```
2928

3029
Input Arguments:
31-
<ul>
32-
<li><code>recordname</code> (mandatory) - The name of the WFDB record to be read (without any file extensions).</li>
33-
<li><code>sampfrom</code> (default=0) - The starting sample number to read for each channel.</li>
34-
<li><code>sampto</code> (default=length of entire signal)- The final sample number to read for each channel.</li>
35-
<li><code>channels</code> (default=all channels) - Indices specifying the channel to be returned.</li>
36-
<li><code>physical</code> (default=1) - Flag that specifies whether to return signals in physical (1) or digital (0) units.</li>
37-
<li><code>stacksegments</code> (default=1) - Flag used only for multi-segment files. Specifies whether to return the signal as a single stacked/concatenated numpy array (1) or as a list of one numpy array for each segment (0). </li>
38-
<li>pbdl (default=0): If this argument is set, the function will assume that the user is trying to download a physiobank file. Therefore the 'recordname' argument will be interpreted as a physiobank record name including the database subdirectory, rather than a local directory.</li>
39-
<li>dldir (default=os.getcwd()): The directory to download physiobank files to.</li>
40-
<li>keepfiles (default=0): Flag specifying whether to keep physiobank files newly downloaded through the function call.</li>
41-
</ul>
30+
31+
* `recordname` (mandatory) - The name of the WFDB record to be read (without any file extensions).
32+
* `sampfrom` (default=0) - The starting sample number to read for each channel.
33+
* `sampto` (default=length of entire signal)- The final sample number to read for each channel.
34+
* `channels` (default=all channels) - Indices specifying the channel to be returned.
35+
* `physical` (default=1) - Flag that specifies whether to return signals in physical (1) or digital (0) units.
36+
* `stacksegments` (default=1) - Flag used only for multi-segment files. Specifies whether to return the signal as a single stacked/concatenated numpy array (1) or as a list of one numpy array for each segment (0).
37+
* `pbdl` (default=0): If this argument is set, the function will assume that the user is trying to download a physiobank file. Therefore the 'recordname' argument will be interpreted as a physiobank record name including the database subdirectory, rather than a local directory.
38+
* `dldir` (default=os.getcwd()): The directory to download physiobank files to.
39+
* `keepfiles` (default=0): Flag specifying whether to keep physiobank files newly downloaded through the function call.
40+
4241

4342
Output Arguments:
44-
<ul>
45-
<li><code>sig</code> - An nxm numpy array where n is the signal length and m is the number of channels. <br>If the input record is a multi-segment record, depending on the input stacksegments flag, sig will either be a single stacked/concatenated numpy array (1) or a list of one numpy array for each segment (0). For empty segments, stacked format will contain Nan values, and non-stacked format will contain a single integer specifying the length of the empty segment.</li>
46-
<li><code>fields</code> - A dictionary of metadata about the record extracted or deduced from the header/signal file. <br>If the input record is a multi-segment record, the output argument will be a list of dictionaries:
47-
<ul>
48-
<li>The first list element will be a dictionary of metadata about the master header.</li>
49-
<li>If the record is in variable layout format, the next list element will be a dictionary of metadata about the layout specification header.</li>
50-
<li>The last list element will be a list of dictionaries of metadata for each segment. For empty segments, the dictionary will be replaced by a single string: 'Empty Segment'</li>
51-
</ul>
52-
</ul>
43+
* `sig` - An nxm numpy array where n is the signal length and m is the number of channels. If the input record is a multi-segment record, depending on the input stacksegments flag, sig will either be a single stacked/concatenated numpy array (1) or a list of one numpy array for each segment (0). For empty segments, stacked format will contain Nan values, and non-stacked format will contain a single integer specifying the length of the empty segment.
44+
* `fields` - A dictionary of metadata about the record extracted or deduced from the header/signal file. If the input record is a multi-segment record, the output argument will be a list of dictionaries:
45+
* The first list element will be a dictionary of metadata about the master header.
46+
* If the record is in variable layout format, the next list element will be a dictionary of metadata about the layout specification header.
47+
* The last list element will be a list of dictionaries of metadata for each segment. For empty segments, the dictionary will be replaced by a single string: 'Empty Segment'
48+
5349

5450

5551
### Reading Annotations
5652

57-
<strong>rdann</strong> - Read a WFDB annotation file <code>recordname.annot</code> and return the fields as lists or arrays.
53+
**rdann** - Read a WFDB annotation file `recordname.annot` and return the fields as lists or arrays.
5854

5955
```
6056
annsamp, anntype, subtype, chan, num, aux, annfs = wfdb.rdann(recordname, annot, sampfrom=0, sampto=[], anndisp=1)
@@ -67,32 +63,29 @@ annsamp, anntype, subtype, chan, num, aux, annfs = wfdb.rdann('100', 'atr')
6763
```
6864

6965
Input Arguments:
70-
<ul>
71-
<li><code>recordname</code> (required) - The record name of the WFDB annotation file. ie. for file <code>100.atr</code> recordname='100'.</li>
72-
<li><code>annot</code> (required) - The annotator extension of the annotation file. ie. for file <code>100.atr</code> annot='atr'.</li>
73-
<li><code>sampfrom</code> (default=0)- The minimum sample number for annotations to be returned.</li>
74-
<li><code>sampto</code> (default=the final annotation sample) - The maximum sample number for annotations to be returned.</li>
75-
<li><code>anndisp</code> (default=1) - The annotation display flag that controls the data type of the <code>anntype</code> output parameter. <code>anntype</code> will either be an integer key(0), a shorthand display symbol(1), or a longer annotation code(2).</li>
76-
</ul>
66+
67+
* `recordname` (required) - The record name of the WFDB annotation file. ie. for file `100.atr` recordname='100'.
68+
* `annot` (required) - The annotator extension of the annotation file. ie. for file `100.atr` annot='atr'.
69+
* `sampfrom` (default=0)- The minimum sample number for annotations to be returned.
70+
* `sampto` (default=the final annotation sample) - The maximum sample number for annotations to be returned.
71+
* `anndisp` (default=1) - The annotation display flag that controls the data type of the `anntype` output parameter. `anntype` will either be an integer key(0), a shorthand display symbol(1), or a longer annotation code(2).
7772

7873
Output arguments:
7974

80-
<ul>
81-
<li><code>annsamp</code> - The annotation location in samples relative to the beginning of the record.</li>
82-
<li><code>anntype</code> - The annotation type according the the standard WFDB keys.</li>
83-
<li><code>subtype</code> - The marked class/category of the annotation.</li>
84-
<li><code>chan</code> - The signal channel associated with the annotations.</li>
85-
<li><code>num</code> - The marked annotation number. This is not equal to the index of the current annotation.</li>
86-
<li><code>aux</code> - The auxiliary information string for the annotation.</li>
87-
<li><code>annfs</code> - The sampling frequency written in the beginning of the annotation file if present.</li>
88-
</ul>
75+
* `annsamp` - The annotation location in samples relative to the beginning of the record.
76+
* `anntype` - The annotation type according the the standard WFDB keys.
77+
* `subtype` - The marked class/category of the annotation.
78+
* `chan` - The signal channel associated with the annotations.
79+
* `num` - The marked annotation number. This is not equal to the index of the current annotation.
80+
* `aux` - The auxiliary information string for the annotation.
81+
* `annfs` - The sampling frequency written in the beginning of the annotation file if present.
8982

90-
<strong>*NOTE</strong>: Every annotation contains the 'annsamp' and 'anntype' field. All other fields default to 0 or empty if not present.
83+
***NOTE**: Every annotation contains the 'annsamp' and 'anntype' field. All other fields default to 0 or empty if not present.
9184

9285

9386
### Plotting Data
9487

95-
<strong>plotwfdb</strong> - Subplot and label each channel of an nxm signal on a graph. Also subplot annotation locations on selected channels if present.
88+
**plotwfdb** - Subplot and label each channel of an nxm signal on a graph. Also subplot annotation locations on selected channels if present.
9689

9790
```
9891
plotwfdb(sig, fields, annsamp=[], annch=[0], title=[], plottime=1)
@@ -108,19 +101,16 @@ wfdb.plotwfdb(sig, fields, annsamp, 'mitdb record 100'):
108101
```
109102

110103
Input Arguments:
111-
<ul>
112-
<li>sig (required)- An nxm numpy array containing the signal to be plotted - the first output argument of <code>readsignal.rdsamp</code>.</li>
113-
<li>fields (required) - A dictionary of metadata about the record - the second output argument of <code>readsignal.rdsamp</code>.</li>
114-
<li>annsamp (optional) - A 1d numpy array of annotation locations to be plotted on top of selected channels - first output argument of <code>readannot.rdann()</code>.
115-
<li>annch</li> (default=[0]) - A list of channels on which to plot the annotations.
116-
<li>title (optional)- A string containing the title of the graph.</li>
117-
<li>plottime (default=1) - Flag that specifies whether to plot the x axis as time (1) or samples (0). Defaults to samples if the input <code>fields</code> dictionary does not contain a value for <code>fs</code>.</li>
118-
</ul>
119-
104+
* `sig` (required)- An nxm numpy array containing the signal to be plotted - the first output argument of `readsignal.rdsamp`.
105+
* `fields` (required) - A dictionary of metadata about the record - the second output argument of `readsignal.rdsamp`.
106+
* `annsamp` (optional) - A 1d numpy array of annotation locations to be plotted on top of selected channels - first output argument of `rdann`.
107+
* `annch` (default=[0]) - A list of channels on which to plot the annotations.
108+
* `title` (optional)- A string containing the title of the graph.
109+
* `plottime` (default=1) - Flag that specifies whether to plot the x axis as time (1) or samples (0). Defaults to samples if the input `fields` dictionary does not contain a value for `fs`.
120110

121111

122112
## Based on the original WFDB software package specifications
123113

124-
[WFDB Software Package](http://physionet.org/physiotools/wfdb.shtml)
125-
<br>[WFDB Applications Guide](http://physionet.org/physiotools/wag/)
126-
<br>[WFDB Header File Specifications](https://physionet.org/physiotools/wag/header-5.htm)
114+
[WFDB Software Package](http://physionet.org/physiotools/wfdb.shtml)
115+
[WFDB Applications Guide](http://physionet.org/physiotools/wag/)
116+
[WFDB Header File Specifications](https://physionet.org/physiotools/wag/header-5.htm)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040

4141
# You can just specify the packages manually here if your project is
4242
# simple. Or you can use find_packages().
43-
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
44-
# packages=['wfdb'],
43+
# packages=find_packages(exclude=['contrib', 'docs', 'tests']),
44+
packages=['wfdb'],
4545

4646
# Alternatively, if you want to distribute just a my_module.py, uncomment
4747
# this:

0 commit comments

Comments
 (0)