You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update documentation for acquire-zarr v0.5.1 (part 2 / 2) (#104)
* Emphasize acquire-zarr and deëmphasize acquire-python in README
* Add a core concepts page
* Add note about streaming-only design
* Get started -> Getting started
* Update Getting started with Python
* Update deploy_docs.yml
* Update getting started page
* Point to Getting Started page for acquire-zarr installation
The `acquire-zarr` library provides both Python and C interfaces.
1
+
# Getting started
3
2
4
-
## Get Started with Python
3
+
You can use `acquire-zarr` to stream data in either Python or C/C++ programs.
4
+
This document provides a quick overview of how to get started with both languages.
5
5
6
-
### Install the Python library
6
+
> [!TIP]
7
+
> New to Zarr streaming? Check out our [Core concepts](core_concepts.md) page to understand the key terminology used throughout this guide.
7
8
8
-
The `acquire-zarr` Python library is compatible with Python versions 3.9-3.13.
9
+
## Getting started with Python
9
10
10
-
To install the library on Windows, macOS, or Ubuntu, run the following command:
11
+
### Installation
12
+
13
+
The `acquire-zarr` Python library is supported for Python versions 3.9-3.13.
14
+
15
+
To install the library on Windows, macOS, or Linux, run the following command, after ensuring that the `python` command points to the correct Python version you want to use:
11
16
12
17
```bash
13
18
python -m pip install acquire-zarr
@@ -17,7 +22,7 @@ We recommend installing `acquire-zarr` in a fresh conda environment or virtualen
17
22
For example, to install `acquire-zarr` in a conda environment named `acquire`:
18
23
19
24
```shell
20
-
conda create -n acquire python#compatible with python 3.9-3.13
25
+
conda create -n acquire python=3.13 # or python=3.12, python=3.11, etc.
21
26
conda activate acquire
22
27
python -m pip install acquire-zarr
23
28
```
@@ -26,98 +31,231 @@ or with virtualenv:
26
31
27
32
```shell
28
33
$ python -m venv venv
29
-
$ . ./venv/bin/activate # or on Windows: .\venv\Scripts\Activate.bat or .\venv\Scripts\Activate.ps1
34
+
$ . ./venv/bin/activate # or on Windows: .\venv\Scripts\Activate
30
35
(venv) $ python -m pip install acquire-zarr
31
36
```
32
37
33
-
Once you have `acquire-zarr` installed, simply call `import acquire_zarr`in your script, notebook, or module to start utilizing the package.
38
+
Now in your scripts or notebooks, import acquire-zarr with:
34
39
35
40
```python
36
-
import acquire_zarr
41
+
import acquire_zarras aqz # or simply `import acquire_zarr`
37
42
```
38
43
39
-
####Usage
44
+
### Usage
40
45
41
-
The library provides two main classes. First, `ZarrStream`, representing an output stream to a Zarr dataset.
42
-
Second, `ZarrStreamSettings` to configure a Zarr stream.
46
+
The typical workflow for acquiring data in Python is to create a stream by configuring it with the desired settings, and then to append data to the stream.
43
47
44
-
A typical use case for a 4-dimensional acquisition in Python might look like this:
48
+
The *stream* represents a Zarr dataset that can be written to.
49
+
You can write data to one or more *arrays* in the stream, where each array corresponds to a separate subset of the data.
50
+
For example, you might have a stream for a multi-camera acquisition, where each camera's data is stored in a separate array.
51
+
52
+
Here's how you might configure a stream for a 4-dimensional acquisition (time, channel, height, width) with a single array and append data to it:
45
53
46
54
```python
47
55
import acquire_zarr as aqz
48
56
import numpy as np
49
57
50
58
settings = aqz.StreamSettings(
51
59
store_path="my_stream.zarr",
52
-
data_type=aqz.DataType.UINT16,
53
-
version=aqz.ZarrVersion.V3
60
+
version=aqz.ZarrVersion.V3,
61
+
overwrite=True, # this will remove any existing data at my_stream.zarr
62
+
arrays=[
63
+
aqz.ArraySettings(
64
+
output_key="array1",
65
+
data_type=np.uint16,
66
+
dimensions= [
67
+
aqz.Dimension(
68
+
name="t",
69
+
type=aqz.DimensionType.TIME,
70
+
array_size_px=0,
71
+
chunk_size_px=32,
72
+
shard_size_chunks=10
73
+
),
74
+
aqz.Dimension(
75
+
name="c",
76
+
type=aqz.DimensionType.CHANNEL,
77
+
array_size_px=3,
78
+
chunk_size_px=1,
79
+
shard_size_chunks=1
80
+
),
81
+
aqz.Dimension(
82
+
name="y",
83
+
type=aqz.DimensionType.SPACE,
84
+
array_size_px=1080,
85
+
chunk_size_px=270,
86
+
shard_size_chunks=2
87
+
),
88
+
aqz.Dimension(
89
+
name="x",
90
+
type=aqz.DimensionType.SPACE,
91
+
array_size_px=1920,
92
+
chunk_size_px=480,
93
+
shard_size_chunks=2
94
+
)
95
+
]
96
+
)
97
+
]
54
98
)
55
99
56
-
settings.dimensions.extend([
57
-
aqz.Dimension(
58
-
name="t",
59
-
type=aqz.DimensionType.TIME,
60
-
array_size_px=0,
61
-
chunk_size_px=100,
62
-
shard_size_chunks=10
63
-
),
64
-
aqz.Dimension(
65
-
name="c",
66
-
type=aqz.DimensionType.CHANNEL,
67
-
array_size_px=3,
68
-
chunk_size_px=1,
69
-
shard_size_chunks=1
70
-
),
71
-
aqz.Dimension(
72
-
name="y",
73
-
type=aqz.DimensionType.SPACE,
74
-
array_size_px=1080,
75
-
chunk_size_px=270,
76
-
shard_size_chunks=2
77
-
),
78
-
aqz.Dimension(
79
-
name="x",
80
-
type=aqz.DimensionType.SPACE,
81
-
array_size_px=1920,
82
-
chunk_size_px=480,
83
-
shard_size_chunks=2
84
-
)
85
-
])
86
-
87
100
# Generate some random data: one time point, all channels, full frame
# When done, close the stream to flush any remaining data
109
+
stream.close()
110
+
```
111
+
112
+
When all is said and done, the data will be stored in a Zarr dataset on disk at `my_stream.zarr`, which can be read by any Zarr-compatible library.
113
+
It will contain one array named `array1` with the data organized in the specified dimensions according to the chunk and shard layout you specified.
114
+
115
+
If you instead had a multichannel acquisition with both brightfield and fluorescence channels, you could create a stream with two arrays, one for each channel type:
116
+
117
+
```python
118
+
import acquire_zarr as aqz
119
+
import numpy as np
120
+
121
+
# configure the stream with two arrays
122
+
settings = aqz.StreamSettings(
123
+
store_path="experiment.zarr",
124
+
version=aqz.ZarrVersion.V3,
125
+
overwrite=True, # this will remove any existing data at experiment.zarr
126
+
arrays=[
127
+
aqz.ArraySettings(
128
+
output_key="sample1/brightfield",
129
+
data_type=np.uint16,
130
+
dimensions=[
131
+
aqz.Dimension(
132
+
name="t",
133
+
type=aqz.DimensionType.TIME,
134
+
array_size_px=0,
135
+
chunk_size_px=100,
136
+
shard_size_chunks=1
137
+
),
138
+
aqz.Dimension(
139
+
name="c",
140
+
type=aqz.DimensionType.CHANNEL,
141
+
array_size_px=1,
142
+
chunk_size_px=1,
143
+
shard_size_chunks=1
144
+
),
145
+
aqz.Dimension(
146
+
name="y",
147
+
type=aqz.DimensionType.SPACE,
148
+
array_size_px=1080,
149
+
chunk_size_px=270,
150
+
shard_size_chunks=2
151
+
),
152
+
aqz.Dimension(
153
+
name="x",
154
+
type=aqz.DimensionType.SPACE,
155
+
array_size_px=1920,
156
+
chunk_size_px=480,
157
+
shard_size_chunks=2
158
+
)
159
+
]
160
+
),
161
+
aqz.ArraySettings(
162
+
output_key="sample1/fluorescence",
163
+
data_type=np.uint16,
164
+
dimensions=[
165
+
aqz.Dimension(
166
+
name="t",
167
+
type=aqz.DimensionType.TIME,
168
+
array_size_px=0,
169
+
chunk_size_px=100,
170
+
shard_size_chunks=1
171
+
),
172
+
aqz.Dimension(
173
+
name="c",
174
+
type=aqz.DimensionType.CHANNEL,
175
+
array_size_px=2, # two fluorescence channels
176
+
chunk_size_px=1,
177
+
shard_size_chunks=1
178
+
),
179
+
aqz.Dimension(
180
+
name="y",
181
+
type=aqz.DimensionType.SPACE,
182
+
array_size_px=1080,
183
+
chunk_size_px=270,
184
+
shard_size_chunks=2
185
+
),
186
+
aqz.Dimension(
187
+
name="x",
188
+
type=aqz.DimensionType.SPACE,
189
+
array_size_px=1920,
190
+
chunk_size_px=480,
191
+
shard_size_chunks=2
192
+
)
193
+
]
194
+
)
195
+
]
196
+
)
197
+
198
+
stream = aqz.ZarrStream(settings)
199
+
200
+
# ... append data ...
201
+
brightfield_frame_data =...# define your brightfield frame data here
202
+
fluorescence_frame_data =...# define your fluorescence frame data here
# When done, close the stream to flush any remaining data
210
+
stream.close()
92
211
```
93
-
### Build Python Bindings from Source
94
212
95
-
The library must be built from source to contribute to the latest development version or to customize the installation for your system.
96
-
To build the Python bindings from source, follow [these instructions](https://github.com/acquire-project/acquire-zarr/blob/main/README.md#building).
213
+
See the [API reference](api_reference/index.md) for more details on the available settings and methods.
214
+
215
+
### Building the Python library from source
216
+
217
+
If you want to [contribute](for_contributors/index.md) to acquire-zarr, or customize the installation for your own system, you'll need to be able to build the Python bindings from source.
218
+
The first step is to install the system dependencies as found in the ["Installing dependencies" section](https://github.com/acquire-project/acquire-zarr/blob/main/README.md#installing-dependencies) of the README.md file in the `acquire-zarr` repository.
219
+
In your Python environment, you also need the following dependencies:
The `acquire-zarr` C library is distributed as a binary and headers, which you can download for your system from our [Releases page](https://github.com/acquire-project/acquire-zarr/releases). You will also need to install the following dependencies:
We suggest using [vcpkg](https://github.com/microsoft/vcpkg) or another package manager to handle dependencies.
245
+
`acquire-zarr` provides a C API that works with both C and C++ projects.
246
+
You can download the library for your system from our [Releases page](https://github.com/acquire-project/acquire-zarr/releases).
247
+
The library ships with header files and precompiled binaries for Windows x86, macOS (x86 or ARM), or Linux (x86 or ARM), as well as source code examples and a sample CMakeLists.txt file.
110
248
111
-
[Here](https://github.com/acquire-project/acquire-zarr/blob/main/examples/CMakeLists.txt) is an example CMakeLists.txt file of C executables using acquire-zarr.
249
+
### Usage
112
250
113
-
#### Usage
251
+
Similarly with Python, the typical workflow for acquiring data in C is to create a stream by configuring it with the desired settings, and then to append data to the stream.
114
252
115
253
The library provides two main structs. First, `ZarrStream`, representing an output stream to a Zarr dataset.
116
254
Second, `ZarrStreamSettings` to configure a Zarr stream.
117
255
118
256
A typical use case for a 4-dimensional acquisition in C might look like this:
119
257
120
-
```c
258
+
```C
121
259
#include"acquire.zarr.h"
122
260
#include"assert.h"
123
261
@@ -171,7 +309,25 @@ int main() {
171
309
172
310
Look at [acquire.zarr.h](include/acquire.zarr.h) for more details.
173
311
174
-
### Building the C Library from Source
312
+
### Building the library from source
313
+
314
+
If you want to [contribute](for_contributors/index.md) to acquire-zarr, or customize the installation for your own system, you'll need to be able to build the library from source.
315
+
The first step is to install the system dependencies as found in the ["Installing dependencies" section](https://github.com/acquire-project/acquire-zarr/blob/main/README.md#installing-dependencies) of the README.md file in the `acquire-zarr` repository.
316
+
As in the README, we recommend using vcpkg to install them.
317
+
You will also need CMake to build the library.
318
+
319
+
Once you have built the library, try running the tests to ensure everything is working correctly.
0 commit comments