Skip to content

Commit 1b9c90c

Browse files
author
Benjamin Moody
committed
rdrecord: handle smooth_frames when maximum spf is 1.
rdrecord can return signal data in any of four formats: - by resampling all signals to a uniform rate ("smoothing"), and setting d_signal to a two-dimensional array, where d_signal[t,s] is sample t of signal s - by resampling to a uniform rate, and setting p_signal to a two-dimensional array, where p_signal[t,s] is sample t of signal s converted into physical units - by setting e_d_signal to a list of one-dimensional arrays, where e_d_signal[s][t] is sample t of signal s - by setting e_p_signal to a list of one-dimensional arrays, where e_p_signal[s][t] is sample t of signal s converted into physical units If the selected signals contain multiple samples per frame, the behavior of rdrecord is consistent: - If smooth_frames is True, the selected signals are resampled to the frame rate and stored as d_signal or p_signal. - If smooth_frames is False, the selected signals are stored in their original form as e_d_signal or e_p_signal. However, if each of the selected signals contains only one sample per frame, rdrecord would previously behave inconsistently: - If all signals in the record contain only one sample per frame, and smooth_frames is False and physical is True, the selected signals would be stored as p_signal (not e_p_signal as the caller would expect.) - If all signals in the record contain only one sample per frame, and smooth_frames is False and physical is False, rdrecord would crash with a TypeError in convert_dtype. - If some signals in the record contain multiple samples per frame (but the selected signals don't), rdrecord would crash with an AttributeError in _arrange_fields. Change this behavior so that if smooth_frames is false, rdrecord will always store the signals as e_d_signal or e_p_signal, regardless of the underlying number of samples per frame.
1 parent 3e84119 commit 1b9c90c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

wfdb/io/record.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,10 +3363,9 @@ def rdrecord(record_name, sampfrom=0, sampto=None, channels=None,
33633363
directly return a WFDB MultiRecord object (False), or to convert
33643364
it into and return a WFDB Record object (True).
33653365
smooth_frames : bool, optional
3366-
Used when reading records with signals having multiple samples
3367-
per frame. Specifies whether to smooth the samples in signals
3368-
with more than one sample per frame and return an (MxN) uniform
3369-
numpy array as the `d_signal` or `p_signal` field (True), or to
3366+
Specifies whether to smooth the samples in signals with more
3367+
than one sample per frame and return an (MxN) uniform numpy
3368+
array as the `d_signal` or `p_signal` field (True), or to
33703369
return a list of 1d numpy arrays containing every expanded
33713370
sample as the `e_d_signal` or `e_p_signal` field (False).
33723371
ignore_skew : bool, optional
@@ -3535,7 +3534,7 @@ def rdrecord(record_name, sampfrom=0, sampto=None, channels=None,
35353534
return_res=return_res)
35363535

35373536
# Only 1 sample/frame, or frames are smoothed. Return uniform numpy array
3538-
if smooth_frames or max([record.samps_per_frame[c] for c in channels]) == 1:
3537+
if smooth_frames:
35393538
# Read signals from the associated dat files that contain
35403539
# wanted channels
35413540
record.d_signal = signals

0 commit comments

Comments
 (0)