Skip to content

Commit 4831940

Browse files
correct image generation in the overview
1 parent 86b1e81 commit 4831940

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

docs/getting-started/quick-start.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,25 @@ import zarr
99
import numpy as np
1010
from anscombe_transform import AnscombeTransformV3
1111

12-
# Generate sample data with Poisson noise
13-
# Simulating photon-limited imaging data
14-
data = np.random.poisson(lam=50, size=(100, 512, 512)).astype('int16')
12+
# Synthesize data with Poisson noise - simulating photon-limited microscopy data
13+
n_frames, height, width = 50, 256, 256
14+
mean_photon_rate = 5.0 # Average photons per pixel (exponential distribution of rates)
15+
zero_level = 20.0 # camera baseline
16+
conversion_gain = 30.0 # levels per photon
17+
photon_rate = np.random.exponential(scale=mean_photon_rate, size=(1, height, width))
18+
photon_counts = np.random.poisson(np.tile(photon_rate, (n_frames, 1, 1)))
19+
measured_signal = photon_counts + np.random.randn(*size) * 0.2
20+
21+
data = (zero_level + conversion_gain * measured_signal).astype('int16')
1522

1623
# Create a Zarr array with the Anscombe codec
1724
store = zarr.storage.MemoryStore()
1825
arr = zarr.create(
1926
store=store,
2027
shape=data.shape,
21-
chunks=(10, 512, 512),
28+
chunks=(12, 160, 80),
2229
dtype='int16',
23-
filters=[AnscombeTransformV3(zero_level=100, conversion_gain=2.5)],
30+
filters=[AnscombeTransformV3(zero_level=zero_level, conversion_gain=conversion_gain)],
2431
zarr_format=3
2532
)
2633

@@ -44,10 +51,10 @@ import zarr
4451
arr = zarr.open_array(
4552
'data.zarr',
4653
mode='w',
47-
shape=(100, 512, 512),
48-
chunks=(10, 512, 512),
54+
shape=data.shape,
55+
chunks=(12, 160, 80),
4956
dtype='int16',
50-
compressor=AnscombeTransformV2(zero_level=100, conversion_gain=2.5)
57+
compressor=AnscombeTransformV2(zero_level=zero_level, conversion_gain=conversion_gain)
5158
)
5259

5360
# Write and read data
@@ -64,10 +71,10 @@ from anscombe_transform import compute_conversion_gain
6471
import numpy as np
6572

6673
# Load your movie data as (time, height, width)
67-
movie = np.random.poisson(lam=50, size=(100, 512, 512))
74+
movie = data
6875

6976
# Estimate parameters
70-
result = compute_conversion_gain(movie)
77+
result = compute_conversion_gain(data)
7178

7279
print(f"Estimated conversion gain: {result['sensitivity']:.3f}")
7380
print(f"Estimated zero level: {result['zero_level']:.3f}")
@@ -90,10 +97,10 @@ from anscombe_transform import AnscombeTransformV3
9097

9198
# For Zarr V3, use filters + codecs
9299
arr = zarr.create(
93-
shape=(100, 512, 512),
100+
shape=data.shape,
94101
chunks=(10, 512, 512),
95102
dtype='int16',
96-
filters=[AnscombeTransformV3(zero_level=100, conversion_gain=2.5)],
103+
filters=[AnscombeTransformV3(zero_level=zero_level, conversion_gain=conversion_gain)],
97104
compressor={'id': 'blosc', 'cname': 'zstd', 'clevel': 5},
98105
zarr_format=3
99106
)
@@ -102,7 +109,7 @@ arr = zarr.create(
102109
## Key Parameters
103110

104111
- **`zero_level`**: The signal value when no photons are detected. This is the baseline offset in your camera sensor.
105-
- **`conversion_gain`** (also called `photon_sensitivity`): How many signal units correspond to one photon. For example, if your camera reports 2.5 ADU per photon, use `conversion_gain=2.5`.
112+
- **`conversion_gain`** (also called `photon_sensitivity`): How many signal units correspond to one photon. For example, if your camera reports 2.5 levels increase in signal per photon, use `conversion_gain=2.5`.
106113
- **`encoded_dtype`**: The data type for encoded values (default: `uint8`). Use `uint8` for maximum compression.
107114
- **`decoded_dtype`**: The data type for decoded values (default: inferred from data).
108115

docs/user-guide/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ These tables are computed once during codec initialization and reused for all en
7474
### Compression Ratios
7575

7676
Typical compression ratios (Anscombe + Blosc/Zstd):
77-
- **4-8x** for typical multiphoton microscopy data
77+
- **3-8x** for typical multiphoton microscopy data
7878
- **6-10x** for astronomy data
7979
- **3-6x** for radiography data
8080

0 commit comments

Comments
 (0)