Skip to content

Commit 1da6bbc

Browse files
committed
Merge branch 'glow-up-docs' into introduce-image-class
2 parents f27c627 + b39a0c1 commit 1da6bbc

22 files changed

+1268
-564
lines changed

.codespellrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ skip = .git,*.pdf,*.svg
33
# nd - for N-dimensional
44
# visibles - plural variable for visible
55
ignore-words-list = nd,visibles
6+
ignore-regex = [A-Za-z0-9+/]{100,}

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@ dist/
77
target/
88
docs/build/
99
*.DS_Store
10+
*Thumbs.db
1011
# Testing files
1112
.tox*
1213
.coverage*
1314
coverage.xml
1415

1516
# Generated version file
1617
ome_zarr/_version.py
18+
19+
# MyST build outputs
20+
_build
21+
22+
# demo notebooks
23+
*.ome.zarr
24+
*.zarr
25+
*.ipynb_checkpoints
26+
*/jupyter_execute

.readthedocs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build:
1313

1414
# Build documentation in the docs/ directory with Sphinx
1515
sphinx:
16-
fail_on_warning: true
16+
fail_on_warning: false
1717
configuration: docs/source/conf.py
1818

1919
# If using Sphinx, optionally build your docs in additional formats such as PDF
@@ -23,4 +23,6 @@ sphinx:
2323
# Optionally declare the Python requirements required to build your docs
2424
python:
2525
install:
26-
- requirements: docs/requirements.txt
26+
- requirements: docs/requirements.txt
27+
- method: pip
28+
path: .

docs/requirements.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ rangehttpserver
88
scipy
99
scikit-image
1010
Deprecated
11+
sphinx-copybutton
12+
sphinx-togglebutton
13+
myst-nb
14+
sphinx-thebe
15+
sphinx-comments
16+
sphinx-design
17+
sphinx-book-theme
18+
sphinx-external-toc
19+
sphinx-jupyterbook-latex
20+
linkify-it-py
21+
napari
22+
pyqt6

