@@ -12,22 +12,22 @@ class Annotation():
1212 """
1313 The class representing WFDB annotations.
1414
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
1616 file with 'rdann'.
1717
1818 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 :
2020 - annsamp: The annotation location in samples relative to the beginning of the record.
2121 - anntype: The annotation type according the the standard WFDB codes.
2222 - subtype: The marked class/category of the annotation.
2323 - chan: The signal channel associated with the annotations.
2424 - num: The labelled annotation number.
2525 - 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 .
2727
2828 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.
3131 """
3232 def __init__ (self , recordname , annotator , annsamp , anntype , subtype = None , chan = None , num = None , aux = None , fs = None ):
3333 self .recordname = recordname
@@ -350,28 +350,59 @@ def field2bytes(field, value):
350350
351351
352352# 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 ()
358386
359387# Display the annotation symbols and the codes they represent
360388def showanncodes ():
361389 """
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
363392
364- Usage: showanncodes()
393+ Usage:
394+ showanncodes()
365395 """
366396 display (symcodes )
367397
368398## ------------- Reading Annotations ------------- ##
369399
370400def 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.
372403
373404 Usage:
374- annotation = rdann(recordname, annot , sampfrom=0, sampto=None)
405+ annotation = rdann(recordname, annotator , sampfrom=0, sampto=None, pbdir =None)
375406
376407 Input arguments:
377408 - 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):
380411 file '100.atr', annotator='atr'
381412 - sampfrom (default=0): The minimum sample number for annotations to be returned.
382413 - 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'.
383417
384418 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
386420 descriptions.
387421
388422 Note: For every annotation sample, the annotation file explictly stores the 'annsamp'
0 commit comments