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.
Install via pip:
pip install anscombe-transform
- Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/anscombe-transform.git
cd anscombe-transform- Install Hatch
Via pip:
pip install hatchOr directly.
- Create a development environment
# See available environments
hatch env show
# Enter a test environment
hatch shell test.py3.11-2.2Install pre-commit
- 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_transformThe project uses pytest for testing. Tests are found in the tests/ directory.
# Install docs dependencies
hatch run docs:mkdocs serve
# View at http://127.0.0.1:8000# Build static site
hatch run docs:mkdocs build
# Output in site/- Questions? Open a GitHub Discussion
- Bug reports? Open an Issue
By contributing, you agree that your contributions will be licensed under the MIT License.