smart_arrays_peaks 2.0.6

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 62

Smart Arrays Peaks #

What the package can do for you #

This package provides functions that detect peaks (maximum values) in one- or two-dimensional arrays. Peak detection (peak search, peak picking) does not simply mean finding maximum values. Data originating from measurements are often subject to noise, i.e. random small variations of the measured values. The provided algorithms therefore allow you to specify a noise value to exclude noise effects from peak search.

The major API functionalities #

  • class PeakPicker1D

This example will pick the positive and negative peaks in the entire array using the noise discriminator 2.0. The result contains the array indices of the found peaks.

List<int> peakIndices = PeakPicker1D.detectPeaks( array, 0, array.length, 2.0, 0.0, PeakPicker1D.PICK_POSNEG, 0);

  • class PeakPicker2D:

This example will pick the negative peaks in the entire array2D using the noise discriminator 2.0. The result contains the array indices (row/column pairs) of the found peaks.

List<List<int>> peakIndices = PeakPicker2D.detectPeaks( array2D, 0, array2D.length,0,array2D[0].lebngth, 2.0, 0.00, PeakPicker1D.PICK_NEG, 0);

Detailed API #

Please view the detailed API documentation in the API reference of this package (sidebar at the right of this page).

smart_arrays_base: Basic functions for 1D and 2D arrays

smart_arrays_numerics: Numerics with 1D and 2D arrays

smart_arrays_compress: Compress 1D and 2D arrays to a smaller size.

smart_arrays_dbstore: Store 1D and 2D arrays along with metadata on the local device.

smart_arrays_lmfit: Fits (x, y) data given as arrays to a specified model function using the Levenberg-Marquardt algorithm.

smart_lorentz-gauss: Compute Lorentz-Gauss (pseudo-Voigt) line shapes.

smart_signal_processing: Fourier transform and more.

smart_dialogs: Easy-to-use dialogs in Web applications

Smart Arrays Peaks #

Version history #

2.0.0 - 2019-03-13 First version available on pub site

2.0.1 - 2019-03-14 Minor corrections

2.0.2 - 2019-03-14 Docu updates

2.0.3 - 2019-03-15 Docu updates

2.0.4 - 2019-03-24 Docu updates

2.0.5 - 2019-04-04 Docu updates

2.0.6 - 2019-05-05 Docu updates

example/example.dart

// Copyright (c) 2019, Dr. Bruno Guigas. All rights reserved. Use of this source
// code is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:smart_arrays_peaks/smart_arrays_peaks.dart';
import 'dart:typed_data';
import 'dart:math' as math;

