@@ -86,7 +86,7 @@ def wrann(self):
8686 # Return indices of anntype field which are not encoded, and thus need
8787 # to be moved to the aux field.
8888 def checkfields (self ):
89- # Enforce mandatory write fields
89+ # Enforce the presence of mandatory write fields
9090 for field in ['recordname' , 'annotator' , 'annsamp' , 'anntype' ]:
9191 if getattr (self , field ) is None :
9292 print ('The ' , field , ' field is mandatory for writing annotation files' )
@@ -127,9 +127,9 @@ def checkfield(self, field):
127127 else :
128128 fielditem = getattr (self , field )
129129
130- # Ensure the field item is a list.
131- if type (fielditem ) != list :
132- print ('The ' , field , ' field must be a list' )
130+ # Ensure the field item is a list or array .
131+ if type (fielditem ) not in [ list , np . ndarray ] :
132+ print ('The ' , field , ' field must be a list or numpy array ' )
133133 sys .exit ()
134134
135135 # Check the data types of the elements
@@ -164,20 +164,20 @@ def checkfield(self, field):
164164 if set (self .anntype ) - set (annsyms .values ()) != set ():
165165 print ("The 'anntype' field contains items not encoded in the WFDB annotation library." )
166166 print ('To see the valid annotation codes call: showanncodes()' )
167- print ('To transfer non-encoded anntype items into the aux field call: self.type2aux' )
167+ print ('To transfer non-encoded anntype items into the aux field call: self.type2aux() ' )
168168 sys .exit ()
169- elif field == 'num' :
170- # signed character
171- if min (self .num ) < 0 or max (self .num ) > 255 :
172- sys .exit ("The 'num' field must only contain non-negative integers up to 255" )
173169 elif field == 'subtype' :
174170 # signed character
175171 if min (self .subtype ) < 0 or max (self .subtype ) > 127 :
176172 sys .exit ("The 'subtype' field must only contain non-negative integers up to 127" )
177173 elif field == 'chan' :
178174 # unsigned character
179- if min (self .chan ) < 0 or max (self .chan ) > 127 :
180- sys .exit ("The 'chan' field must only contain non-negative integers up to 127" )
175+ if min (self .chan ) < 0 or max (self .chan ) > 255 :
176+ sys .exit ("The 'chan' field must only contain non-negative integers up to 255" )
177+ elif field == 'num' :
178+ # signed character
179+ if min (self .num ) < 0 or max (self .num ) > 127 :
180+ sys .exit ("The 'num' field must only contain non-negative integers up to 127" )
181181 #elif field == 'aux': # No further conditions for aux field.
182182
183183
@@ -769,7 +769,7 @@ def proccustomtypes(annsamp,anntype,num,subtype,chan,aux):
769769
770770# Mapping annotation symbols to the annotation codes
771771# For printing/user guidance
772- symcodes = pd .DataFrame ({'Ann Symbol' : list (annsyms .values ()), 'Ann Code/ Meaning' : list (anncodes .values ())})
772+ symcodes = pd .DataFrame ({'Ann Symbol' : list (annsyms .values ()), 'Ann Code Meaning' : list (anncodes .values ())})
773773symcodes = symcodes .set_index ('Ann Symbol' , list (annsyms .values ()))
774774
775775annfields = ['recordname' , 'annotator' , 'annsamp' , 'anntype' , 'num' , 'subtype' , 'chan' , 'aux' , 'fs' ]
0 commit comments