Skip to content

Commit 7622756

Browse files
authored
Merge pull request #97 from melissawm/zarr-reorg
Reorganize page for Acquire Zarr
2 parents 6802b24 + a0233ac commit 7622756

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1551
-325
lines changed

.github/workflows/convert.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
echo "Converting all .md tutorials to .py files..."
3-
TUTS_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../../docs/tutorials"
3+
TUTS_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../../docs/acquire-imaging/tutorials"
44
pushd ${TUTS_DIR}
55
for subdir in */; do
66
pushd $subdir

.github/workflows/deploy_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
8282
- name: Replace relative links in Doxygen include
8383
run: |
84-
sed -i 's@acquire_zarr_c_api/acquire_zarr_c_api#@#@g' acquire-docs/site/stream_to_zarr/c_api/index.html
84+
sed -i 's@acquire_zarr_c_api/acquire_zarr_c_api#@#@g' acquire-docs/site/api_reference/c_api/index.html
8585
8686
- name: Deploy docs
8787
uses: peaceiris/actions-gh-pages@v3

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
site/
22
venv/
3-
docs/stream_to_zarr/acquire_zarr_c_api
3+
docs/api_reference/acquire_zarr_c_api
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# API Reference
2+
3+
Information on the classes in the `acquire-imaging` package along with the attributes and methods associated with them.
4+
5+
::: acquire
File renamed without changes.
File renamed without changes.
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# Getting Started with Acquire
2+
3+
Acquire (`acquire-imaging` [on PyPI](https://pypi.org/project/acquire-imaging/)) is a Python package providing a multi-camera video streaming library focused on performant microscopy, with support for up to two simultaneous, independent, video streams.
4+
5+
This tutorial covers Acquire installation and shows an example of using Acquire with its provided simulated cameras to demonstrate the acquisition process.
6+
7+
## Installation
8+
9+
To install Acquire on Windows, macOS, or Ubuntu, simply run the following command:
10+
11+
```
12+
python -m pip install acquire-imaging
13+
```
14+
15+
We recommend installing `Acquire` in a fresh conda environment or virtualenv.
16+
For example, to install `Acquire` in a conda environment named `acquire`:
17+
18+
```
19+
conda create -n acquire python=3.10 # follow the prompts and proceed with the defaults
20+
conda activate acquire
21+
python -m pip install acquire-imaging
22+
```
23+
24+
or with virtualenv:
25+
26+
```shell
27+
$ python -m venv venv
28+
$ . ./venv/bin/activate # or on Windows: .\venv\Scripts\Activate.bat or .\venv\Scripts\Activate.ps1
29+
(venv) $ python -m pip install acquire-imaging
30+
```
31+
32+
Once you have Acquire installed, simply call `import acquire` in your script, notebook, or module to start utilizing the package.
33+
34+
```python
35+
import acquire
36+
```
37+
38+
## Supported Cameras and File Formats
39+
40+
Acquire supports the following cameras (currently only on Windows):
41+
42+
- [Hamamatsu Orca Fusion BT (C15440-20UP)](https://www.hamamatsu.com/eu/en/product/cameras/cmos-cameras/C15440-20UP.html)
43+
- [Vieworks VC-151MX-M6H00](https://www.visionsystech.com/products/cameras/vieworks-vc-151mx-sony-imx411-sensor-ultra-high-resolution-cmos-camera-151-mp)
44+
- [FLIR Blackfly USB3 (BFLY-U3-23S6M-C)](https://www.flir.com/products/blackfly-usb3/?model=BFLY-U3-23S6M-C&vertical=machine+vision&segment=iis)
45+
- [FLIR Oryx 10GigE (ORX-10GS-51S5M-C)](https://www.flir.com/products/oryx-10gige/?model=ORX-10GS-51S5M-C&vertical=machine+vision&segment=iis)
46+
47+
Acquire also supports the following output file formats:
48+
49+
- [Tiff](https://en.wikipedia.org/wiki/TIFF)
50+
- [Zarr](https://zarr.dev/)
51+
52+
Acquire also provides a few simulated cameras, as well as raw byte storage and "trash," which discards all data written to it.
53+
54+
## Tutorial Prerequisites
55+
56+
We will be streaming to [TIFF](http://bigtiff.org/), using [scikit-image](https://scikit-image.org/) to load and inspect the data, and visualizing the data using [napari](https://napari.org/stable/).
57+
58+
You can install the prerequisites with:
59+
60+
```
61+
python -m pip install "napari[all]" scikit-image
62+
```
63+
64+
## Setup for Acquisition
65+
66+
In Acquire parlance, the combination of a source (camera), filter, and sink (output) is called a **video stream**.
67+
We will generate data using simulated cameras (our source) and output to TIFF on the filesystem (our sink).
68+
(For this tutorial, we will not use a filter.)
69+
Acquire supports up to two such video streams.
70+
71+
Sources are implemented as **Camera** devices, and sinks are implemented as **Storage** devices.
72+
We'll start by seeing all the devices that Acquire supports:
73+
74+
```python
75+
import acquire
76+
77+
runtime = acquire.Runtime()
78+
dm = runtime.device_manager()
79+
80+
for device in dm.devices():
81+
print(device)
82+
```
83+
84+
The **runtime** is the main entry point in Acquire.
85+
Through the runtime, you configure your devices, start acquisition, check acquisition status, inspect data as it streams from your cameras, and terminate acquisition.
86+
87+
Let's configure our devices now.
88+
To do this, we'll get a copy of the current runtime configuration.
89+
We can update the configuration with identifiers from the runtime's **device manager**, but these devices won't be created until we start the acquisition.
90+
91+
Before configuring the streams, grab the current configuration of the `Runtime` object with:
92+
93+
```python
94+
config = runtime.get_configuration()
95+
```
96+
97+
Video streams are configured independently.
98+
Configure the first video stream by setting properties on `config.video[0]` and the second video stream with `config.video[1]`.
99+
We'll be using simulated cameras, one generating a radial sine pattern and one generating a random pattern.
100+
101+
```python
102+
config.video[0].camera.identifier = dm.select(acquire.DeviceKind.Camera, "simulated: radial sin")
103+
104+
# how many adjacent pixels in each direction to combine by averaging; here, 1 means not to combine
105+
config.video[0].camera.settings.binning = 1
106+
107+
# how long (in microseconds) your camera should collect light from the sample; for simulated cameras,
108+
# this is just a waiting period before generating the next frame
109+
config.video[0].camera.settings.exposure_time_us = 5e4 # 50 ms
110+
111+
# the data type representing each pixel; here we choose unsigned 8-bit integer
112+
config.video[0].camera.settings.pixel_type = acquire.SampleType.U8
113+
114+
# the shape, in pixels, of the image; width first, then height
115+
config.video[0].camera.settings.shape = (1024, 768)
116+
```
117+
118+
119+
```python
120+
config.video[1].camera.identifier = dm.select(acquire.DeviceKind.Camera, "simulated: uniform random")
121+
122+
# how many adjacent pixels in each direction to combine by averaging; here, 1 means not to combine
123+
config.video[1].camera.settings.binning = 1
124+
125+
# how long (in microseconds) your camera should collect light from the sample; for simulated cameras,
126+
# this is just a waiting period before generating the next frame
127+
config.video[1].camera.settings.exposure_time_us = 1e4 # 10 ms
128+
129+
# the data type representing each pixel; here we choose unsigned 8-bit integer
130+
config.video[1].camera.settings.pixel_type = acquire.SampleType.U8
131+
132+
# the shape, in pixels, of the image; width first, then height
133+
config.video[1].camera.settings.shape = (1280, 720)
134+
```
135+
136+
Now we'll configure each output, or sink device.
137+
For both simulated cameras, we'll be writing to [TIFF](http://bigtiff.org/), a well-known format for storing image data.
138+
For now, we'll simply specify the output file name.
139+
140+
```python
141+
config.video[0].storage.identifier = dm.select(acquire.DeviceKind.Storage, "Tiff")
142+
143+
# what file or directory to write the data to
144+
config.video[0].storage.settings.filename = "output1.tif"
145+
```
146+
147+
148+
```python
149+
config.video[1].storage.identifier = dm.select(acquire.DeviceKind.Storage, "Tiff")
150+
151+
# what file or directory to write the data to
152+
config.video[1].storage.settings.filename = "output2.tif"
153+
```
154+
155+
Finally, let's specify how many frames to generate for each camera before stopping our simulated acquisition.
156+
We also need to register our configuration with the runtime using the `set_configuration` method.
157+
158+
If you want to let the runtime acquire effectively forever, you can set `max_frame_count` to `2**64 - 1`.
159+
160+
```python
161+
config.video[0].max_frame_count = 100 # collect 100 frames
162+
config.video[1].max_frame_count = 150 # collect 150 frames
163+
164+
config = runtime.set_configuration(config)
165+
```
166+
167+
!!! note
168+
169+
If you run this tutorial multiple times, you can clear output from previous runs with:
170+
171+
```python
172+
from pathlib import Path
173+
174+
Path(config.video[0].storage.settings.uri).unlink(missing_ok=True)
175+
Path(config.video[1].storage.settings.uri).unlink(missing_ok=True)
176+
```
177+
178+
## Acquire Data
179+
180+
To start acquiring data:
181+
182+
```python
183+
runtime.start()
184+
```
185+
186+
Acquisition happens in a separate thread, so at any point we can check on the status by calling the `get_state` method.
187+
188+
```python
189+
runtime.get_state()
190+
```
191+
192+
Finally, once we're done acquiring, we call `runtime.stop()`.
193+
This method will wait until you've reached the number of frames to collect specified in `config.video[0].max_frame_count` or `config.video[1].max_frame_count`, whichever is larger.
194+
195+
```python
196+
runtime.stop()
197+
```
198+
199+
## Visualizing the data with napari
200+
201+
Let's take a look at what we've written.
202+
We'll load each Zarr dataset as a Dask array and inspect its dimensions, then we'll use napari to view it.
203+
204+
```python
205+
from skimage.io import imread
206+
import napari
207+
208+
data1 = imread(config.video[0].storage.settings.filename)
209+
data2 = imread(config.video[1].storage.settings.filename)
210+
211+
viewer1 = napari.view_image(data1)
212+
213+
viewer2 = napari.view_image(data2)
214+
```
215+
216+
## Conclusion
217+
218+
For more examples of using Acquire, check out our [tutorials page](tutorials/index.md).
219+
220+
References:
221+
[Tiff]: https://en.wikipedia.org/wiki/TIFF
222+
[scikit-image]: https://scikit-image.org/
223+
[napari]: https://napari.org/stable/

docs/acquire-imaging/index.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Acquire Docs
3+
template: home.html
4+
---
5+
6+
## Guides
7+
8+
<div class="cards">
9+
<div class="card">
10+
<h4>Get Started</h4>
11+
<p>Install Acquire and use simulated cameras</p>
12+
<a href="get_started" class="button">Get Started</a>
13+
</div>
14+
<div class="card">
15+
<h4>API Reference</h4>
16+
<p>Information on classes and methods</p>
17+
<a href="api_reference" class="button">API Reference</a>
18+
</div>
19+
<div class="card">
20+
<h4>Tutorials</h4>
21+
<p>Guides on using Acquire for specific tasks</p>
22+
<a href="tutorials" class="button">Tutorials</a>
23+
</div>
24+
<div class="card">
25+
<h4>For contributors</h4>
26+
<p>Learn how to contribute code or documentation to Acquire</p>
27+
<a href="../for_contributors" class="button">For contributors</a>
28+
</div>
29+
</div>
30+
31+
## About Acquire
32+
33+
[Acquire](https://github.com/acquire-project/acquire-python) (`acquire-imaging` on [PyPI](https://pypi.org/project/acquire-imaging/)) provides high-speed, multi-camera, video streaming and image acquisition with a [programming interface](api_reference.md) for streaming video data directly to [napari](https://napari.org/stable/), Python and cloud-friendly file formats.
34+
35+
## Installation
36+
37+
To install Acquire on Windows, macOS, or Ubuntu, simply run the following command:
38+
39+
```
40+
python -m pip install acquire-imaging
41+
```
42+
43+
## Supported Cameras and File Formats
44+
Acquire supports the following cameras (currently only on Windows):
45+
46+
- [Hamamatsu Orca Fusion BT (C15440-20UP)](https://www.hamamatsu.com/eu/en/product/cameras/cmos-cameras/C15440-20UP.html)
47+
- [Vieworks VC-151MX-M6H00](https://www.visionsystech.com/products/cameras/vieworks-vc-151mx-sony-imx411-sensor-ultra-high-resolution-cmos-camera-151-mp)
48+
- [FLIR Blackfly USB3 (BFLY-U3-23S6M-C)](https://www.flir.com/products/blackfly-usb3/?model=BFLY-U3-23S6M-C&vertical=machine+vision&segment=iis)
49+
- [FLIR Oryx 10GigE (ORX-10GS-51S5M-C)](https://www.flir.com/products/oryx-10gige/?model=ORX-10GS-51S5M-C&vertical=machine+vision&segment=iis)
50+
51+
For testing and demonstration purposes, Acquire also provides a few simulated video sources. For more information on supported cameras and video sources, check out [this tutorial](./tutorials/setup_acquisition/drivers.md).
52+
53+
Acquire supports the following output file formats:
54+
55+
- [Tiff](https://en.wikipedia.org/wiki/TIFF)
56+
- [OME-Zarr](https://ngff.openmicroscopy.org/latest/) for [Zarr v2](https://zarr.readthedocs.io/en/stable/spec/v2.html)
57+
- [Zarr v3](https://zarr.readthedocs.io/en/stable/spec/v3.html)
58+
59+
Acquire also supports raw and trash storage devices. For more information on supported file formats and storage devices, check out the [Storage Device Selection tutorial](./tutorials/setup_acquisition/storage.md).
60+
61+
## Citing Acquire
62+
63+
~~~
64+
{% include "../CITATION.cff" %}
65+
~~~
66+
67+
## Acquire License
68+
`Acquire` is provided under an [Apache 2.0 license](https://github.com/acquire-project/acquire-python/blob/main/LICENSE). [Learn more about the Apache license](https://www.apache.org/licenses/LICENSE-2.0).
File renamed without changes.

0 commit comments

Comments
 (0)