Skip to main content

A library for creating binomial sampled data mimicking SPAD images.

Project description

SPADSampler

CI PyPI - Version License: CC0-1.0 Python Versions

SPADSampler is a simple tool for creating binomial sampled data mimicking SPAD (Single-Photon Avalanche Diode) images. It provides tools for sampling, histogram computation, and visualization of image data. It has two sampling methods: Binomial and Bernoulli. The image is sampled using the integer value as the trails. A target range of mean photon counts are specified, and the image is sampled to match the specified range. If the sampling method is Bernoulli, the image is truncated to 0 or 1 to mimic the SPAD cut-off.

Installation

You can clone this repository or install SPADSampler using pip:

# Install directly from GitHub
pip install git+https://github.com/lyehe/spadsampler.git

# Install from PyPI
pip install spadsampler

Quick Start with Google Colab

You can try out SPADSampler quickly using our Google Colab notebook: Open In Colab

Features

  1. Binomial and Bernoulli Sampling: Sample data using either binomial or Bernoulli distribution.
  2. Histogram Computation: Compute and visualize histograms of image data.
  3. Flexible Input: Accept both numpy arrays and file paths as input.
  4. Customizable Sampling: Adjust sampling parameters such as probability range and processing axis.
  5. Visualization: Easily visualize original and sampled data side by side.

Usage

Here's a basic example of how to use SPADSampler:

import numpy as np
from spadsampler import sample_data, imshow_pairs, SamplingMethod

# Generate random data
data = np.random.randint(0, 256, (40, 128, 128, 5), dtype=np.uint8)

# Sample data using binomial sampling
output, = sample_data(data, range=(-6, -3))

# Visualize the results
imshow_pairs(output)

# Sample data using Bernoulli sampling
output_b, = sample_data(data, range=(-6, -3), sampling_method=SamplingMethod.BERNOULLI)

# Visualize the input and Bernoulli sampling results
imshow_pairs({"Input": data} | output_b)

Project details


Download files

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

Source Distribution

spadsampler-0.1.3.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

spadsampler-0.1.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file spadsampler-0.1.3.tar.gz.

File metadata

  • Download URL: spadsampler-0.1.3.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.6

File hashes

Hashes for spadsampler-0.1.3.tar.gz
Algorithm Hash digest
SHA256 eed19cc720042bbf04bd4c38bc88c0329cc1a8e8987630955819a4ff66d44646
MD5 721d3c13dee27587fa9c0e3c01024fb9
BLAKE2b-256 214a51975cbe6b6d198de17ea3b0e80c9daa2976fbf5f6f3b3c98349b8f9e9cd

See more details on using hashes here.

File details

Details for the file spadsampler-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: spadsampler-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.6

File hashes

Hashes for spadsampler-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9c68a79ff151d350ed1a0085cb4febd15e291670fc36b6e56d3fa610f2e54499
MD5 7c47f50833feb84e5b9d65c89b2956dc
BLAKE2b-256 30df9bc5561ae2a5d14432ff5cba0b728150f87481c9addb2a5ef97e9fb8bc79

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page