diff --git a/jetpack/signals.py b/jetpack/signals.py index 65124b8..1a9298c 100644 --- a/jetpack/signals.py +++ b/jetpack/signals.py @@ -10,7 +10,7 @@ import numpy as np from scipy.ndimage.filters import gaussian_filter1d -__all__ = ['peakdet', 'smooth', 'norms', 'sfthr', 'sq', 'arr'] +__all__ = ['peakdet', 'smooth', 'norms', 'sfthr', 'sfrct', 'sq', 'arr'] def peakdet(v, delta, x=None): @@ -182,6 +182,30 @@ def sfthr(x, threshold): return np.sign(x) * np.maximum(np.abs(x) - threshold, 0) +def sfrct(x, threshold): + """ + Soft rectification function + + y = log(1 + exp(x - threshold)) + + Parameters + ---------- + x : array_like + The input array to the soft thresholding function + + threshold : float + The threshold of the function + + Returns + ------- + y : array_like + The output of the soft thresholding function + + """ + + return np.log1p(np.exp(x - threshold)) + + def sq(x): """ Reshape vector to a square image