Skip to content

Commit eb20733

Browse files
committed
added download database function
1 parent 8726ab7 commit eb20733

File tree

4 files changed

+131
-726
lines changed

4 files changed

+131
-726
lines changed

devtests.ipynb

Lines changed: 16 additions & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 1,
12+
"execution_count": null,
1313
"metadata": {
1414
"collapsed": false
1515
},
@@ -20,68 +20,11 @@
2020
},
2121
{
2222
"cell_type": "code",
23-
"execution_count": 1,
23+
"execution_count": null,
2424
"metadata": {
2525
"collapsed": false
2626
},
27-
"outputs": [
28-
{
29-
"name": "stdout",
30-
"output_type": "stream",
31-
"text": [
32-
"[[ 1.88948535e-02 5.15576324e+01 -1.04000000e-01]\n",
33-
" [ 7.76038626e-03 5.13239875e+01 -9.30000000e-02]\n",
34-
" [ 2.36185669e-03 5.09345794e+01 -8.20000000e-02]\n",
35-
" [ 6.74816197e-04 5.03894081e+01 -7.15000000e-02]\n",
36-
" [ 6.74816197e-04 4.96105919e+01 -6.10000000e-02]\n",
37-
" [ 6.74816197e-04 4.87538941e+01 -5.05000000e-02]\n",
38-
" [ -3.03667289e-03 4.76635514e+01 -4.05000000e-02]\n",
39-
" [ -1.01222430e-03 4.64953271e+01 -3.05000000e-02]\n",
40-
" [ -3.03667289e-03 4.51713396e+01 -2.00000000e-02]\n",
41-
" [ 6.74816197e-04 4.37694704e+01 -8.50000000e-03]\n",
42-
" [ -3.03667289e-03 4.23676012e+01 4.00000000e-03]\n",
43-
" [ 6.74816197e-04 4.08878505e+01 1.75000000e-02]\n",
44-
" [ -4.72371338e-03 3.94859813e+01 3.05000000e-02]\n",
45-
" [ -3.03667289e-03 3.81619938e+01 4.25000000e-02]\n",
46-
" [ -3.03667289e-03 3.70716511e+01 5.35000000e-02]\n",
47-
" [ -1.01222430e-03 3.61370717e+01 6.35000000e-02]\n",
48-
" [ -4.72371338e-03 3.54361371e+01 7.40000000e-02]\n",
49-
" [ -3.03667289e-03 3.48130841e+01 8.60000000e-02]\n",
50-
" [ -1.58581806e-02 3.44236760e+01 9.95000000e-02]\n",
51-
" [ -5.29730715e-02 3.40342679e+01 1.14500000e-01]]\n",
52-
"\n",
53-
"\n",
54-
" (75000, 3) \n",
55-
"\n",
56-
"\n",
57-
"{'comments': [], 'units': ['mV', 'mmHg', 'mV'], 'signame': ['MCL1', 'ABP', 'RESP'], 'fs': 125.0}\n",
58-
"\n",
59-
"\n",
60-
"\n",
61-
"\n",
62-
"[[ -2.69926479e-02 3.06853583e+01 4.16500000e-01]\n",
63-
" [ 9.44742676e-03 3.07632399e+01 4.08500000e-01]\n",
64-
" [ 3.00293208e-02 3.08411215e+01 4.01500000e-01]\n",
65-
" [ 3.74522989e-02 3.09190031e+01 3.95000000e-01]\n",
66-
" [ 4.65623176e-02 3.09190031e+01 3.88000000e-01]\n",
67-
" [ 5.02738067e-02 3.09190031e+01 3.79000000e-01]\n",
68-
" [ 5.02738067e-02 3.08411215e+01 3.68500000e-01]\n",
69-
" [ 5.60097443e-02 3.07632399e+01 3.56500000e-01]\n",
70-
" [ 5.39852958e-02 3.07632399e+01 3.44500000e-01]\n",
71-
" [ 4.65623176e-02 3.06853583e+01 3.33500000e-01]\n",
72-
" [ 4.28508285e-02 3.05295950e+01 3.24000000e-01]\n",
73-
" [ 4.28508285e-02 3.03738318e+01 3.15500000e-01]\n",
74-
" [ 4.48752771e-02 3.02180685e+01 3.06500000e-01]\n",
75-
" [ 4.85867662e-02 2.99844237e+01 2.97000000e-01]\n",
76-
" [ 6.14082739e-02 2.98286604e+01 2.86500000e-01]\n",
77-
" [ 7.99657193e-02 2.95950156e+01 2.75000000e-01]\n",
78-
" [ 9.31246352e-02 2.95171340e+01 nan]\n",
79-
" [ 1.03921694e-01 2.94392523e+01 nan]\n",
80-
" [ 1.18767651e-01 2.95171340e+01 nan]\n",
81-
" [ 1.33613607e-01 2.99065421e+01 nan]]\n"
82-
]
83-
}
84-
],
27+
"outputs": [],
8528
"source": [
8629
"import wfdb\n",
8730
"# Testing rdsamp multiple samples per frame (and fmt 12)\n",
@@ -96,27 +39,12 @@
9639
},
9740
{
9841
"cell_type": "code",
99-
"execution_count": 2,
42+
"execution_count": null,
10043
"metadata": {
10144
"collapsed": false,
10245
"scrolled": true
10346
},
104-
"outputs": [
105-
{
106-
"name": "stdout",
107-
"output_type": "stream",
108-
"text": [
109-
"[[-0.17241379 0. ]\n",
110-
" [-0.17241379 0. ]\n",
111-
" [-0.20689655 0. ]\n",
112-
" ..., \n",
113-
" [-0.24137931 0.25 ]\n",
114-
" [-0.27586207 0.25 ]\n",
115-
" [-0.24137931 0.25 ]]\n",
116-
"{'comments': [], 'units': ['mV', 'mV'], 'signame': ['II', 'V'], 'fs': 125.0}\n"
117-
]
118-
}
119-
],
47+
"outputs": [],
12048
"source": [
12149
"# Testing rdsamp format 80\n",
12250
"sig, fields=wfdb.srdsamp('sampledata/3000003_0003')\n",
@@ -292,155 +220,38 @@
292220
},
293221
{
294222
"cell_type": "code",
295-
"execution_count": 4,
223+
"execution_count": null,
296224
"metadata": {
297225
"collapsed": false
298226
},
299227
"outputs": [],
300228
"source": [
301-
"import requests\n",
302-
"\n",
303-
"url = 'https://physionet.org/physiobank/database/a'\n",
304-
"\n",
305-
"r = requests.get(url)\n",
306-
"\n"
307-
]
308-
},
309-
{
310-
"cell_type": "code",
311-
"execution_count": 7,
312-
"metadata": {
313-
"collapsed": false
314-
},
315-
"outputs": [
316-
{
317-
"data": {
318-
"text/plain": [
319-
"True"
320-
]
321-
},
322-
"execution_count": 7,
323-
"metadata": {},
324-
"output_type": "execute_result"
325-
}
326-
],
327-
"source": [
328-
"r.status_code == 404"
229+
"r = requests.get('http://physionet.org/physiobank/database/mitdb/100.hea')\n",
230+
"help(r.raise_for_status)"
329231
]
330232
},
331233
{
332234
"cell_type": "code",
333-
"execution_count": 8,
334-
"metadata": {
335-
"collapsed": false
336-
},
337-
"outputs": [
338-
{
339-
"data": {
340-
"text/plain": [
341-
"'edf'"
342-
]
343-
},
344-
"execution_count": 8,
345-
"metadata": {},
346-
"output_type": "execute_result"
347-
}
348-
],
349-
"source": [
350-
"x = 'hello.edf'\n",
351-
"x[-3:]"
352-
]
353-
},
354-
{
355-
"cell_type": "code",
356-
"execution_count": 10,
357-
"metadata": {
358-
"collapsed": false
359-
},
360-
"outputs": [
361-
{
362-
"data": {
363-
"text/plain": [
364-
"8"
365-
]
366-
},
367-
"execution_count": 10,
368-
"metadata": {},
369-
"output_type": "execute_result"
370-
}
371-
],
372-
"source": [
373-
"import os\n",
374-
"os.cpu_count()"
375-
]
376-
},
377-
{
378-
"cell_type": "code",
379-
"execution_count": 12,
380-
"metadata": {
381-
"collapsed": false
382-
},
383-
"outputs": [
384-
{
385-
"data": {
386-
"text/plain": [
387-
"True"
388-
]
389-
},
390-
"execution_count": 12,
391-
"metadata": {},
392-
"output_type": "execute_result"
393-
}
394-
],
395-
"source": [
396-
"'hello'.endswith('llo')"
397-
]
398-
},
399-
{
400-
"cell_type": "code",
401-
"execution_count": 15,
235+
"execution_count": null,
402236
"metadata": {
403237
"collapsed": false
404238
},
405-
"outputs": [
406-
{
407-
"ename": "AttributeError",
408-
"evalue": "'list' object has no attribute 'any'",
409-
"output_type": "error",
410-
"traceback": [
411-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
412-
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
413-
"\u001b[0;32m<ipython-input-15-a0aa019c7e14>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0ml\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'hello'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'jello'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'coffee'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0ml\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0many\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
414-
"\u001b[0;31mAttributeError\u001b[0m: 'list' object has no attribute 'any'"
415-
]
416-
}
417-
],
239+
"outputs": [],
418240
"source": [
419-
"l = ['hello', 'jello', 'coffee']\n"
241+
"with open('temp', \"wb\") as writefile:\n",
242+
" writefile.write(b'22')"
420243
]
421244
},
422245
{
423246
"cell_type": "code",
424-
"execution_count": 19,
247+
"execution_count": null,
425248
"metadata": {
426249
"collapsed": false
427250
},
428-
"outputs": [
429-
{
430-
"data": {
431-
"text/plain": [
432-
"'http://physionet.org/physiobank/database/mitdb'"
433-
]
434-
},
435-
"execution_count": 19,
436-
"metadata": {},
437-
"output_type": "execute_result"
438-
}
439-
],
251+
"outputs": [],
440252
"source": [
441-
"import os\n",
442-
"\n",
443-
"os.path.join('http://physionet.org/physiobank/database/', 'mitdb')"
253+
"import wfdb\n",
254+
"wfdb.dldatabase(pbdb = 'fecgsyndb', dlbasedir = '/home/chen/Downloads/dbfolder')"
444255
]
445256
},
446257
{

wfdb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .records import Record, MultiRecord, rdheader, rdsamp, srdsamp, wrsamp
22
from .annotations import Annotation, rdann, wrann, showanncodes
33
from .plots import plotrec, plotann
4-
#from .downloads import dldatabase
4+
from .downloads import dldatabase

0 commit comments

Comments
 (0)