/// Demonstrates peak picking for 1D and 2D arrays.
main() {
  // generate noisy sine wave ([noise] is a fraction of [ampl])
  Float64List genSine(
      double ampl, double phase, int nperiods, int nxvalues, double noise) {
    math.Random rand = math.Random();
    double xmax = 2 * math.pi * nperiods, x, y;
    Float64List sine = new Float64List(nxvalues);
    for (int i = 0; i < nxvalues; i++) {
      x = (i * xmax) / nxvalues;
      y = ampl * math.sin(x + phase);
      // add noise between -1 and 1
      sine[i] = y + noise * ampl * (2 * rand.nextDouble() - 1.0).sign;
    }
    return sine;
  }

  // Example 1D peak picking
  Float64List array = genSine(100.0, 0.0, 10, 1000, 0.005); // sine with noise

  // pick peaks: use noise discriminator 2.0 to suppress "noise peaks".
  List<int> peakIndices = PeakPicker1D.detectPeaks(
      array, 0, array.length, 2.0, 0.001, PeakPicker1D.PICK_POSNEG, 0);

  // print result: we expect 10 minima with values around -100 and 10 maxima
  // around +100.
  for (int i = 0; i < peakIndices.length; i++) {
    int ipeak = peakIndices[i];
    print("Peak # / index / value: " +
        "${i + 1} / $ipeak / ${array[ipeak].toStringAsFixed(2)}");
  }
  print("");

  // Example 2D peak picking
  final List<List<double>> PEAK_2D = [
    [70, 80, 75, 73],
    [80, 85, 90, 91],
    [83, 100, 90, 80],
    [81, 95, 93, 92]
  ]; // a sample 2D peak

  // Create a matrix with 2 peaks at row/col positions 10/20 and 20/15
  final int NROWS = 32, NCOLS = 41;
  List<Float64List> matrix = List(NROWS);
  for (int i = 0; i < NROWS; i++) {
    matrix[i] = Float64List(NCOLS);
    if (i == 8 || i == 9 || i == 10 || i == 11)
      matrix[i].setRange(19, 19 + PEAK_2D[0].length - 1, PEAK_2D[i - 8]);
    if (i == 18 || i == 19 || i == 20 || i == 21)
      matrix[i].setRange(14, 14 + PEAK_2D[0].length - 1, PEAK_2D[i - 18]);
  }

  // pick peaks
  List<List<int>> peakIndices2D = PeakPicker2D().detectPeaks(
      matrix, 0, NROWS, 0, NCOLS, 0.0, 0.0, PeakPicker1D.PICK_POSNEG, 0);

  // print result: we expect 2 maxima with value 100 at positions 10/20 and 20/15
  for (int i = 0; i < peakIndices2D.length; i++) {
    int row = peakIndices2D[i][0];
    int col = peakIndices2D[i][1];
    print("2D Peak # / row /col / value: " +
        "${i + 1} / $row / $col / ${matrix[row][col].toStringAsFixed(2)}");
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  smart_arrays_peaks: ^2.0.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:smart_arrays_peaks/smart_arrays_peaks.dart';
  
Version Uploaded Documentation Archive
2.0.6 May 6, 2019 Go to the documentation of smart_arrays_peaks 2.0.6 Download smart_arrays_peaks 2.0.6 archive
2.0.5 Apr 4, 2019 Go to the documentation of smart_arrays_peaks 2.0.5 Download smart_arrays_peaks 2.0.5 archive
2.0.4 Mar 24, 2019 Go to the documentation of smart_arrays_peaks 2.0.4 Download smart_arrays_peaks 2.0.4 archive
2.0.3 Mar 15, 2019 Go to the documentation of smart_arrays_peaks 2.0.3 Download smart_arrays_peaks 2.0.3 archive
2.0.2 Mar 14, 2019 Go to the documentation of smart_arrays_peaks 2.0.2 Download smart_arrays_peaks 2.0.2 archive
2.0.1 Mar 14, 2019 Go to the documentation of smart_arrays_peaks 2.0.1 Download smart_arrays_peaks 2.0.1 archive
2.0.0 Mar 13, 2019 Go to the documentation of smart_arrays_peaks 2.0.0 Download smart_arrays_peaks 2.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
37
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
65
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Jun 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:smart_arrays_peaks/smart_arrays_peaks.dart.

Health suggestions

Format lib/src/peak_pick1d.dart.

Run dartfmt to format lib/src/peak_pick1d.dart.

Maintenance issues and suggestions

Support latest dependencies. (-35 points)

The version constraint in pubspec.yaml does not support the latest published versions for 6 dependencies (1 direct: build_web_compilers).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
build_runner ^1.1.2 1.5.2
build_web_compilers ^1.0.0 1.2.2 2.1.1
pedantic ^1.5.0 1.7.0
smart_arrays_base ^2.0.0 2.0.7
Transitive dependencies
analyzer 0.35.4 0.36.3
archive 2.0.10
args 1.5.2
async 2.2.0
bazel_worker 0.1.21
build 1.1.4
build_config 0.4.0
build_daemon 1.0.0
build_modules 1.0.11 2.3.0
build_resolvers 1.0.5
build_runner_core 3.0.6
built_collection 4.2.2
built_value 6.6.0
charcode 1.1.2
code_builder 3.2.0
collection 1.14.11
convert 2.1.1
crypto 2.0.6
dart_style 1.2.4 1.2.8
fixnum 0.10.9
front_end 0.1.14 0.1.18
glob 1.1.7
graphs 0.2.0
http 0.12.0+2
http_multi_server 2.1.0
http_parser 3.1.3
io 0.3.3
js 0.6.1+1
json_annotation 2.4.0
kernel 0.3.14 0.3.18
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
mime 0.9.6+3
package_config 1.0.5
package_resolver 1.0.10
path 1.6.2
pool 1.4.0
protobuf 0.13.12
pub_semver 1.4.2
pubspec_parse 0.1.4
quiver 2.0.3
scratch_space 0.0.3+2
shelf 0.7.5
shelf_web_socket 0.2.3
source_maps 0.10.8
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
stream_transform 0.0.19
string_scanner 1.0.4
term_glyph 1.1.0
timing 0.1.1+1
typed_data 1.1.6
watcher 0.9.7+10
web_socket_channel 1.0.13
yaml 2.1.16