@@ -33,7 +33,7 @@ Objects
33
33
As of version 1.0.0, wfdb records are stored in **Record ** or **MultiRecord ** objects, and annotations are stored in **Annotation ** objects. To see all attributes of an object, call `object.__dict__ `
34
34
35
35
36
- **record ** - The class representing WFDB headers, and single segment WFDB records.
36
+ **Record ** - The class representing WFDB headers, and single segment WFDB records.
37
37
38
38
Record objects can be created using the constructor, by reading a WFDB header
39
39
with 'rdheader', or a WFDB record (header and associated dat files) with rdsamp'
@@ -48,20 +48,21 @@ signals of WFDB records with at least one channel.
48
48
Contructor function:
49
49
::
50
50
51
- def __init__(self, p_signals=None, d_signals=None,
52
- recordname=None, nsig=None,
53
- fs=None, counterfreq=None, basecounter=None,
54
- siglen=None, basetime=None, basedate=None,
55
- filename=None, fmt=None, sampsperframe=None,
56
- skew=None, byteoffset=None, adcgain=None,
57
- baseline=None, units=None, adcres=None,
58
- adczero=None, initvalue=None, checksum=None,
59
- blocksize=None, signame=None, comments=None)
51
+ def __init__(self, p_signals=None, d_signals=None,
52
+ recordname=None, nsig=None,
53
+ fs=None, counterfreq=None, basecounter=None,
54
+ siglen=None, basetime=None, basedate=None,
55
+ filename=None, fmt=None, sampsperframe=None,
56
+ skew=None, byteoffset=None, adcgain=None,
57
+ baseline=None, units=None, adcres=None,
58
+ adczero=None, initvalue=None, checksum=None,
59
+ blocksize=None, signame=None, comments=None)
60
60
61
61
Example Usage:
62
62
::
63
- import wfdb
64
- record1 = wfdb.Record(recordname='r1', fs=250, nsig=2, siglen=1000, filename=['r1.dat','r1.dat'])
63
+
64
+ import wfdb
65
+ record1 = wfdb.Record(recordname='r1', fs=250, nsig=2, siglen=1000, filename=['r1.dat','r1.dat'])
65
66
66
67
67
68
**MultiRecord ** - The class representing multi-segment WFDB records.
@@ -81,6 +82,7 @@ of the record as a Record object. The resulting Record object will have its 'p_s
81
82
82
83
Contructor function:
83
84
::
85
+
84
86
def __init__(self, segments = None, layout = None,
85
87
recordname=None, nsig=None, fs=None,
86
88
counterfreq=None, basecounter=None,
@@ -89,6 +91,7 @@ Contructor function:
89
91
90
92
Example Usage:
91
93
::
94
+
92
95
import wfdb
93
96
recordM = wfdb.MultiRecord(recordname='rm', fs=50, nsig=8, siglen=9999, segname=['rm_1', '~', rm_2'], seglen=[800, 200, 900])
94
97
@@ -103,23 +106,25 @@ file with 'rdann'.
103
106
104
107
The attributes of the Annotation object give information about the annotation as specified
105
108
by https://www.physionet.org/physiotools/wag/annot-5.htm:
106
- - annsamp: The annotation location in samples relative to the beginning of the record.
107
- - anntype: The annotation type according the the standard WFDB codes.
108
- - subtype: The marked class/category of the annotation.
109
- - chan: The signal channel associated with the annotations.
110
- - num: The labelled annotation number.
111
- - aux: The auxiliary information string for the annotation.
112
- - fs: The sampling frequency of the record if contained in the annotation file.
113
-
114
- Constructor function:
109
+ - ``annsamp ``: The annotation location in samples relative to the beginning of the record.
110
+ - ``anntype ``: The annotation type according the the standard WFDB codes.
111
+ - ``subtype ``: The marked class/category of the annotation.
112
+ - ``chan ``: The signal channel associated with the annotations.
113
+ - ``num ``: The labelled annotation number.
114
+ - ``aux ``: The auxiliary information string for the annotation.
115
+ - ``fs ``: The sampling frequency of the record if contained in the annotation file.
116
+
117
+ Constructor function:
118
+ ::
119
+
115
120
def __init__(self, recordname, annotator, annsamp, anntype, subtype = None,
116
121
chan = None, num = None, aux = None, fs = None)
117
122
118
- Call 'showanncodes()' to see the list of standard annotation codes. Any text used to label
119
- annotations that are not one of these codes should go in the 'aux' field rather than the
120
- 'anntype' field.
123
+ Call 'showanncodes()' to see the list of standard annotation codes. Any text used to label annotations that are not one of these codes should go in the 'aux' field rather than the 'anntype' field.
124
+
125
+ Example usage:
126
+ ::
121
127
122
- Example usage:
123
128
import wfdb
124
129
ann1 = wfdb.Annotation(recordname='ann1', annotator='atr', annsamp=[10,20,400],
125
130
anntype = ['N','N','['], aux=[None, None, 'Serious Vfib'])
@@ -131,11 +136,13 @@ Reading Signals
131
136
**rdsamp ** - Read a WFDB record and return the signal and record descriptors as attributes in a Record or MultiRecord object.
132
137
133
138
::
139
+
134
140
record = rdsamp(recordname, sampfrom=0, sampto=None, channels=None, physical=True, pbdir = None, m2s=True)
135
141
136
142
Example Usage:
137
143
138
144
::
145
+
139
146
import wfdb
140
147
ecgrecord = wfdb.rdsamp('sampledata/test01_00s', sampfrom=800, channels = [1,3])
141
148
@@ -156,11 +163,13 @@ Output Arguments:
156
163
**srdsamp ** - A simplified wrapper function around rdsamp. Read a WFDB record and return the physical signal and a few important descriptor fields.
157
164
158
165
::
166
+
159
167
signals, fields = srdsamp(recordname, sampfrom=0, sampto=None, channels=None, pbdir=None)
160
168
161
169
Example Usage:
162
170
163
171
::
172
+
164
173
import wfdb
165
174
sig, fields = wfdb.srdsamp('sampledata/test01_00s', sampfrom=800, channels = [1,3])
166
175
@@ -190,6 +199,7 @@ The Record class has a **wrsamp** instance method for writing wfdb record files.
190
199
**wrsamp ** - Write a single segment WFDB record, creating a WFDB header file and any associated dat files.
191
200
192
201
::
202
+
193
203
wrsamp(recordname, fs, units, signames, p_signals = None, d_signals=None, fmt = None, gain = None, baseline = None, comments = None)
194
204
195
205
Example Usage:
@@ -229,10 +239,12 @@ Reading Annotations
229
239
**rdann ** - Read a WFDB annotation file ``recordname.annot `` and return an Annotation object.
230
240
231
241
::
242
+
232
243
annotation = rdann(recordname, annotator, sampfrom=0, sampto=None, pbdir=None)
233
244
234
245
Example Usage:
235
246
::
247
+
236
248
import wfdb
237
249
ann = wfdb.rdann('sampledata/100', 'atr', sampto = 300000)
238
250
@@ -261,6 +273,7 @@ Output arguments:
261
273
**showanncodes ** - Display the annotation symbols and the codes they represent according to the standard WFDB library 10.5.24
262
274
263
275
::
276
+
264
277
showanncodes()
265
278
266
279
Writing Annotations
@@ -273,11 +286,13 @@ The Annotation class has a **wrann** instance method for writing wfdb annotation
273
286
**wrann ** - Write a WFDB annotation file.
274
287
275
288
::
289
+
276
290
wrann(recordname, annotator, annsamp, anntype, num = None, subtype = None, chan = None, aux = None, fs = None)
277
291
278
292
Example Usage:
279
293
280
294
::
295
+
281
296
import wfdb
282
297
annotation = wfdb.rdann('b001', 'atr', pbdir='cebsdb')
283
298
wfdb.wrann('b001', 'cpy', annotation.annsamp, annotation.anntype)
@@ -303,11 +318,13 @@ Plotting Data
303
318
**plotrec ** - Subplot and label each channel of a WFDB Record. Optionally, subplot annotation locations over selected channels.
304
319
305
320
::
321
+
306
322
plotrec(record=None, title = None, annotation = None, annch = [0], timeunits='samples', returnfig=False)
307
323
308
324
Example Usage:
309
325
310
326
::
327
+
311
328
import wfdb
312
329
record = wfdb.rdsamp('sampledata/100', sampto = 15000)
313
330
annotation = wfdb.rdann('sampledata/100', 'atr', sampto = 15000)
@@ -331,11 +348,13 @@ Output argument:
331
348
**plotann ** - Plot sample locations of an Annotation object.
332
349
333
350
::
351
+
334
352
plotann(annotation, title = None, timeunits = 'samples', returnfig = False)
335
353
336
354
Example Usage:
337
355
338
356
::
357
+
339
358
import wfdb
340
359
record = wfdb.rdsamp('sampledata/100', sampto = 15000)
341
360
annotation = wfdb.rdann('sampledata/100', 'atr', sampto = 15000)
@@ -363,22 +382,26 @@ Download files from various Physiobank databases. The Physiobank index page list
363
382
**getdblist ** - Return a list of all the physiobank databases available.
364
383
365
384
::
385
+
366
386
dblist = wfdb.getdblist()
367
387
368
388
Example Usage:
369
389
370
390
::
391
+
371
392
import wfdb
372
393
dblist = wfdb.getdblist()
373
394
374
395
**dldatabase ** - Download WFDB record (and optionally annotation) files from a Physiobank database. The database must contain a 'RECORDS' file in its base directory which lists its WFDB records.
375
396
376
397
::
398
+
377
399
dldatabase(pbdb, dlbasedir, records = 'all', annotators = 'all' , keepsubdirs = True, overwrite = False)
378
400
379
401
Example Usage:
380
402
381
403
::
404
+
382
405
import wfdb
383
406
wfdb.dldatabase('ahadb', os.getcwd())
384
407
@@ -396,11 +419,13 @@ Input arguments:
396
419
**dldatabasefiles ** - Download specified files from a Physiobank database.
397
420
398
421
::
422
+
399
423
dldatabasefiles(pbdb, dlbasedir, files, keepsubdirs = True, overwrite = False)
400
424
401
425
Example Usage:
402
426
403
427
::
428
+
404
429
import wfdb
405
430
wfdb.dldatabasefiles('ahadb', os.getcwd(), ['STAFF-Studies-bibliography-2016.pdf', 'data/001a.hea', 'data/001a.dat'])
406
431
0 commit comments