Skip to main content

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)

Metadata

Release files for spadsampler 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spadsampler 0.1.6
File Size Uploaded
spadsampler-0.1.6.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spadsampler 0.1.6
File Interpreter ABI Platform
spadsampler-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 23.4 kB

Release files / spadsampler-0.1.6.tar.gz

Download URL spadsampler-0.1.6.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
582f429cd844323b6b49adb99c97e25a485209dbbc21a9d8a2ef2dbfca820549
BLAKE2b-256 checksum
How to use checksums
6380cb53cd1331a49e516db5e4c8b062f93e2a55388e28f5a720e24716c5efac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.7

Release files / spadsampler-0.1.6-py3-none-any.whl

Download URL spadsampler-0.1.6-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f1645a9c88ecfe482c6640f9055fdb14d4b8f04fbe66199f15898fdc453c419
BLAKE2b-256 checksum
How to use checksums
b6622e4ae6fd75972dedfcfbf4ec9f0fc92028f65358fa23882c93de8184b987
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page