Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RoboCT H5
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RoboCT (Public)
RoboCT H5
Commits
df8bbede
Commit
df8bbede
authored
2 weeks ago
by
Simon Wittl
Browse files
Options
Downloads
Patches
Plain Diff
add projection load utility
parent
d8333008
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/h5schemas/load_utilities/projection.py
+56
-0
56 additions, 0 deletions
src/h5schemas/load_utilities/projection.py
src/h5schemas/load_utilities/projection_geometry.py
+1
-1
1 addition, 1 deletion
src/h5schemas/load_utilities/projection_geometry.py
with
57 additions
and
1 deletion
src/h5schemas/load_utilities/projection.py
0 → 100644
+
56
−
0
View file @
df8bbede
from
h5schemas.load_utilities.projection_geometry
import
extract_projection_geometry
,
ProjectionGeometry
from
h5py
import
Group
import
numpy
as
np
from
typing
import
NamedTuple
,
ClassVar
,
Literal
from
dataclasses
import
dataclass
@dataclass
class
GeomOptions
:
PROJECTION_GEOMETRY
:
ClassVar
[
str
]
=
"
projection_geometry
"
PROJECTION_GEOMETRY_NOMINAL
:
ClassVar
[
str
]
=
"
projection_geometry_nominal
"
DEFAULT
=
"
projection_geometry
"
NOMINAL
=
"
projection_geometry_nominal
"
GeomElement
=
Literal
[
DEFAULT
,
NOMINAL
]
class
Projection
(
NamedTuple
):
projection_geometry
:
ProjectionGeometry
image_array
:
np
.
ndarray
uuid
:
np
.
ndarray
timestamp
:
np
.
ndarray
def
extract_projection
(
h5_group
:
Group
,
indices
:
slice
|
int
,
projection_geometry_group
:
str
=
GeomOptions
.
PROJECTION_GEOMETRY
,
crop
:
list
[
slice
]
|
None
=
None
)
->
Projection
:
if
crop
is
None
:
crop
=
(
slice
(
0
,
None
,
1
),
slice
(
0
,
None
,
1
))
if
len
(
crop
)
!=
3
and
isinstance
(
indices
,
slice
):
crop
=
(
slice
(
0
,
None
),
crop
[
0
],
crop
[
1
])
projection_geometry
=
extract_projection_geometry
(
h5_group
[
projection_geometry_group
],
indices
)
uuid
=
h5_group
[
"
image
"
][
"
header
"
][
"
uuid
"
][
indices
]
timestamp
=
h5_group
[
"
image
"
][
"
header
"
][
"
timestamp
"
][
indices
]
image
=
h5_group
[
"
image
"
][
"
image_array
"
][
indices
][
crop
]
return
Projection
(
projection_geometry
,
image
,
uuid
,
timestamp
,
)
if
__name__
==
"
__main__
"
:
from
h5py
import
File
test_file
=
File
(
"
./examples/projection.h5
"
,
"
r
"
)
projection
=
extract_projection
(
test_file
,
1
,
GeomOptions
.
PROJECTION_GEOMETRY
)
print
(
projection
)
print
(
projection
.
image_array
.
shape
)
projection
=
extract_projection
(
test_file
,
slice
(
0
,
2
),
GeomOptions
.
PROJECTION_GEOMETRY
,
crop
=
(
slice
(
20
,
50
),
slice
(
50
,
100
)))
print
(
projection
)
print
(
projection
.
image_array
.
shape
)
This diff is collapsed.
Click to expand it.
src/h5schemas/load_utilities/projection_geometry.py
+
1
−
1
View file @
df8bbede
...
@@ -14,7 +14,7 @@ class ProjectionGeometry(NamedTuple):
...
@@ -14,7 +14,7 @@ class ProjectionGeometry(NamedTuple):
timestamp
:
np
.
ndarray
timestamp
:
np
.
ndarray
def
extract_projection_geometry
(
h5_group
:
Group
,
indices
:
slice
)
->
ProjectionGeometry
:
def
extract_projection_geometry
(
h5_group
:
Group
,
indices
:
slice
|
int
)
->
ProjectionGeometry
:
detector_center_position_mm
=
extract_vector
(
detector_center_position_mm
=
extract_vector
(
h5_group
[
"
detector_center_position_mm
"
],
indices
,
CommonVectors
.
XYZ
h5_group
[
"
detector_center_position_mm
"
],
indices
,
CommonVectors
.
XYZ
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment