Skip to content

Commit e0a719d

Browse files
committed
Ventricular rate from VRate tag.
VRate was ignored and ventricular rate was always calculated from RR Interval. Now if VRate is present it is used in the legend string, if VRate is not defined we fall back calculating the ventricular rate.
1 parent 233a7db commit e0a719d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

ecg/ecg.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ def legend(self):
342342
'QT Interval',
343343
'QTc Interval',
344344
'RR Interval',
345+
'VRate',
345346
'QRS Duration',
346347
'QRS Axis',
347348
'T Axis',
@@ -350,18 +351,22 @@ def legend(self):
350351
):
351352
ecgdata[cncs.CodeMeaning] = str(was.NumericValue)
352353

353-
ret_str = "%s: -\n" % i18n.ventr_freq
354-
if ecgdata.get('RR Interval'):
354+
# If VRate is not defined we calculate ventricular rate from
355+
# RR interval
356+
try:
357+
vrate = float(ecgdata.get('VRate'))
358+
except (TypeError, ValueError):
355359
try:
356-
bpm = (
360+
vrate = (
357361
60.0 / self.duration *
358-
self.samples / float(ecgdata['RR Interval'])
362+
self.samples / float(ecgdata.get('RR Interval'))
359363
)
360-
ret_str = "%s: %.1f BPM\n" % (i18n.ventr_freq, bpm)
361-
except ZeroDivisionError:
362-
pass
364+
except (TypeError, ValueError, ZeroDivisionError):
365+
vrate = "(unknown)"
363366

367+
ret_str = "%s: %.1f BPM\n" % (i18n.ventr_freq, vrate)
364368
ret_str_tmpl = "%s: %s ms\n%s: %s ms\n%s: %s/%s ms\n%s: %s %s %s"
369+
365370
ret_str += ret_str_tmpl % (
366371
i18n.pr_interval,
367372
ecgdata.get('PR Interval', ''),

0 commit comments

Comments
 (0)