Skip to main content

Meta

Python

Documentation Status

Testing

Unittest Status

Unittest coverage

Google Colab

PyPI

PyPI version

PyPI downloads

Anaconda

Anaconda version

Anaconda downloads

Latest release date

DeepPeak

DeepPeak is a Python package for generating, detecting, and analyzing peaks in one-dimensional signals. Its central workflow is to compare direct peak detection with optional neural deconvolution followed by peak detection. It also provides classical signal-processing methods, trainable neural-network models, synthetic signal generation, and dilution-series analysis.

It is designed for researchers and engineers working with pulse-like traces, event streams, and other sparse one-dimensional signals.

Key Features

  • Classical peak detection: Height, sigma, prominence, zero-crossing, and non-maximum-suppression methods.

  • Optional neural deconvolution: CNN, WaveNet, and 1D U-Net models can reconstruct a cleaner pulse signal before peak detection.

  • Synthetic data generation: Gaussian, Lorentzian, square, Dirac, custom, and two-lobe kernels with configurable noise and peak-count models.

  • Trace analysis: Arrival-time, amplitude, width, pulse-shape, noise, and dead-time analysis.

  • Direct-versus-deconvolved evaluation: Compare event counts, time-of-arrival, amplitude, and width distributions on the same traces.

  • Dilution-series workflows: Standard and flash dilution-series analysis with detector-specific metrics and plots.

  • Plotting and diagnostics: Figures are returned as Matplotlib objects so they can be customized, saved, or embedded in notebooks.

Installation

Install the released package from PyPI:

pip install DeepPeak

The classical signal-processing and generation APIs do not require TensorFlow. Install the optional neural-network stack when using the models package:

pip install "DeepPeak[ml]"

For development, install the repository and its test/documentation tools in your preferred virtual environment.

Quickstart: generate a signal

The generation API can create reproducible training and evaluation data:

from DeepPeak import Gaussian, SignalGenerator, UniformCount

generator = SignalGenerator(sequence_length=1_000)
dataset = generator.generate(
    n_samples=128,
    kernel=Gaussian(
        amplitude=(1.0, 10.0),
        position=(0.1, 0.9),
        width=(0.02, 0.05),
    ),
    peak_count=UniformCount(bounds=(1, 4)),
    seed=42,
    noise_std=0.05,
)

signals = dataset.signals

Analysis quickstart

For standard dilution-series analysis, provide trace files as (filename, dilution) pairs and run the configured workflow:

from DeepPeak.analysis import HeightPeakTrigger, StandardDilutionSeries

series = StandardDilutionSeries(
    folder="path/to/traces",
    files=[
        ("path/to/traces/trace_1.csv", 1.0),
        ("path/to/traces/trace_2.csv", 10.0),
    ],
    trigger=HeightPeakTrigger(height=0.05, hysteresis=0.03),
    initial_concentration=1.0,
    nrows=100_000,
)

result = series.run()
series.plot.standard_detection(index=0)

series.poisson.plot.expected_histogram(
    index=0,
    base_index=0,
    detector="standard",
    x_axis="time",
)

series.amplitude.plot.histogram(index=0, detector="standard")
series.width.plot.histogram(index=0, detector="standard", x_axis="time")

For reusable settings, prefer the typed configuration objects exposed by DeepPeak.core. They validate values at construction time and can be passed to analyzers, dilution-series workflows, and plotting helpers:

import numpy as np

from DeepPeak.core import DetectionConfig, PlotConfig, Trace
from DeepPeak.detection import HeightPeakTrigger
from DeepPeak.analysis import StandardTraceAnalyzer

detection_config = DetectionConfig(
    sequence_length=1_000,
    normalization="zscore",
    trigger=HeightPeakTrigger(height=0.05),
)
analyzer = StandardTraceAnalyzer(config=detection_config)
signal = np.zeros(1_000)
signal[500] = 1.0
detection = analyzer.detect(Trace(signal=signal, dx=1.0))
record = analyzer.analyze_processed_signal(signal, dx=1.0)

figure = record.plot_standard_detection(
    config=PlotConfig(show=False, close=False, dpi=150),
)

The plotting API always returns figures. Set show=False for scripts and tests, and set close=True when a figure should be closed automatically after it is created.

The detector-specific classes StandardDilutionSeries and FlashDilutionSeries are also available when a workflow should expose only one detector mode. Use FlashDilutionSeries with a trained neural model for CNN-based workflows.

