Skip to content

Commit 09945bd

Browse files
author
Benjamin Moody
committed
rdrecord: allow smooth_frames=False for multi-segment records.
When reading a multi-segment, multi-frequency record, we want to have the option of reading each signal at its original sampling frequency, which requires using smooth_frames=False. Previously this simply wasn't allowed, either with or without multi-to-single conversion. To do this, we need to ensure each segment is loaded in the appropriate (smooth or non-smooth) mode (which formerly would have failed if certain segments *didn't* contain multiple samples per frame.) After loading the segments, we must invoke multi_to_single, if desired, in the appropriate mode.
1 parent ef7b6f9 commit 09945bd

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

wfdb/io/record.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,6 @@ def check_read_inputs(self, sampfrom, sampto, channels, physical,
412412
if physical and return_res == 8:
413413
raise ValueError("return_res must be one of the following when physical is True: 64, 32, 16")
414414

415-
# Cannot expand multiple samples/frame for multi-segment records
416-
if isinstance(self, MultiRecord):
417-
if not smooth_frames:
418-
raise ValueError('This package version cannot expand all samples when reading multi-segment records. Must enable frame smoothing.')
419-
420415

421416
def _adjust_datetime(self, sampfrom):
422417
"""
@@ -3658,7 +3653,7 @@ def rdrecord(record_name, sampfrom=0, sampto=None, channels=None,
36583653
os.path.join(dir_name, record.seg_name[seg_num]),
36593654
sampfrom=seg_ranges[i][0], sampto=seg_ranges[i][1],
36603655
channels=seg_channels[i], physical=physical, pn_dir=pn_dir,
3661-
return_res=return_res)
3656+
smooth_frames=smooth_frames, return_res=return_res)
36623657

36633658
# Arrange the fields of the layout specification segment, and
36643659
# the overall object, to reflect user input.
@@ -3669,6 +3664,7 @@ def rdrecord(record_name, sampfrom=0, sampto=None, channels=None,
36693664
# Convert object into a single segment Record object
36703665
if m2s:
36713666
record = record.multi_to_single(physical=physical,
3667+
expanded=(not smooth_frames),
36723668
return_res=return_res)
36733669

36743670
# Perform dtype conversion if necessary

0 commit comments

Comments
 (0)