Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bandpass(x, lowcut, highcut, fs, order=5, axis=-1, kind='butter'):
- """
- Parameters
- ----------
- x : ndarray
- 1d time series data
- lowcut : float
- Defines lower frequency cutoff (e.g. in Hz)
- highcut : float
- Defines upper frequency cutoff (e.g. in Hz)
- fs : float
- Sampling frequency (e.g. in Hz)
- order : int
- Filter order parameter
- kind : str
- Specifies the kind of filter
- axis : int
- Axis along which to bandpass filter data
- """
- nyq = 0.5 * fs
- low = lowcut / nyq
- high = highcut / nyq
- if kind == "butter":
- b, a = butter(order, [low, high], btype="band")
- else:
- raise ValueError("Filter kind not recognized.")
- return filtfilt(b, a, x, axis=axis)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement