@@ -12,22 +12,22 @@ class Annotation():
12
12
"""
13
13
The class representing WFDB annotations.
14
14
15
- Annotation objects can be created as with any other class , or by reading a WFDB annotation
15
+ Annotation objects can be created using the constructor , or by reading a WFDB annotation
16
16
file with 'rdann'.
17
17
18
18
The attributes of the Annotation object give information about the annotation as specified
19
- by https://www.physionet.org/physiotools/wag/ <INSERT> :
19
+ by https://www.physionet.org/physiotools/wag/annot-5.htm :
20
20
- annsamp: The annotation location in samples relative to the beginning of the record.
21
21
- anntype: The annotation type according the the standard WFDB codes.
22
22
- subtype: The marked class/category of the annotation.
23
23
- chan: The signal channel associated with the annotations.
24
24
- num: The labelled annotation number.
25
25
- aux: The auxiliary information string for the annotation.
26
- - fs: The sampling frequency of the record.
26
+ - fs: The sampling frequency of the record if contained in the annotation file .
27
27
28
28
Call 'showanncodes()' to see the list of standard annotation codes. Any text used to label
29
- annotations that are not one of the codes go in the 'aux' field rather than the 'anntype'
30
- field.
29
+ annotations that are not one of these codes should go in the 'aux' field rather than the
30
+ 'anntype' field.
31
31
"""
32
32
def __init__ (self , recordname , annotator , annsamp , anntype , subtype = None , chan = None , num = None , aux = None , fs = None ):
33
33
self .recordname = recordname
@@ -350,28 +350,59 @@ def field2bytes(field, value):
350
350
351
351
352
352
# Function for writing annotations
353
- def wrann (recordname , annotator , annsamp , anntype , num = None , subtype = None , chan = None , aux = None , fs = None ):
354
- # Create Annotation object
355
- annotation = Annotation (recordname , annotator , annsamp , anntype , num , subtype , chan , aux , fs )
356
- # Perform field checks and write the annotation file
357
- annotation .wrann ()
353
+ def wrann (recordname , annotator , annsamp , anntype , subtype = None , chan = None , num = None , aux = None , fs = None ):
354
+ """Write a WFDB annotation file.
355
+
356
+ Usage:
357
+ wrann(recordname, annotator, annsamp, anntype, num = None, subtype = None, chan = None, aux = None, fs = None)
358
+
359
+ Input arguments:
360
+ - recordname (required): The string name of the WFDB record to be written (without any file extensions).
361
+ - annsamp (required): The annotation location in samples relative to the beginning of the record.
362
+ - anntype (required): The annotation type according the the standard WFDB codes.
363
+ - subtype (default=None): The marked class/category of the annotation.
364
+ - chan (default=None): The signal channel associated with the annotations.
365
+ - num (default=None): The labelled annotation number.
366
+ - aux (default=None): The auxiliary information string for the annotation.
367
+ - fs (default=None): The numerical sampling frequency of the record to be written to the file.
368
+
369
+ Note: This gateway function was written to enable a simple way to write WFDB annotation files without
370
+ needing to explicity create an Annotation object beforehand.
371
+
372
+ You may also create an Annotation object, manually set its attributes, and call its wrann() instance method.
373
+
374
+ Example Usage:
375
+ import wfdb
376
+ # Read an annotation as an Annotation object
377
+ annotation = wfdb.rdann('b001', 'atr', pbdir='cebsdb')
378
+ # Call the gateway wrann function, manually inserting fields as function input parameters
379
+ wfdb.wrann('b001', 'cpy', annotation.annsamp, annotation.anntype)
380
+ """
381
+
382
+ # Create Annotation object
383
+ annotation = Annotation (recordname , annotator , annsamp , anntype , num , subtype , chan , aux , fs )
384
+ # Perform field checks and write the annotation file
385
+ annotation .wrann ()
358
386
359
387
# Display the annotation symbols and the codes they represent
360
388
def showanncodes ():
361
389
"""
362
- Display the annotation symbols and the codes they represent
390
+ Display the annotation symbols and the codes they represent according to the
391
+ standard WFDB library 10.5.24
363
392
364
- Usage: showanncodes()
393
+ Usage:
394
+ showanncodes()
365
395
"""
366
396
display (symcodes )
367
397
368
398
## ------------- Reading Annotations ------------- ##
369
399
370
400
def rdann (recordname , annotator , sampfrom = 0 , sampto = None , pbdir = None ):
371
- """ Read a WFDB annotation file recordname.annotator and return the fields as lists or arrays
401
+ """ Read a WFDB annotation file recordname.annotator and return an
402
+ Annotation object.
372
403
373
404
Usage:
374
- annotation = rdann(recordname, annot , sampfrom=0, sampto=None)
405
+ annotation = rdann(recordname, annotator , sampfrom=0, sampto=None, pbdir =None)
375
406
376
407
Input arguments:
377
408
- recordname (required): The record name of the WFDB annotation file. ie. for
@@ -380,9 +411,12 @@ def rdann(recordname, annotator, sampfrom=0, sampto=None, pbdir=None):
380
411
file '100.atr', annotator='atr'
381
412
- sampfrom (default=0): The minimum sample number for annotations to be returned.
382
413
- sampto (default=None): The maximum sample number for annotations to be returned.
414
+ - pbdir (default=None): Option used to stream data from Physiobank. The Physiobank database
415
+ directory from which to find the required annotation file.
416
+ eg. For record '100' in 'http://physionet.org/physiobank/database/mitdb', pbdir = 'mitdb'.
383
417
384
418
Output argument:
385
- - annotation: The annotation object. Call help(wfdb.Annotation) for the attribute
419
+ - annotation: The Annotation object. Call help(wfdb.Annotation) for the attribute
386
420
descriptions.
387
421
388
422
Note: For every annotation sample, the annotation file explictly stores the 'annsamp'
0 commit comments