Commit bc74cd9f authored by Tim Schoof's avatar Tim Schoof
Browse files

Add data handler module

parent b40e4396
......@@ -16,7 +16,7 @@ VERSION = '0.0.1'
# What packages are required for this module to be executed?
'attrs', 'numpy', 'asapo_consumer', 'asapo_producer', 'scikit-image'
# What packages are optional?
import io
import numpy as np
from import imread
def get_image(data, metadata):
typ = metadata["name"].rpartition(".")[-1]
if typ == "tif":
buf = io.BytesIO(data)
image = imread(buf)
elif typ == "numpy":
shape = metadata["meta"]["shape"]
dtype = metadata["meta"]["dtype"]
image = np.frombuffer(data, dtype=dtype).reshape(shape)
raise ValueError("Unknown extension: " + typ)
return image
def get_filename_parts(metadata):
name = metadata["name"]
base, sep, index_and_ext = name.rpartition("-")
index, ext = index_and_ext.split(".")
return base, int(index), ext
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment