@@ -1170,14 +1170,14 @@ def calc_core_bytes(self):
1170
1170
1171
1171
# Process the samp (difference) and sym items
1172
1172
data_bytes .append (
1173
- field2bytes ("samptype" , [sampdiff [i ], self .symbol [i ]])
1173
+ field2bytes ("samptype" , [sampdiff [i ], self .symbol [i ]], self . custom_labels )
1174
1174
)
1175
1175
1176
1176
# Process the extra optional fields
1177
1177
for field in extra_write_fields :
1178
1178
value = getattr (compact_annotation , field )[i ]
1179
1179
if value is not None :
1180
- data_bytes .append (field2bytes (field , value ))
1180
+ data_bytes .append (field2bytes (field , value , self . custom_labels ))
1181
1181
1182
1182
# Flatten and convert to correct format
1183
1183
data_bytes = np .array (
@@ -1600,7 +1600,7 @@ def compact_carry_field(full_field):
1600
1600
return compact_field
1601
1601
1602
1602
1603
- def field2bytes (field , value ):
1603
+ def field2bytes (field , value , custom_labels = None ):
1604
1604
"""
1605
1605
Convert an annotation field into bytes to write.
1606
1606
@@ -1619,11 +1619,17 @@ def field2bytes(field, value):
1619
1619
"""
1620
1620
data_bytes = []
1621
1621
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
+ print (label_table )
1627
+
1622
1628
# samp and sym bytes come together
1623
1629
if field == "samptype" :
1624
1630
# Numerical value encoding annotation symbol
1625
- typecode = ann_label_table .loc [
1626
- ann_label_table ["symbol" ] == value [1 ], "label_store"
1631
+ typecode = label_table .loc [
1632
+ label_table ["symbol" ] == value [1 ], "label_store"
1627
1633
].values [0 ]
1628
1634
1629
1635
# sample difference
0 commit comments