Skip to content

Commit 5d7f524

Browse files
committed
WIP: DOC: Improved Python interface docs
1 parent b7f5975 commit 5d7f524

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A lean and kind
2929
3030
quick_start.md
3131
installation.md
32-
array_api.md
32+
python.md
3333
cli.md
3434
itk.md
3535
methods.md

docs/itk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Bidirectional type conversion that preserves spatial metadata is available with
88
Once represented as an `NgffImage`, a multiscale representation can be generated
99
with `to_multiscales`. And an OME-Zarr can be generated from the multiscales
1010
with `to_ngff_zarr`. For more information, see the
11-
[Python Array API documentation](./array_api.md).
11+
[Python interface documentation](./python.md).
1212

1313
## ITK Python
1414

docs/array_api.md renamed to docs/python.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
# 🐍 Python Array API
1+
# 🐍 Python Interface
22

3-
NGFF-Zarr supports conversion of any NumPy array-like object that follows the
4-
[Python Array API Standard](https://data-apis.org/array-api/latest/) into
5-
OME-Zarr. This includes such objects an NumPy `ndarray`'s, Dask Arrays, PyTorch
6-
Tensors, CuPy arrays, Zarr array, etc.
3+
NGFF-Zarr is a Python library that provides a simple, natural interface for
4+
working with OME-Zarr data structures, creating chunked, multiscale OME-Zarr
5+
image pyramids, and reading and writing OME-Zarr multiscale image files.
6+
7+
NGFF-Zarr's interface, which reflects the OME-Zarr data model, is built on
8+
Python's built-in [dataclasses] and [Dask arrays]. It is designed to be simple,
9+
flexible, and easy to use.
710

811
## Array to NGFF Image
912

10-
Convert the array to an `NgffImage`, which is a standard
11-
[Python dataclass](https://docs.python.org/3/library/dataclasses.html) that
12-
represents an OME-Zarr image for a single scale.
13+
NGFF-Zarr supports conversion of any NumPy array-like object that follows the
14+
[Python Array API Standard] into the OME-Zarr data model. This includes such
15+
objects an NumPy `ndarray`'s, Dask Arrays, PyTorch Tensors, CuPy arrays, Zarr
16+
array, etc.
17+
18+
Convert the array to an [`NgffImage`], which is a standard Python [dataclass]
19+
that represents an OME-Zarr image for a single scale.
1320

1421
When creating the image from the array, you can specify
1522

1623
- names of the `dims` from `{‘t’, ‘z’, ‘y’, ‘x’, ‘c’}`
1724
- the `scale`, the pixel spacing for the spatial dims
1825
- the `translation`, the origin or offset of the center of the first pixel
1926
- a `name` for the image
20-
- and `axes_units` with
21-
[UDUNITS-2 identifiers](https://ngff.openmicroscopy.org/latest/#axes-md)
27+
- and `axes_units` with [UDUNITS-2 identifiers]
2228

2329
```python
2430
>>> # Load an image as a NumPy array
@@ -28,7 +34,7 @@ When creating the image from the array, you can specify
2834
<class 'numpy.ndarray'>
2935
```
3036

31-
Specify optional additional metadata with `to_ngff_zarr`.
37+
Specify optional additional metadata with [`to_ngff_image`].
3238

3339
```python
3440
>>> import ngff_zarr as nz
@@ -50,16 +56,16 @@ chunksize=(256, 256), chunktype=numpy.ndarray>,
5056
)
5157
```
5258

53-
The image data is nested in a lazy `dask.array` and chucked.
59+
The image data is nested in a lazy `dask.Array` and chucked.
5460

5561
If `dims`, `scale`, or `translation` are not specified, NumPy-compatible
5662
defaults are used.
5763

58-
## Generate multiscales
64+
## Generate Multiscales
5965

6066
OME-Zarr represents images in a chunked, multiscale data structure. Use
61-
`to_multiscales` to build a task graph that will produce a chunked, multiscale
62-
image pyramid. `to_multiscales` has optional `scale_factors` and `chunks`
67+
[`to_multiscales`] to build a task graph that will produce a chunked, multiscale
68+
image pyramid. [`to_multiscales`] has optional `scale_factors` and `chunks`
6369
parameters. An [antialiasing method](./methods.md) can also be prescribed.
6470

6571
```python
@@ -152,7 +158,7 @@ scale according the OME-Zarr data model. Note that the correct `scale` and
152158

153159
## Write to Zarr
154160

155-
To write the multiscales to Zarr, use `to_ngff_zarr`.
161+
To write the multiscales to Zarr, use [`to_ngff_zarr`].
156162

157163
```python
158164
nz.to_ngff_zarr('cthead1.ome.zarr', multiscales)
@@ -165,3 +171,13 @@ Any other
165171
also be used.
166172

167173
The multiscales will be computed and written out-of-core, limiting memory usage.
174+
175+
[dataclass]: https://docs.python.org/3/library/dataclasses.html
176+
[dataclasses]: https://docs.python.org/3/library/dataclasses.html
177+
[Dask arrays]: https://docs.dask.org/en/stable/array.html
178+
[Python Array API Standard]: https://data-apis.org/array-api/latest/
179+
[UDUNITS-2 identifiers]: https://ngff.openmicroscopy.org/latest/#axes-md
180+
[`NgffImage`]: ../apidocs/ngff_zarr/ngff_zarr.ngff_image.html
181+
[`to_ngff_zarr`]: ../apidocs/ngff_zarr/ngff_zarr.to_ngff_zarr.html
182+
[`to_ngff_image`]: ../apidocs/ngff_zarr/ngff_zarr.to_ngff_image.html
183+
[`to_multiscales`]: ../apidocs/ngff_zarr/ngff_zarr.to_multiscales.html

0 commit comments

Comments
 (0)