|
16 | 16 | "outputs": [], |
17 | 17 | "source": [ |
18 | 18 | "import numpy as np\n", |
19 | | - "from wfdb import readsignal\n", |
| 19 | + "from wfdb import rdsamp\n", |
20 | 20 | "# Testing rdsamp format 212\n", |
21 | | - "sig, fields=readsignal.rdsamp('sampledata/100', channels=[1], sampfrom=114, physical=0) # Default physical values\n", |
| 21 | + "sig, fields=rdsamp('sampledata/100', channels=[1], sampfrom=114, physical=0) # Default physical values\n", |
22 | 22 | "print(sig)\n", |
23 | 23 | "print(len(sig))\n", |
24 | 24 | "\n", |
|
35 | 35 | }, |
36 | 36 | "outputs": [], |
37 | 37 | "source": [ |
38 | | - "from wfdb import readsignal\n", |
| 38 | + "from wfdb import rdsamp\n", |
39 | 39 | "\n", |
40 | 40 | "# Testing rdsamp format 16\n", |
41 | | - "sig, fields=readsignal.rdsamp('sampledata/test01_00s')\n", |
| 41 | + "sig, fields=rdsamp('sampledata/test01_00s')\n", |
42 | 42 | "print(sig)\n", |
43 | 43 | "print(fields)\n" |
44 | 44 | ] |
|
52 | 52 | "outputs": [], |
53 | 53 | "source": [ |
54 | 54 | "# Testing rdsamp multiple samples per frame (and fmt 12)\n", |
55 | | - "from wfdb import readsignal\n", |
56 | | - "sig, fields=readsignal.rdsamp('sampledata/03700181', physical=0)\n", |
| 55 | + "from wfdb import rdsamp\n", |
| 56 | + "sig, fields=rdsamp('sampledata/03700181', physical=0)\n", |
57 | 57 | "print(sig[:20,:])\n", |
58 | 58 | "print(\"\\n\\n\", sig.shape, \"\\n\\n\")\n", |
59 | 59 | "print(fields)\n", |
|
72 | 72 | "outputs": [], |
73 | 73 | "source": [ |
74 | 74 | "# Testing rdsamp format 80\n", |
75 | | - "sig, fields=readsignal.rdsamp('sampledata/3000003_0003')\n", |
| 75 | + "sig, fields=rdsamp('sampledata/3000003_0003')\n", |
76 | 76 | "print(sig)\n", |
77 | 77 | "print(fields)" |
78 | 78 | ] |
|
87 | 87 | "source": [ |
88 | 88 | "# Testing rdsamp format 16 with byte offset (actually a .mat file too)\n", |
89 | 89 | "import numpy as np\n", |
90 | | - "from wfdb import readsignal\n", |
91 | | - "sig, fields=readsignal.rdsamp('sampledata/a103l') \n", |
| 90 | + "from wfdb import rdsamp\n", |
| 91 | + "sig, fields=rdsamp('sampledata/a103l') \n", |
92 | 92 | "#print(sig)\n", |
93 | 93 | "#print(sig.shape)\n", |
94 | 94 | "#print(fields)\n", |
|
116 | 116 | "source": [ |
117 | 117 | "# Testing rdsamp multi-segment variable layout record (from https://physionet.org/physiobank/database/mimic2wdb/matched/s00001/)\n", |
118 | 118 | "import numpy as np\n", |
119 | | - "from wfdb import readsignal\n", |
| 119 | + "from wfdb import rdsamp\n", |
120 | 120 | "\n", |
121 | 121 | "# Return list of arrays\n", |
122 | | - "sig, fields=readsignal.rdsamp('sampledata/matched/s00001/s00001-2896-10-10-00-31', sampfrom=3200, sampto=20000, stacksegments=0)\n", |
| 122 | + "sig, fields=rdsamp('sampledata/matched/s00001/s00001-2896-10-10-00-31', sampfrom=3200, sampto=20000, stacksegments=0)\n", |
123 | 123 | "#print(\"len(sig): \", len(sig))\n", |
124 | 124 | "#print(len(fields))\n", |
125 | 125 | "\n", |
|
146 | 146 | "source": [ |
147 | 147 | "# Testing rdsamp multi-segment variable layout record - stacksegments\n", |
148 | 148 | "import numpy as np\n", |
149 | | - "from wfdb import readsignal\n", |
| 149 | + "from wfdb import rdsamp\n", |
150 | 150 | "\n", |
151 | 151 | "\n", |
152 | 152 | "# Return single numpy array\n", |
153 | | - "sig, fields=readsignal.rdsamp('sampledata/multisegmentV/s00001-2896-10-10-00-31', stacksegments=1, sampto=10000, channels=[1, 2])\n", |
| 153 | + "sig, fields=rdsamp('sampledata/matched/s00001/s00001-2896-10-10-00-31', stacksegments=1, sampto=10000, channels=[1, 2])\n", |
154 | 154 | "\n", |
155 | 155 | "print(sig)\n", |
156 | 156 | "print(sig.shape)\n", |
|
172 | 172 | "source": [ |
173 | 173 | "# Testing rdsamp multi-dat signals (from https://physionet.org/physiobank/database/ptbdb/patient001/)\n", |
174 | 174 | "import numpy as np\n", |
175 | | - "from wfdb import readsignal\n", |
| 175 | + "from wfdb import rdsamp\n", |
176 | 176 | "\n", |
177 | | - "sig, fields=readsignal.rdsamp('sampledata/s0010_re', channels=[14, 0, 5, 10, 11], sampfrom=100, sampto=20000)\n", |
| 177 | + "sig, fields=rdsamp('sampledata/s0010_re', channels=[14, 0, 5, 10, 11], sampfrom=100, sampto=20000)\n", |
178 | 178 | "from wfdb import plotwfdb\n", |
179 | 179 | "plotwfdb.plotsigs(sig, fields)\n", |
180 | 180 | "print(\"\\n\\n\\n\", sig, \"\\n\\n\\n\")\n", |
|
192 | 192 | "source": [ |
193 | 193 | "# Testing rdsamp multi-segment record with sampfrom, sampto, and channel selection\n", |
194 | 194 | "import numpy as np\n", |
195 | | - "from wfdb import readsignal\n", |
| 195 | + "from wfdb import rdsamp\n", |
196 | 196 | "\n", |
197 | 197 | "# Return list of arrays\n", |
198 | | - "sig, fields=readsignal.rdsamp('sampledata/multisegmentV/s00001-2896-10-10-00-31', sampfrom=10, sampto=10200, channels=[2,3], stacksegments=0)\n", |
| 198 | + "sig, fields=rdsamp('sampledata/matched/s00001/s00001-2896-10-10-00-31', sampfrom=10, sampto=10200, channels=[2,3], stacksegments=0)\n", |
199 | 199 | "\n", |
200 | 200 | "print(sig)\n", |
201 | 201 | "# Return single array\n", |
202 | | - "sig, fields=readsignal.rdsamp('sampledata/multisegmentV/s00001-2896-10-10-00-31', sampfrom=10, sampto=10200, channels=[1,0,2],stacksegments=1)\n", |
| 202 | + "sig, fields=rdsamp('sampledata/matched/s00001/s00001-2896-10-10-00-31', sampfrom=10, sampto=10200, channels=[1,0,2],stacksegments=1)\n", |
203 | 203 | "\n", |
204 | 204 | "print(sig)" |
205 | 205 | ] |
206 | 206 | }, |
207 | | - { |
208 | | - "cell_type": "code", |
209 | | - "execution_count": null, |
210 | | - "metadata": { |
211 | | - "collapsed": false |
212 | | - }, |
213 | | - "outputs": [], |
214 | | - "source": [] |
215 | | - }, |
216 | 207 | { |
217 | 208 | "cell_type": "markdown", |
218 | 209 | "metadata": {}, |
|
223 | 214 | }, |
224 | 215 | { |
225 | 216 | "cell_type": "code", |
226 | | - "execution_count": null, |
| 217 | + "execution_count": 1, |
227 | 218 | "metadata": { |
228 | | - "collapsed": true |
| 219 | + "collapsed": false |
229 | 220 | }, |
230 | | - "outputs": [], |
| 221 | + "outputs": [ |
| 222 | + { |
| 223 | + "name": "stdout", |
| 224 | + "output_type": "stream", |
| 225 | + "text": [ |
| 226 | + "[[-0.39341784 -0.107 ]\n", |
| 227 | + " [-0.32661104 -0.1185 ]\n", |
| 228 | + " [-0.23247418 -0.1305 ]\n", |
| 229 | + " ..., \n", |
| 230 | + " [-0.00472371 0.148 ]\n", |
| 231 | + " [-0.00303667 0.1375 ]\n", |
| 232 | + " [-0.00303667 0.127 ]]\n", |
| 233 | + "yay\n" |
| 234 | + ] |
| 235 | + } |
| 236 | + ], |
231 | 237 | "source": [ |
232 | 238 | "import numpy as np\n", |
233 | | - "from wfdb import readsignal\n", |
| 239 | + "from wfdb import rdsamp\n", |
234 | 240 | "\n", |
235 | 241 | "# Test 1 - Format 212/Entire signal/Physical \n", |
236 | 242 | "# Target file created with: rdsamp -r sampledata/100 -P | cut -f 2- > target1\n", |
237 | | - "sig, fields=readsignal.rdsamp('sampledata/100') \n", |
| 243 | + "sig, fields=rdsamp('sampledata/100') \n", |
238 | 244 | "\n", |
239 | 245 | "# Test 2 - Format 212/Selected Duration/Selected Channel/Digital\n", |
240 | 246 | "# Target file created with: rdsamp -r sampledata/100 -f 1 -t 30 -s 1 | cut -f 2- > target2\n", |
241 | | - "sig, fields=readsignal.rdsamp('sampledata/100', sampfrom=360, sampto=10800, channels=[1], physical=0) \n", |
| 247 | + "sig, fields=rdsamp('sampledata/100', sampfrom=360, sampto=10800, channels=[1], physical=0) \n", |
242 | 248 | "\n", |
243 | 249 | "# Test 3 - Format 16/Entire signal/Digital\n", |
244 | 250 | "# Target file created with: rdsamp -r sampledata/test01_00s | cut -f 2- > target3\n", |
245 | | - "sig, fields=readsignal.rdsamp('sampledata/test01_00s', physical=0)\n", |
| 251 | + "sig, fields=rdsamp('sampledata/test01_00s', physical=0)\n", |
246 | 252 | "\n", |
247 | 253 | "# Test 4 - Format 16 with byte offset/Selected Duration/Selected Channels/Physical\n", |
248 | 254 | "# Target file created with: rdsamp -r sampledata/a103l -f 50 -t 160 -s 2 0 -P | cut -f 2- > target4\n", |
249 | | - "sig, fields=readsignal.rdsamp('sampledata/a103l', sampfrom=12500, sampto=40000, channels=[2, 0])\n", |
| 255 | + "sig, fields=rdsamp('sampledata/a103l', sampfrom=12500, sampto=40000, channels=[2, 0])\n", |
250 | 256 | "\n", |
251 | 257 | "# Test 5 - Format 16 with byte offset/Selected Duration/Selected Channels/Digital\n", |
252 | 258 | "# Target file created with: rdsamp -r sampledata/a103l -f 80 -s 0 1 | cut -f 2- > target5\n", |
253 | | - "sig, fields=readsignal.rdsamp('sampledata/a103l', sampfrom=20000, physical=0, channels=[0, 1])\n", |
| 259 | + "sig, fields=rdsamp('sampledata/a103l', sampfrom=20000, physical=0, channels=[0, 1])\n", |
254 | 260 | "\n", |
255 | 261 | "# Test 6 - Format 80/Selected Duration/Selected Channels/Physical\n", |
256 | 262 | "# Target file created with: rdsamp -r sampledata/3000003_0003 -f 1 -t 8 -s 1 -P | cut -f 2- > target6\n", |
257 | | - "sig, fields=readsignal.rdsamp('sampledata/3000003_0003', sampfrom=125, sampto=1000, channels=[1])\n", |
| 263 | + "sig, fields=rdsamp('sampledata/3000003_0003', sampfrom=125, sampto=1000, channels=[1])\n", |
258 | 264 | "\n", |
259 | 265 | "# Test 7 - Multi-dat/Entire signal/Digital\n", |
260 | 266 | "# Target file created with: rdsamp -r sampledata/s0010_re | cut -f 2- > target7\n", |
261 | | - "sig, fields=readsignal.rdsamp('sampledata/s0010_re', physical=0)\n", |
| 267 | + "sig, fields=rdsamp('sampledata/s0010_re', physical=0)\n", |
262 | 268 | "\n", |
263 | 269 | "# Test 8 - Multi-dat/Selected Duration/Selected Channels/Physical\n", |
264 | 270 | "# Target file created with: rdsamp -r sampledata/s0010_re -f 5 -t 38 -P -s 13 0 4 8 3 | cut -f 2- > target8\n", |
265 | | - "sig, fields=readsignal.rdsamp('sampledata/s0010_re', sampfrom=5000, sampto=38000, channels=[13, 0, 4, 8, 3])\n", |
| 271 | + "sig, fields=rdsamp('sampledata/s0010_re', sampfrom=5000, sampto=38000, channels=[13, 0, 4, 8, 3])\n", |
266 | 272 | "\n", |
267 | 273 | "# Test 9 - Format 12 multi-samples/frame and skew/Entire Signal/Digital\n", |
268 | 274 | "# Target file created with: rdsamp -r sampledata/03700181 | cut -f 2- > target9\n", |
269 | | - "sig, fields=readsignal.rdsamp('sampledata/03700181', physical=0)\n", |
| 275 | + "sig, fields=rdsamp('sampledata/03700181', physical=0)\n", |
270 | 276 | "\n", |
271 | 277 | "# Test 10 - Format 12 multi-samples/frame and skew/Selected Duration/Selected channel/Physical\n", |
272 | | - "# Target file created with: rdsamp -r sampledata/03700181 -f 8 -t 16000 | cut -f 2- > target10\n", |
273 | | - "sig, fields=readsignal.rdsamp('sampledata/03700181', physical=0)" |
| 278 | + "# Target file created with: rdsamp -r sampledata/03700181 -f 8 -t 128 -P | cut -f 2- > target10\n", |
| 279 | + "sig, fields=rdsamp('sampledata/03700181', channels=[0, 2], sampfrom=1000, sampto=16000)\n", |
| 280 | + "print(sig)\n", |
| 281 | + "\n", |
| 282 | + "print('yay')" |
274 | 283 | ] |
275 | 284 | }, |
| 285 | + { |
| 286 | + "cell_type": "code", |
| 287 | + "execution_count": null, |
| 288 | + "metadata": { |
| 289 | + "collapsed": false |
| 290 | + }, |
| 291 | + "outputs": [], |
| 292 | + "source": [] |
| 293 | + }, |
276 | 294 | { |
277 | 295 | "cell_type": "markdown", |
278 | 296 | "metadata": {}, |
|
290 | 308 | "outputs": [], |
291 | 309 | "source": [ |
292 | 310 | "import numpy as np\n", |
293 | | - "from wfdb import readannot\n", |
| 311 | + "from wfdb import rdann\n", |
294 | 312 | "\n", |
295 | 313 | "# Test 1 - \n", |
296 | 314 | "# Target file created with: rdann -r 100 -a atr > anntarget1\n", |
297 | | - "annsamp, anntype, num, subtype, chan, aux, annfs=readannot.rdann('sampledata/100', 'atr')\n", |
| 315 | + "annsamp, anntype, num, subtype, chan, aux, annfs=rdann('sampledata/100', 'atr')\n", |
298 | 316 | "\n", |
299 | 317 | "\n", |
300 | 318 | "# Test 2\n", |
301 | 319 | "# Target file created with: rdann -r chb01_03.edf -a seizures > anntarget2\n", |
302 | | - "annsamp, anntype, num, subtype, chan, aux, annfs=readannot.rdann('sampledata/chb01_03', 'seizures')\n" |
| 320 | + "annsamp, anntype, num, subtype, chan, aux, annfs=rdann('sampledata/chb01_03', 'seizures')\n" |
303 | 321 | ] |
304 | 322 | }, |
305 | 323 | { |
|
310 | 328 | }, |
311 | 329 | "outputs": [], |
312 | 330 | "source": [ |
313 | | - "from wfdb import readannot\n", |
314 | | - "annsamp, anntype, num, subtype, chan, aux, annfs=readannot.rdann('sampledata/100', 'fake2', sampfrom=17)\n", |
| 331 | + "from wfdb import rdann\n", |
| 332 | + "annsamp, anntype, num, subtype, chan, aux, annfs=rdann('sampledata/100', 'fake2', sampfrom=17)\n", |
315 | 333 | "print(\"annsamp: \", annsamp)\n", |
316 | 334 | "print(\"anntype: \", anntype)\n", |
317 | 335 | "print(\"num: \", num)\n", |
|
337 | 355 | }, |
338 | 356 | "outputs": [], |
339 | 357 | "source": [ |
340 | | - "from wfdb import readannot\n", |
341 | | - "annsamp, anntype, num, subtype, chan, aux, annfs=readannot.rdann('sampledata/chb01_03.edf', 'seizures', sampfrom=766977, sampto=777326)\n", |
| 358 | + "from wfdb import rdann\n", |
| 359 | + "annsamp, anntype, num, subtype, chan, aux, annfs=rdann('sampledata/chb01_03.edf', 'seizures', sampfrom=766977, sampto=777326)\n", |
342 | 360 | "print(\"annsamp: \", annsamp)\n", |
343 | 361 | "print(\"anntype: \", anntype)\n", |
344 | 362 | "print(\"num: \", num)\n", |
|
356 | 374 | }, |
357 | 375 | "outputs": [], |
358 | 376 | "source": [ |
359 | | - "from wfdb import readannot\n", |
360 | | - "annsamp, anntype, num, subtype, chan, aux, annfs=readannot.rdann('sampledata/100', 'fake3', anndisp=1)\n", |
| 377 | + "from wfdb import rdann\n", |
| 378 | + "annsamp, anntype, num, subtype, chan, aux, annfs=rdann('sampledata/100', 'fake3', anndisp=1)\n", |
361 | 379 | "print(\"annsamp: \", annsamp)\n", |
362 | 380 | "print(\"anntype: \", anntype)\n", |
363 | 381 | "print(\"num: \", num)\n", |
|
412 | 430 | "indata.tofile(f)\n", |
413 | 431 | "f.close()\n", |
414 | 432 | "\n", |
415 | | - "from wfdb import readsignal\n", |
416 | | - "sig, fields=readsignal.rdsamp('tmp')\n", |
| 433 | + "from wfdb import rdsamp\n", |
| 434 | + "sig, fields=rdsamp('tmp')\n", |
417 | 435 | "print(sig)\n" |
418 | 436 | ] |
419 | 437 | }, |
|
471 | 489 | "outputs": [], |
472 | 490 | "source": [ |
473 | 491 | "# Testing format 310 record. Written using rdsamp -r sampledata/100 | cut -f 2- | wrsamp -o test310 -O 310 \n", |
474 | | - "from wfdb import readsignal\n", |
475 | | - "sig, fields=readsignal.rdsamp('sampledata/test310', physical=0, sampto=1)\n", |
| 492 | + "from wfdb import rdsamp\n", |
| 493 | + "sig, fields=rdsamp('sampledata/test310', physical=0, sampto=1)\n", |
476 | 494 | "print(\"sig final output:\\n\", sig)\n", |
477 | 495 | "#print(sig.shape)\n", |
478 | 496 | "\n", |
|
490 | 508 | "outputs": [], |
491 | 509 | "source": [ |
492 | 510 | "# Testing format 311 record. Written using rdsamp -r sampledata/100 | cut -f 2- | wrsamp -o test311 -O 311\n", |
493 | | - "from wfdb import readsignal\n", |
494 | | - "sig, fields=readsignal.rdsamp('sampledata/test311', physical=0)\n", |
| 511 | + "from wfdb import rdsamp\n", |
| 512 | + "sig, fields=rdsamp('sampledata/test311', physical=0)\n", |
495 | 513 | "print(\"sig final output:\\n\", sig)\n", |
496 | 514 | "#print(sig.shape)\n", |
497 | 515 | "\n", |
|
508 | 526 | }, |
509 | 527 | "outputs": [], |
510 | 528 | "source": [ |
511 | | - "from wfdb import readsignal\n", |
512 | | - "sig, fields=readsignal.rdsamp('sampledata/s0010_re', sampfrom=5000, sampto=38000, channels=[13, 0, 4, 8, 3])\n", |
| 529 | + "from wfdb import rdsamp\n", |
| 530 | + "sig, fields=rdsamp('sampledata/s0010_re', sampfrom=5000, sampto=38000, channels=[13, 0, 4, 8, 3])\n", |
513 | 531 | "sig=sig[:-4,:]\n", |
514 | 532 | "\n", |
515 | 533 | "\n", |
|
713 | 731 | " " |
714 | 732 | ] |
715 | 733 | }, |
716 | | - { |
717 | | - "cell_type": "code", |
718 | | - "execution_count": null, |
719 | | - "metadata": { |
720 | | - "collapsed": false |
721 | | - }, |
722 | | - "outputs": [], |
723 | | - "source": [ |
724 | | - "# Testing the results of getPBfiles, seeing if rdsamp works after files have been downloaded. \n", |
725 | | - "import os\n", |
726 | | - "\n", |
727 | | - "\n", |
728 | | - "\n", |
729 | | - "os.chdir('/home/cx1111/Downloads')\n", |
730 | | - "from wfdb import readsignal\n", |
731 | | - "\n", |
732 | | - "sig, fields=readsignal.rdsamp('mimic2wdb/matched/s25047/s25047-2704-05-04-10-44')\n", |
733 | | - "#sig, fields=readsignal.rdsamp('Testfolder/s25047-2704-05-04-10-44')\n", |
734 | | - "\n", |
735 | | - "print(sig)" |
736 | | - ] |
737 | | - }, |
738 | 734 | { |
739 | 735 | "cell_type": "code", |
740 | 736 | "execution_count": null, |
|
813 | 809 | " " |
814 | 810 | ] |
815 | 811 | }, |
816 | | - { |
817 | | - "cell_type": "code", |
818 | | - "execution_count": null, |
819 | | - "metadata": { |
820 | | - "collapsed": false |
821 | | - }, |
822 | | - "outputs": [], |
823 | | - "source": [] |
824 | | - }, |
825 | 812 | { |
826 | 813 | "cell_type": "code", |
827 | 814 | "execution_count": null, |
|
848 | 835 | "name": "python", |
849 | 836 | "nbconvert_exporter": "python", |
850 | 837 | "pygments_lexer": "ipython3", |
851 | | - "version": "3.5.1" |
| 838 | + "version": "3.5.2" |
852 | 839 | } |
853 | 840 | }, |
854 | 841 | "nbformat": 4, |
|
0 commit comments