Skip to content

Commit 8098338

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 d330a4a commit 8098338

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

wfdb/io/record.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,6 @@ def check_read_inputs(
510510
"return_res must be one of the following when physical is True: 64, 32, 16"
511511
)
512512

513-
# Cannot expand multiple samples/frame for multi-segment records
514-
if isinstance(self, MultiRecord):
515-
if not smooth_frames:
516-
raise ValueError(
517-
"This package version cannot expand all samples when reading multi-segment records. Must enable frame smoothing."
518-
)
519-
520513
def _adjust_datetime(self, sampfrom):
521514
"""
522515
Adjust date and time fields to reflect user input if possible.
@@ -4226,6 +4219,7 @@ def rdrecord(
42264219
channels=seg_channels[i],
42274220
physical=physical,
42284221
pn_dir=pn_dir,
4222+
smooth_frames=smooth_frames,
42294223
return_res=return_res,
42304224
)
42314225

@@ -4242,7 +4236,9 @@ def rdrecord(
42424236
# Convert object into a single segment Record object
42434237
if m2s:
42444238
record = record.multi_to_single(
4245-
physical=physical, return_res=return_res
4239+
physical=physical,
4240+
expanded=(not smooth_frames),
4241+
return_res=return_res,
42464242
)
42474243

42484244
# Perform dtype conversion if necessary

0 commit comments

Comments
 (0)