2
$\begingroup$

I am working with temporal data objects and experimenting with FindPeaks. I find that the function sometimes fails with the error

FindPeaks::arg: The argument TimeSeries[] at position 1 is not a consistent list of real values.

See for example the following time series:

in = {{3685681800, -2132.95}, {3685682100, -2133.78}, {3685682400, -2130.24}, {3685682700, -2129.87}, {3685683000, -2130.27}, {3685683300, -2128.06}, {3685683600, -2128.38}, {3685683900, -2128.75}, {3685684200, -2129.35}, {3685684500, -2130.29}, {3685684800, -2130.16}, {3685685100, -2133.46}, {3685685400, -2133.9}, {3685685700, -2132.86}, {3685686000, -2133.03}, {3685686300, -2132.51}, {3685686600, -2131.83}, {3685686900, -2130.02}, {3685687200, -2130.47}, {3685687500, -2130.8}, {3685687800, -2130.12}, {3685688100, -2130.42}, {3685688400, -2131.01}, {3685688700, -2130.18}, {3685689000, -2128.85}, {3685689300, -2129.86}, {3685689600, -2130.65}, {3685689900, -2131.3}, {3685690200, -2130.24}, {3685690500, -2131.8}, {3685690800, -2131.56}, {3685691100, -2131.39}, {3685691400, -2130.51}, {3685691700, -2129.95}, {3685692000, -2130.17}, {3685692300, -2130.07}, {3685692600, -2128.77}};

inTS = TimeSeries[in];

FindPeaks works some some levels of Gaussian blur but not others.

FindPeaks[inTS, 1] (*fine*)
FindPeaks[inTS, 2] (*fine*)
FindPeaks[inTS, 3] (*fine*)
FindPeaks[inTS, 4] (*fine*)
FindPeaks[inTS, 5] (*fine*)
FindPeaks[inTS, 6] (*fine*)
FindPeaks[inTS, 7] (*fine*)
FindPeaks[inTS, 8] (*fine*)
FindPeaks[inTS, 9] (*fine*)
FindPeaks[inTS, 10] (*ka-boom!*)
FindPeaks[inTS, 11] (*fine*)

I am working with a large number of data sets, and can't manually tune for each one. Why this is the error appearing and what can be done about it?

$\endgroup$
  • $\begingroup$ The result you get for FindPeaks[inTS, 11] is not "fine"; it is an artifact of the way the data set terminates. In fact, no real peaks are found for any σ greater than approximately 9.904. $\endgroup$ – m_goldberg May 9 '17 at 19:57
4
$\begingroup$

This is more of an extended comment rather than an answer.

For $\sigma=10$ no peaks are found. You can see what happens as $\sigma$ is changed in the following:

Manipulate[
 peaks = FindPeaks[in[[All, 2]], σ];
 gf = GaussianFilter[in[[All, 2]], σ];
 ListLinePlot[{in[[All, 2]], gf},
  Epilog -> {Red, PointSize[0.04], Point[peaks]}],
 {σ, 1, 15, Appearance -> "Labeled"}]

Sigma around 4 Sigma around 10

Using

FindPeaks[in[[All, 2]], 10]

returns {} whereas

FindPeaks[inTS, 10]

returns the error you see.

$\endgroup$

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.