Direct versus deconvolved comparison

The neural model is an optional deconvolution stage. The same peak-detection concept can therefore be evaluated directly on the raw trace and after neural deconvolution:

raw trace ────────────────> detector ──> direct result
    │
    └─ optional CNN/WaveNet/U-Net ──> detector ──> deconvolved result

Use TraceComparisonAnalyzer to compare the two branches. The result provides arrival-time, amplitude, and width distributions, together with summary statistics and distribution differences. Set deconvolver=None to run only the direct branch.

from DeepPeak.analysis import TraceComparisonAnalyzer
from DeepPeak.core import Trace
from DeepPeak.detection import HeightPeakTrigger

comparison = TraceComparisonAnalyzer(
    standard_trigger=HeightPeakTrigger(height=0.05),
    deconvolver=trained_model,  # optional CNN, WaveNet, or U-Net wrapper
).compare(Trace(signal=signal, dx=1e-9))

arrival_comparison = comparison.compare_distribution("arrival")
amplitude_comparison = comparison.compare_distribution("amplitude")
width_comparison = comparison.compare_distribution("width")

The same comparison can be run over multiple traces with compare_many. This makes it possible to quantify changes in event counts, time-of-arrival distributions, retrieved amplitudes, widths, and distribution distances.

For this workflow, the neural model must be trained as a reconstruction model: its target should be a clean or deconvolved pulse trace, not only a binary ROI mask. For example, a WaveNet model should use a linear output head and a regression loss when it is trained to predict pulse amplitudes. The existing ROI-classification examples demonstrate a related model use case, but are not deconvolution models by themselves.

Architecture

DeepPeak is being organized around clear domain boundaries:

DeepPeak/
├── core/          shared types, protocols, configuration, exceptions
├── generation/    synthetic signals, kernels, noise, datasets
├── detection/     classical and neural detection algorithms
├── models/        trainable neural-network architectures and losses
├── analysis/      trace and dilution-series workflows
├── metrics/       numerical diagnostics and distribution summaries
├── plotting/      visualization of traces, detections, and metrics
└── io/            trace loading and result serialization

The intended dependency direction is:

core
  ↓
generation / detection / models
  ↓
analysis
  ↓
metrics / plotting / io

This separation keeps numerical analysis independent from plotting and keeps TensorFlow-specific code isolated from the core signal-processing API. The domain namespaces are the supported public API for new code.

Public API guide

Use these namespaces when writing new code:

DeepPeak.analysis

Trace analyzers, dilution-series workflows, triggers, and analysis results.

DeepPeak.generation

Synthetic datasets, kernels, noise models, and peak-count models.

DeepPeak.detection

Detection algorithms, triggers, and the common detection-result type.

DeepPeak.models

DenseNet, WaveNet, UNet1D, neural losses, and model utilities.

DeepPeak.metrics

Detection, amplitude, width, arrival-time, and series metrics.

DeepPeak.plotting and DeepPeak.io

Figure helpers and trace/file loading utilities.

DeepPeak.core

Stable Trace, DetectionResult, MetricResult, and SeriesResult objects, plus typed TraceConfig, DetectionConfig, SeriesConfig, and PlotConfig settings.

The root DeepPeak namespace exposes the most common user-facing types for interactive work and notebooks.

Documentation

The full API reference, theory notes, and executable examples are available at the DeepPeak documentation.

Contact

For questions or contributions, contact martin.poinsinet.de.sivry@gmail.com.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deeppeak-0.1.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deeppeak-0.1.0-py3-none-any.whl (165.8 kB view details)

Uploaded Python 3

File details

Details for the file deeppeak-0.1.0.tar.gz.

File metadata

  • Download URL: deeppeak-0.1.0.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for deeppeak-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c1cc907df8e7f3d12c26549456655bf379adf333fe455594ca0d6e70904ccf4
MD5 465dac82a99479bf843ba1e5114af5a0
BLAKE2b-256 4b8761cdc6636b422d2b2302a434ae1075ddc10934115abaa71c14c54e83a852

See more details on using hashes here.

File details

Details for the file deeppeak-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: deeppeak-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 165.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for deeppeak-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28652c4926e3433d15023d563a3ec833beeaa06d54fb84d1a926774039d8ff3b
MD5 a038779afddde29e2bd36cb1ea8aebd9
BLAKE2b-256 71aac5d39029f27a3491f716faa2e529cfa428c2801ce2e92b0e86487b15e432

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page