Skip to content

Commit ba7e7f9

Browse files
committed
dev
1 parent 22a0767 commit ba7e7f9

File tree

3 files changed

+78
-10
lines changed

3 files changed

+78
-10
lines changed

devtests.ipynb

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,27 +1321,88 @@
13211321
},
13221322
{
13231323
"cell_type": "code",
1324-
"execution_count": 3,
1324+
"execution_count": 4,
13251325
"metadata": {
13261326
"collapsed": false
13271327
},
13281328
"outputs": [
13291329
{
13301330
"data": {
13311331
"text/plain": [
1332-
"array([ 18, 77, 370, ..., 647414, 647672, 647934])"
1332+
"{'annsamp': array([647672, 647934, 648203, 648477, 648733, 648978, 649232, 649484,\n",
1333+
" 649734]),\n",
1334+
" 'anntype': ['#', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'],\n",
1335+
" 'aux': ['', '', '', '', '', '', '', '', ''],\n",
1336+
" 'chan': array([0, 0, 0, 0, 0, 0, 0, 0, 0]),\n",
1337+
" 'fs': None,\n",
1338+
" 'num': array([0, 0, 0, 0, 0, 0, 0, 0, 0]),\n",
1339+
" 'subtype': array([0, 0, 0, 0, 0, 0, 0, 0, 0])}"
13331340
]
13341341
},
1335-
"execution_count": 3,
1342+
"execution_count": 4,
13361343
"metadata": {},
13371344
"output_type": "execute_result"
13381345
}
13391346
],
13401347
"source": [
13411348
"import wfdb\n",
1349+
"import numpy as np\n",
1350+
"a = wfdb.rdann('/home/chen/Projects/wfdb-python/sampledata/100', 'atr', sampfrom =647672, sampto = 649734 )\n",
1351+
"a.anntype[0] = '#'\n",
1352+
"a.__dict__\n"
1353+
]
1354+
},
1355+
{
1356+
"cell_type": "code",
1357+
"execution_count": 6,
1358+
"metadata": {
1359+
"collapsed": false
1360+
},
1361+
"outputs": [
1362+
{
1363+
"data": {
1364+
"text/plain": [
1365+
"['#', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N']"
1366+
]
1367+
},
1368+
"execution_count": 6,
1369+
"metadata": {},
1370+
"output_type": "execute_result"
1371+
}
1372+
],
1373+
"source": [
1374+
"z = a.anntype\n",
13421375
"\n",
1343-
"a = wfdb.rdann('/home/chen/Projects/wfdb-python/sampledata/100', 'atr', sampto = 647934)\n",
1344-
"a.annsamp\n"
1376+
"z\n",
1377+
"\n",
1378+
"\n",
1379+
"#a.type2aux()\n",
1380+
"#a.__dict__\n",
1381+
"\n",
1382+
"\n",
1383+
"#a.wrann()"
1384+
]
1385+
},
1386+
{
1387+
"cell_type": "code",
1388+
"execution_count": 7,
1389+
"metadata": {
1390+
"collapsed": false
1391+
},
1392+
"outputs": [
1393+
{
1394+
"data": {
1395+
"text/plain": [
1396+
"(array([], dtype=int64),)"
1397+
]
1398+
},
1399+
"execution_count": 7,
1400+
"metadata": {},
1401+
"output_type": "execute_result"
1402+
}
1403+
],
1404+
"source": [
1405+
"np.where(z == 'N')"
13451406
]
13461407
},
13471408
{

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
'nose>=1.3.7',
5656
'numpy>=1.11.0',
5757
'matplotlib>=1.5.1',
58-
'requests>=2.10.0'
58+
'requests>=2.10.0',
59+
'pandas>=0.19.1'
5960
],
6061

6162
# List additional groups of dependencies here (e.g. development

wfdb/annotations.py

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

@@ -32,7 +33,7 @@ def wrann(self):
3233
def checkfields(self):
3334
# Enforce mandatory write fields
3435
for field in ['annsamp', 'anntype']:
35-
if not getattr(self, field):
36+
if getattr(self, field) is None:
3637
print('The ', field, ' field is mandatory for writing annotation files')
3738
sys.exit()
3839

@@ -82,8 +83,8 @@ def checkfield(self, field):
8283
# Ensure all fields lie in standard WFDB annotation codes
8384
if set(self.anntype) - set(annsyms.values()) != set():
8485
print('The anntype field contains items not encoded in the WFDB annotation library.')
85-
print('To see the valid annotation codes, call: showanncodes()')
86-
print('To transfer non-encoded anntype items into the aux field, call: self.type2aux')
86+
print('To see the valid annotation codes call: showanncodes()')
87+
print('To transfer non-encoded anntype items into the aux field call: self.type2aux')
8788
sys.exit()
8889
elif field == 'num':
8990
if min(self.num) < 0 :
@@ -129,8 +130,13 @@ def type2aux(self):
129130
self.aux = [None]*len(self.annsamp)
130131

131132
# Move the anntype fields
133+
print(external_anntypes)
134+
132135
for ext in external_anntypes:
136+
print(ext)
137+
print(np.where(self.anntype == ext))
133138
for i in np.where(self.anntype == ext):
139+
print('i: ',i)
134140
if self.aux[i] == None:
135141
self.aux[i] = self.anntype[i]
136142
self.anntype[i] = ''
@@ -509,7 +515,7 @@ def format_anntype(anndisp,anntype):
509515

510516
annfields = ['annsamp', 'anntype', 'num', 'subtype', 'chan', 'aux', 'fs']
511517

512-
annfieldtypes = {'annsamp': _headers.inttypes, 'anntypes': [str],
518+
annfieldtypes = {'annsamp': _headers.inttypes, 'anntype': [str],
513519
'num':_headers.inttypes, 'subtype': _headers.inttypes,
514520
'chan': _headers.inttypes, 'aux': [str],
515521
'fs': _headers.floattypes}

0 commit comments

Comments
 (0)