SharpMeow commited on
Commit
ed64aa7
·
1 Parent(s): a11db9d

build.py: read blosc-compressed surface volumes

Browse files
Files changed (1) hide show
  1. tools/build.py +5 -1
tools/build.py CHANGED
@@ -65,7 +65,8 @@ def fetch_ct(w, src, shape_hw):
65
  break
66
  base = f"{root}/{lvl}"
67
  meta = json.loads(urllib.request.urlopen(f"{base}/.zarray").read())
68
- assert meta.get("compressor") is None, f"compressed zarr not handled: {meta.get('compressor')}"
 
69
  D, H, W = meta["shape"]
70
  cz, ch, cw = meta["chunks"]
71
  sep = meta.get("dimension_separator") or "."
@@ -81,6 +82,9 @@ def fetch_ct(w, src, shape_hw):
81
  body = r.stdout[:-3]
82
  if code in (b"403", b"404"):
83
  return ij, None
 
 
 
84
  if code == b"200" and len(body) == cz * ch * cw:
85
  raw = body
86
  break
 
65
  break
66
  base = f"{root}/{lvl}"
67
  meta = json.loads(urllib.request.urlopen(f"{base}/.zarray").read())
68
+ comp = meta.get("compressor")
69
+ assert comp is None or comp.get("id") == "blosc", f"compressed zarr not handled: {comp}"
70
  D, H, W = meta["shape"]
71
  cz, ch, cw = meta["chunks"]
72
  sep = meta.get("dimension_separator") or "."
 
82
  body = r.stdout[:-3]
83
  if code in (b"403", b"404"):
84
  return ij, None
85
+ if code == b"200" and comp:
86
+ import imagecodecs
87
+ body = imagecodecs.blosc_decode(body)
88
  if code == b"200" and len(body) == cz * ch * cw:
89
  raw = body
90
  break