Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FS-SC
AsapoWorker
Commits
bc74cd9f
Commit
bc74cd9f
authored
Apr 17, 2020
by
Tim Schoof
Browse files
Add data handler module
parent
b40e4396
Changes
2
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
bc74cd9f
...
...
@@ -16,7 +16,7 @@ VERSION = '0.0.1'
# What packages are required for this module to be executed?
REQUIRED
=
[
'attrs'
'attrs'
,
'numpy'
,
'asapo_consumer'
,
'asapo_producer'
,
'scikit-image'
]
# What packages are optional?
...
...
src/AsapoWorker/data_handler.py
0 → 100644
View file @
bc74cd9f
import
io
import
numpy
as
np
from
skimage.io
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
)
else
:
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment