5
$\begingroup$

I have data that looks like this: Data

Sometimes the data has a higher point in the middle of the shallow slope

Data with peak in shallow slope

I want to find a way to filter the data such that it smooths it and leaves the first rising edge as the peak like so

Ideal

Is a weighted average a good way to achieve this? or would that not do the trick? Are there better methods

Right now i have been using a weight average to smooth it but it leaves me with a peak in the center of the slope instead of towards the rising edge.

$\endgroup$
3
  • 3
    $\begingroup$ Have you tried a median filter? It removes noise while preserving edges. $\endgroup$
    – Matt L.
    Commented Sep 11, 2014 at 7:18
  • 1
    $\begingroup$ what should the output look like? Do you want a rectangular pulse? $\endgroup$
    – endolith
    Commented Sep 11, 2014 at 13:34
  • $\begingroup$ the output should look as i drew, with a sharp slope up to the peak and then slowly dissipating. $\endgroup$ Commented Sep 11, 2014 at 21:17

3 Answers 3

3
$\begingroup$

Try looking into posts on "onset detection", where typically "flux" (or first order difference, typically of spectral magnitude) is used to compute the "rate of change" of a signal. The high rate of change is the most salient feature of the images you drew above.

However, your third image seems to translate the maximum of the curve (to the left) is that your intent?

$\endgroup$
2
$\begingroup$

You could use a median filter like Matt suggested. Or, if you are sure your data will always look like the third image, then you can use it as a template and correlate it with the test signal. You can come up with some measure as to how far away from the correlated peaks is your actual ascent point in template, and use the same for rest of the correlated peaks.

$\endgroup$
0
$\begingroup$

An empirical approach:

Smooth the signal with a standard lowpass (Gaussian), to get $G_k$.

On another hand, compute a sliding difference over $n$ values ($D_k=S_{k+n}-S_{k-n}$). This derived signal will be maximum at a rising edge. (You can also try the smoothed difference, $D_k=G_{k+n}-G_{k-n}$.)

Then mix the original signal with the smoothed one, using an adaptive weighting like

$$F_k=w(D_k)S_k+(1-w(D_k))G_k,$$ where the function $w$ is close to $1$ for values of $D_k$ close to the expected step height, and decreasing to $0$ for lower values.

Note that this approach will rather preserve the edge than the "peak".

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.