0
$\begingroup$

I have two timeseries signals. They look like this:

enter image description here

Each signal started out from the same array, but each received different preprocessing treatments. Ultimately, each signal represents the breathing rate of a subject. Each peak constitutes the peak of an inhale, so the number of peaks/time yields the respiratory rate. I want to determine which preprocessing treatments yield a more periodic signal so that I can conduct the most optimal peak detection.

As you can see, both signals are noisy, but it looks like the orange timeseries has more consistent periodicity, making it more suitable for my task. What is an optimal test to determine how periodic each signal is so that I can determine the signal without having to look at them?

Ideally, a solution implemented in python or c++ would be great, but not necessary.

Edit

Here is a way to compute average frequency per signal.

enter image description here

Am I correct to assume the higher value is more periodic, or is that too simplistic?

Edit 2

More "periodic" probably isn't the right term. This is what I mean:

enter image description here

enter image description here

The first plot has less noise, so it is cleaner/easier to determine the periods between peaks. Again, I am ultimately trying to solve a peak detection problem.

$\endgroup$
4
  • $\begingroup$ What do you mean by “more periodic”? $\endgroup$
    – Engineer
    Jan 29, 2021 at 12:53
  • $\begingroup$ I am somewhat new to signals, so apologies if my language is not ideal. See my new edits for an explanation of what I mean. $\endgroup$
    – connor449
    Jan 29, 2021 at 13:14
  • 1
    $\begingroup$ Oh I see. Signal to noise ratio (SNR) is probably the term you want $\endgroup$
    – Engineer
    Jan 29, 2021 at 15:04
  • $\begingroup$ The question is not very well stated. It is unclear, what your final goal is. Is it to determine the main frequency of the signal, ie the breathing cycle? Also, the measurements look very strange. How was it measured? Why are the two curves so different, if they originate from the same raw data? What are the units of the x and y axes? Is it at all legit to assume that there is ONE breathing frequency over such a long time? Also, you compute the mean value of the abs-power spectrum, which is an arbitrary number if you don't normalize your spectra, and it is unclear whether this is what you need $\endgroup$
    – M529
    Jan 29, 2021 at 18:00

1 Answer 1

3
$\begingroup$

Something you could do is calculate the FFT of both signals and define some criterion for periodicity. For example, you pick the highest component of each FFT and compare the two (one from each signal) and thus determine which is more "periodic". You could consider an average of all the FFT components and compare. This would be a rather robust solution, since the FFT calculates the frequency decomposition of a signal.

$\endgroup$
2
  • $\begingroup$ Thanks for your reply. I think I implemented what you mean, see edits above. The average of all FFT components is computed and visualized. Am I correct to assume the higher value is more "periodic"? If that is correct, could you recommend a threshold? $\endgroup$
    – connor449
    Jan 29, 2021 at 12:46
  • 1
    $\begingroup$ Not necessarily. As someone mentioned, you need a precise definition of periodicity. To give you an example: consider $f(t)=sin(2t)$ and $g(t)=10sin(2t)$, then if you take the FFT, you're going to get that both signal have a strong peak at the frequency 2, but $g$ has a higher peak because its magnitude is bigger; is it more periodic? it depends on your definition of periodicity. You can probably define the notion of periodicity in some way that works for your problem, but you need to be careful about contradictions. Hope that makes sense. $\endgroup$
    – Schach21
    Jan 29, 2021 at 23:49

Your Answer

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

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