docs/source/_toc.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
format: jb-book
2+
root: index
3+
4+
options:
5+
numbered: False
6+
7+
parts:
8+
- caption: Basic
9+
chapters:
10+
- file: basic/write_image
11+
- file: basic/read_image
12+
- file: basic/view_images
13+
- file: basic/write_labels
14+
- file: basic/cli_basics
15+
16+
17+
- caption: Advanced
18+
chapters:
19+
- file: advanced/build_custom_pyramid
20+
- file: advanced/write_hcs_plate
21+
22+
- caption: Explanation
23+
chapters:
24+
- file: explanation/ome_ngff_overview
25+
- file: explanation/multiscale_pyramids
26+
- file: explanation/zarr_concepts
27+
28+
- caption: API Reference
29+
chapters:
30+
- file: api
31+
sections:
32+
- file: api/writer
33+
- file: api/reader
34+
- file: api/io
35+
- file: api/scale
36+
- file: api/format
37+
- file: api/cli
38+
- file: api/utils
39+
- file: api/csv
40+
- file: api/data
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "95d84769",
6+
"metadata": {},
7+
"source": [
8+
"# Customizing the pyramid\n",
9+
"(advanced:pyramid)=\n",
10+
"\n",
11+
"\n",
12+
"Multi-resolution pyramids are an integral part of ome-zarr image data\n",
13+
"and enable fast rendering of large images.\n",
14+
"The entrypoints to writing ome-zarr images in ome-zarr-py ({py:func}`ome_zarr.writer.write_image` and {py:func}`ome_zarr.writer.write_labels`)\n",
15+
"build these pyramids under the hood as delayed dask arrays based on the settings for the scaling functions and scale factors.\n",
16+
"\n",
17+
"In this example, the downsampling will be applied in all spatial dimensions *except the z dimension*, which will be left at a scale factor of 1.\n",
18+
"To apply equal or custom downsampling factors along all spatial dimensions, pass the scale factors as a list of dicts (see [below](#advanced:custom-downsampling-values))."
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": 16,
24+
"id": "642955b1",
25+
"metadata": {},
26+
"outputs": [
27+
{
28+
"data": {
29+
"text/plain": [
30+
"[]"
31+
]
32+
},
33+
"execution_count": 16,
34+
"metadata": {},
35+
"output_type": "execute_result"
36+
}
37+
],
38+
"source": [
39+
"import numpy as np\n",
40+
"\n",
41+
"from ome_zarr.writer import write_image\n",
42+
"\n",
43+
"scale_factors = [2, 4, 8]\n",
44+
"rng = np.random.default_rng(0)\n",
45+
"data = rng.poisson(lam=10, size=(64, 64, 64)).astype(np.uint8)\n",
46+
"\n",
47+
"write_image(\n",
48+
" data,\n",
49+
" \"test_ngff_image.ome.zarr\",\n",
50+
" axes=\"zyx\",\n",
51+
" scale_factors=scale_factors,\n",
52+
" )"
53+
]
54+
},
55+
{
56+
"cell_type": "markdown",
57+
"id": "cec0fc73",
58+
"metadata": {},
59+
"source": [
60+
"## Custom downsampling values\n",
61+
"(advanced:custom-downsampling-values)=\n",
62+
"\n",
63+
"To specify custom downsampling values, pass a list of dictionaries with the keys being the names of the axes to the writer function like in the following example.\n",
64+
"This will apply equal downsampling factors along all present axes (`zyx` in this case):"
65+
]
66+
},
67+
{
68+
"cell_type": "code",
69+
"execution_count": 17,
70+
"id": "60dcd278",
71+
"metadata": {},
72+
"outputs": [
73+
{
74+
"data": {
75+
"text/plain": [
76+
"[]"
77+
]
78+
},
79+
"execution_count": 17,
80+
"metadata": {},
81+
"output_type": "execute_result"
82+
}
83+
],
84+
"source": [
85+
"scale_factors = [\n",
86+
" {\"z\": 2,\"x\": 2, \"y\": 2},\n",
87+
" {\"z\": 4,\"x\": 4, \"y\": 4},\n",
88+
" {\"z\": 8,\"x\": 8, \"y\": 8},\n",
89+
"]\n",
90+
"\n",
91+
"write_image(\n",
92+
" data,\n",
93+
" \"test_ngff_image_custom_scale.ome.zarr\",\n",
94+
" axes=\"zyx\",\n",
95+
" scale_factors=scale_factors,\n",
96+
" )"
97+
]
98+
},
99+
{
100+
"cell_type": "markdown",
101+
"id": "6b276be7",
102+
"metadata": {},
103+
"source": [
104+
"## Custom downsampling functions\n",
105+
"\n",
106+
"ome-zarr-py provides multiple methods for downsampling, which can be found in the {py:class}`ome_zarr.scale.Methods` class:"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": 18,
112+
"id": "877ab60d",
113+
"metadata": {},
114+
"outputs": [
115+
{
116+
"name": "stdout",
117+
"output_type": "stream",
118+
"text": [
119+
"['resize', 'nearest', 'local_mean', 'zoom']\n"
120+
]
121+
}
122+
],
123+
"source": [
124+
"from ome_zarr.scale import Methods\n",
125+
"\n",
126+
"print([m.value for m in Methods])"
127+
]
128+
},
129+
{
130+
"cell_type": "markdown",
131+
"id": "9a086164",
132+
"metadata": {},
133+
"source": [
134+
"You can use one of these functions for downsampling by passing the method name as a string to the writer function, e.g. `method=\"local_mean\"` or `method=\"resize\"`, i.e.:"
135+
]
136+
},
137+
{
138+
"cell_type": "code",
139+
"execution_count": 19,
140+
"id": "859ca482",
141+
"metadata": {},
142+
"outputs": [
143+
{
144+
"data": {
145+
"text/plain": [
146+
"[]"
147+
]
148+
},
149+
"execution_count": 19,
150+
"metadata": {},
151+
"output_type": "execute_result"
152+
}
153+
],
154+
"source": [
155+
"write_image(\n",
156+
" data,\n",
157+
" \"test_ngff_image_custom_method.ome.zarr\",\n",
158+
" axes=\"zyx\",\n",
159+
" scale_factors=scale_factors,\n",
160+
" method=\"nearest\"\n",
161+
")\n"
162+
]
163+
},
164+
{
165+
"cell_type": "markdown",
166+
"id": "893a1b3b",
167+
"metadata": {},
168+
"source": [
169+
"```{warning}\n",
170+
"\n",
171+
"The choice of the correct downsampling function is typically of secondary importance,\n",
172+
"*unless* your data specifically requires a certain method.\n",
173+
"\n",
174+
"For instance, when writing categorical data (i.e., segmentations or generally labels),\n",
175+
"you will want to use a method that preserves the label values, such as {py:func}`ome_zarr.scale.Methods.NEAREST`.\n",
176+
"\n",
177+
"See also section on [writing labels](basic:labels)\n",
178+
"\n",
179+
"```"
180+
]
181+
},
182+
{
183+
"cell_type": "markdown",
184+
"id": "fbbeecf3",
185+
"metadata": {},
186+
"source": []
187+
}
188+
],
189+
"metadata": {
190+
"kernelspec": {
191+
"display_name": "ngff-spec",
192+
"language": "python",
193+
"name": "python3"
194+
},
195+
"language_info": {
196+
"codemirror_mode": {
197+
"name": "ipython",
198+
"version": 3
199+
},
200+
"file_extension": ".py",
201+
"mimetype": "text/x-python",
202+
"name": "python",
203+
"nbconvert_exporter": "python",
204+
"pygments_lexer": "ipython3",
205+
"version": "3.12.12"
206+
}
207+
},
208+
"nbformat": 4,
209+
"nbformat_minor": 5
210+
}

0 commit comments

Comments
 (0)