@@ -320,6 +320,7 @@ def __init__(self, p_signals=None, d_signals=None,
320
320
"""
321
321
# Constructor
322
322
def __init__ (self , p_signals = None , d_signals = None ,
323
+ e_p_signals = None , e_d_signals = None ,
323
324
recordname = None , nsig = None ,
324
325
fs = None , counterfreq = None , basecounter = None ,
325
326
siglen = None , basetime = None , basedate = None ,
@@ -338,6 +339,9 @@ def __init__(self, p_signals=None, d_signals=None,
338
339
339
340
self .p_signals = p_signals
340
341
self .d_signals = d_signals
342
+ self .e_p_signals = e_p_signals
343
+ self .e_d_signals = e_d_signals
344
+
341
345
342
346
self .filename = filename
343
347
self .fmt = fmt
@@ -695,12 +699,14 @@ def multi_to_single(self):
695
699
#------------------- Reading Records -------------------#
696
700
697
701
# Read a WFDB single or multi segment record. Return a Record or MultiRecord object
698
- def rdsamp (recordname , sampfrom = 0 , sampto = None , channels = None , physical = True , pbdir = None , m2s = True ):
702
+ def rdsamp (recordname , sampfrom = 0 , sampto = None , channels = None , physical = True , pbdir = None ,
703
+ m2s = True , smoothframes = True ):
699
704
"""Read a WFDB record and return the signal and record descriptors as attributes in a
700
705
Record or MultiRecord object.
701
706
702
707
Usage:
703
- record = rdsamp(recordname, sampfrom=0, sampto=None, channels=None, physical=True, pbdir = None, m2s=True)
708
+ record = rdsamp(recordname, sampfrom=0, sampto=None, channels=None, physical=True, pbdir = None,
709
+ m2s=True, smoothframes = True)
704
710
705
711
Input arguments:
706
712
- recordname (required): The name of the WFDB record to be read (without any file extensions).
@@ -715,8 +721,13 @@ def rdsamp(recordname, sampfrom=0, sampto=None, channels = None, physical = True
715
721
directory from which to find the required record files.
716
722
eg. For record '100' in 'http://physionet.org/physiobank/database/mitdb', pbdir = 'mitdb'.
717
723
- m2s (default=True): Flag used when reading multi-segment records. Specifies whether to
718
- directly return a wfdb MultiRecord object (false ), or to convert it into and return a wfdb
724
+ directly return a wfdb MultiRecord object (False ), or to convert it into and return a wfdb
719
725
Record object (True).
726
+ - smoothframes (default=True): Flag used when reading records with signals having multiple
727
+ samples per frame. Specifies whether to smooth the samples in signals with more than
728
+ one sample per frame to return an mxn uniform numpy array as the d_signals or p_signals
729
+ field (True), or to return a list of 1d numpy arrays containing every expanded sample as
730
+ the e_d_signals or e_p_signals field (False).
720
731
721
732
Output argument:
722
733
- record: The wfdb Record or MultiRecord object representing the contents of the record read.
@@ -752,17 +763,25 @@ def rdsamp(recordname, sampfrom=0, sampto=None, channels = None, physical = True
752
763
record .checkreadinputs (sampfrom , sampto , channels )
753
764
# A single segment record
754
765
if type (record ) == Record :
755
- # Read signals from the associated dat files that contain wanted channels
756
- record .d_signals = _signals .rdsegment (record .filename , dirname , pbdir , record .nsig , record .fmt , record .siglen ,
757
- record .byteoffset , record .sampsperframe , record .skew ,
758
- sampfrom , sampto , channels )
759
- # Arrange/edit the object fields to reflect user channel and/or signal range input
760
- record .arrangefields (channels , sampto - sampfrom )
761
- if physical == 1 :
762
- # Perform dac to get physical signal
763
- record .p_signals = record .dac ()
764
- # Clear memory
765
- record .d_signals = None
766
+
767
+ # Multi-sample frames are smoothed to make a uniform numpy array
768
+ if smoothframes or :
769
+ # Read signals from the associated dat files that contain wanted channels
770
+ record .d_signals = _signals .rdsegment (record .filename , dirname , pbdir , record .nsig , record .fmt , record .siglen ,
771
+ record .byteoffset , record .sampsperframe , record .skew ,
772
+ sampfrom , sampto , channels )
773
+ # Arrange/edit the object fields to reflect user channel and/or signal range input
774
+ record .arrangefields (channels , sampto - sampfrom )
775
+ if physical == 1 :
776
+ # Perform dac to get physical signal
777
+ record .p_signals = record .dac ()
778
+ # Clear memory
779
+ record .d_signals = None
780
+
781
+ # Return each sample of the signals with multiple samples per frame
782
+ else :
783
+ record .e_d_signals = _signals .rdsegment ()
784
+
766
785
# A multi segment record
767
786
768
787
# We can make another rdsamp function (called rdsamp_segment) to call
0 commit comments