Skip to content

datajoint/anscombe-transform

Repository files navigation

PyPI version tests

Anscombe transform

This codec is designed for compressing image recordings with Poisson noise such as in microscopy, radiography, and astronomy.

Status: This is the official and actively maintained Anscombe transform codec for Zarr/Numcodecs, maintained by DataJoint. It originated as a fork of AllenNeuralDynamics/poisson-numcodecs and earlier developments at https://github.com/datajoint/compress-multiphoton. It has since diverged significantly. New users should rely on this repository as the canonical source.

The codec assumes that the video is linearly encoded with a potential offset (zero_level) and that the conversion_gain (also called photon_sensitivity)—the average increase in intensity per photon—is either already known or can be accurately estimated from the data.

The codec re-quantizes the grayscale efficiently with a square-root-like transformation to equalize the noise variance across the grayscale levels: the Anscombe Transform. This results in a smaller number of unique grayscale levels and significant improvements in the compressibility of the data without sacrificing signal accuracy.

To use the codec, one must supply two pieces of information: zero_level (the input value corresponding to the absence of light) and conversion_gain (levels/photon).

The codec is used in Zarr as a filter prior to compression.

Zarr.

Installation

Install via pip:

pip install anscombe-transform

Development Setup

Getting Started

  1. Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/anscombe-transform.git
cd anscombe-transform
  1. Install Hatch

Via pip:

pip install hatch

Or directly.

  1. Create a development environment
# See available environments
hatch env show

# Enter a test environment
hatch shell test.py3.11-2.2

Install pre-commit

  1. Run tests
# Run all tests
hatch run test:pytest tests/

# Run specific test file
hatch run test:pytest tests/test_codec.py

# Run with coverage
hatch run test:pytest tests/ --cov=src/anscombe_transform

Testing

The project uses pytest for testing. Tests are found in the tests/ directory.

Building Documentation

Local Documentation Server

# Install docs dependencies
hatch run docs:mkdocs serve

# View at http://127.0.0.1:8000

Building Documentation

# Build static site
hatch run docs:mkdocs build

# Output in site/

Getting Help

License

By contributing, you agree that your contributions will be licensed under the MIT License.

About

Zarr v2/v3 codec images with Poisson noise (e.g. microscopy, radiography, astronomy)

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 10

Languages