Closed lmanzanillas closed 1 year ago
I have this type of signals: and I'm interested in getting the peak position above a threshold, small peaks are just noise, I understand findmaxima find the local maxima, but it will be great to have as an option a give threshold, i.e. the same function to findmaxima(x, threshold) to find all the peaks above the threshold.
Where is your array of floats, vals
, coming from/being created? The error message shows that vals
is a Vector{Any}
, and we can't determine a reasonable minheight
(there isn't a logical minimum value for type Any
).
Some ways you might be getting a Vector
of type Any
is if you are creating vals
yourself, like vals = []
. That syntax creates an array of type Any
; the solution in that case would be to add a type like so: vals = Float64[]
. Alternately, if vals
is created/returned by some function, you should look for type-instabilities that might be causing the array to be promoted to Any
. (See docs on type instabilites
Once you have the element type of the array fixed, peakheights
or peakproms
can definitely remove the unwanted small peaks from your array.
(Unrelated to your error, but your version of Julia is out-of-date, the most recent release was v1.9, several days ago.)
Indeed, the problem was the Vector{Any}, converting it to Float64 solves the issue
Hello,
I'm trying to use this code to find peak position from an array of floats. However I'm getting this error:
If I run the example code with this array x = [0,5,2,3,3,1,4,0]; I do get a result, any idea of what is the problem?
Thanks in advance!