Commit 401be2f8 authored by Mikhail Karnevskiy's avatar Mikhail Karnevskiy
Browse files

Implement seedee lib for serialisation

parent 1aff432f
Pipeline #30326 failed with stage
in 37 seconds
...@@ -17,7 +17,7 @@ VERSION = '0.0.4' ...@@ -17,7 +17,7 @@ VERSION = '0.0.4'
# What packages are required for this module to be executed? # What packages are required for this module to be executed?
REQUIRED = [ REQUIRED = [
'attrs', 'numpy', 'asapo_consumer', 'asapo_producer', 'scikit-image', 'attrs', 'numpy', 'asapo_consumer', 'asapo_producer', 'scikit-image',
'h5py', 'hdf5plugin' 'h5py', 'hdf5plugin', 'seedee'
] ]
# What packages are optional? # What packages are optional?
......
...@@ -2,11 +2,15 @@ import io ...@@ -2,11 +2,15 @@ import io
import numpy as np import numpy as np
import hdf5plugin import hdf5plugin
import h5py import h5py
import seedee
import zlib import zlib
from skimage.io import imread from skimage.io import imread
def get_image(data, metadata): def get_image(data, metadata):
if "_data_type" in metadata["meta"]:
return seedee.deserialize(data, metadata["meta"]["_data_type"])
Please register or sign in to reply
if metadata["name"] == 'liveimage': if metadata["name"] == 'liveimage':
image = zlib.decompress(data) image = zlib.decompress(data)
if metadata['meta']['frame_depth'] == 24: if metadata['meta']['frame_depth'] == 24:
...@@ -41,6 +45,12 @@ def get_image(data, metadata): ...@@ -41,6 +45,12 @@ def get_image(data, metadata):
return image return image
def serialize_image(array, compression=None):
Please register or sign in to reply
if not compression:
Please register or sign in to reply
compression = seedee.COMPRESSION_BITSHUFFLE
return seedee.serialize(images, compression)
def serialize_ndarray(array): def serialize_ndarray(array):
""" """
Serialize ndarray into compressed h5 in-memory file Serialize ndarray into compressed h5 in-memory file
...@@ -74,3 +84,4 @@ def get_filename_parts(metadata): ...@@ -74,3 +84,4 @@ def get_filename_parts(metadata):
base, sep, index_and_ext = name.rpartition("-") base, sep, index_and_ext = name.rpartition("-")
index, ext = index_and_ext.split(".") index, ext = index_and_ext.split(".")
return base, int(index), ext 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