Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xsocs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kmap
xsocs
Commits
b0587814
Commit
b0587814
authored
Nov 29, 2018
by
Thomas Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use str_to_hdf5_utf8 and _get_array_str
parent
7eb6822c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
xsocs/io/QSpaceH5.py
xsocs/io/QSpaceH5.py
+6
-11
xsocs/io/XsocsH5Base.py
xsocs/io/XsocsH5Base.py
+12
-0
No files found.
xsocs/io/QSpaceH5.py
View file @
b0587814
...
...
@@ -156,10 +156,8 @@ class QSpaceH5(XsocsH5Base):
def
selected_entries
(
self
):
"""Returns the input entries used for the conversion."""
path
=
self
.
_ENTRIES_PATH
+
'/selected'
entries
=
self
.
_get_array_data
(
path
)
if
entries
is
not
None
:
return
[
entry
.
decode
()
for
entry
in
entries
]
return
[]
entries
=
self
.
_get_array_str
(
path
)
return
entries
if
entries
is
not
None
else
[]
@
property
def
shifts
(
self
):
...
...
@@ -207,10 +205,8 @@ class QSpaceH5(XsocsH5Base):
Returns the input entries that were not used for the conversion.
"""
path
=
self
.
_ENTRIES_PATH
+
'/discarded'
entries
=
self
.
_get_array_data
(
path
)
if
entries
is
not
None
:
return
[
entry
.
decode
()
for
entry
in
entries
]
return
[]
entries
=
self
.
_get_array_str
(
path
)
return
entries
if
entries
is
not
None
else
[]
@
property
def
image_mask
(
self
):
...
...
@@ -434,11 +430,10 @@ class QSpaceH5Writer(QSpaceH5):
number of selected entries. The shift is in grid coordinates.
"""
path
=
self
.
_ENTRIES_PATH
+
'/selected'
selected
=
_np
.
array
(
selected
,
dtype
=
_np
.
string_
)
selected
=
str_to_h5_utf8
(
selected
)
self
.
_set_array_data
(
path
,
selected
)
path
=
self
.
_ENTRIES_PATH
+
'/discarded'
discarded
=
_np
.
array
((
discarded
is
not
None
and
discarded
)
or
[],
dtype
=
_np
.
string_
)
discarded
=
str_to_h5_utf8
(
discarded
if
discarded
is
not
None
or
[])
self
.
_set_array_data
(
path
,
discarded
)
if
sample_shifts
is
not
None
:
...
...
xsocs/io/XsocsH5Base.py
View file @
b0587814
...
...
@@ -160,6 +160,18 @@ class XsocsH5Base(object):
except
KeyError
:
return
None
def
_get_array_str
(
self
,
path
):
"""Returns the array of string contained in the dataset.
:param str path: The path of the dataset in the HDF5 file
:rtype: List[str]
"""
strings
=
self
.
_get_array_data
(
path
=
path
)
if
strings
is
None
:
return
None
else
:
return
[
s
.
decode
()
if
hasattr
(
s
,
'decode'
)
else
s
for
s
in
strings
]
def
_set_scalar_data
(
self
,
path
,
value
):
with
self
.
_get_file
()
as
h5_f
:
value_np
=
_np
.
array
(
value
)
...
...
Write
Preview
Markdown
is supported
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