@@ -80,7 +80,7 @@ def pcg(signal=None, sampling_rate=1000., units=None, path=None, show=True):
80
80
filtered , fs , params = st .filter_signal (signal , 'butter' , 'bandpass' , order , passBand , sampling_rate )
81
81
82
82
# 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 )
84
84
85
85
# classify heart sounds
86
86
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):
119
119
120
120
return utils .ReturnTuple (args , names )
121
121
122
- def find_peaks (signal = None ,sampling_rate = 1000. ):
122
+ def find_peaks (signal = None ,sampling_rate = 1000. , filter = True ):
123
123
124
124
"""Finds the peaks of the heart sounds from the homomorphic envelope
125
125
@@ -140,7 +140,7 @@ def find_peaks(signal=None,sampling_rate=1000.):
140
140
"""
141
141
142
142
# Compute homomorphic envelope
143
- envelope , = homomorphic_filter (signal ,sampling_rate )
143
+ envelope , = homomorphic_filter (signal ,sampling_rate , filter = filter )
144
144
envelope , = st .normalize (envelope )
145
145
146
146
# Find the prominent peaks of the envelope
@@ -152,7 +152,7 @@ def find_peaks(signal=None,sampling_rate=1000.):
152
152
('peaks' ,'homomorphic_envelope' ))
153
153
154
154
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 ):
156
156
"""Finds the homomorphic envelope of a signal.
157
157
158
158
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):
196
196
# Filter Design
197
197
passBand = np .array ([25 , 400 ])
198
198
199
+ if filter :
199
200
# 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
201
205
202
206
# LP-filter Design (to reject the oscillating component of the signal):
203
207
b , a = ss .butter (order , 2 * f_LPF / fs , 'low' )
0 commit comments