@@ -1170,14 +1170,14 @@ def calc_core_bytes(self):
11701170
11711171 # Process the samp (difference) and sym items
11721172 data_bytes .append (
1173- field2bytes ("samptype" , [sampdiff [i ], self .symbol [i ]])
1173+ field2bytes ("samptype" , [sampdiff [i ], self .symbol [i ]], self . custom_labels )
11741174 )
11751175
11761176 # Process the extra optional fields
11771177 for field in extra_write_fields :
11781178 value = getattr (compact_annotation , field )[i ]
11791179 if value is not None :
1180- data_bytes .append (field2bytes (field , value ))
1180+ data_bytes .append (field2bytes (field , value , self . custom_labels ))
11811181
11821182 # Flatten and convert to correct format
11831183 data_bytes = np .array (
@@ -1600,7 +1600,7 @@ def compact_carry_field(full_field):
16001600 return compact_field
16011601
16021602
1603- def field2bytes (field , value ):
1603+ def field2bytes (field , value , custom_labels = None ):
16041604 """
16051605 Convert an annotation field into bytes to write.
16061606
@@ -1619,11 +1619,16 @@ def field2bytes(field, value):
16191619 """
16201620 data_bytes = []
16211621
1622+ # allow use of custom labels
1623+ label_table = ann_label_table
1624+ if custom_labels is not None :
1625+ label_table = pd .concat ([label_table , custom_labels ], ignore_index = True )
1626+
16221627 # samp and sym bytes come together
16231628 if field == "samptype" :
16241629 # Numerical value encoding annotation symbol
1625- typecode = ann_label_table .loc [
1626- ann_label_table ["symbol" ] == value [1 ], "label_store"
1630+ typecode = label_table .loc [
1631+ label_table ["symbol" ] == value [1 ], "label_store"
16271632 ].values [0 ]
16281633
16291634 # sample difference
0 commit comments