Skip to content

Commit 99761e3

Browse files
committed
adcgain defaults to float 200. dac divides by float gain for safety
1 parent d8b7b43 commit 99761e3

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Versions should comply with PEP440. For a discussion on single-sourcing
2121
# the version across setup.py and the project code, see
2222
# https://packaging.python.org/en/latest/single_source_version.html
23-
version='1.0.3',
23+
version='1.0.4',
2424

2525
description='The WFDB Python Toolbox',
2626
long_description=long_description,

wfdb/_headers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ def read_rec_line(recline):
441441

442442
# Extract fields from signal line strings into a dictionary
443443
def read_sig_lines(siglines):
444-
445444
# Dictionary for signal fields
446445
d_sig = {}
447446

@@ -471,6 +470,7 @@ def read_sig_lines(siglines):
471470
# that different channels can be present or missing.
472471
if d_sig[field][i] == '':
473472
d_sig[field][i] = sigfieldspecs[field].read_def
473+
474474
# Special case: missing baseline defaults to ADCzero if present
475475
if field == 'baseline' and d_sig['adczero'][i] != '':
476476
d_sig['baseline'][i] = int(d_sig['adczero'][i])
@@ -482,7 +482,7 @@ def read_sig_lines(siglines):
482482
d_sig[field][i] = float(d_sig[field][i])
483483
# Special case: gain of 0 means 200
484484
if field == 'adcgain' and d_sig['adcgain'][i] == 0:
485-
d_sig['adcgain'][i] = 200
485+
d_sig['adcgain'][i] = 200.
486486

487487
return d_sig
488488

@@ -566,7 +566,7 @@ def __init__(self, allowedtypes, delimiter, dependency, write_req, read_def, wri
566566
('sampsperframe', WFDBheaderspecs(inttypes, 'x', 'fmt', False, None, None)),
567567
('skew', WFDBheaderspecs(inttypes, ':', 'fmt', False, None, None)),
568568
('byteoffset', WFDBheaderspecs(inttypes, '+', 'fmt', False, None, None)),
569-
('adcgain', WFDBheaderspecs(floattypes, ' ', 'fmt', True, 200, None)),
569+
('adcgain', WFDBheaderspecs(floattypes, ' ', 'fmt', True, 200., None)),
570570
('baseline', WFDBheaderspecs(inttypes, '(', 'adcgain', True, 0, None)),
571571
('units', WFDBheaderspecs([str], '/', 'adcgain', True, 'mV', None)),
572572
('adcres', WFDBheaderspecs(inttypes, ' ', 'adcgain', False, None, 0)),

wfdb/_signals.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,14 @@ def adc(self):
168168
def dac(self):
169169

170170
# The digital nan values for each channel
171-
dnans = digi_nan(self.fmt)
171+
dnans = digi_nan(self.fmt)
172172

173173
# Get nan indices, indicated by minimum value.
174174
nanlocs = self.d_signals == dnans
175175

176-
p_signal = (self.d_signals - self.baseline)/self.adcgain
177-
176+
# adcgain values must be float for python 2 to ensure dtype = float64
177+
p_signal = (self.d_signals - self.baseline)/[float(g) for g in self.adcgain]
178+
178179
p_signal[nanlocs] = np.nan
179180

180181
return p_signal

wfdb/records.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,13 @@ def requiredsegments(self, sampfrom, sampto, channels):
527527

528528
# Obtain the sampfrom and sampto to read for each segment
529529
if readsegs[1] == readsegs[0]:
530-
#print('a')
531530
# Only one segment to read
532531
readsegs = [readsegs[0]]
533532
# The segment's first sample number relative to the entire record
534533
segstartsamp = sum(self.seglen[0:readsegs[0]])
535534
readsamps = [[sampfrom-segstartsamp, sampto-segstartsamp]]
536535

537536
else:
538-
#print('b')
539537
# More than one segment to read
540538
readsegs = list(range(readsegs[0], readsegs[1]+1))
541539
readsamps = [[0, self.seglen[s]] for s in readsegs]

0 commit comments

Comments
 (0)