I have multiple signals as shown in this image. I'd like automatically detect time for the earliest detection of the signal (approx 0.7e4 in S1-B3-B (orange)) and last detected occurrence of the signal (approx 4.2e4 in S2-B3-B (purple)).

enter image description here

Is there a smart way to that? I'm quite new to signal processing.


There are many sources on Detection Theory. I think there are two relatively simple approaches to your problem. From the example graph I can clearly see a distinct signal. if the desired detected signal has the same trend/shape a good detection technique would be in the direction of matched filtering.

(1) Matched filtering is basically correlating the test signal with the measured signal. if the signals are very similar to each other, matched filtering would return a high value on which you could detect that with a threshold. A good starting point for signal detection would be this lecture slide.

(2) However, that might already be a bit too difficult since you mentioned to be new to signal processing. Another approach when I look at the signal is seeing that the noise is very low when the signal is not present. I'm not sure if the example signals have these distinct amplitudes when the signal is not present (yellow at ~15, purple at ~-730). But if this amplitude is know, we could simply check when the signal is different from this steady value. Or we could calculate how much the signal changes by calculating the gradient (or simply the difference between samples) for example. If the gradient is high, the signal would be increasing at a higher rate.

Maybe start by calculating the difference between samples, i.e.: $s[i]-s[i-1]$ for each sample. I highly encourage to just play with the signals when starting with signal processing. Try different functions on the samples.

  • $\begingroup$ Hi @ehagenaars, thanks a lot for your reply. Matched filtering seems like a good option. But the only issue is that I have a lot of signals. I'm going to check it out. Regarding the second option, actually the noise value is not really known and it changes with time. Actually the main reason why I wanted to find the beginning and the end is that I want to offset the signal by making the beginning value equal to zero. I tried getting the difference between the samples and the gradient of the signal. The gradient is helpful but not too much $\endgroup$ – Shihab Khan Mar 28 at 0:49
  • $\begingroup$ I stumbled across otsu thresholding for image processing and binarization. It worked for me. However I wasn't able to get the exact beginning of the signal using that. Do you have any other recommendations? $\endgroup$ – Shihab Khan Mar 28 at 0:50

This code helps identify the starting point, little tweaking should work: [https://stackoverflow.com/questions/44013269/recorded-audio-of-one-note-produces-multiple-onset-times][1]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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