npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3-peaks

v0.0.1

Published

Find peaks in a noisy dataset.

Downloads

39

Readme

d3-peaks

Find peaks in an array based on "Improved peak detection" [1]

[1] Du, Pan, Warren A. Kibbe, and Simon M. Lin. "Improved peak detection in mass spectrum by incorporating continuous wavelet transform-based pattern matching." Bioinformatics 22.17 (2006): 2059-2065.

For examples, please see:

Installing

If you use NPM, npm install d3-peaks. Otherwise, download the latest release.

API Reference

Find Peaks

# d3_peaks.findPeaks([signal])

If specified, returns an array of points that represents the peaks in the signal. Otherwise, returns a function to find peaks. An example point returned is:

[{
  index: 10,
  width: 2,
  snr: 1.5
}]

Where index represents the index of the peak in the original signal, width is the width of the peak, and snr is the signal to noise ratio.

# widths([w])

If specified, [w] is an array of expected peak widths that the algorithm should find. Otherwise, returns the current values.

var findPeaks = d3_peaks.findPeaks().widths([1, 2, 10]);

# kernel(kernel)

If specified, changes the kernel function or "smoother". Otherwise, returns the current value.

var ricker = d3_peaks.ricker;
var findPeaks = d3_peaks.findPeaks().kernel(ricker);

# gapThreshold(gap)

If specified, gap represents the maximum allowed number of gaps in the ridgeline. The higher is this number the more connected peaks we will find. Otherwise, returns the current value.

var findPeaks = d3_peaks.findPeaks().gapThreshold(3);

# minLineLength(length)

If specified, length represents the minimum ridgeline length. The higher is this number the more constrained are the lines and we will find fewer peaks. Otherwise, returns the current value.

var findPeaks = d3_peaks.findPeaks().minLineLength(2);

# minSNR(snr)

If specified, snr represents the minimum signal to noise ratio the ridge lines should have. Otherwise, returns the current value. By default the minimum snr is 1.0 for peaks of width 1. This number should be higher for bigger widths.

var findPeaks = d3_peaks.findPeaks().minSNR(1.5);

Convolution

# d3_peaks.convolve([signal])

If specified, convolve the signal array with the smoother. Otherwise, returns a function to convolve a signal with the smoother.

# kernel(kernel)

If specified, changes the kernel function or "smoother". Otherwise, returns the current kernel.

var convolve = d3_peaks.convolve()
                        .kernel(ricker);
var signal = convolve([1,2,3,2.5,0,1,4,5,3,-1,-2]);

Kernels

# d3_peaks.ricker(x)

If specified , it returns φ(x). Otherwise, returns a function to compute the ricker wavelet with default standard deviation 1.0.

# std(value)

If specified, it sets the standard deviation of the curve to value. Otherwise, returns the "width" or standard deviation of the wavelet.

# reach()

Returns the range value reach such that φ(reach) ~ 0.

var y = d3_peaks.ricker()
  .std(2);
var output = y(3.5);
var reach = y.reach();