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
fc5619a4
Commit
fc5619a4
authored
Jul 13, 2020
by
Tim Schoof
Browse files
Add limited support for nexus files
parent
24d22b6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
fc5619a4
...
...
@@ -16,7 +16,8 @@ VERSION = '0.0.3'
# What packages are required for this module to be executed?
REQUIRED
=
[
'attrs'
,
'numpy'
,
'asapo_consumer'
,
'asapo_producer'
,
'scikit-image'
'attrs'
,
'numpy'
,
'asapo_consumer'
,
'asapo_producer'
,
'scikit-image'
,
'h5py'
]
# What packages are optional?
...
...
src/AsapoWorker/data_handler.py
View file @
fc5619a4
import
io
import
numpy
as
np
import
h5py
from
skimage.io
import
imread
...
...
@@ -12,11 +13,29 @@ def get_image(data, metadata):
shape
=
metadata
[
"meta"
][
"shape"
]
dtype
=
metadata
[
"meta"
][
"dtype"
]
image
=
np
.
frombuffer
(
data
,
dtype
=
dtype
).
reshape
(
shape
)
elif
typ
==
"nxs"
:
buf
=
io
.
BytesIO
(
data
)
h5file
=
h5py
.
File
(
buf
)
image
=
get_default_data
(
h5file
)
else
:
raise
ValueError
(
"Unknown extension: "
+
typ
)
return
image
def
get_default_data
(
group
):
default_name
=
group
.
attrs
.
get
(
"default"
,
None
)
if
default_name
:
return
get_default_data
(
group
[
default_name
])
signal_name
=
group
.
attrs
.
get
(
"signal"
,
"data"
)
signal
=
group
[
signal_name
]
if
signal
.
ndim
==
1
:
axis_name
=
group
.
attrs
.
get
(
"axes"
,
"axis"
)[
0
]
axis
=
group
[
axis_name
]
return
np
.
vstack
((
axis
,
signal
)).
T
else
:
return
np
.
asarray
(
signal
)
def
get_filename_parts
(
metadata
):
name
=
metadata
[
"name"
]
base
,
sep
,
index_and_ext
=
name
.
rpartition
(
"-"
)
...
...
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