Skip to content

Commit 165ea7a

Browse files
committed
dev
1 parent 240b346 commit 165ea7a

File tree

2 files changed

+268
-6
lines changed

2 files changed

+268
-6
lines changed

devtests.ipynb

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,268 @@
17841784
"print(auxilliarymsg)"
17851785
]
17861786
},
1787+
{
1788+
"cell_type": "code",
1789+
"execution_count": 1,
1790+
"metadata": {
1791+
"collapsed": false
1792+
},
1793+
"outputs": [],
1794+
"source": [
1795+
"import wfdb\n"
1796+
]
1797+
},
1798+
{
1799+
"cell_type": "code",
1800+
"execution_count": 2,
1801+
"metadata": {
1802+
"collapsed": false
1803+
},
1804+
"outputs": [
1805+
{
1806+
"data": {
1807+
"text/html": [
1808+
"<div>\n",
1809+
"<table border=\"1\" class=\"dataframe\">\n",
1810+
" <thead>\n",
1811+
" <tr style=\"text-align: right;\">\n",
1812+
" <th></th>\n",
1813+
" <th>Ann Code/Meaning</th>\n",
1814+
" </tr>\n",
1815+
" <tr>\n",
1816+
" <th>Ann Symbol</th>\n",
1817+
" <th></th>\n",
1818+
" </tr>\n",
1819+
" </thead>\n",
1820+
" <tbody>\n",
1821+
" <tr>\n",
1822+
" <th></th>\n",
1823+
" <td>NOTQRS</td>\n",
1824+
" </tr>\n",
1825+
" <tr>\n",
1826+
" <th>N</th>\n",
1827+
" <td>NORMAL</td>\n",
1828+
" </tr>\n",
1829+
" <tr>\n",
1830+
" <th>L</th>\n",
1831+
" <td>LBBB</td>\n",
1832+
" </tr>\n",
1833+
" <tr>\n",
1834+
" <th>R</th>\n",
1835+
" <td>RBBB</td>\n",
1836+
" </tr>\n",
1837+
" <tr>\n",
1838+
" <th>a</th>\n",
1839+
" <td>ABERR</td>\n",
1840+
" </tr>\n",
1841+
" <tr>\n",
1842+
" <th>V</th>\n",
1843+
" <td>PVC</td>\n",
1844+
" </tr>\n",
1845+
" <tr>\n",
1846+
" <th>F</th>\n",
1847+
" <td>FUSION</td>\n",
1848+
" </tr>\n",
1849+
" <tr>\n",
1850+
" <th>J</th>\n",
1851+
" <td>NPC</td>\n",
1852+
" </tr>\n",
1853+
" <tr>\n",
1854+
" <th>A</th>\n",
1855+
" <td>APC</td>\n",
1856+
" </tr>\n",
1857+
" <tr>\n",
1858+
" <th>S</th>\n",
1859+
" <td>SVPB</td>\n",
1860+
" </tr>\n",
1861+
" <tr>\n",
1862+
" <th>E</th>\n",
1863+
" <td>VESC</td>\n",
1864+
" </tr>\n",
1865+
" <tr>\n",
1866+
" <th>j</th>\n",
1867+
" <td>NESC</td>\n",
1868+
" </tr>\n",
1869+
" <tr>\n",
1870+
" <th>/</th>\n",
1871+
" <td>PACE</td>\n",
1872+
" </tr>\n",
1873+
" <tr>\n",
1874+
" <th>Q</th>\n",
1875+
" <td>UNKNOWN</td>\n",
1876+
" </tr>\n",
1877+
" <tr>\n",
1878+
" <th>~</th>\n",
1879+
" <td>NOISE</td>\n",
1880+
" </tr>\n",
1881+
" <tr>\n",
1882+
" <th>|</th>\n",
1883+
" <td>ARFCT</td>\n",
1884+
" </tr>\n",
1885+
" <tr>\n",
1886+
" <th>s</th>\n",
1887+
" <td>STCH</td>\n",
1888+
" </tr>\n",
1889+
" <tr>\n",
1890+
" <th>T</th>\n",
1891+
" <td>TCH</td>\n",
1892+
" </tr>\n",
1893+
" <tr>\n",
1894+
" <th>*</th>\n",
1895+
" <td>SYSTOLE</td>\n",
1896+
" </tr>\n",
1897+
" <tr>\n",
1898+
" <th>D</th>\n",
1899+
" <td>DIASTOLE</td>\n",
1900+
" </tr>\n",
1901+
" <tr>\n",
1902+
" <th>\"</th>\n",
1903+
" <td>NOTE</td>\n",
1904+
" </tr>\n",
1905+
" <tr>\n",
1906+
" <th>=</th>\n",
1907+
" <td>MEASURE</td>\n",
1908+
" </tr>\n",
1909+
" <tr>\n",
1910+
" <th>p</th>\n",
1911+
" <td>PWAVE</td>\n",
1912+
" </tr>\n",
1913+
" <tr>\n",
1914+
" <th>B</th>\n",
1915+
" <td>BBB</td>\n",
1916+
" </tr>\n",
1917+
" <tr>\n",
1918+
" <th>^</th>\n",
1919+
" <td>PACESP</td>\n",
1920+
" </tr>\n",
1921+
" <tr>\n",
1922+
" <th>t</th>\n",
1923+
" <td>TWAVE</td>\n",
1924+
" </tr>\n",
1925+
" <tr>\n",
1926+
" <th>+</th>\n",
1927+
" <td>RHYTHM</td>\n",
1928+
" </tr>\n",
1929+
" <tr>\n",
1930+
" <th>u</th>\n",
1931+
" <td>UWAVE</td>\n",
1932+
" </tr>\n",
1933+
" <tr>\n",
1934+
" <th>?</th>\n",
1935+
" <td>LEARN</td>\n",
1936+
" </tr>\n",
1937+
" <tr>\n",
1938+
" <th>!</th>\n",
1939+
" <td>FLWAV</td>\n",
1940+
" </tr>\n",
1941+
" <tr>\n",
1942+
" <th>[</th>\n",
1943+
" <td>VFON</td>\n",
1944+
" </tr>\n",
1945+
" <tr>\n",
1946+
" <th>]</th>\n",
1947+
" <td>VFOFF</td>\n",
1948+
" </tr>\n",
1949+
" <tr>\n",
1950+
" <th>e</th>\n",
1951+
" <td>AESC</td>\n",
1952+
" </tr>\n",
1953+
" <tr>\n",
1954+
" <th>n</th>\n",
1955+
" <td>SVESC</td>\n",
1956+
" </tr>\n",
1957+
" <tr>\n",
1958+
" <th>@</th>\n",
1959+
" <td>LINK</td>\n",
1960+
" </tr>\n",
1961+
" <tr>\n",
1962+
" <th>x</th>\n",
1963+
" <td>NAPC</td>\n",
1964+
" </tr>\n",
1965+
" <tr>\n",
1966+
" <th>f</th>\n",
1967+
" <td>PFUS</td>\n",
1968+
" </tr>\n",
1969+
" <tr>\n",
1970+
" <th>(</th>\n",
1971+
" <td>WFON</td>\n",
1972+
" </tr>\n",
1973+
" <tr>\n",
1974+
" <th>)</th>\n",
1975+
" <td>WFOFF</td>\n",
1976+
" </tr>\n",
1977+
" <tr>\n",
1978+
" <th>r</th>\n",
1979+
" <td>RONT</td>\n",
1980+
" </tr>\n",
1981+
" </tbody>\n",
1982+
"</table>\n",
1983+
"</div>"
1984+
],
1985+
"text/plain": [
1986+
" Ann Code/Meaning\n",
1987+
"Ann Symbol \n",
1988+
" NOTQRS\n",
1989+
"N NORMAL\n",
1990+
"L LBBB\n",
1991+
"R RBBB\n",
1992+
"a ABERR\n",
1993+
"V PVC\n",
1994+
"F FUSION\n",
1995+
"J NPC\n",
1996+
"A APC\n",
1997+
"S SVPB\n",
1998+
"E VESC\n",
1999+
"j NESC\n",
2000+
"/ PACE\n",
2001+
"Q UNKNOWN\n",
2002+
"~ NOISE\n",
2003+
"| ARFCT\n",
2004+
"s STCH\n",
2005+
"T TCH\n",
2006+
"* SYSTOLE\n",
2007+
"D DIASTOLE\n",
2008+
"\" NOTE\n",
2009+
"= MEASURE\n",
2010+
"p PWAVE\n",
2011+
"B BBB\n",
2012+
"^ PACESP\n",
2013+
"t TWAVE\n",
2014+
"+ RHYTHM\n",
2015+
"u UWAVE\n",
2016+
"? LEARN\n",
2017+
"! FLWAV\n",
2018+
"[ VFON\n",
2019+
"] VFOFF\n",
2020+
"e AESC\n",
2021+
"n SVESC\n",
2022+
"@ LINK\n",
2023+
"x NAPC\n",
2024+
"f PFUS\n",
2025+
"( WFON\n",
2026+
") WFOFF\n",
2027+
"r RONT"
2028+
]
2029+
},
2030+
"metadata": {},
2031+
"output_type": "display_data"
2032+
}
2033+
],
2034+
"source": [
2035+
"wfdb.showanncodes()"
2036+
]
2037+
},
2038+
{
2039+
"cell_type": "code",
2040+
"execution_count": 5,
2041+
"metadata": {
2042+
"collapsed": true
2043+
},
2044+
"outputs": [],
2045+
"source": [
2046+
"from IPython.display import display"
2047+
]
2048+
},
17872049
{
17882050
"cell_type": "code",
17892051
"execution_count": null,

wfdb/annotations.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import pandas as pd
3-
from . import headers
3+
from IPython.display import display
4+
from . import _headers
45

56
# Class for WFDB annotations
67
class Annotation():
@@ -67,7 +68,7 @@ def checkfield(self, field):
6768
# Check the data types of the elements
6869
for item in fielditem:
6970
if type(item) not in annfieldtypes[field]+[None]:
70-
print('All elements of the ' field, 'field must be None or one of the following types: ', annfieldtypes[field])
71+
print('All elements of the ', field, 'field must be None or one of the following types: ', annfieldtypes[field])
7172
sys.exit()
7273

7374
# Field specific checks
@@ -139,7 +140,7 @@ def type2aux(self):
139140

140141

141142
def showanncodes():
142-
symcodes
143+
display(symcodes)
143144

144145

145146
## ------------- Reading Annotations ------------- ##
@@ -278,8 +279,7 @@ def get_fs(filebytes):
278279
testbytes = filebytes[:12, :].flatten()
279280
# First 2 bytes indicate dt=0 and anntype=NOTE. Next 2 indicate auxlen
280281
# and anntype=AUX. Then follows "## time resolution: "
281-
if [testbytes[i] for i in [ 0,1] + list(range(3,24))] ==
282-
[0,88,252,35,35,32,116,105,109,101,32,114,101,115,111,108,117,116,105,111,110,58,32]:
282+
if [testbytes[i] for i in [ 0,1] + list(range(3,24))] == [0,88,252,35,35,32,116,105,109,101,32,114,101,115,111,108,117,116,105,111,110,58,32]:
283283
# The file's leading bytes match the expected pattern for encoding fs.
284284
# Length of the auxilliary string that includes the fs written into
285285
# the file.
@@ -512,5 +512,5 @@ def format_anntype(anndisp,anntype):
512512

513513
annfieldtypes = {'annsamp': _headers.inttypes, 'anntypes': [str],
514514
'num':_headers.inttypes, 'subtype': _headers.inttypes,
515-
'chan' = _headers.inttypes, 'aux': [str],
515+
'chan': _headers.inttypes, 'aux': [str],
516516
'fs': _headers.floattypes}

0 commit comments

Comments
 (0)