Skip to content

Commit

Permalink
Second half of acquire-project#125
Browse files Browse the repository at this point in the history
  • Loading branch information
aliddell committed Oct 19, 2023
1 parent 189349e commit 8d7331f
Show file tree
Hide file tree
Showing 9 changed files with 968 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Support for [Zarr v3](https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html).
- Support for
the [sharding storage transformer](https://web.archive.org/web/20230213221154/https://zarr-specs.readthedocs.io/en/latest/extensions/storage-transformers/sharding/v1.0.html)
in Zarr v3.
- Ship debug libs for C-Blosc on Linux and Mac.

### Changed
Expand Down
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ This is an Acquire Driver that supports chunked streaming to [zarr][].
- **Zarr**
- **ZarrBlosc1ZstdByteShuffle**
- **ZarrBlosc1Lz4ByteShuffle**
- **ZarrV3**
- **ZarrV3Blosc1ZstdByteShuffle**
- **ZarrV3Blosc1Lz4ByteShuffle**

## Using the Zarr storage device

Expand All @@ -24,6 +27,10 @@ Chunking is configured using `storage_properties_set_chunking_props()` when conf
Multiscale storage can be enabled or disabled by calling `storage_properties_set_enable_multiscale()` when configuring
the video stream.

For the [Zarr v3] version of each device, you can use the `ZarrV3*` devices.
**Note:** Zarr v3 is not [yet](https://github.com/ome/ngff/pull/206) supported by the Python OME-Zarr library, so you
will not be able to read multiscale metadata from the resulting dataset.

### Configuring chunking

You can configure chunking by calling `storage_properties_set_chunking_props()` on your `StorageProperties` object
Expand All @@ -41,21 +48,21 @@ storage_properties_set_chunking_props(struct StorageProperties* out,
```
| ![frames](https://github.com/aliddell/acquire-driver-zarr/assets/844464/3510d468-4751-4fa0-b2bf-0e29a5f3ea1c) |
|:--:|
| A collection of frames. |
|:-------------------------------------------------------------------------------------------------------------:|
| A collection of frames. |
A _tile_ is a contiguous section, or region of interest, of a _frame_.
| ![tiles](https://github.com/aliddell/acquire-driver-zarr/assets/844464/f8d16139-e0ac-44db-855f-2f5ef305c98b) |
|:--:|
| A collection of frames, divided into tiles. |
|:------------------------------------------------------------------------------------------------------------:|
| A collection of frames, divided into tiles. |
A _chunk_ is nothing more than some number of stacked tiles from subsequent frames, with each tile in a chunk having
the same ROI in its respective frame.
| ![chunks](https://github.com/aliddell/acquire-driver-zarr/assets/844464/653e4d82-363e-4e04-9a42-927b052fb6e7) |
|:--:|
| A collection of frames, divided into tiles. A single chunk has been highlighted in red. |
| ![chunks](https://github.com/aliddell/acquire-driver-zarr/assets/844464/653e4d82-363e-4e04-9a42-927b052fb6e7) |
|:-------------------------------------------------------------------------------------------------------------:|
| A collection of frames, divided into tiles. A single chunk has been highlighted in red. |
You can specify the width and height, in pixels, of each tile, and if your frame size has more than one plane, you can
specify the number of planes you want per tile as well.
Expand Down Expand Up @@ -120,3 +127,5 @@ Then the sequence of levels will have dimensions 1920 x 1080, 960 x 540, 480 x 2
[Blosc]: https://github.com/Blosc/c-blosc
[Blosc docs]: https://www.blosc.org/
[Zarr v3]: https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ add_library(${tgt} MODULE
zarr.cpp
zarr.v2.hh
zarr.v2.cpp
zarr.v3.hh
zarr.v3.cpp
zarr.driver.c
)
target_enable_simd(${tgt})
Expand Down
19 changes: 19 additions & 0 deletions src/zarr.driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ struct Storage*
compressed_zarr_v2_zstd_init();
struct Storage*
compressed_zarr_v2_lz4_init();
struct Storage*
zarr_v3_init();
struct Storage*
compressed_zarr_v3_zstd_init();
struct Storage*
compressed_zarr_v3_lz4_init();

//
// GLOBALS
Expand All @@ -49,6 +55,9 @@ enum StorageKind
Storage_Zarr,
Storage_ZarrBlosc1ZstdByteShuffle,
Storage_ZarrBlosc1Lz4ByteShuffle,
Storage_ZarrV3,
Storage_ZarrV3Blosc1ZstdByteShuffle,
Storage_ZarrV3Blosc1Lz4ByteShuffle,
Storage_Number_Of_Kinds
};

Expand All @@ -71,6 +80,9 @@ storage_kind_to_string(const enum StorageKind kind)
CASE(Storage_Zarr);
CASE(Storage_ZarrBlosc1ZstdByteShuffle);
CASE(Storage_ZarrBlosc1Lz4ByteShuffle);
CASE(Storage_ZarrV3);
CASE(Storage_ZarrV3Blosc1ZstdByteShuffle);
CASE(Storage_ZarrV3Blosc1Lz4ByteShuffle);
#undef CASE
default:
return "(unknown)";
Expand Down Expand Up @@ -99,6 +111,9 @@ zarr_describe(const struct Driver* driver,
XXX(Zarr),
XXX(ZarrBlosc1ZstdByteShuffle),
XXX(ZarrBlosc1Lz4ByteShuffle),
XXX(ZarrV3),
XXX(ZarrV3Blosc1ZstdByteShuffle),
XXX(ZarrV3Blosc1Lz4ByteShuffle),
};
// clang-format on
#undef XXX
Expand Down Expand Up @@ -160,6 +175,10 @@ acquire_driver_init_v0(acquire_reporter_t reporter)
[Storage_Zarr] = zarr_v2_init,
[Storage_ZarrBlosc1ZstdByteShuffle] = compressed_zarr_v2_zstd_init,
[Storage_ZarrBlosc1Lz4ByteShuffle] = compressed_zarr_v2_lz4_init,
[Storage_ZarrV3] = zarr_v3_init,
[Storage_ZarrV3Blosc1ZstdByteShuffle] =
compressed_zarr_v3_zstd_init,
[Storage_ZarrV3Blosc1Lz4ByteShuffle] = compressed_zarr_v3_lz4_init,
};
memcpy(
globals.constructors, impls, nbytes); // cppcheck-suppress uninitvar
Expand Down
Loading

0 comments on commit 8d7331f

Please sign in to comment.