Skip to content

Commit e3813f7

Browse files
author
Benjamin Moody
committed
plot_wfdb: handle differing frame/annotation frequencies.
An annotation file (represented by a wfdb.Annotation object) may have a "sampling frequency" that differs from the sampling frequency or frequencies of the signals themselves. This will be the case, for example, for annotations generated by programs like sqrs that operate on an upsampled or downsampled copy of the input signals. To handle this case, since record.fs does not equal annotation.fs, we must explicitly specify both sampling_freq and ann_freq when calling plot_items.
1 parent 0cd0486 commit e3813f7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

wfdb/plot/plot.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,12 +779,25 @@ def plot_wfdb(record=None, annotation=None, plot_sym=False,
779779
annotation=annotation,
780780
plot_sym=plot_sym)
781781

782+
if record:
783+
sampling_freq = record.fs
784+
else:
785+
sampling_freq = None
786+
787+
if annotation and annotation.fs is not None:
788+
ann_freq = annotation.fs
789+
elif record:
790+
ann_freq = record.fs
791+
else:
792+
ann_freq = None
793+
782794
return plot_items(signal=signal, ann_samp=ann_samp, ann_sym=ann_sym, fs=fs,
783795
time_units=time_units, ylabel=ylabel,
784796
title=(title or record_name),
785797
sig_style=sig_style, sig_units=sig_units,
786798
ann_style=ann_style, ecg_grids=ecg_grids,
787-
figsize=figsize, return_fig=return_fig)
799+
figsize=figsize, return_fig=return_fig,
800+
sampling_freq=sampling_freq, ann_freq=ann_freq)
788801

789802

790803
def get_wfdb_plot_items(record, annotation, plot_sym):

0 commit comments

Comments
 (0)