@@ -80,7 +80,7 @@ def pcg(signal=None, sampling_rate=1000., units=None, path=None, show=True):
8080 filtered , fs , params = st .filter_signal (signal , 'butter' , 'bandpass' , order , passBand , sampling_rate )
8181
8282 # find peaks
83- peaks , envelope = find_peaks (signal = filtered , sampling_rate = sampling_rate )
83+ peaks , envelope = find_peaks (signal = filtered , sampling_rate = sampling_rate , filter = False )
8484
8585 # classify heart sounds
8686 hs , = identify_heart_sounds (beats = peaks , sampling_rate = sampling_rate )
@@ -119,7 +119,7 @@ def pcg(signal=None, sampling_rate=1000., units=None, path=None, show=True):
119119
120120 return utils .ReturnTuple (args , names )
121121
122- def find_peaks (signal = None ,sampling_rate = 1000. ):
122+ def find_peaks (signal = None ,sampling_rate = 1000. , filter = True ):
123123
124124 """Finds the peaks of the heart sounds from the homomorphic envelope
125125
@@ -140,7 +140,7 @@ def find_peaks(signal=None,sampling_rate=1000.):
140140 """
141141
142142 # Compute homomorphic envelope
143- envelope , = homomorphic_filter (signal ,sampling_rate )
143+ envelope , = homomorphic_filter (signal ,sampling_rate , filter = filter )
144144 envelope , = st .normalize (envelope )
145145
146146 # Find the prominent peaks of the envelope
@@ -152,7 +152,7 @@ def find_peaks(signal=None,sampling_rate=1000.):
152152 ('peaks' ,'homomorphic_envelope' ))
153153
154154
155- def homomorphic_filter (signal = None , sampling_rate = 1000. , f_LPF = 8 , order = 2 ):
155+ def homomorphic_filter (signal = None , sampling_rate = 1000. , f_LPF = 8 , order = 2 , filter = True ):
156156 """Finds the homomorphic envelope of a signal.
157157
158158 Adapted to Python from original MATLAB code written by David Springer, 2016 (C), for
@@ -196,8 +196,12 @@ def homomorphic_filter(signal=None, sampling_rate=1000., f_LPF=8, order=2):
196196 # Filter Design
197197 passBand = np .array ([25 , 400 ])
198198
199+ if filter :
199200 # Band-Pass filtering of the PCG:
200- signal , fs , params = st .filter_signal (signal , 'butter' , 'bandpass' , order , passBand , sampling_rate )
201+ signal , fs , params = st .filter_signal (signal , 'butter' , 'bandpass' , order , passBand , sampling_rate )
202+
203+ else :
204+ fs = sampling_rate
201205
202206 # LP-filter Design (to reject the oscillating component of the signal):
203207 b , a = ss .butter (order , 2 * f_LPF / fs , 'low' )
0 commit comments