Skip to content

Commit

Permalink
N5VolumeService: Add blosc compression option
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarteberg committed Sep 4, 2020
1 parent 8984d77 commit 6fae4ac
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions flyemflows/volumes/n5_volume_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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'
Expand All @@ -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:
Expand All @@ -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"]
Expand Down

0 comments on commit 6fae4ac

Please sign in to comment.