Skip to content

Commit

Permalink
rdrecord: allow smooth_frames=False for multi-segment records.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Benjamin Moody committed Oct 13, 2021
1 parent 9797577 commit 1e30da0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions wfdb/io/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,6 @@ def check_read_inputs(self, sampfrom, sampto, channels, physical,
if physical is True and return_res == 8:
raise ValueError("return_res must be one of the following when physical is True: 64, 32, 16")

# Cannot expand multiple samples/frame for multi-segment records
if isinstance(self, MultiRecord):
if smooth_frames is False:
raise ValueError('This package version cannot expand all samples when reading multi-segment records. Must enable frame smoothing.')


def _adjust_datetime(self, sampfrom):
"""
Expand Down Expand Up @@ -3678,7 +3673,7 @@ def rdrecord(record_name, sampfrom=0, sampto=None, channels=None,
os.path.join(dir_name, record.seg_name[seg_num]),
sampfrom=seg_ranges[i][0], sampto=seg_ranges[i][1],
channels=seg_channels[i], physical=physical, pn_dir=pn_dir,
return_res=return_res)
smooth_frames=smooth_frames, return_res=return_res)

# Arrange the fields of the layout specification segment, and
# the overall object, to reflect user input.
Expand All @@ -3689,6 +3684,7 @@ def rdrecord(record_name, sampfrom=0, sampto=None, channels=None,
# Convert object into a single segment Record object
if m2s:
record = record.multi_to_single(physical=physical,
expanded=(not smooth_frames),
return_res=return_res)

# Perform dtype conversion if necessary
Expand Down

0 comments on commit 1e30da0

Please sign in to comment.