From 6fae4ac8cdec7a9bb507c6b417f47711448e0b26 Mon Sep 17 00:00:00 2001 From: Stuart Berg Date: Thu, 3 Sep 2020 21:00:45 -0400 Subject: [PATCH] N5VolumeService: Add blosc compression option --- flyemflows/volumes/n5_volume_service.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/flyemflows/volumes/n5_volume_service.py b/flyemflows/volumes/n5_volume_service.py index 76e3a49b..36562c1d 100644 --- a/flyemflows/volumes/n5_volume_service.py +++ b/flyemflows/volumes/n5_volume_service.py @@ -54,13 +54,13 @@ }, "compression": { "description": "The type of compression to use for all blocks.\n" - 'Choices: ["raw", "gzip", "bzip2", "xz", "lz4"]', + 'Choices: ["raw", "gzip", "bzip2", "xz", "lz4", "blosc"]', "type": "string", - "enum": ["raw", "gzip", "bzip2", "xz", "lz4"], + "enum": ["raw", "gzip", "bzip2", "xz", "lz4", "blosc"], # blosc means blosc-lz4, apparently. "default": "raw" }, "compression-level": { - "description": "The compression setting (ignored when compression is 'raw').", + "description": "The compression setting (ignored for 'raw' and 'blosc').", "type": "integer", "default": 5 } @@ -258,7 +258,7 @@ def _ensure_datasets_exist(self, volume_config): writable = volume_config["n5"]["writable"] if writable is None: writable = create_if_necessary - + mode = 'r' if writable: mode = 'a' @@ -269,10 +269,12 @@ def _ensure_datasets_exist(self, volume_config): bounding_box_zyx = np.array(volume_config["geometry"]["bounding-box"])[:,::-1] creation_shape = np.array(volume_config["n5"]["creation-settings"]["shape"][::-1]) replace_default_entries(creation_shape, bounding_box_zyx[1]) - + compression = volume_config["n5"]["creation-settings"]["compression"] compression_options = {} - if compression != "raw": + if compression == "blosc": + compression_options['clevel'] = volume_config["n5"]["creation-settings"]["compression-level"] + elif compression != "raw": compression_options['level'] = volume_config["n5"]["creation-settings"]["compression-level"] if create_if_necessary: @@ -283,7 +285,7 @@ def _ensure_datasets_exist(self, volume_config): "(or extend) the data with, because you didn't specify a " "volume creation shape (or bounding box") max_scale = choose_pyramid_depth(creation_shape, 512) - + available_scales = [*range(1+max_scale)] else: available_scales = volume_config["geometry"]["available-scales"]