Skip to content

Commit a12cc69

Browse files
committed
More descriptive annotation error message MIT-LCP#162
l
1 parent f4ada09 commit a12cc69

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

wfdb/io/annotation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pandas as pd
55
import re
66
import posixpath
7+
import pdb
78

89
from . import download
910
from . import _header

wfdb/plot/plot.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import matplotlib.pyplot as plt
22
import numpy as np
33
import os
4+
import pdb
45

56
from ..io.record import Record, rdrecord
67
from ..io._header import float_types
@@ -91,7 +92,7 @@ def plot_items(signal=None, ann_samp=None, ann_sym=None, fs=None,
9192
>>> ann = wfdb.rdann('sample-data/100', 'atr', sampto=3000)
9293
9394
>>> wfdb.plot_items(signal=record.p_signal,
94-
annotation=[ann.sample, ann.sample],
95+
ann_samp=[ann.sample, ann.sample],
9596
title='MIT-BIH Record 100', time_units='seconds',
9697
figsize=(10,4), ecg_grids='all')
9798
@@ -302,13 +303,17 @@ def plot_annotation(ann_samp, n_annot, ann_sym, signal, n_sig, fs, time_units,
302303
# Figure out the y values to plot on a channel basis
303304

304305
# 1 dimensional signals
305-
if n_sig > ch:
306-
if signal.ndim == 1:
307-
y = signal[ann_samp[ch]]
306+
try:
307+
if n_sig > ch:
308+
if signal.ndim == 1:
309+
y = signal[ann_samp[ch]]
310+
else:
311+
y = signal[ann_samp[ch], ch]
308312
else:
309-
y = signal[ann_samp[ch], ch]
310-
else:
311-
y = np.zeros(len(ann_samp[ch]))
313+
y = np.zeros(len(ann_samp[ch]))
314+
except IndexError:
315+
raise Exception('IndexError: try setting shift_samps=True in '
316+
'the "rdann" function?')
312317

313318
axes[ch].plot(ann_samp[ch] / downsample_factor, y, ann_style[ch])
314319

@@ -529,9 +534,9 @@ def plot_wfdb(record=None, annotation=None, plot_sym=False,
529534
Parameters
530535
----------
531536
record : WFDB Record, optional
532-
The Record object to be plotted
537+
The Record object to be plotted.
533538
annotation : WFDB Annotation, optional
534-
The Annotation object to be plotted
539+
The Annotation object to be plotted.
535540
plot_sym : bool, optional
536541
Whether to plot the annotation symbols on the graph.
537542
time_units : str, optional

0 commit comments

Comments
 (0)