Skip to content

ymtoo/FindPeaks1D.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FindPeaks1D

CI codecov

Finding peaks in a 1-D signal in Julia. The implementation is based on find_peaks in SciPy.

Installation

julia>]
pkg> add FindPeaks1D

Usage

using FindPeaks1D, ImageFiltering, Plots

n = 48001
s1 = ImageFiltering.Kernel.gaussian((1000,), (n,))
s2 = ImageFiltering.Kernel.gaussian((500,), (n,))
s = s1.parent/maximum(s1.parent) + 0.5 * circshift(
    s2.parent/maximum(s2.parent), (10000,))
pkindices, properties = findpeaks1d(s; 
                                    height=0.1, 
                                    prominence=0.2, 
                                    width=1000.0, 
                                    relheight=0.9)

plot(s; color="black", label=false)
scatter!(pkindices, s[pkindices]; color="red", markersize=5, label="peaks")
vline!(properties["leftips"]; color="blue", width=2, label="peak edges")
vline!(properties["rightips"]; color="blue", width=2, label=false)
xlabel!("Sample")

window

pkindices, properties = findpeaks1d(s; 
                                    height=0.1, 
                                    distance=12000, 
                                    prominence=0.2, 
                                    width=1000.0, 
                                    relheight=0.9)

plot(s; color="black", label=false)
scatter!(pkindices, s[pkindices]; color="red", markersize=5, label="peaks")
vline!(properties["leftips"]; color="blue", width=2, label="peak edges")
vline!(properties["rightips"]; color="blue", width=2, label=false)
xlabel!("Sample")

window