Skip to content

Commit 378a802

Browse files
committed
fix record line regex for base_counter. Fixes MIT-LCP#121
1 parent 8f23d44 commit 378a802

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

wfdb/io/_header.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@
118118
# Record line
119119
_rx_record = re.compile(''.join(
120120
["(?P<record_name>[-\w]+)/?(?P<n_seg>\d*)[ \t]+",
121-
"(?P<n_sig>\d+)[ \t]*",
122-
"(?P<fs>\d*\.?\d*)/*(?P<counterfs>\d*\.?\d*)\(?(?P<base_counter>\d*\.?\d*)\)?[ \t]*",
123-
"(?P<sig_len>\d*)[ \t]*",
121+
"(?P<n_sig>\d+)[ \t]*(?P<fs>\d*\.?\d*)/*(?P<counter_freq>-?\d*\.?\d*)",
122+
"\(?(?P<base_counter>-?\d*\.?\d*)\)?[ \t]*(?P<sig_len>\d*)[ \t]*",
124123
"(?P<base_time>\d{,2}:?\d{,2}:?\d{,2}\.?\d{,6})[ \t]*",
125124
"(?P<base_date>\d{,2}/?\d{,2}/?\d{,4})"])
126125
)
@@ -129,9 +128,10 @@
129128
_rx_signal = re.compile(''.join(
130129
["(?P<file_name>~?[-\w]*\.?[\w]*)[ \t]+(?P<fmt>\d+)x?"
131130
"(?P<samps_per_frame>\d*):?(?P<skew>\d*)\+?(?P<byte_offset>\d*)[ \t]*",
132-
"(?P<adc_gain>-?\d*\.?\d*e?[\+-]?\d*)\(?(?P<baseline>-?\d*)\)?/?(?P<units>[\w\^\-\?%]*)[ \t]*",
133-
"(?P<adc_res>\d*)[ \t]*(?P<adc_zero>-?\d*)[ \t]*(?P<init_value>-?\d*)[ \t]*",
134-
"(?P<checksum>-?\d*)[ \t]*(?P<block_size>\d*)[ \t]*(?P<sig_name>[\S]?[^\t\n\r\f\v]*)"])
131+
"(?P<adc_gain>-?\d*\.?\d*e?[\+-]?\d*)\(?(?P<baseline>-?\d*)\)?",
132+
"/?(?P<units>[\w\^\-\?%]*)[ \t]*(?P<adc_res>\d*)[ \t]*",
133+
"(?P<adc_zero>-?\d*)[ \t]*(?P<init_value>-?\d*)[ \t]*(?P<checksum>-?\d*)",
134+
"[ \t]*(?P<block_size>\d*)[ \t]*(?P<sig_name>[\S]?[^\t\n\r\f\v]*)"])
135135
)
136136

137137
# Segment line
@@ -458,6 +458,9 @@ def wr_header_file(self, rec_write_fields, sig_write_fields, write_dir):
458458
string_field[:4]))
459459

460460
record_line += RECORD_SPECS.loc[field, 'delimiter'] + string_field
461+
# The 'base_counter' field needs to be closed with ')'
462+
if field == 'base_counter':
463+
record_line += ')'
461464

462465
header_lines = [record_line]
463466

wfdb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.1.0'
1+
__version__ = '2.1.1'

0 commit comments

Comments
 (0)