Skip to content

Commit

Permalink
Add 2 notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelecoq committed Mar 2, 2024
1 parent 0c26c26 commit 5c9ec50
Show file tree
Hide file tree
Showing 5 changed files with 436 additions and 50 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

This codec is designed for compressing movies with Poisson noise, which are produced by photon-limited modalities such multiphoton microscopy, radiography, and astronomy.

The codec assumes that the video is linearly encoded with a potential offset (`zero_level`) and that the `photon_sensitivity` (the average increase in intensity per photon) is known or can be accurately estimated from the data.
The codec assumes that the video is linearly encoded with a potential offset (`dark_signal`) and that the `photon_sensitivity` (the average increase in intensity per photon) is 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](https://en.wikipedia.org/wiki/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.
This results in a smaller number of unique grayscale levels and improvements in the compressibility of the data with a tunable trade-off (`beta`) for 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 `photon_sensitivity` (levels/photon).
To use the codec, one must supply two pieces of information: `dark_signal` (the input value corresponding to the absence of light) and `photon_sensitivity` (levels/photon). We provide two alternative routines to extract those numbers directly from signal statistics. Alternatively, they can be directly measured at the moment of data acquisition. Those calibration routines are provided in the [src/calibrate.py](src/calibrate.py) file.

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

Expand Down Expand Up @@ -43,4 +43,5 @@ pytest tests/

## Usage

An complete example is provided in [examples/workbook.ipynb](examples/workbook.ipynb)
A complete example with sequential calibration and look-up compression is provided in [examples/raster_calibration_and_compression.ipynb](examples/raster_calibration_and_compression.ipynb)
A complete example with raster calibration and compression is provided in [examples/sequential_calibration_and_lookup_compression.ipynb](examples/sequential_calibration_and_lookup_compression.ipynb)
376 changes: 376 additions & 0 deletions examples/raster_calibration_and_compression.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ numcodecs
zarr
matplotlib
scipy
scikit-learn
imageio
scikit-learn
8 changes: 3 additions & 5 deletions src/poisson_numcodecs/Calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,12 @@ def plot_poisson_curve(self):
for index, local_gain in enumerate(self.photon_sensitivity):
local_offset = self.dark_signal[index]

background_noise_mean = (
-local_offset / local_gain
)
plt.tight_layout()
plt.plot(
mean_range,
local_gain * (mean_range - background_noise_mean),
label=f"Line {index}",
local_gain * (mean_range - local_offset),
'r',
label=f"Line {index}",
)

plt.legend()
Expand Down

0 comments on commit 5c9ec50

Please sign in to comment.